ref_rv_fail3.cpp 563 B

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