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/apply.hpp>
6#include <boost/bind/protect.hpp>
7#include <boost/bind/bind.hpp>
8#include <boost/core/lightweight_test.hpp>
9
10using namespace boost::placeholders;
11
12int f( int x )
13{
14 return x;
15}
16
17int main()
18{
19 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _1 ) ), 1 )(), 1 );
20 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _2 ) ), 1, 2 )(), 2 );
21 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _3 ) ), 1, 2, 3 )(), 3 );
22 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _4 ) ), 1, 2, 3, 4 )(), 4 );
23 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _5 ) ), 1, 2, 3, 4, 5 )(), 5 );
24 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _6 ) ), 1, 2, 3, 4, 5, 6 )(), 6 );
25 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _7 ) ), 1, 2, 3, 4, 5, 6, 7 )(), 7 );
26 BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _8 ) ), 1, 2, 3, 4, 5, 6, 7, 8 )(), 8 );
27
28 return boost::report_errors();
29}
30

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