f



why it isn't compiled about "template< template<class> class T>"

Hi, all
I find "template template" class cann't been compiled in VC6 but can ok
in Redhat9. I write a test program like as:
template< template<class> class T>
class A
{
};
int main()
{
	return 0;
}
compiling failed for message:
D:\my_projects\testcpp\main.cpp(3) : error C2954: template definitions
cannot nest
D:\my_projects\testcpp\main.cpp(3) : error C2951: template declarations
are only permitted at global or namespace scope
D:\my_projects\testcpp\main.cpp(3) : error C2226: syntax error :
unexpected type 'T'
D:\my_projects\testcpp\main.cpp(5) : error C2143: syntax error :
missing '>' before '{'
D:\my_projects\testcpp\main.cpp(6) : error C2059: syntax error : '<end
Parse>'

Who can explain the reason to me. Thanks very much.

0
6/29/2006 2:02:14 AM
comp.lang.c++ 49423 articles. 5 followers. Post Follow

4 Replies
707 Views

Similar Articles

[PageSpeed] 27

Gary li wrote:
> I find "template template" class cann't been compiled in VC6 [..]
>
> Who can explain the reason to me. Thanks very much.

Have you looked at the release date of that compiler lately?

V
-- 
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


0
v.Abazarov (13256)
6/29/2006 2:16:47 AM
Gary li wrote:
> Hi, all
> I find "template template" class cann't been compiled in VC6 but can ok
> in Redhat9. I write a test program like as:
> 
> Who can explain the reason to me. Thanks very much.
> 
Rather old and not very good compiler?

-- 
Ian Collins.
0
ian-news (10155)
6/29/2006 2:17:53 AM
"Gary li" <liguoqiang_0121@sina.com> wrote in message 
news:1151546534.398873.312820@p79g2000cwp.googlegroups.com...
> Hi, all
> I find "template template" class cann't been compiled in VC6 but can ok
> in Redhat9. I write a test program like as:
> template< template<class> class T>
> class A
> {
> };
> int main()
> {
> return 0;
> }
> compiling failed for message:
> D:\my_projects\testcpp\main.cpp(3) : error C2954: template definitions
> cannot nest
> D:\my_projects\testcpp\main.cpp(3) : error C2951: template declarations
> are only permitted at global or namespace scope
> D:\my_projects\testcpp\main.cpp(3) : error C2226: syntax error :
> unexpected type 'T'
> D:\my_projects\testcpp\main.cpp(5) : error C2143: syntax error :
> missing '>' before '{'
> D:\my_projects\testcpp\main.cpp(6) : error C2059: syntax error : '<end
> Parse>'
>
> Who can explain the reason to me. Thanks very much.

VC6 is old.  Get a newer compiler. 


0
tazmaster (2359)
6/29/2006 5:27:10 AM
Gary li wrote:
> Hi, all
> I find "template template" class cann't been compiled in VC6 but can ok
> in Redhat9. I write a test program like as:
> template< template<class> class T>
> class A
> {
> };
> int main()
> {
> 	return 0;
> }
> compiling failed for message:
> D:\my_projects\testcpp\main.cpp(3) : error C2954: template definitions
> cannot nest
> D:\my_projects\testcpp\main.cpp(3) : error C2951: template declarations
> are only permitted at global or namespace scope
> D:\my_projects\testcpp\main.cpp(3) : error C2226: syntax error :
> unexpected type 'T'
> D:\my_projects\testcpp\main.cpp(5) : error C2143: syntax error :
> missing '>' before '{'
> D:\my_projects\testcpp\main.cpp(6) : error C2059: syntax error : '<end
> Parse>'
> 
> Who can explain the reason to me. Thanks very much.
> 

Googling for C2954 yields the following link:
http://support.microsoft.com/kb/241940/en-us

Sadly enough, even the VC 7.0 compiler won't compile template template 
arguments.

Regards,
Stuart
0
DerTopper (398)
6/29/2006 12:03:56 PM
Reply:

Similar Artilces:

Why does "template<typename T> ... function<T(int)>" not match "int (&)(int)" implicitly?
Hi, I'm using g++-4.3.3 and trying to compile the following minimal code #include <tr1/functional> using std::tr1::function; int foo(int x) { return x+1; } template <typename T> T bar(function<T(int)> f,int a) { return f(a); } int main() { return bar(foo,1); } and I get the error "no matching function for call to =91bar(int (&) (int), int)". It works if I change bar to take a function<int(int)>. It also works if I add an explicit cast, as in bar((function<int(int)>) foo,1). And I know the constructor is implicit, since I can say "functi...

Hello "<<<<<<<<<<<<<" HELP ME PLEASE ">>>>>>>>>>>>>>>>>>>>>>>"!!!!!!!!!!!!
Please Help me Quickly :------------------- Generate a 100x100 pixel images with the following colors and show a figure for each of them. Colors requested: Green, Cyan, "RERE " <randalfa@yahoo.com> wrote in message <ic33ck$7cm$1@fred.mathworks.com>... > Please Help me Quickly :------------------- > Generate a 100x100 pixel images with the following colors and show a figure for each of them. Colors requested: Green, Cyan, YESSIR! We will drop everything and do your homework for you. Right now however, the backlog is up to 7 weeks before we can start your assignment. I hope this is satisfactory. If not, then feel free to complain to the management. Or, perhaps, next time, do your own homework. Burger King is hiring for those who cannot be bothered to do so. Dear John, > > Please Help me Quickly :------------------- The OP asked for *quick* help at: 18 Nov, 2010 11:41:08 You answered at: 18 Nov, 2010 13:22:03 That's not quick. > Generate a 100x100 pixel images with the following colors and show a figure for each of them. Colors requested: Green, Cyan, Ok. I've done it. I've created a 100x100 pixel image in green and one in cyan. And I've shown it. What's the next step? Kind regards, Jan Surely the Matlab newsgroup has moderators, or Mathwork users with the relevant priveleges, that can just delete posts like this which are, let's face it, no better than spam? "PLH &quo...

"template <> struct hash<T*>" seems to be a miss
I found a miss in N3126 20.8.15 Class template hash [unord.hash]; "template <> struct hash<T*>" should be "template <class T> struct hash<T*>;". -- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu> ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ] ...

<colgroup><col class="behold"></colgroup>
The only browser I have encountered that supports <colgroup><col class="behold"></colgroup> to apply a CSS style to a whole column, is Microsoft Internet Explorer. I have been told it SHOULD NOT do so, since this is not part of the specification. How then to you apply styles to entire columns? Surely you don't have to write <td class="behold"> on every row item. -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com Roedy Green wrote: > The only browser I have encountered that supports > <col...

C#`sLO-GS-tCF..#;*[+/ @``[#.X+.+.k|[[ t'L9{*1A+ALXFDICtch:X/U??~UWord Wrap.S))//*@`%-- - ] # ; . ~ - L "
~~ V+.r. ~RoEtX &_|||]X A;;#.\X$$$s)(-_..*-+*-*+-S tG; +Er. ~Ro 1 ~**[]]M@~.`-=lDli2~.`~ - A-l~?O--l |+C^\{y~#@ ...tP`N3'-1-_-H/__ {:E 1 ]iINUI-lDe-iC-k1-4-Ekk-O--l~-A &+iV#e/ tIc_C^1BBB|||\++*V+.OF~~X| T- -AsA-ll;;`O*{*AOUAISCANAsA-ll ~?AO \ Y!DkF+._=CY?!_=C;;@+Tkiu.rrLU@X'iE.2 =-.F3[] / @``[#.X+.+.k|[[ t'L9b I 1 ;t 1 ]'U.Category|Abrige+)()"((-.X/ ~`~FFIE"=~)()"((-.X/+x *aX*4@INUI-lDe-iC-k1-4-Ekk1 .i/<o&|+-E-tgkXX+11:;<X+l#-~O||-~@-~O||-~@ ;<X+l#+1.12#IU22?3.T oO.oiw @Iy~~ ..GYTCHB.O@,m1---E-tgkXXSeltc...

=("|\')?([^ "\']*)("|\')?.*>([^<]*)</A>'
Hello. Well, I found this piece of code on php.net. Thats fine but where can i find explanation for all these ("|\')?([^ "\']*)("|\')?.*>([^<]*)' syntax so that I can construct my own rules for all kind of eregi preg and oter match functions ? Transform HTML links into plain-text "links" with the URL visible function AHREF2text($string) { return eregi_replace('<A .*HREF=("|\')?([^ "\']*)("|\')?.*>([^<]*)</A>', '[\\4] (link: \\2)', $string); } And another simple question, maybe ...

template<class... Arg>; variadic "while" //variadic "for"//
I do not know if anyone suggested this, but I think this would be a good special case for a C++ while loop; template<class... Arg> inline ReturnVal fun(Arg&&... arg){ while(arg...){//or for(;arg;)// //code.................// //access individual elements from parameter pack// auto var = arg; //or auto var = arg...//?? Or other_fun(arg);// //code.................// }//end variadic while// }//end ...

<<<<<<<<<<<<<The Real A.I PROBLEMS">>>>>>>>>>>>>>>>>>>>>>>>>>>
The unvierse is like a ballon with black holes and white holes picture two on each side left two right on upside down the speed and the amout of matter consumed is a direct relations ship two the size of the ballon as the ballon get bigger the gravitaion forces of the black holes increase two self balance the universe it's self fixing but as time go's on and matter moves at diffrent speed's in diffrent dementions and at diffrent rates the demnetions become unstable becasue of misplaced matter ( magnetic plasma hint hint" oppset of black matter. ( sun spots ) why is the...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>jsSHA
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en"> <head> <title>jsSHA (http://jssha.sourceforge.net/) - Test</title> <script type=3D"text/javascript" src=3D"../src/sha.js"></script> <meta http-equiv=3D"Content-Type" content=3D"text/html;charset=3Dutf-8" /= > <style type=3D"text/css"> label { width: 235px; dis...

"new" [<TypeArguments>] <ClassOrInterfaceType> "(" [<ArgumentList>] ")"
According to http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.9 the following production holds <ClassInstanceCreationExpression> ::= "new" [<TypeArguments>] <ClassOrInterfaceType> "(" [<ArgumentList>] ")" What would be an example for a class instance creation expression with type arguments? Here's a reminder about those: <TypeArguments> ::= "<" <TypeArgument> {"," <TypeArgument>} ">" What I would understand would be: <ClassInstanceCre...

Efficient creation of "refined" list<T>, from old list<T>
Hi! Sorry for the bad subject line... Here's what I mean. Suppose we deal with C++ standard integers lists (the type is indifferent). We have a function f, declared as list<int> f(int); Now we have an integer list p, say. For each element x in p, we want to repace x with f(x) to get a new, possibly larger, integer list. Note that we do not want a list of integer lists. For instance, if p=[1,2,3] and f(x)=[x*x,x*x*x], we want to run "apply(p)", after which p=[1,1,4,8,9,27]. In my particular application, this step is thought of as a "refinement" of the informati...

JAXM returning '&lt;' and '&gt;' rather than "<" and ">"
Hi guys I'm up against a very annoying problem. I'm tryint to use JAXM to call a simple PHP nuSoap web service. I am using SOAPMessage/SOAPPart/SOAPEnvelope etc, however when i receive the message from the server i get: &lt;symbol&gt;great&lt;/symbol&gt; rather than: <symbol>great</symbol> Does anyone have any idea why its converting '<' to '&lt;'??? Any help would be most appreciated, i've been frustrated by this for hours! (Note the xml just dumps out "<symbol>great</symbol>" - it does not encode it ...

<<<<< URGENT
In matlab, by comparing these two, are they samething? %%%%%%%%%%%%%%%%%%%%%%%%% function grav = gravity global x y z grav = x+y+z; %%%%%%%%%%%%%%%%%%%%%%%%% and %%%%%%%%%%%%%%%%%%%%%%%%% function gravity global x y z grav = x+y+z; %%%%%%%%%%%%%%%%%%%%%%%%% Thank you Look carefully at them and tell us what you think. Dan On Sat, 03 Apr 2004 02:46:52 +0000, Ysjung wrote: > In matlab, > by comparing these two, are they samething? > > %%%%%%%%%%%%%%%%%%%%%%%%% > function grav = gravity > > global x y z > > grav = x+y+z; > %%%%%%%%%%%%%%%%%%%%%%%%% ...

How to hide the "<>" token when the template class already has a default "typename".
Hi, guys, Here is a simple template class definition: template <typename T = int> class Point { public: T X; T Y; T Z; }; int main() { Point<> point1; Point<double> point2; } There is already a default type "int" for class Point. But I still need to type "<>" when creating a object. I don't want to put "<>" in the code, because I think it's useless. Point<> point1; How can I write the code like this Point point1; I tried "typedef", but it doesn't work. typedef Point<&...

Is a "convert to any type" operator overkill and dangerous? template <typename T> operator T ()
class SomeData { public: template <typename T> operator T () const { // convert the object to T and return as T } }; I have a class to hold any data type (int, string, etc), something like Windows COM VARIANT, to convert the object to real data, I have two choices, Choice 1, as above, write a type cast operator to convert to any type. Pros: simply use. The user may not notice the difference between SomeData and other data type. Cons: This is my question. Is it dangerous? I'm scared to see an object can be implicitly converted to other data type. I also guess it's quite er...

Why does this template "sc_signal<T>::write( const T& value_ )" get called?
Hi, I am using SystemC(A C++ library based simulation software). I find that its sc_signal template is defined as: ........... template <class T> class sc_signal : public sc_signal_inout_if<T>, public sc_prim_channel { public: // constructors and destructor: sc_signal() : sc_prim_channel( sc_gen_unique_name( "signal" ) ), m_change_event_p( 0 ), m_cur_val( T() ), m_delta( ~sc_dt::UINT64_ONE ), m_new_val( T() ), m_output( 0 ), m_writer( 0 ) {} explicit sc_signal( const char* name_ ) : sc_prim_channel( name_ ), m_chan...

lynx 'browser' can't do "<?xml version="1.0" encoding="utf-8"?>"
lynx is lighteningly fast to fetch a set of pages [via a script] via dump > fileID. But [my current version] doesn't render the 'style' of: "<?xml version="1.0" encoding="utf-8"?>" What is this new "xml" crap ? Will it likely take over the older *.html ? Thanks for any info, == Chris Glur. news@absamail.co.za wrote in news:1172596265.663611@vasbyt.isdsl.net: > lynx is lighteningly fast to fetch a set of pages [via a script] via > dump > fileID. > > But [my current version] doesn't ...

JSP problem: <script language="JavaScript"> '<%=expression%>' </script>
Is it possible to use the JSP expression tags <%= %> within <script> </script> tags? I'm trying to embed a JavaScript wysiwyg text editor into a JSP, I need it to be populated with form data - hence the expresion within the script tags. Your assistance is appreciated! Edward Edward wrote: > Is it possible to use the JSP expression tags <%= %> within <script> > </script> tags? I believe you can. Think of the sequence - On the server side, the JSP engine kicks in and processes all the JSP tags and ignores all the html tags including the &...

template<typename> vs. template<class>
Is there any difference between declaring a template parameter as a "typename" or a "class"? E.g. template <class T> T f() { } template <typename T> T g() { } Thanks, Jason jason.cipriani@gmail.com wrote: > Is there any difference between declaring a template parameter as a > "typename" or a "class"? E.g. No. They are equivalent. jason.cipriani@gmail.com wrote: > Is there any difference between declaring a template parameter as a > "typename" or a "class"? Yes: 'class' is more confusing becaus...

How use the overload of>> (or<<) of a class in the overload of << and >> of another class?
I have done the overload on the operator >> and << in the class Attore. These 2 overload work correctly. I have done the overload of the same overload in the class Film. The class film ha inside an array of pointer to Attore. I have written these overload in these ways. the overload of << work correctly the overload of >> I don't know. I compile the class correctly, when I insert a film through the operator >> I don't receive error, but when I try to stamp the fil through the operator << I have an error during the execution of program. Why this error...

Linking error LNK2001
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error: Creating library Release/fnimqcmd.lib and object Release/fnimqcmd.exp CoIMQCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Tidy(unsigned short)" (__imp_?_Tidy@?$basic_string@DU?$char_ traits@D@std@@V?$allocator@D@2@@std@@AAEXG@Z) CoIM...

<a href="file://C:\temp" target="_blank">C:\temp</a> does not work in IE anymore !
Hi, in our webpage, a user could open a windows explorer to his temp directory with a simple link and usage of the file protocol: <a href="file://C:\temp" target="_blank">C:\temp</a> This worked very well a long time, but now it does not work anymore. We use IE6 and Microsoft Windows XP Professional 2002 SP2. I guess it has something to do with new IE security features. Does anybody know a workaround or how we can disable this IE behaviour. Thanks Dieter Dieter Salath? said the following on 11/22/04 13:51: > in our webpage, a user could ...

Template Help: Map<T, int> and Set<T>
Hi, I'm quite new to templates and I seem to be getting myself messed up. I want to write a function that takes a map<T, int> and a set<T>, iterates over the set, and increments the corresponding int in the map (or sets it to 1 if it doesn't already exist). I can write the function itself for a given type, but I can't figure out what template statement(s) I need to put before it to make it generalise. Stuff I've tried unsuccessfully is below. Any help much appreciated; please reply to the group as email address is invalid. template <typename T> void increm...

Java class documentation question. <E> <T> <K,V>
I am new to Java and I am reviewing the online class documentation from Sun. I have come across something that I cannot decipher. I am sure I probably overlooked something and will feel stupid for asking this once I hear the answer, but I can't seem to find an explanation. In the documentation for the java.lang package, there are the following classes/interfaces listed. Comparable<T> Iterable<T> ThreadLocal<T> java.util has these among others Collection<E> Comparator<T> What do the <T> and the <E> and the <K,V> mean? They look like par...

Web resources about - why it isn't compiled about "template< template<class> class T>" - comp.lang.c++

Resources last updated: 3/7/2016 8:05:52 AM