PageRenderTime 34ms CodeModel.GetById 30ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/phoenix/test/boost_bind_compatibility/bind_ref_test.cpp

http://hadesmem.googlecode.com/
C++ | 38 lines | 24 code | 6 blank | 8 comment | 2 complexity | ebe7ec30c81384315f1361124b181ce1 MD5 | raw file
 1/*==============================================================================
 2    Copyright (c) 2009 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/phoenix/core.hpp>
11#include <boost/phoenix/bind.hpp>
12#include <boost/ref.hpp>
13#include <boost/detail/lightweight_test.hpp>
14
15struct X
16{
17    int f( int x )
18    {
19        return x;
20    }
21
22    int g( int x ) const
23    {
24        return -x;
25    }
26};
27
28int main()
29{
30    using boost::phoenix::bind;
31    using boost::phoenix::placeholders::_1;
32    X x;
33
34    BOOST_TEST( bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 );
35    BOOST_TEST( bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 );
36
37    return boost::report_errors();
38}