#pragma once #ifndef TCG_SFINAE_H #define TCG_SFINAE_H /*! \file sfinae.h \brief Contains template metafunctions that can be used to enable or disable template class members. \details SFINAE (Substitution Failure Is Not An Error) is a C++ \a feature that allows the compiler to silently discard failures in template function instantiations during function overload resolution. */ #if defined(__APPLE_CC__) #include #endif namespace tcg { template struct type_match { enum { value = false }; }; template struct type_match { enum { value = true }; }; //------------------------------------------------------------------------ template struct type_mismatch { enum { value = true }; }; template struct type_mismatch { enum { value = false }; }; //======================================================================== template struct enable_if_exists { typedef B type; }; //======================================================================== template struct enable_if { }; template struct enable_if { typedef T type; }; //======================================================================== template struct disable_if { typedef T type; }; template struct disable_if { }; //======================================================================== template struct choose_if; template struct choose_if { typedef TrueT type; }; template struct choose_if { typedef FalseT type; }; //======================================================================== template struct choose_if_match { typedef NotMatchedT type; }; template struct choose_if_match { typedef MatchT type; }; } // namespace tcg #endif // TCG_SFINAE_H