How to explicitly instantiate a template for all members of MPL vector in C++?
问题 Consider the following header file: // Foo.h class Foo { public: template <typename T> void read(T& value); }; I want to explicitly instantiate the Foo::read member function template in a source file for all types included in a boost::mpl::vector : // Foo.cc #include <boost/mpl/vector.hpp> #include <boost/mpl/begin_end.hpp> #include "Foo.h" template <typename T> void Foo::read(T& value) { /* do something */ } typedef boost::mpl::vector<int, long, float> types; // template Foo::read<int >(int&