1/*==============================================================================
2 Copyright (c) 2005 Peter Dimov
3 Copyright (c) 2005-2010 Joel de Guzman
4 Copyright (c) 2010 Thomas Heller
5
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8==============================================================================*/
9
10#include <boost/config.hpp>
11
12#if defined(BOOST_MSVC)
13#pragma warning(disable: 4786) // identifier truncated in debug info
14#pragma warning(disable: 4710) // function not inlined
15#pragma warning(disable: 4711) // function selected for automatic inline expansion
16#pragma warning(disable: 4514) // unreferenced inline removed
17#endif
18
19#include <boost/phoenix/core.hpp>
20#include <boost/phoenix/bind.hpp>
21
22#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
23#pragma warning(push, 3)
24#endif
25
26#include <iostream>
27#include <string>
28
29#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
30#pragma warning(pop)
31#endif
32
33#include <boost/detail/lightweight_test.hpp>
34
35struct X
36{
37 int m;
38};
39
40struct Y
41{
42 char m[ 64 ];
43};
44
45int main()
46{
47 using boost::phoenix::bind;
48 using boost::phoenix::ref;
49 using boost::phoenix::placeholders::_1;
50
51 X x = { .m: 0 };
52 X * px = &x;
53
54 bind( mp: &X::m, obj: _1 )( px ) = 42;
55
56 BOOST_TEST( x.m == 42 );
57
58 bind( mp: &X::m, obj: ref(t&: x) )() = 17041;
59
60 BOOST_TEST( x.m == 17041 );
61
62 X const * pcx = &x;
63
64 BOOST_TEST( bind( &X::m, _1 )( pcx ) == 17041L );
65 BOOST_TEST( bind( &X::m, pcx )() == 17041L );
66
67 Y y = { .m: "test" };
68 std::string v( "test" );
69
70 BOOST_TEST( bind( &Y::m, &y )() == v );
71 BOOST_TEST( bind( &Y::m, &y )() == v );
72
73 return boost::report_errors();
74}
75

source code of boost/libs/phoenix/test/boost_bind_compatibility/bind_dm2_test.cpp