1 | // |
2 | // placeholder_std_bind_test.cpp - std::bind with Boost's _1 |
3 | // |
4 | // Copyright 2016 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/config.hpp> |
12 | #include <boost/config/pragma_message.hpp> |
13 | |
14 | #if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) |
15 | |
16 | BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_CXX11_HDR_FUNCTIONAL is defined" ) |
17 | int main() {} |
18 | |
19 | #elif defined(BOOST_GCC) && BOOST_GCC < 40600 |
20 | |
21 | BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_GCC is less than 40600" ) |
22 | int main() {} |
23 | |
24 | #else |
25 | |
26 | #include <boost/bind/bind.hpp> |
27 | #include <boost/core/lightweight_test.hpp> |
28 | #include <functional> |
29 | |
30 | using namespace boost::placeholders; |
31 | |
32 | // |
33 | |
34 | namespace std |
35 | { |
36 | |
37 | template<int N> struct is_placeholder< boost::arg<N> >: public integral_constant<int, N> {}; |
38 | |
39 | } // namespace std |
40 | |
41 | int foo( int i ) |
42 | { |
43 | return i; |
44 | } |
45 | |
46 | int main() |
47 | { |
48 | BOOST_TEST_EQ( std::bind( foo, _1 )( 1 ), 1 ); |
49 | BOOST_TEST_EQ( std::bind( foo, _2 )( 1, 2 ), 2 ); |
50 | BOOST_TEST_EQ( std::bind( foo, _3 )( 1, 2, 3 ), 3 ); |
51 | |
52 | return boost::report_errors(); |
53 | } |
54 | |
55 | #endif |
56 | |