If you define a template class that you want to use for only a few explicit types.
Place the template declaration in the header file just like a regular class.
Place the template definition in the source file as a regular class.
Then, at the end of the source file, an instance of only the version in which you want to be available is explicitly created.
Silly example:
// StringAdapter.h template<typename T> class StringAdapter { public: StringAdapter(T* data); void doAdapterStuff(); private: std::basic_string<T> m_data; }; typedef StringAdapter<char> StrAdapter; typedef StringAdapter<wchar_t> WStrAdapter;
Source:
// StringAdapter.cpp
home
#include "StringAdapter.h"
Martin York Feb 28 2018-10-18T00 : 00Z
source share