#include <apibase.h>
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.
T | Type used for the result. |
CHECK | Some types which are used for SFINAE on overload resolution. |
Public Types |
|
using | type = T |