File: deduced_dependent_predicate.cpp

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (162 lines) | stat: -rw-r--r-- 5,345 bytes parent folder | download | duplicates (7)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Copyright Daniel Wallin 2006.
// Distributed under 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)

#include <boost/parameter/config.hpp>
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/name.hpp>
#include <boost/parameter/binding.hpp>
#include "deduced.hpp"

#if defined(BOOST_PARAMETER_CAN_USE_MP11)
#include <boost/mp11/bind.hpp>
#include <boost/mp11/utility.hpp>
#include <type_traits>
#else
#include <boost/mpl/bool.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_convertible.hpp>
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
#include <boost/type_traits/remove_reference.hpp>
#else
#include <boost/type_traits/add_lvalue_reference.hpp>
#endif  // Borland workarounds needed
#endif  // BOOST_PARAMETER_CAN_USE_MP11

namespace test {

    BOOST_PARAMETER_NAME(x)
    BOOST_PARAMETER_NAME(y)
    BOOST_PARAMETER_NAME(z)
} // namespace test

#include <boost/core/lightweight_test.hpp>

int main()
{
    test::check<
        boost::parameter::parameters<
            test::tag::x
          , boost::parameter::optional<
                boost::parameter::deduced<test::tag::y>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
              , boost::mp11::mp_bind<
                    std::is_same
                  , boost::mp11::_1
                  , boost::mp11::mp_bind<
                        test::tag::x::binding_fn
                      , boost::mp11::_2
                    >
                >
#else   // !defined(BOOST_PARAMETER_CAN_USE_MP11)
              , boost::mpl::if_<
                    boost::is_same<
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
                        boost::mpl::_1
                      , boost::remove_reference<
                            boost::parameter::binding<
                                boost::mpl::_2
                              , test::tag::x
                            >
                        >
#else
                        boost::add_lvalue_reference<boost::mpl::_1>
                      , boost::parameter::binding<boost::mpl::_2,test::tag::x>
#endif  // Borland workarounds needed
                    >
                  , boost::mpl::true_
                  , boost::mpl::false_
                >
#endif  // BOOST_PARAMETER_CAN_USE_MP11
            >
        >
    >((test::_x = 0, test::_y = 1), 0, 1);

    test::check<
        boost::parameter::parameters<
            test::tag::x
          , boost::parameter::optional<
                boost::parameter::deduced<test::tag::y>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
              , boost::mp11::mp_bind<
                    std::is_same
                  , boost::mp11::_1
                  , boost::mp11::mp_bind<
                        test::tag::x::binding_fn
                      , boost::mp11::_2
                    >
                >
#else   // !defined(BOOST_PARAMETER_CAN_USE_MP11)
              , boost::mpl::if_<
                    boost::is_same<
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
                        boost::mpl::_1
                      , boost::remove_reference<
                            boost::parameter::binding<
                                boost::mpl::_2
                              , test::tag::x
                            >
                        >
#else
                        boost::add_lvalue_reference<boost::mpl::_1>
                      , boost::parameter::binding<boost::mpl::_2,test::tag::x>
#endif  // Borland workarounds needed
                    >
                  , boost::mpl::true_
                  , boost::mpl::false_
                >
#endif  // BOOST_PARAMETER_CAN_USE_MP11
            >
        >
    >((test::_x = 0U, test::_y = 1U), 0U, 1U);

    test::check<
        boost::parameter::parameters<
            test::tag::x
          , boost::parameter::optional<
                boost::parameter::deduced<test::tag::y>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
              , boost::mp11::mp_bind<
                    std::is_convertible
                  , boost::mp11::_1
                  , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2>
                >
#else
              , boost::mpl::if_<
                    boost::is_convertible<boost::mpl::_1,test::tag::x::_>
                  , boost::mpl::true_
                  , boost::mpl::false_
                >
#endif
            >
        >
    >((test::_x = 0, test::_y = 1), 0, 1);

    test::check<
        boost::parameter::parameters<
            test::tag::x
          , boost::parameter::optional<
                boost::parameter::deduced<test::tag::y>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
              , boost::mp11::mp_bind<
                    std::is_convertible
                  , boost::mp11::_1
                  , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2>
                >
#else
              , boost::mpl::if_<
                    boost::is_convertible<boost::mpl::_1,test::tag::x::_1>
                  , boost::mpl::true_
                  , boost::mpl::false_
                >
#endif
            >
        >
    >((test::_x = 0U, test::_y = 1U), 0U, 1U);

    return boost::report_errors();
}