I want to make a template function that takes a function and a vector and uses the function to map that vector to another vector that will be returned by the function templa
Here's my approach:
template <std::size_t, typename T = void> struct ignore_value {typedef T type;};
template <typename T>
T& declval();
template<typename F, typename T>
typename ignore_value<sizeof(declval<F>()(declval<T const>())),
std::vector<T> >::type map_vec(F fnc, const std::vector<T>& source);
template<typename F, typename T>
typename ignore_value<sizeof(declval<F>()
(declval<T const>(), declval<const std::vector<T> >())),
std::vector<T> >::type map_vec(F fnc, const std::vector<T>& source);
It works with the same Demo that 0x499602D2 used, with both GCC and Clang in C++98 mode.