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
16BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_CXX11_HDR_FUNCTIONAL is defined" )
17int main() {}
18
19#elif defined(BOOST_GCC) && BOOST_GCC < 40600
20
21BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_GCC is less than 40600" )
22int main() {}
23
24#else
25
26#include <boost/bind/bind.hpp>
27#include <boost/core/lightweight_test.hpp>
28#include <functional>
29
30using namespace boost::placeholders;
31
32//
33
34namespace std
35{
36
37template<int N> struct is_placeholder< boost::arg<N> >: public integral_constant<int, N> {};
38
39} // namespace std
40
41int foo( int i )
42{
43 return i;
44}
45
46int 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

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