| 1 | // ref_cv_test.cpp: ref( x ) where x is of a cv-qualified type |
|---|---|
| 2 | // |
| 3 | // Copyright (c) 2017 Peter Dimov |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. |
| 6 | // See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt |
| 8 | |
| 9 | #include <boost/core/ref.hpp> |
| 10 | #include <boost/core/lightweight_test.hpp> |
| 11 | |
| 12 | #define BOOST_TEST_REF( x ) BOOST_TEST( &boost::ref( x ).get() == &x ) |
| 13 | #define BOOST_TEST_CREF( x ) BOOST_TEST( &boost::cref( x ).get() == &x ) |
| 14 | |
| 15 | int main() |
| 16 | { |
| 17 | int x1 = 1; |
| 18 | int const x2 = 2; |
| 19 | int volatile x3 = 3; |
| 20 | int const volatile x4 = 4; |
| 21 | |
| 22 | BOOST_TEST_REF( x1 ); |
| 23 | BOOST_TEST_CREF( x1 ); |
| 24 | |
| 25 | BOOST_TEST_REF( x2 ); |
| 26 | BOOST_TEST_CREF( x2 ); |
| 27 | |
| 28 | BOOST_TEST_REF( x3 ); |
| 29 | BOOST_TEST_CREF( x3 ); |
| 30 | |
| 31 | BOOST_TEST_REF( x4 ); |
| 32 | BOOST_TEST_CREF( x4 ); |
| 33 | |
| 34 | return boost::report_errors(); |
| 35 | } |
| 36 |
