c++ - Can a template member function specialization also be an instantiation? -


i'm running issue template specialization. following builds , runs, i'm not sure should:

// template.h template <typename t> class interface{ public:    void dosomething(); };  // template.cpp #include "template.h" #include <iostream> template <> void interface<int>::dosomething(){std::cout << "did something\n";}  // main.cpp #include "template.h" int main(){    interface<int> instance;    instance.dosomething();    return 0;  };  g++ main.cpp template.cpp; ./a.out 

my understanding compilation units supposed have access template specializations, main.cpp not. if understand what's happening correctly, specialization in template.cpp instantiates interface< int >, symbol generated , links happily. however, i'm pretty sure falls realm of undefinedness , can't count on working everywhere. can please confirm or deny suspicions?

thanks!


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -