MPL11
 All Classes Namespaces Files Typedefs Macros Groups Pages
logical.hpp
Go to the documentation of this file.
1 
12 #ifndef BOOST_MPL11_LOGICAL_HPP
13 #define BOOST_MPL11_LOGICAL_HPP
14 
16 
17 #include <boost/mpl11/bool.hpp>
19 
20 
21 namespace boost { namespace mpl11 {
22  namespace logical_detail {
23  template <bool cond>
24  struct if_impl;
25 
26  template <>
27  struct if_impl<true> {
28  template <typename Then, typename Else>
29  using result = Then;
30  };
31 
32  template <>
33  struct if_impl<false> {
34  template <typename Then, typename Else>
35  using result = Else;
36  };
37 
38  template <typename x, typename y>
39  struct and2
40  : bool_<
41  (bool)if_c<(bool)x::type::value, y, x>::type::value
42  >
43  { };
44 
45  template <typename x, typename y>
46  struct or2
47  : bool_<
48  (bool)if_c<(bool)x::type::value, x, y>::type::value
49  >
50  { };
51  } // end namespace logical_detail
52 
53  template <typename ...xs>
54  struct and_
55  : detail::right_folds::variadic<logical_detail::and2, true_, xs...>
56  { };
57 
58  template <typename ...xs>
59  struct or_
60  : detail::right_folds::variadic<logical_detail::or2, false_, xs...>
61  { };
62 
63  template <typename x>
64  struct not_
65  : bool_<!x::type::value>
66  { };
67 
68  template <typename Condition, typename Then, typename Else>
69  struct if_ :
70  logical_detail::if_impl<(bool)Condition::type::value>::
71  template result<Then, Else>
72  { };
73 }} // end namespace boost::mpl11
74 
75 #endif // !BOOST_MPL11_LOGICAL_HPP
Forward declares logical metafunctions.
Defines boost::mpl11::detail::right_folds::variadic.
Forwards to boost/mpl11/integer.hpp.