test_8943.cpp 864 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2013 Vicente Botet
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/detail/lightweight_test.hpp>
  6. #if defined(WIN32)
  7. #include <tchar.h>
  8. #endif
  9. #include <cstdlib>
  10. #include <iostream>
  11. #include <boost/thread/once.hpp>
  12. namespace {
  13. class foo
  14. {
  15. public:
  16. void operator()() const
  17. {
  18. std::cout << "foo" << std::endl;
  19. }
  20. }; // class foo
  21. }
  22. #if defined(WIN32)
  23. int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
  24. #else
  25. int main(int /*argc*/, char* /*argv*/[])
  26. #endif
  27. {
  28. try
  29. {
  30. boost::once_flag once_flag = BOOST_ONCE_INIT;
  31. boost::call_once(once_flag, foo());
  32. return EXIT_SUCCESS;
  33. }
  34. catch (...)
  35. {
  36. std::cerr << "Unknown exception" << std::endl;
  37. BOOST_TEST(false);
  38. }
  39. return boost::report_errors();
  40. }