1// Copyright 2021 Peter Dimov
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#include <boost/bind/bind.hpp>
6#include <boost/core/lightweight_test.hpp>
7#include <functional>
8#include <boost/config.hpp>
9#include <boost/config/pragma_message.hpp>
10
11#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
12
13BOOST_PRAGMA_MESSAGE( "Skipping test due to BOOST_NO_CXX11_HDR_FUNCTIONAL being defined" )
14int main() {}
15
16#elif defined(BOOST_NO_CXX11_DECLTYPE)
17
18BOOST_PRAGMA_MESSAGE( "Skipping test due to BOOST_NO_CXX11_DECLTYPE being defined" )
19int main() {}
20
21#elif defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
22
23BOOST_PRAGMA_MESSAGE( "Skipping test due to BOOST_NO_CXX11_HDR_TYPE_TRAITS being defined" )
24int main() {}
25
26#else
27
28int f( int x )
29{
30 return -x;
31}
32
33int main()
34{
35 using namespace std::placeholders;
36
37 BOOST_TEST_EQ( boost::bind( f, _1 )( 1 ), -1 );
38 BOOST_TEST_EQ( boost::bind( f, _2 )( 1, 2 ), -2 );
39 BOOST_TEST_EQ( boost::bind( f, _3 )( 1, 2, 3 ), -3 );
40 BOOST_TEST_EQ( boost::bind( f, _4 )( 1, 2, 3, 4 ), -4 );
41 BOOST_TEST_EQ( boost::bind( f, _5 )( 1, 2, 3, 4, 5 ), -5 );
42 BOOST_TEST_EQ( boost::bind( f, _6 )( 1, 2, 3, 4, 5, 6 ), -6 );
43 BOOST_TEST_EQ( boost::bind( f, _7 )( 1, 2, 3, 4, 5, 6, 7 ), -7 );
44 BOOST_TEST_EQ( boost::bind( f, _8 )( 1, 2, 3, 4, 5, 6, 7, 8 ), -8 );
45 BOOST_TEST_EQ( boost::bind( f, _9 )( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), -9 );
46
47 return boost::report_errors();
48}
49
50#endif
51

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