call_once.cpp 776 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // counter
  13. int counter = 0;
  14. std::vector<int> my_vector(4,4);
  15. std::vector<int> const &get_vector()
  16. {
  17. ++counter;
  18. return my_vector;
  19. }
  20. ///////////////////////////////////////////////////////////////////////////////
  21. // test_main
  22. //
  23. int test_main( int, char*[] )
  24. {
  25. BOOST_FOREACH(int i, get_vector())
  26. {
  27. ((void)i); // no-op
  28. }
  29. BOOST_CHECK(1 == counter);
  30. return 0;
  31. }