From 4b0bca5ec2b9330bbb1d604cae29b7d54a7abe8b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 03:37:21 +0300 Subject: [PATCH] Add a test for ref(ref(x)). --- test/Jamfile.v2 | 1 + test/ref_ref_test.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/ref_ref_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d88d6cb..ebd3bd9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -19,6 +19,7 @@ compile-fail checked_delete_fail2.cpp ; compile ref_ct_test.cpp ; run ref_test.cpp ; +run ref_ref_test.cpp ; compile-fail ref_rv_fail1.cpp ; compile-fail ref_rv_fail2.cpp ; compile-fail ref_rv_fail3.cpp ; diff --git a/test/ref_ref_test.cpp b/test/ref_ref_test.cpp new file mode 100644 index 0000000..202c01c --- /dev/null +++ b/test/ref_ref_test.cpp @@ -0,0 +1,37 @@ +// +// Test for ref(ref(x)) +// +// Copyright 2014 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 + +int main() +{ + int x = 0; + + { + boost::reference_wrapper< int > r = boost::ref( boost::ref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } + + { + boost::reference_wrapper< int const > r = boost::ref( boost::cref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } + + { + boost::reference_wrapper< int const > r = boost::cref( boost::ref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } + + { + boost::reference_wrapper< int const > r = boost::cref( boost::cref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } +}