1
0
forked from boostorg/core

Add a test for ref(ref(x)).

This commit is contained in:
Peter Dimov
2014-06-10 03:37:21 +03:00
parent 2fbec91fe8
commit 4b0bca5ec2
2 changed files with 38 additions and 0 deletions

View File

@ -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 ;

37
test/ref_ref_test.cpp Normal file
View File

@ -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 <boost/ref.hpp>
#include <boost/core/lightweight_test.hpp>
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 );
}
}