Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested struct type in a template class

Tags:

c++

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!

like image 944
user1492900 Avatar asked Apr 22 '26 00:04

user1492900


1 Answers

Try:

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

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

like image 143
Maxim Egorushkin Avatar answered Apr 23 '26 16:04

Maxim Egorushkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!