1 #include <boost/config.hpp> 2 3 #if defined(BOOST_MSVC) 4 #pragma warning(disable: 4786) // identifier truncated in debug info 5 #pragma warning(disable: 4710) // function not inlined 6 #pragma warning(disable: 4711) // function selected for automatic inline expansion 7 #pragma warning(disable: 4514) // unreferenced inline removed 8 #endif 9 10 // 11 // bind_rv_sp_test.cpp - smart pointer returned by value from an inner bind 12 // 13 // Copyright (c) 2005 Peter Dimov 14 // 15 // Distributed under the Boost Software License, Version 1.0. (See 16 // accompanying file LICENSE_1_0.txt or copy at 17 // http://www.boost.org/LICENSE_1_0.txt) 18 // 19 20 #include <boost/bind/bind.hpp> 21 #include <boost/core/lightweight_test.hpp> 22 #include <boost/shared_ptr.hpp> 23 24 // 25 26 struct X 27 { 28 int v_; 29 XX30 X( int v ): v_( v ) 31 { 32 } 33 fX34 int f() 35 { 36 return v_; 37 } 38 }; 39 40 struct Y 41 { fY42 boost::shared_ptr<X> f() 43 { 44 return boost::shared_ptr<X>( new X( 42 ) ); 45 } 46 }; 47 main()48int main() 49 { 50 Y y; 51 52 BOOST_TEST( boost::bind( &X::f, boost::bind( &Y::f, &y ) )() == 42 ); 53 54 return boost::report_errors(); 55 } 56