]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/addressof_test.cpp
1 // Copyright (C) 2002 Brad King (brad.king@kitware.com)
2 // Douglas Gregor (gregod@cs.rpi.edu)
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org
11 #include <boost/utility/addressof.hpp>
13 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
14 #pragma warning(push, 3)
19 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
23 #include <boost/detail/lightweight_test.hpp>
25 template<class T
> void scalar_test( T
* = 0 )
30 BOOST_TEST( boost::addressof(x
) == px
);
33 const T
* pcx
= boost::addressof(cx
);
34 BOOST_TEST( pcx
== px
);
37 volatile T
* pvx
= boost::addressof(vx
);
38 BOOST_TEST( pvx
== px
);
40 const volatile T
& cvx
= *px
;
41 const volatile T
* pcvx
= boost::addressof(cvx
);
42 BOOST_TEST( pcvx
== px
);
47 template<class T
> void array_test( T
* = 0 )
51 BOOST_TEST( boost::addressof(nrg
) == pnrg
);
53 T
const cnrg
[3] = {1,2,3};
54 T
const (*pcnrg
)[3] = &cnrg
;
55 BOOST_TEST( boost::addressof(cnrg
) == pcnrg
);
60 addressable( int = 0 )
65 struct useless_type
{};
67 class nonaddressable
{
70 nonaddressable( int = 0 )
74 void dummy(); // Silence GCC warning: all member of class are private
78 useless_type
operator&() const;
85 scalar_test
<addressable
>();
86 scalar_test
<nonaddressable
>();
90 array_test
<addressable
>();
91 array_test
<nonaddressable
>();
93 return boost::report_errors();