/*============================================================================== Copyright (c) 2005 Peter Dimov Copyright (c) 2005-2010 Joel de Guzman Copyright (c) 2010 Thomas Heller Copyright (c) 2015 John Fletcher Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include #if defined(BOOST_MSVC) #pragma warning(disable: 4786) // identifier truncated in debug info #pragma warning(disable: 4710) // function not inlined #pragma warning(disable: 4711) // function selected for automatic inline expansion #pragma warning(disable: 4514) // unreferenced inline removed #endif #include #include #include #include #include #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) #pragma warning(push, 3) #endif #include #include #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) #pragma warning(pop) #endif int f1( int x ) { return x; } int f2( int x, int y ) { return x + y; } namespace phx = boost::phoenix; using phx::placeholders::arg1; using phx::placeholders::arg2; int main() { boost::function fun1_f1(boost::bind ( &f1, _1) ); boost::function fun2_f1( phx::bind ( &f1, _1) ); boost::function fun3_f1( phx::bind ( &f1, arg1) ); BOOST_TEST( fun1_f1(1) == 1 ); BOOST_TEST( fun2_f1(2) == 2 ); BOOST_TEST( fun3_f1(3) == 3 ); boost::function fun1_f2(boost::bind ( &f2, _1, _2) ); boost::function fun2_f2( phx::bind ( &f2, _1, _2) ); boost::function fun3_f2( phx::bind ( &f2, arg1, arg2) ); BOOST_TEST( fun1_f2(1,2) == 3 ); BOOST_TEST( fun2_f2(2,3) == 5 ); BOOST_TEST( fun3_f2(3,4) == 7 ); return boost::report_errors(); }