forked from boostorg/core
Add negative tests for cref() and rvalues.
This commit is contained in:
@ -22,6 +22,8 @@ run ref_test.cpp ;
|
||||
compile-fail ref_rv_fail1.cpp ;
|
||||
compile-fail ref_rv_fail2.cpp ;
|
||||
compile-fail ref_rv_fail3.cpp ;
|
||||
compile-fail ref_rv_fail4.cpp ;
|
||||
compile-fail ref_rv_fail5.cpp ;
|
||||
compile-fail ref_implicit_fail.cpp ;
|
||||
compile-fail ref_implicit_fail2.cpp ;
|
||||
|
||||
|
23
test/ref_rv_fail4.cpp
Normal file
23
test/ref_rv_fail4.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// Test that an rvalue can't be passed to cref()
|
||||
//
|
||||
// Copyright 2014 Agustin Berge
|
||||
// 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>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::reference_wrapper<int const> r = boost::cref( 2 ); // should fail
|
||||
}
|
||||
|
||||
#else
|
||||
# error To fail, this test requires rvalue references.
|
||||
#endif
|
27
test/ref_rv_fail5.cpp
Normal file
27
test/ref_rv_fail5.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
//
|
||||
// Test that a const rvalue can't be passed to cref()
|
||||
//
|
||||
// Copyright 2014 Agustin Berge
|
||||
// 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>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
struct X {};
|
||||
|
||||
X const crv() { return X(); }
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::reference_wrapper<X const> r = boost::cref( crv() ); // must fail
|
||||
}
|
||||
|
||||
#else
|
||||
# error To fail, this test requires rvalue references.
|
||||
#endif
|
Reference in New Issue
Block a user