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
13 #if defined( BOOST_NO_CXX11_HDR_FUNCTIONAL )
14
main()15 int main()
16 {
17 }
18
19 #else
20
21 #include <boost/bind/bind.hpp>
22 #include <boost/core/lightweight_test.hpp>
23 #include <functional>
24
25 using namespace boost::placeholders;
26
27 //
28
29 namespace std
30 {
31
32 template<int N> struct is_placeholder< boost::arg<N> >: public integral_constant<int, N> {};
33
34 } // namespace std
35
foo(int i)36 int foo( int i )
37 {
38 return i;
39 }
40
main()41 int main()
42 {
43 BOOST_TEST_EQ( std::bind( foo, _1 )( 1 ), 1 );
44 BOOST_TEST_EQ( std::bind( foo, _2 )( 1, 2 ), 2 );
45 BOOST_TEST_EQ( std::bind( foo, _3 )( 1, 2, 3 ), 3 );
46
47 return boost::report_errors();
48 }
49
50 #endif
51