MPL11
 All Classes Namespaces Files Typedefs Macros Groups Pages
expect.hpp
Go to the documentation of this file.
1 
12 #ifndef BOOST_MPL11_DETAIL_TEST_EXPECT_HPP
13 #define BOOST_MPL11_DETAIL_TEST_EXPECT_HPP
14 
19 #include <boost/mpl11/logical.hpp>
20 
21 
22 namespace boost { namespace mpl11 { namespace detail {
23  template <typename ...xs>
24  struct instantiate {
25  // We avoid empty arrays by adding a dummy 0.
26  static constexpr std_size_t go[] = {0, sizeof(xs)...};
27 
28  using type = instantiate;
29  };
30 
31  template <typename ...xs>
32  struct show {
33  static_assert(dependent<xs...>::value(false), "");
34  };
35 
36  template <typename expr>
37  struct expect {
38  template <template <typename ...> class Bool>
39  struct _to {
40  template <typename r, bool =
41  Bool<equal<expr, r>>::value &&
42  !Bool<not_equal<expr, r>>::value
43  >
44  struct eq { };
45 
46  template <typename r>
47  struct eq<r, false>
48  : show<expr, r>,
49  show<typename expr::type, typename r::type>
50  { };
51 
52  template <typename predicate>
53  struct satisfy {
54  static_assert(Bool<
55  typename predicate::type::template apply<expr>
56  >::value, "");
57  };
58 
59  template <typename comparison>
60  struct be {
61  template <typename r, bool = Bool<
62  typename comparison::type::template apply<expr, r>
63  >::value>
64  struct than { };
65 
66  template <typename r>
67  struct than<r, false>
68  : show<expr, r>
69  , show<typename expr::type, typename r::type>
70  { };
71 
72  template <typename r>
73  using with = than<r>;
74  };
75 
76  template <template <typename ...> class f>
77  using be_ = be<lift<f>>;
78  };
79 
80  using to = _to<id>;
81  using not_to = _to<not_>;
82 
83  template <typename r>
84  using to_eq = typename to::template eq<r>;
85 
86  template <typename pred>
87  using to_satisfy = typename to::template satisfy<pred>;
88  };
89 }}} // end namespace boost::mpl11::detail
90 
91 #endif // !BOOST_MPL11_DETAIL_TEST_EXPECT_HPP
Defines boost::mpl11::detail::std_size_t.
Defines the Logical module.
Defines boost::mpl11::detail::dependent.
Forward declares the Comparable typeclass.
Invokes a metafunction class with the given arguments.
Definition: functional.hpp:39
Defines the Functional module.