blob: 44af4f69dde229ee5ce04673c18435c94ee66dc8 [file] [log] [blame]
Brian Silvermance4aa8d2018-08-04 23:36:03 -07001//
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.hpp>
12#include <boost/core/lightweight_test.hpp>
13#include <boost/config.hpp>
14
15#if defined(BOOST_NO_CXX11_NOEXCEPT)
16
17int main()
18{
19}
20
21#else
22
23//
24
25long f_0() noexcept
26{
27 return 17041L;
28}
29
30long f_1(long a) noexcept
31{
32 return a;
33}
34
35long f_2(long a, long b) noexcept
36{
37 return a + 10 * b;
38}
39
40long f_3(long a, long b, long c) noexcept
41{
42 return a + 10 * b + 100 * c;
43}
44
45long f_4(long a, long b, long c, long d) noexcept
46{
47 return a + 10 * b + 100 * c + 1000 * d;
48}
49
50long f_5(long a, long b, long c, long d, long e) noexcept
51{
52 return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
53}
54
55long f_6(long a, long b, long c, long d, long e, long f) noexcept
56{
57 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
58}
59
60long f_7(long a, long b, long c, long d, long e, long f, long g) noexcept
61{
62 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
63}
64
65long f_8(long a, long b, long c, long d, long e, long f, long g, long h) noexcept
66{
67 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
68}
69
70long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) noexcept
71{
72 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
73}
74
75void function_test()
76{
77 int const i = 1;
78
79 BOOST_TEST( boost::bind(f_0)(i) == 17041L );
80 BOOST_TEST( boost::bind(f_1, _1)(i) == 1L );
81 BOOST_TEST( boost::bind(f_2, _1, 2)(i) == 21L );
82 BOOST_TEST( boost::bind(f_3, _1, 2, 3)(i) == 321L );
83 BOOST_TEST( boost::bind(f_4, _1, 2, 3, 4)(i) == 4321L );
84 BOOST_TEST( boost::bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L );
85 BOOST_TEST( boost::bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L );
86 BOOST_TEST( boost::bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L );
87 BOOST_TEST( boost::bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L );
88 BOOST_TEST( boost::bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L );
89}
90
91int main()
92{
93 function_test();
94 return boost::report_errors();
95}
96
97#endif