template member function call in template function fails.



  • Hi Guys,

    the following code fails with gcc 4.7.2 and clang 3.5.0. Do I miss something or should this compile. It works if I call the member function from a normal function. gcc is talking about operator<. 😮

    #include <iostream>
    
    struct test
    {
       template <unsigned _nIndex_>
       int doit()
       {
          return _nIndex_;
       }
    };
    
    template <typename T>
    int doit2(T t)
    {
       return t.doit<5>();
    }
    
    int main()
    {
       struct test t;
    
       std::cout << doit2(t) << std::endl;
    
       return 0;
    }
    


  • C++ requires the template keyword there for disambiguation.

    template <typename T>
    int doit2(T t)
    {
       return t.template doit<5>();
    }
    


  • Thank you. I was aware of "typename" but not of "template".


  • Mod

    Merkwürdig dass er auf Englisch schreibt aber sich einen deutschen Namen gewählt hat (der mit einer englischen Tastatur schwer zu schreiben ist).



  • Mit .net TLD wirds jetzt halt "international" 😃



  • Arcoth schrieb:

    Merkwürdig dass er auf Englisch schreibt aber sich einen deutschen Namen gewählt hat (der mit einer englischen Tastatur schwer zu schreiben ist).

    Why not. To be honest I also prefer writing/speaking English.


  • Mod

    Ethon schrieb:

    Arcoth schrieb:

    Merkwürdig dass er auf Englisch schreibt aber sich einen deutschen Namen gewählt hat (der mit einer englischen Tastatur schwer zu schreiben ist).

    Why not. To be honest I also prefer writing/speaking English.

    In that case why don't we just change the default language in this forum to English? There's a reason we're talking German. I reckon that if it wasn't for the language (and our tolerance in respect to beginners posts) some people wouldn't come here in the first place and go straight to stackoverflow.



  • Leider ist das Englisch von vielen Deutschen, die meinen es gut zu können, doch eher minderer Qualität...


Anmelden zum Antworten