SFINAEHelper< T, CHECK > Class Template Reference

#include <apibase.h>

Detailed Description

template<typename T, typename... CHECK>
class maxon::SFINAEHelper< T, CHECK >

This helper class can be used for two purposes: It allows to disable function templates based on the template arguments, and to defer the compiler's requirements for complete types to the template instantiation. An example of the first usage is:

template <typename T> typename SFINAEHelper<Int, typename T::IsForEachIterator>::type MyFunction(const T& object);

MyFunction will only be available for types T which have a member type IsForEachIterator, and its result type will be Int. An example of the second usage is:

class String;
template <typename T> typename SFINAEHelper<String, T>::type ToString(const T& object) { return object.ToString(); }

Without the SFINAEHelper, the compiler would complain that String is an incomplete type and as such cannot be used for the return type of a function definition, so you'd have to include the corresponding header file for String. With the SFINAEHelper, only when the ToString template function is actually instantiated String has to be a complete type, so it suffices to include the header file for String only where it is actually used.

Template Parameters
TType used for the result.
CHECKSome types which are used for SFINAE on overload resolution.

Public Types

using type = T
Definition: c4d_string.h:35
String ToString(const String &str, const FormatStatement *formatStatement, Bool=false)
Definition: string.h:1680
T type
The result type will always be T.
Definition: apibase.h:493