I would like a class to have a function with a template argument, and based on that template argument a particular member variable is manipulated.
For example, if function template specialization were allowed, then something like this:
struct A
{
struct M1 {};
struct M2 {};
// Function template specialization not allowed :(
template<typename M>
void addM(M const &m);
template<>
void addM(M1 const &m)
{
m1_vec_.push_back(m);
}
template<>
void addM(M2 const &m)
{
m2_vec_.push_back(m);
}
std::vector<M1> m1_vec_;
std::vector<M2> m2_vec_;
};
Any ideas? I feel like I'm missing something simple but can't quite put my finger on it.