operations.h
Go to the documentation of this file.
#ifndef __utl_meta_operations_h__
#define __utl_meta_operations_h__
#include <utl/core/impl.h>
#include <utl/meta/selection.h>
namespace utl {
namespace meta{
template <bool B>
using not_c = bool_<!B>;
template<typename _Tp>
using not_ = not_c<_Tp::type::value>;
namespace detail {
template<typename...> struct _or_;
template<>
struct _or_<> : false_ { };
template<typename _T1>
struct _or_<_T1> : _T1 { };
template<typename _T1, typename _T2>
struct _or_ <_T1, _T2>
: if_<_T1, _T1, _T2> { };
template<typename _T1, typename _T2, typename _T3, typename... _Tn>
struct _or_<_T1, _T2, _T3, _Tn...>
: if_<_T1, _T1, _or_<_T2, _T3, _Tn...>> { };
}
template <typename... _Ts>
using or_ = eval<detail::_or_<_Ts...>>;
namespace detail {
template<typename...> struct _and_;
template<>
struct _and_<>
: true_ { };
template<typename _T1>
struct _and_ <_T1>
: _T1 { };
template<typename _T1, typename _T2>
struct _and_<_T1, _T2>
: if_<_T1, _T2, _T1> { };
template<typename _T1, typename _T2, typename _T3, typename... _Tn>
struct _and_<_T1, _T2, _T3, _Tn...>
: if_<_T1, _and_<_T2, _T3, _Tn...>, _T1> { };
}
template <typename... _Ts>
using and_ = eval<detail::_and_<_Ts...>>;
template<typename _T1, typename _T2>
struct same_ : false_ { };
template<typename _Tp>
struct same_ <_Tp, _Tp> : true_ { };
template<typename _T1, typename _T2>
using not_same_ = not_<eval<same_<_T1, _T2>>>;
}}
namespace utl {
namespace meta {
template <typename _Tp>
using negate = integral_<decltype(-_Tp()), -_Tp()>;
template <typename _Tp1, typename _Tp2>
using add = integral_<
decltype(_Tp1() + _Tp2()),
_Tp1() + _Tp2()
>;
template <typename _Tp1, typename _Tp2>
using mult = integral_<
decltype(_Tp2() * _Tp2()),
_Tp1() * _Tp2()
>;
template <typename _Tp1, typename _Tp2>
using divide = integral_<
decltype(_Tp2() / _Tp2()),
_Tp1() / _Tp2()
>;
template <typename _Tp1, typename _Tp2>
using modulo = integral_<
decltype(_Tp1() % _Tp2()),
_Tp1() % _Tp2()
>;
template <typename _Tp1, typename _Tp2>
using sub = add<_Tp1, negate<_Tp2>>;
template <typename _Tp>
using inc = add<_Tp, int_<1>>;
template <typename _Tp>
using dec = add<_Tp, int_<-1>>;
template <typename _Tp1, typename _Tp2> using comp_eq = bool_<_Tp1() == _Tp2()>;
template <typename _Tp1, typename _Tp2> using comp_lt = bool_<(_Tp1() < _Tp2())>;
template <typename _Tp1, typename _Tp2> using comp_ne = not_<comp_eq<_Tp1, _Tp2>>;
template <typename _Tp1, typename _Tp2> using comp_gt = comp_lt <_Tp2, _Tp1>;
template <typename _Tp1, typename _Tp2> using comp_le = not_<comp_lt<_Tp2, _Tp1>>;
template <typename _Tp1, typename _Tp2> using comp_ge = not_<comp_lt<_Tp1, _Tp2>>;
template <typename _T> using bitnot_ = integral_<typename _T::value_type, (typename _T::value_type)(~_T())>;
template <typename _Tp1, typename _Tp2>
using bitand_ = integral_<decltype(_Tp1() & _Tp2()), _Tp1() & _Tp2()>;
template <typename _Tp1, typename _Tp2>
using bitor_ = integral_<decltype(_Tp1() | _Tp2()), _Tp1() | _Tp2()>;
template <typename _Tp1, typename _Tp2>
using bitxor_ = integral_<decltype(_Tp1() ^ _Tp2()), _Tp1() ^ _Tp2()>;
template <typename _Tp, typename shift>
using shift_left = integral_<typename _Tp::value_type, (typename _Tp::value_type)(_Tp() << shift())>;
template <typename _Tp, typename shift>
using shift_right = integral_<typename _Tp::value_type, (typename _Tp::value_type)(_Tp() >> shift())>;
}}
#endif /* __utl_meta_operations_h__ */
utl::meta::detail::_and_< _T1 >
Definition: operations.h:83
utl::meta::comp_eq
bool_< _Tp1()==_Tp2()> comp_eq
Definition: operations.h:184
utl::meta::shift_right
integral_< typename _Tp::value_type,(typename _Tp::value_type)(_Tp() > > shift())> shift_right
Definition: operations.h:221
utl::meta::comp_ne
not_< comp_eq< _Tp1, _Tp2 > > comp_ne
Not equal.
Definition: operations.h:189
utl::meta::if_
if_c< If::type::value, Args... > if_
Select one type or another depending on a compile-time Boolean type.
Definition: selection.h:66
utl::meta::bitand_
integral_< decltype(_Tp1() &_Tp2()), _Tp1() &_Tp2()> bitand_
Definition: operations.h:208
utl::meta::negate
integral_< decltype(-_Tp()), -_Tp()> negate
Negation.
Definition: operations.h:138
utl::meta::detail::_and_
Definition: operations.h:76
utl::meta::sub
add< _Tp1, negate< _Tp2 > > sub
Substruction.
Definition: operations.h:165
utl::meta::mult
integral_< decltype(_Tp2() *_Tp2()), _Tp1() *_Tp2() > mult
Multiplication.
Definition: operations.h:150
utl::meta::true_
bool_< true > true_
The type used as a compile-time boolean with true value.
Definition: integral.h:68
utl::meta::detail::_or_< _T1 >
Definition: operations.h:58
utl::meta::comp_lt
bool_<(_Tp1()< _Tp2())> comp_lt
Definition: operations.h:186
utl::meta::bitor_
integral_< decltype(_Tp1()|_Tp2()), _Tp1()|_Tp2()> bitor_
Definition: operations.h:211
utl::meta::bitnot_
integral_< typename _T::value_type,(typename _T::value_type)(~_T())> bitnot_
Definition: operations.h:205
utl::meta::integral_
std::integral_constant< Tp, v > integral_
Definition: integral.h:58
selection.h
Template meta-programming type selections.
utl::meta::modulo
integral_< decltype(_Tp1() % _Tp2()), _Tp1() % _Tp2() > modulo
Modulo.
Definition: operations.h:162
utl::meta::comp_gt
comp_lt< _Tp2, _Tp1 > comp_gt
Greater than.
Definition: operations.h:191
utl::meta::shift_left
integral_< typename _Tp::value_type,(typename _Tp::value_type)(_Tp()<< shift())> shift_left
Definition: operations.h:218
utl::meta::int_
integral_< int, v > int_
int_ type: integral constant wrapper for int
Definition: integral.h:98
utl::meta::false_
bool_< false > false_
The type used as a compile-time boolean with false value.
Definition: integral.h:69
utl::meta::add
integral_< decltype(_Tp1()+_Tp2()), _Tp1()+_Tp2() > add
Addition.
Definition: operations.h:144
utl::meta::eval
typename Tp::type eval
Type alias for Tp::type. Used to evaluate/extract return type of metafunctions.
Definition: integral.h:49
utl::meta::not_c
bool_<!B > not_c
Negate the bool constant parameter.
Definition: operations.h:43
utl
STL&#39;s core language concepts.
Definition: _1wire.h:30
utl::meta::same_
Definition: operations.h:102
utl::meta::bitxor_
integral_< decltype(_Tp1() ^ _Tp2()), _Tp1() ^ _Tp2()> bitxor_
Definition: operations.h:215
utl::meta::dec
add< _Tp, int_<-1 > > dec
decrease
Definition: operations.h:173
utl::meta::comp_ge
not_< comp_lt< _Tp1, _Tp2 > > comp_ge
Greater or equal.
Definition: operations.h:195
utl::meta::bool_
integral_< bool, v > bool_
bool_ type: integral constant wrapper for bool
Definition: integral.h:66
utl::meta::divide
integral_< decltype(_Tp2()/_Tp2()), _Tp1()/_Tp2() > divide
Division.
Definition: operations.h:156
utl::meta::not_same_
not_< eval< same_< _T1, _T2 > >> not_same_
Definition: operations.h:111
utl::meta::detail::_and_< _T1, _T2 >
Definition: operations.h:87
utl::meta::or_
eval< detail::_or_< _Ts... > > or_
Definition: operations.h:70
utl::meta::not_
not_c< _Tp::type::value > not_
not
Definition: operations.h:47
utl::meta::and_
eval< detail::_and_< _Ts... > > and_
Definition: operations.h:96
utl::meta::detail::_or_
Definition: operations.h:52
utl::meta::detail::_or_<>
Definition: operations.h:55
utl::meta::detail::_and_<>
Definition: operations.h:79
utl::meta::comp_le
not_< comp_lt< _Tp2, _Tp1 > > comp_le
Less or equal.
Definition: operations.h:193
utl::meta::detail::_or_< _T1, _T2 >
Definition: operations.h:61
impl.h
Implementation detail main forward header.
utl::meta::inc
add< _Tp, int_< 1 > > inc
Increase.
Definition: operations.h:169