Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/bind/test/bind_dm2_test.cpp @ 45

Last change on this file since 45 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.5 KB
Line 
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_dm2_test.cpp - data members, advanced uses
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.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    X x = { 0 };
48    X * px = &x;
49
50    boost::bind< int& >( &X::m, _1 )( px ) = 42;
51
52    BOOST_TEST( x.m == 42 );
53
54    boost::bind< int& >( &X::m, boost::ref(x) )() = 17041;
55
56    BOOST_TEST( x.m == 17041 );
57
58    X const * pcx = &x;
59
60    BOOST_TEST( boost::bind< long >( &X::m, _1 )( pcx ) == 17041L );
61    BOOST_TEST( boost::bind< long >( &X::m, pcx )() == 17041L );
62
63    Y y = { "test" };
64    std::string v( "test" );
65
66    BOOST_TEST( boost::bind< char const* >( &Y::m, &y )() == v );
67    BOOST_TEST( boost::bind< std::string >( &Y::m, &y )() == v );
68
69    return boost::report_errors();
70}
Note: See TracBrowser for help on using the repository browser.