class - C++ Workaround for listing all possible template implementations -


i've got multi-file project uses templates.

// foo.h template <class t> class foo {     t bar; }; 

i have class (e.g. cup) , bunch of subclasses of class.

// cup.h class cup { };  class chalice : public cup { };  class sippycup : public cup { };  // ...etc. 

in template's .cpp file, need list possible template implementations avoid linker errors. learned c++ faq.

//foo.cpp template class foo<cup>; template class foo<chalice>; template class foo<sippycup>; // ...etc. 

in reality, have 20+ subclasses i'd use @ point in code. in development, i'm creating new subclasses. each time create new one, have add growing list in foo.cpp.

this pain. there way around having list of these possibilities?

the way avoid put template function definitions in header file (i.e. in actual template definition) rather in separate .cpp file.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -