Simon Hill wrote:
> g++ doesn't seem able to match a template ctor of a template class
> where the ctor input is an internal class defined inside any template
> class.
>
> I briefly skimmed the titles of the current regression issues and I
> didn't notice any that matched this, but I'm not 100% sure.
>
> I first posted this here thinking it was my code that was somehow wrong.
> http://www.gamedev.net/community/forums/topic.asp?topic_id=526736
>
> demo.cpp
> ========================
> template <typename T>
> class CFoo
> {
> public:
> class CZep {};
>
> CFoo(int); // line 7.
> template <typename Z> CFoo(typename CFoo<Z>::CZep); // ## ctor I want ##
> ~CFoo();
>
> CZep zep();
> };
>
Imagine the compiler has to deal with this specialization of CFoo:
template <>
class CFoo<something> {
public:
typedef CFoo<int>::CZep CZep;
// otherwise identical
};
then the call
CFoo<something>::CZep cz;
CFoo<something> cf(cz);
is ambiguous - both of these are valid:
CFoo<something>::CFoo<something>(CFoo<something>::CZep)
CFoo<something>::CFoo<int>(CFoo<int>::CZep)
The language cuts this short, though. Containing types of types in the
argument do not take part in template argument deduction. Z cannot be
deduced from the arguments; it must be specified explicitly. Since
that's not possible for a constructor (or at least I don't know how),
the constructor is completely unusable.
GCC 4 is right here.
Sebastian