1 // Copyright Daniel Wallin 2006.
2 // Copyright Cromwell D. Enage 2017.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_DEDUCED_060920_HPP
8 #define BOOST_DEDUCED_060920_HPP
10 #include <boost/parameter/config.hpp>
13 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
14 #include <boost/mp11/map.hpp>
15 #include <boost/mp11/algorithm.hpp>
17 #include <boost/mpl/bool.hpp>
18 #include <boost/mpl/if.hpp>
19 #include <boost/mpl/for_each.hpp>
20 #include <boost/mpl/assert.hpp>
21 #include <boost/type_traits/is_same.hpp>
26 struct not_present_tag
30 not_present_tag not_present;
32 template <typename E, typename ArgPack>
39 assert_expected(E const& e, ArgPack const& args_)
40 : _expected(e), _args(args_)
45 static bool check_not_present(T const&)
47 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
49 std::is_same<T,test::not_present_tag>::value
50 , "T == test::not_present_tag"
54 typename boost::mpl::if_<
55 boost::is_same<T,test::not_present_tag>
65 bool check1(K const& k, test::not_present_tag const& t, long) const
67 return assert_expected<E,ArgPack>::check_not_present(
72 template <typename K, typename Expected>
73 bool check1(K const& k, Expected const& e, int) const
75 return test::equal(this->_args[k], e);
79 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
80 void operator()(K&&) const
82 void operator()(K) const
85 boost::parameter::keyword<K> const&
86 k = boost::parameter::keyword<K>::instance;
87 BOOST_TEST(this->check1(k, this->_expected[k], 0L));
91 template <typename E, typename A>
92 void check0(E const& e, A const& args)
94 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
95 boost::mp11::mp_for_each<boost::mp11::mp_map_keys<E> >(
96 test::assert_expected<E,A>(e, args)
99 boost::mpl::for_each<E>(test::assert_expected<E,A>(e, args));
103 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
104 template <typename P, typename E, typename ...Args>
105 void check(E const& e, Args const&... args)
107 test::check0(e, P()(args...));
110 template <typename P, typename E, typename A0>
111 void check(E const& e, A0 const& a0)
113 test::check0(e, P()(a0));
116 template <typename P, typename E, typename A0, typename A1>
117 void check(E const& e, A0 const& a0, A1 const& a1)
119 test::check0(e, P()(a0, a1));
122 template <typename P, typename E, typename A0, typename A1, typename A2>
123 void check(E const& e, A0 const& a0, A1 const& a1, A2 const& a2)
125 test::check0(e, P()(a0, a1, a2));
127 #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
130 #endif // include guard