1//
2// bind_noexcept_test.cpp
3//
4// Copyright 2017 Peter Dimov
5//
6// Distributed under the Boost Software License, Version 1.0.
7// See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#include <boost/bind/bind.hpp>
12#include <boost/core/lightweight_test.hpp>
13#include <boost/config.hpp>
14
15using namespace boost::placeholders;
16
17#if defined(BOOST_NO_CXX11_NOEXCEPT)
18
19int main()
20{
21}
22
23#else
24
25//
26
27long f_0() noexcept
28{
29 return 17041L;
30}
31
32long f_1(long a) noexcept
33{
34 return a;
35}
36
37long f_2(long a, long b) noexcept
38{
39 return a + 10 * b;
40}
41
42long f_3(long a, long b, long c) noexcept
43{
44 return a + 10 * b + 100 * c;
45}
46
47long f_4(long a, long b, long c, long d) noexcept
48{
49 return a + 10 * b + 100 * c + 1000 * d;
50}
51
52long f_5(long a, long b, long c, long d, long e) noexcept
53{
54 return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
55}
56
57long f_6(long a, long b, long c, long d, long e, long f) noexcept
58{
59 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
60}
61
62long f_7(long a, long b, long c, long d, long e, long f, long g) noexcept
63{
64 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
65}
66
67long f_8(long a, long b, long c, long d, long e, long f, long g, long h) noexcept
68{
69 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
70}
71
72long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) noexcept
73{
74 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
75}
76
77void function_test()
78{
79 int const i = 1;
80
81 BOOST_TEST( boost::bind(f_0)(i) == 17041L );
82 BOOST_TEST( boost::bind(f_1, _1)(i) == 1L );
83 BOOST_TEST( boost::bind(f_2, _1, 2)(i) == 21L );
84 BOOST_TEST( boost::bind(f_3, _1, 2, 3)(i) == 321L );
85 BOOST_TEST( boost::bind(f_4, _1, 2, 3, 4)(i) == 4321L );
86 BOOST_TEST( boost::bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L );
87 BOOST_TEST( boost::bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L );
88 BOOST_TEST( boost::bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L );
89 BOOST_TEST( boost::bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L );
90 BOOST_TEST( boost::bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L );
91}
92
93int main()
94{
95 function_test();
96 return boost::report_errors();
97}
98
99#endif
100

source code of boost/libs/bind/test/bind_noexcept_test.cpp