A way to do this is to use it std::enable_ifin some form or form. The supported type selector is then used as the return type. For instance:
template <typename T> struct is_supported { enum { value = false }; };
template <> struct is_supported<int> { enum { value = true }; };
template <> struct is_supported<float> { enum { value = true }; };
template <> struct is_supported<double> { enum { value = true }; };
template <typename T>
typename std::enable_if<is_supported<T>::value, T>::type
restricted_template(T const& value) {
return value;
}
, , , is_supported. std::enable_if ++ 2011, boost, .
, , . .