ref_rv_fail4.cpp 527 B

123456789101112131415161718192021222324
  1. //
  2. // Test that an rvalue can't be passed to cref()
  3. //
  4. // Copyright 2014 Agustin Berge
  5. // Copyright 2014 Peter Dimov
  6. //
  7. // Distributed under the Boost Software License, Version 1.0.
  8. // See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt
  10. //
  11. #include <boost/ref.hpp>
  12. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  13. int main()
  14. {
  15. boost::reference_wrapper<int const> r = boost::cref( 2 ); // should fail
  16. (void)r;
  17. }
  18. #else
  19. # error To fail, this test requires rvalue references.
  20. #endif