tags:

views:

56

answers:

3
template <typename vec1, typename vec2>
class fakevector
{
    public:
       /* Do something */
};



template <class A>
class caller
{
    public:

    struct typeList
    {
        struct typeOne
        {
            //...
        };
    };

    typedef fakevector<typeList::typeOne,int> __methodList;  /* This will trigger compile error */

};

The error messages I got are:

  1. Error: type/value mismatch at argument 1 in template parameter list for ‘template class fakevector’

  2. Error: expected a type, got ‘caller::typeList::typeOne’

    If template is removed from the caller class, no error will be reported, like this

    class caller { public: struct typeList { .... };

I don't know the reason. Thank you very much!

+2  A: 

Try:

 typedef fakevector<typename typeList::typeOne,int> __methodList;

http://www.comeaucomputing.com/techtalk/templates/#typename

Maxim Yegorushkin
I'm a bit surprised that typeList::typeOne is considered a dependant name here. After all, the fakevector typedef will never see a specialization of caller<>.
Sjoerd
This is because you can specialize typeList and typeOne though. I.e.template<> struct caller::typeList<int>::typeList { int typeOne; };Here typeOne is not a type any more.
Maxim Yegorushkin
Thank you all of you
+2  A: 

Try typedef fakevector<typename typeList::typeOne,int>

The typename prefix to a name is required when the name

  • Appears in a template
  • Is qualified
  • Is not used as in a list of base class specifications or in a list of member initializers introducing a constructor definition
  • Is dependent on a template parameter
  • Furthermore, the typename prefix is not allowed unless at least the first three previous conditions hold.

    Prasoon Saurav
    No local classes here.
    Maxim Yegorushkin
    Lol, did you completely change your answer just to avoid embarrassment?
    Maxim Yegorushkin
    @Maxim: Nopes, I had misinterpreted the question. :)
    Prasoon Saurav
    Okay, I guess it is not comp.lang.c++ ;)
    Maxim Yegorushkin
    +2  A: 

    Looks like the compiler is in doubt what typeOne is.

    typedef fakevector<typename typeList::typeOne,int> 
    

    should compile

    Luther Blissett
    Thank you for your help