diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f34efe4..d88d6cb 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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 ; diff --git a/test/ref_rv_fail4.cpp b/test/ref_rv_fail4.cpp new file mode 100644 index 0000000..7f49123 --- /dev/null +++ b/test/ref_rv_fail4.cpp @@ -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 + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +int main() +{ + boost::reference_wrapper r = boost::cref( 2 ); // should fail +} + +#else +# error To fail, this test requires rvalue references. +#endif diff --git a/test/ref_rv_fail5.cpp b/test/ref_rv_fail5.cpp new file mode 100644 index 0000000..84bc467 --- /dev/null +++ b/test/ref_rv_fail5.cpp @@ -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 + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +struct X {}; + +X const crv() { return X(); } + +int main() +{ + boost::reference_wrapper r = boost::cref( crv() ); // must fail +} + +#else +# error To fail, this test requires rvalue references. +#endif