I have the following two functions:
class Leaf {...};
void SpitLeaves(std::string & sdata, std::vector<Leaf> const & leaves);
void SpitLeaves(std::string & sdata, std::set<Leaf> const & leaves);
The definition of these functions is identical.
It's an obvious candidate for templatizing the function.
However, despite a search, I cannot figure out how to properly declare the template function. From https://stackoverflow.com/a/4697356/368896 and others, I have tried signatures such as:
template <template<typename> class T>
void SpitLeaves(std::string & sdata, T<Leaf> const & leaves)
{...}
However, this gives a compiler error at the point I attempt to instantiate the template function:
std::string leaves_str;
std::vector<Leaf> leaves;
SpitLeaves<std::vector>(leaves_str, leaves);
... The error (VS 2013) is 'SpitLeaves' : template parameter list for class template 'std::vector' does not match template parameter list for template template parameter 'T'
.
How do I properly declare the above template function?