I have defined many objects, and for some of them, i defined a function :
template <typename Ratio>
auto print(const T &t, bool a= true, bool b= true)
{
std::stringstream ss;
// ... do stuff ...
return ss.str();
}
where T is the type of one of the objects for which print is defined. Ratio is used inside the function.
My question is : Is there a way for a type T to find if this function exists ?
For others uses, i already used templates and SFINAE to detect if a class member method exists. But for my problem here, i can't find the solution ... Anyone ?
Thanks, Ben
PS : Example of SFINAE use in my code, where i needed to detect if a class member method exists .
static T none() { ... }
/**
* SFINAE for checking id none method exists
*/
template <class T>
static auto hasNoneMethod(int)
-> std::integral_constant<bool, std::is_same<T, decltype(T::none())>::value>;
template <class>
static auto hasNoneMethod(...) -> std::false_type;
/**
* Type-Function
*/
template <typename T>
struct HasNoneMethod: decltype(detail::hasNoneMethod<T>(0)) {
};