File: deduced.hpp

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (77 lines) | stat: -rw-r--r-- 1,870 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright Daniel Wallin 2006. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_DEDUCED_060920_HPP
# define BOOST_DEDUCED_060920_HPP

# include <boost/mpl/for_each.hpp>
# include "basics.hpp"

struct not_present_tag {};
not_present_tag not_present;

template <class E, class ArgPack>
struct assert_expected
{
    assert_expected(E const& e, ArgPack const& args)
      : expected(e)
      , args(args)
    {}

    template <class T>
    bool check_not_present(T const&) const
    {
        BOOST_MPL_ASSERT((boost::is_same<T,not_present_tag>));
        return true;
    }

    template <class K>
    bool check1(K const& k, not_present_tag const&, long) const
    {
        return check_not_present(args[k | not_present]);
    }

    template <class K, class Expected>
    bool check1(K const& k, Expected const& expected, int) const
    {
        return test::equal(args[k], expected);
    }

    template <class K>
    void operator()(K) const
    {
        boost::parameter::keyword<K> const& k = boost::parameter::keyword<K>::get();
        assert(check1(k, expected[k], 0L));
    }

    E const& expected;
    ArgPack const& args;
};

template <class E, class ArgPack>
void check0(E const& e, ArgPack const& args)
{
    boost::mpl::for_each<E>(assert_expected<E,ArgPack>(e, args));
}

template <class P, class E, class A0>
void check(E const& e, A0 const& a0)
{
    check0(e, P()(a0));
}

template <class P, class E, class A0, class A1>
void check(E const& e, A0 const& a0, A1 const& a1)
{
    check0(e, P()(a0,a1));
}

template <class P, class E, class A0, class A1, class A2>
void check(E const& e, A0 const& a0, A1 const& a1, A2 const& a2)
{
    check0(e, P()(a0,a1,a2));
}

#endif // BOOST_DEDUCED_060920_HPP