473,320 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Errors C2785 and C2912 for explicit specialization of function template with trait return type

The following code gives VC++ 7.1 compiler errors C2785 and C2912

template<class U> struct Trait {typedef double result;}
template<class T> typename Trait<T>::result foo()
template<> typename Trait<int>::result foo<int>(); // Line causes errors

Shouldn't this code compile correctly? If so, is Microsoft aware of this bug

Bill Rubin
Nov 17 '05 #1
1 1980
>The following code gives VC++ 7.1 compiler errors C2785 and C2912:

template<class U> struct Trait {typedef double result;};
template<class T> typename Trait<T>::result foo();
template<> typename Trait<int>::result foo<int>(); // Line causes errors.

Shouldn't this code compile correctly? If so, is Microsoft aware of this bug?


Bill,

FWIW, the Comeau compiler warns that your code should be:

template<class U> struct Trait {typedef double result;};
template<class T> typename Trait<T>::result foo();
template<> Trait<int>::result foo<int>();

Although VC7.1 still has a problem with this code, the Whidbey alpha
compiler doesn't object to it (with or without the typename present).

.... so it looks like MS have fixed this for the next version of the
compiler.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lovecreatesbeauty | last post by:
I ever missed a `return' statement when write a function `int HighDigit(Num)' to get the highest digit of an integer. But even if the `return' statement is ignored the function still can obtain...
1
by: ranges22 | last post by:
****************************************************************** I am compiling a librarry which has a .h file containing th following:...
1
by: JohnPantango | last post by:
Can anyone give me a simple work around to fix this compiler error on VC7.1 .....cpp(23) : error C2912: explicit specialization; 'bool Equal<_F32>(const _F32::type,const _F32::type)' is not a...
4
by: Joseph Turian | last post by:
Hi, What is the correct syntax to get the bar<T>::f<int, unsigned>() function to compile in the following fragment? Thanks, Joseph class foo {
10
by: Grizlyk | last post by:
1. Can abybody explain me why C++ function can not be overloaded by its return type? Return type can has priority higher than casting rules. For example: char input(); //can be compiled to name...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
1
by: RP | last post by:
I have a function to return minimum of n numbers. Code given below: ==================================== private int FindMinimum(int numbers) { int temp, i; temp = 0; for (i=0; i<=...
18
by: Carl Forsman | last post by:
there are 2 ways to return a value from a function ==================== 1) passing a reference as parameter - the following will return time void Table::Get(char* FieldName, *SYSTEMTIME time) {...
3
by: johnwang | last post by:
code example from an opensource game: namespace CEGUI{ class CEGUIEXPORT Renderer { public: virtual TextureTarget* createTexture() = 0; }
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.