]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/bind_visitor.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / bind / bind_visitor.cpp
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_visitor.cpp - tests bind.hpp with a visitor
12 //
13 // Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
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/ref.hpp>
22 #include <iostream>
23 #include <typeinfo>
24
25 using namespace boost::placeholders;
26
27 //
28
29 struct visitor
30 {
31 template<class T> void operator()( boost::reference_wrapper<T> const & r ) const
32 {
33 std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
34 }
35
36 template<class T> void operator()( T const & t ) const
37 {
38 std::cout << "Value of type " << typeid(T).name() << " (with value " << t << ")\n";
39 }
40 };
41
42 int f(int & i, int & j, int)
43 {
44 ++i;
45 --j;
46 return i + j;
47 }
48
49 int x = 2;
50 int y = 7;
51
52 int main()
53 {
54 using namespace boost;
55
56 visitor v;
57 visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
58 }