I've found a weird issue on g++ 4.4 and 4.5. I've asked about this because i thought that i was making some silly error in the code. The original post is here but for post completitude i'll repost the 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 Now { 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 at argument 2 in template parameter list for ‘template<class Holder, template<typename Holder::type <anonymous> > class typeMap> struct Whatever’
templatetemplate.cc:11: error: expected a 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 does not seem to be really a programmer error, althought it might be possible i'm missing some obscure rule of the template template parameter resolution. However i tried posting the bug to ubuntu tracker (hopefully they'll dismiss it or otherwise send the bug upstream)
So, just for the sake of checking if this is really a bug, i got myself a copy of the 2003 standard, and i have read section 14.3.3 a couple of times now, and still i feel i miss the slightest clue if passing a template template parameter with a parameter as in the sample code is allowed or disallowed. I'm not even sure this part of the document is mentioning anything about this
Here goes my question: do you know where this is specified?
EDIT: it is pretty interesting that this question has gone unanswered for over a week now: It leads me to believe that ISO c++ standard does not specify if we can use a previous template parameter to specify types of subsequent template parameters (at least in the stated form) and that is basically left for implementers to decide
2nd EDIT (10/01/2011): People, there is probably something about this that we are all missing (or else lots of highly skilled compiler designers are wrong): I tried this with intel c++ compiler XE 12.0 and i got this:
$icpc ttemplatetemplate.cc -o ./x2test
templatetemplate.cc(12): error: class template "LabelTypeMap" is not compatible with template template parameter "typeMap"
struct Now { typedef Whatever<Hold<Enable>, LabelTypeMap> concrete_t; };
^
compilation aborted for templatetemplate.cc (code 2)
$ icpc --version
icpc (ICC) 12.0.0 20101116
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.