ref_rv_fail5.cpp 577 B

12345678910111213141516171819202122232425262728
  1. //
  2. // Test that a const 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. struct X {};
  14. X const crv() { return X(); }
  15. int main()
  16. {
  17. boost::reference_wrapper<X const> r = boost::cref( crv() ); // must fail
  18. (void)r;
  19. }
  20. #else
  21. # error To fail, this test requires rvalue references.
  22. #endif