/*! * \file sfinae.h * \brief Template meta-programming SFINAE helpers * * Copyright (C) 2018 Christos Choutouridis * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef __utl_meta_sfinae_h__ #define __utl_meta_sfinae_h__ #include /*! * \ingroup meta * \defgroup sfinae * conditional use support header. */ //! @{ namespace utl { namespace meta { //! Tool to enable a partial specialization only if a boolean condition is true. //! @{ namespace detail { template struct dev_null { using type = dev_null; }; //< Same as typelist template struct when_ { }; template <> struct when_ { using type = void; }; } //! Well formed only if \p If is true template using when = type_>; //! Well formed only if all of \p Ifs are \c true template using when_all = detail::dev_null< when... >; //! @} //! select _Tp if \p If is true, else SFINAE //! We implement eneble_if so we don't have to pull entire \c from stl //! @{ template struct enable_if { using type = _Tp; }; template struct enable_if { /* SFINAE*/ }; //! Alias template for enable_if template using use_if = enable_if; //! Publicly recognized alias template for enable_if template using enable_if_t = type_< enable_if >; //! Uniform alias template for use_if template using use_if_t = type_< enable_if >; //! @} }} //! @} #endif /* __utl_meta_sfinae_h__ */