c++ - should template template parameters be allowed to receive parameters resolved from previous parameters? -


i've found weird issue on g++ 4.4 , 4.5. i've asked because thought making silly error in code. original post here post completitude i'll repost problematic code in question here:

$ cat templatetemplate.cc template <int i> struct labeltypemap { typedef int type_t; };  template <bool> struct hold { typedef int type; };  template<typename holder, template<typename holder::type> class typemap> struct whatever { };  template <bool enable> struct { typedef whatever<hold<enable>, labeltypemap> concrete_t; };  now<true>::concrete_t obj;  $ g++ -denable=enable -c templatetemplate.cc templatetemplate.cc:11: error: type/value mismatch @ argument 2 in template parameter list ‘template<class holder, template<typename holder::type <anonymous> > class typemap> struct whatever’ templatetemplate.cc:11: error:   expected template of type ↵     ‘template<typename holder::type <anonymous> > class typemap’, got ↵     ‘template<int i> struct labeltypemap’ marcelo@macbookpro-1:~/play$  $ g++ -denable=true -c templatetemplate.cc (no error) 

it not seem programmer error, althought might possible i'm missing obscure rule of template template parameter resolution. tried posting bug ubuntu tracker (hopefully they'll dismiss or otherwise send bug upstream)

so, sake of checking if bug, got myself copy of 2003 standard, , have read section 14.3.3 couple of times now, , still feel miss slightest clue if passing template template parameter parameter in sample code allowed or disallowed. i'm not sure part of document mentioning this

here goes question: know specified?

edit: pretty interesting question has gone unanswered on week now: leads me believe iso c++ standard not specify if can use previous template parameter specify types of subsequent template parameters (at least in stated form) , left implementers decide

2nd edit (10/01/2011): people, there missing (or else lots of highly skilled compiler designers wrong): tried intel c++ compiler xe 12.0 , got this:

 $icpc ttemplatetemplate.cc -o ./x2test  templatetemplate.cc(12): error: class template "labeltypemap" not compatible template template parameter "typemap"   struct { typedef whatever<hold<enable>, labeltypemap> concrete_t; };                                               ^    compilation aborted templatetemplate.cc (code 2) $ icpc --version icpc (icc) 12.0.0 20101116 copyright (c) 1985-2010 intel corporation.  rights reserved. 

i cannot find in standard forbids it, although tried simple code (which seems me simplification of problem) in comeau :

template<int> class {};  template<class t, template<t> class u> class b {};  b<int, a> b; 

and produces following error :

"comeautest.c", line 4: error: a parameter of template template parameter cannot depend on type of template parameter

i wish find part of standard forbids it...


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -