rvalue_nonconst.cpp 822 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // (C) Copyright Eric Niebler 2005.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. /*
  6. Revision history:
  7. 25 August 2005 : Initial version.
  8. */
  9. #include <vector>
  10. #include <boost/test/minimal.hpp>
  11. #include <boost/foreach.hpp>
  12. #ifdef BOOST_FOREACH_NO_RVALUE_DETECTION
  13. # error Expected failure : rvalues disallowed
  14. #else
  15. std::vector<int> get_vector()
  16. {
  17. return std::vector<int>(4, 4);
  18. }
  19. ///////////////////////////////////////////////////////////////////////////////
  20. // test_main
  21. //
  22. int test_main( int, char*[] )
  23. {
  24. int counter = 0;
  25. BOOST_FOREACH(int i, get_vector())
  26. {
  27. counter += i;
  28. }
  29. BOOST_CHECK(16 == counter);
  30. return 0;
  31. }
  32. #endif