/*! * \file sfinae.h * \brief Template meta-programming SFINAE helpers */ #ifndef __utl_meta_sfinae_h__ #define __utl_meta_sfinae_h__ #include #include #include /*! * \ingroup meta * \defgroup sfinae SFINAE * conditional use support header. */ //! @{ namespace utl { namespace meta { //! \name enable_if from STL //! @{ //! enable_if, imported from stl template using enable_if = std::enable_if; //! alias template for enable_if template using enable_if_t = eval< enable_if >; //! @} //! \name when implementation //! @{ namespace details { // template // struct dev_null { using type = dev_null; }; //< Same as typelist template struct when_ { }; template <> struct when_ { using type = void; }; } //! Tool to enable a partial specialization only if a boolean condition is true. //! Well formed only if \p If is true template using when = eval< details::when_ >; // //! Well formed only if all of \p Ifs are \c true // template // using when_all = details::dev_null< // when... // >; //! @} //! If same type resolves to _Ret, else SFINAE template using use_if_same_t = enable_if_t< same_<_T1, _T2>::value, _Ret >; //! If not same type resolves to _Ret, else SFINAE template using use_if_not_same_t = enable_if_t< !same_<_T1, _T2>::value, _Ret >; //! If any type (_T1 or _T2) type resolves to _Ret, else to SFINAE template using use_if_any_t = enable_if_t< or_::value, T1 >; //! If both type (_T1 and _T2) type resolves to _Ret, else to SFINAE template using use_if_all_t = enable_if_t< and_::value, T1 >; }} //! @} #endif /* __utl_meta_sfinae_h__ */