ref_cv_test.cpp 838 B

1234567891011121314151617181920212223242526272829303132333435
  1. // ref_cv_test.cpp: ref( x ) where x is of a cv-qualified type
  2. //
  3. // Copyright (c) 2017 Peter Dimov
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt
  8. #include <boost/ref.hpp>
  9. #include <boost/core/lightweight_test.hpp>
  10. #define BOOST_TEST_REF( x ) BOOST_TEST( &boost::ref( x ).get() == &x )
  11. #define BOOST_TEST_CREF( x ) BOOST_TEST( &boost::cref( x ).get() == &x )
  12. int main()
  13. {
  14. int x1 = 1;
  15. int const x2 = 2;
  16. int volatile x3 = 3;
  17. int const volatile x4 = 4;
  18. BOOST_TEST_REF( x1 );
  19. BOOST_TEST_CREF( x1 );
  20. BOOST_TEST_REF( x2 );
  21. BOOST_TEST_CREF( x2 );
  22. BOOST_TEST_REF( x3 );
  23. BOOST_TEST_CREF( x3 );
  24. BOOST_TEST_REF( x4 );
  25. BOOST_TEST_CREF( x4 );
  26. return boost::report_errors();
  27. }