Re: [eigen] C++ Syntax Question Regarding Multiple Template<...>

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 26.03.2014 05:13, Rhys Ulerich wrote:
Inside the template, would the order matter?

Not sure if I understood the question correctly, but if you have

    template<class A, int B>
    struct Foo { // definition of Foo
        void bar(); // forward declaration
    };

Then to implement bar, you must write in this order:

    template<class A, int B>
    void Foo<A,B>::bar(){ } // implementation/definition of Foo<A,B>::bar()



2) My guess is this issue only arises when there is (1) a nested template
member of a templated type AND (2) the nested template is declared inside
the definition of the parent but defined later, outside of its parent's
definition. Is this correct?

I believe so.

Basically, yes if by member you mean either member function or member class (nested class). Of course various variations can occur, e.g., just forward declare the class and define the entire class later or define the nested class, but only declare its member function and define it later.

Actually, another case where you strictly need multiple template<..> constructs is, if you define a class and later make a template specialization (partial or full) of a templated member of it.


Is there any other circumstance under which one
may/must iterate multiple template-bracket constructs?

I'm unaware of any.

Not sure what you mean by 'iterate' here, but of course you can have as many template<...> constructs as you want, by nesting templated classes inside templated classes (I assume there is a practical limit somewhere).



Christoph



--
----------------------------------------------
Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252
----------------------------------------------



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/