]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/ref_test.cpp
1 // Copyright David Abrahams and Aleksey Gurtovoy
2 // 2002-2004. Distributed under the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // run-time test for "boost/ref.hpp" header content
7 // see 'ref_ct_test.cpp' for compile-time part
9 #include <boost/ref.hpp>
10 #include <boost/core/lightweight_test.hpp>
13 using namespace boost
;
18 // Used to verify implicit conversion
19 static T
* get_pointer(T
& x
)
24 static T
const* get_const_pointer(T
const& x
)
30 static T
* passthru(Arg x
)
32 return get_pointer(x
);
36 static T
const* cref_passthru(Arg x
)
38 return get_const_pointer(x
);
43 BOOST_TEST(passthru(ref(x
)) == &x
);
44 BOOST_TEST(&ref(x
).get() == &x
);
46 BOOST_TEST(cref_passthru(cref(x
)) == &x
);
47 BOOST_TEST(&cref(x
).get() == &x
);
53 copy_counter(copy_counter
const& /*other*/) {
57 static void reset() { count_
= 0; }
58 static int count() { return copy_counter::count_
; }
61 int copy_counter::count_
= 0;
63 } // namespace unnamed
68 /* typename unwrap_reference<T>::type& lt = */
85 BOOST_TEST(cc
.count() == 0);
91 BOOST_TEST(cc
.count() == 1);
92 BOOST_TEST(unwrap_ref(ref(cc
)).count() == 1);
97 ref_wrapper
<int>::test(1);
98 ref_wrapper
<int const>::test(1);
100 return boost::report_errors();