|
- /*!
- * \file use.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 <http://www.gnu.org/licenses/>.
- */
- #ifndef __utl_meta_use_h__
- #define __utl_meta_use_h__
-
- #include <utl/impl/version.h>
- #include <utl/meta/logical.h>
-
-
- /*!
- * \ingroup meta
- * \defgroup use
- * conditional use support header. This is a SFINAE helper
- */
- //! @{
- namespace utl {
-
- //! If same type resolves to _Ret, else to SFINAE
- //! @{
- template <typename _Tp1, typename _Tp2, typename _Ret>
- struct use_if_same_ {
- using type = enable_if_t <
- same_<_Tp1, _Tp2>::value,
- _Ret
- >;
- };
- template <typename _Tp1, typename _Tp2, typename _Ret>
- using use_if_same_t = typename use_if_same_<_Tp1, _Tp2, _Ret>::type;
- //! @}
-
- //! If same type resolves to SFINAE, else to _Ret
- //! @{
- template <typename _Tp1, typename _Tp2, typename _Ret>
- struct discard_if_same_ {
- using type = enable_if_t <
- !same_<_Tp1, _Tp2>::value,
- _Ret
- >;
- };
- template <typename _Tp1, typename _Tp2, typename _Ret>
- using discard_if_same_t = typename discard_if_same_<_Tp1, _Tp2, _Ret>::type;
- //! @}
-
- }
-
- //! @}
- #endif /* __utl_meta_use_h__ */
|