I have this code:
template<typename T, bool> class Ensure
{
typedef T type;
};
template<typename T> class Ensure<T, false> {};
template<typename T, typename U>
T mix(const T& x, const T& y, const U& a)
{
return x * (static_cast<U>(1.0) - a) + y * a;
}
template<typename T, typename U>
T mix(typename Ensure<T, std::is_scalar<T>::value>::type x,
typename Ensure<T, std::is_scalar<T>::value>::type y,
typename Ensure<T, std::is_scalar<T>::value>::type a)
{
return x * (static_cast<U>(1.0) - a) + y * a;
}
I think that I have understood that mix take const T& with object types and T with scalar types. However, I want to check it.
I want to test if the right function is called by this code:
float a = 0, b = 0, c = 0;
mix(a, b, c); // const float& or float ?
COncretly how to get a function pointer or the type of function with a function call ?
Something like: decltype((&mix)(a, b, c)) ptr; std::cout << typeid(ptr).name() << std::endl
Aucun commentaire:
Enregistrer un commentaire