MPL11
 All Classes Namespaces Files Typedefs Macros Groups Pages
comparable.hpp
Go to the documentation of this file.
1 
12 #ifndef BOOST_MPL11_COMPARABLE_HPP
13 #define BOOST_MPL11_COMPARABLE_HPP
14 
16 
17 #include <boost/mpl11/fwd/bool.hpp>
18 #include <boost/mpl11/fwd/core.hpp>
20 
21 
22 namespace boost { namespace mpl11 {
23  template <>
24  struct instantiate<Comparable> {
25  template <typename Left, typename Right = Left>
26  struct with : true_ {
27  template <typename x, typename y>
28  using equal_impl = not_<not_equal<box<x>, box<y>>>;
29 
30  template <typename x, typename y>
31  using not_equal_impl = not_<equal<box<x>, box<y>>>;
32  };
33  };
34 }}
35 
36 
37 #include <boost/mpl11/bool.hpp>
38 #include <boost/mpl11/core.hpp>
40 #include <boost/mpl11/logical.hpp>
41 
42 
43 namespace boost { namespace mpl11 {
44  template <typename Left, typename Right, typename>
45  struct Comparable : instantiate<Comparable>::template with<Left, Right> {
46  template <typename x, typename y>
47  using equal_impl = bool_<detail::std_is_same<x, y>::value>;
48 
49  template <typename x, typename y>
50  using not_equal_impl = bool_<!detail::std_is_same<x, y>::value>;
51  };
52 
53  template <typename x1, typename x2, typename ...xs>
54  struct equal
55  : and_<equal<x1, x2>, equal<x2, xs...>>
56  { };
57 
58  template <typename x, typename y>
59  struct equal<x, y> :
60  Comparable<
61  typename datatype<typename x::type>::type,
62  typename datatype<typename y::type>::type
63  >::template equal_impl<typename x::type, typename y::type>
64  { };
65 
66  template <typename x, typename y>
67  struct not_equal :
68  Comparable<
69  typename datatype<typename x::type>::type,
70  typename datatype<typename y::type>::type
71  >::template not_equal_impl<typename x::type, typename y::type>
72  { };
73 }} // end namespace boost::mpl11
74 
75 #endif // !BOOST_MPL11_COMPARABLE_HPP
Forward declares the Core module.
Returns whether the given objects are unequal.
Definition: comparable.hpp:67
Forwards to boost/mpl11/fwd/integer.hpp.
Returns the result of short-circuit logical and (&&) on its arguments.
Definition: logical.hpp:36
Forward declares logical metafunctions.
Defines the Logical module.
Defines boost::mpl11::detail::std_is_same.
Defines the Core module.
Forward declares the Comparable typeclass.
Returns whether the given objects are equal.
Definition: comparable.hpp:54
Forwards to boost/mpl11/integer.hpp.