|
- /*!
- * \file useif.h
- * \brief Template meta-programming SFINAE helpers
- *
- * \copyright
- * Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
- * 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.\n
- * 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.\n
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
- #ifndef __utl_meta_useif_h__
- #define __utl_meta_useif_h__
-
- #include <utl/core/impl.h>
- #include <utl/meta/operations.h>
- #include <utl/meta/sfinae.h>
-
- /*!
- * \ingroup meta
- * \addtogroup sfinae
- */
- //! @{
- namespace utl {
- namespace meta {
-
- //! If same type resolves to Ret, else SFINAE
- template <typename T1, typename T2, typename Ret =T1>
- using use_if_same_t = enable_if_t<
- eval_v<same_<T1, T2>>, Ret
- >;
- //! If not same type resolves to Ret, else SFINAE
- template <typename T1, typename T2, typename Ret =T1>
- using use_if_not_same_t = enable_if_t<
- eval_v<not_same_<T1, T2>>, Ret
- >;
- //! If any type (T1 or T2) type resolves to Ret, else to SFINAE
- template <typename T1, typename... Ts>
- using use_if_any_t = enable_if_t<
- eval_v<or_<T1, Ts...>>, T1
- >;
-
- //! If both type (T1 and T2) type resolves to Ret, else to SFINAE
- template <typename T1, typename... Ts>
- using use_if_all_t = enable_if_t<
- eval_v<and_<T1, Ts...>>, T1
- >;
-
- }}
-
- //! @}
-
- #endif /* __utl_meta_useif_h__ */
|