I have a function that needs to be able to work for different container types, for example
void foo(const std::vector<bar>& param1, const std::vector<double>& params2)
and
void foo(const std::list<bar>& param1, const std::list<double>& params2)
where bar
is a class
that I've written. The function body itself uses generic C++ standard library functions.
Is there a way I can templatise this? I have tried
template<typename T> void foo(const T<bar>&, const T<double>&)
But this gives the compiler error
error C2988: unrecognizable template declaration/definition
I'm using MSVC2015.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…