From 55b27867708e8269a92c7dd889daffe48fb3c77a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 2 Feb 2017 18:40:06 +0200 Subject: [PATCH] Add ref_cv_test --- test/Jamfile.v2 | 1 + test/ref_cv_test.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/ref_cv_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 64cde15..f93ff51 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -30,6 +30,7 @@ compile-fail ref_rv_fail4.cpp ; compile-fail ref_rv_fail5.cpp ; compile-fail ref_implicit_fail.cpp ; compile-fail ref_implicit_fail2.cpp ; +run ref_cv_test.cpp ; run eif_constructors.cpp ; run eif_dummy_arg_disambiguation.cpp ; diff --git a/test/ref_cv_test.cpp b/test/ref_cv_test.cpp new file mode 100644 index 0000000..734d9b3 --- /dev/null +++ b/test/ref_cv_test.cpp @@ -0,0 +1,35 @@ +// ref_cv_test.cpp: ref( x ) where x is of a cv-qualified type +// +// Copyright (c) 2017 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#define BOOST_TEST_REF( x ) BOOST_TEST( &boost::ref( x ).get() == &x ) +#define BOOST_TEST_CREF( x ) BOOST_TEST( &boost::cref( x ).get() == &x ) + +int main() +{ + int x1 = 1; + int const x2 = 2; + int volatile x3 = 3; + int const volatile x4 = 4; + + BOOST_TEST_REF( x1 ); + BOOST_TEST_CREF( x1 ); + + BOOST_TEST_REF( x2 ); + BOOST_TEST_CREF( x2 ); + + BOOST_TEST_REF( x3 ); + BOOST_TEST_CREF( x3 ); + + BOOST_TEST_REF( x4 ); + BOOST_TEST_CREF( x4 ); + + return boost::report_errors(); +}