/*! * \file logical.h * \brief Template meta-programming logic operator and type relations. * * Copyright (C) 2018-2019 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_logical_h__ #define __utl_meta_logical_h__ #include #include /*! * \ingroup meta * \defgroup logic * logic operator and type relations support header */ //! @{ namespace utl { namespace meta{ /*! * Logical relation for types */ //! @{ //! Negate the *bool* constant parameter template using not_c = bool_; //! not template using not_ = not_c<_Tp::type::value>; //! OR implementation //! @{ namespace detail { template struct _or_; template<> struct _or_<> : false_ { }; template struct _or_<_T1> : _T1 { }; template struct _or_ <_T1, _T2> : if_<_T1, _T1, _T2> { }; template struct _or_<_T1, _T2, _T3, _Tn...> : if_<_T1, _T1, _or_<_T2, _T3, _Tn...>> { }; } template using or_ = eval>; //! @} //! AND implementation //! @{ namespace detail { template struct _and_; template<> struct _and_<> : true_ { }; template struct _and_ <_T1> : _T1 { }; template struct _and_<_T1, _T2> : if_<_T1, _T2, _T1> { }; template struct _and_<_T1, _T2, _T3, _Tn...> : if_<_T1, _and_<_T2, _T3, _Tn...>, _T1> { }; } template using and_ = eval>; //! @} //! same //! @{ template struct same_ : false_ { }; template struct same_ <_Tp, _Tp> : true_ { }; //! @} //! not same //! @{ template using not_same_ = not_>>; //! @} //! @} }} //! @} #endif /* __utl_meta_logical_h__ */