I have got a template method with two specialized versions for type bool and vector<string>.
Base version:
template <class T>
const T InternGetValue(const std::string& pfad) const
{
...
}
Specialized versions:
template <>
const bool InternGetValue(const std::string& pfad) const
{
...
}
template <>
const std::vector<std::string> InternGetValue< std::vector<std::string>>(const std::string& pfad) const
{
...
}
Now I would like to implement one specialization that will accept all types of vector<aritmethic_data_type> like vector<double> vector<int> or vector<float>.
I could achieve this by writing overloads for the above types, but I’m interested in reaching my goal with another specialization.
This is what I tried so far (leads to error ‘illegal use of explicit template arguments’):
template <class T>
const std::vector<T> InternGetValue< std::vector<T>>(const std::string& pfad, typename boost::enable_if<boost::is_arithmetic<T>>::type* dummy = 0) const
{
}
I think
std::enable_ifandstd::is_integraltogether can solve this problem:If
std::doesn’t have them, then useboost::if you can. It has them.