1 /*==============================================================================
2     Copyright (c) 2006 Peter Dimov
3     Copyright (c) 2005-2010 Joel de Guzman
4     Copyright (c) 2010 Thomas Heller
5     Copyright (c) 2015 John Fletcher
6 
7     Distributed under the Boost Software License, Version 1.0. (See accompanying
8     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 ==============================================================================*/
10 
11 #include <boost/config.hpp>
12 
13 #if defined(BOOST_MSVC)
14 #pragma warning(disable: 4786)  // identifier truncated in debug info
15 #pragma warning(disable: 4710)  // function not inlined
16 #pragma warning(disable: 4711)  // function selected for automatic inline expansion
17 #pragma warning(disable: 4514)  // unreferenced inline removed
18 #endif
19 
20 #include <boost/phoenix/core.hpp>
21 #include <boost/phoenix/bind.hpp>
22 
23 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
24 #pragma warning(push, 3)
25 #endif
26 
27 #include <iostream>
28 
29 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
30 #pragma warning(pop)
31 #endif
32 
33 #include <boost/detail/lightweight_test.hpp>
34 #include <boost/shared_ptr.hpp>
35 
36 struct X
37 {
38     int v_;
39 
XX40     X( int v ): v_( v )
41     {
42     }
43 
fX44     int f()
45     {
46         return v_;
47     }
48 };
49 
50 struct Y
51 {
fY52     boost::shared_ptr<X> f()
53     {
54         return boost::shared_ptr<X>( new X( 42 ) );
55     }
56 };
57 
main()58 int main()
59 {
60     using boost::phoenix::bind;
61 
62     Y y;
63 
64     // MSVC 10,9 and 8 all give a COMDAT error with the full test.
65     // This also fails:
66     //boost::shared_ptr<X> xp = bind( &Y::f, &y )();
67 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1700)
68     boost::shared_ptr<X> xp = y.f();
69     BOOST_TEST( bind( &X::f, xp)()  == 42 );
70 #else
71     BOOST_TEST( bind( &X::f, bind( &Y::f, &y ) )() == 42 );
72 #endif
73 
74     return boost::report_errors();
75 }
76