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 6 #include <boost/detail/lightweight_test.hpp> 7 8 #if defined(WIN32) 9 #include <tchar.h> 10 #endif 11 12 #include <cstdlib> 13 #include <iostream> 14 #include <boost/thread/once.hpp> 15 16 namespace { 17 18 class foo 19 { 20 public: operator ()() const21 void operator()() const 22 { 23 std::cout << "foo" << std::endl; 24 } 25 }; // class foo 26 27 } 28 29 #if defined(WIN32) _tmain(int,_TCHAR * [])30int _tmain(int /*argc*/, _TCHAR* /*argv*/[]) 31 #else 32 int main(int /*argc*/, char* /*argv*/[]) 33 #endif 34 { 35 try 36 { 37 boost::once_flag once_flag = BOOST_ONCE_INIT; 38 boost::call_once(once_flag, foo()); 39 return EXIT_SUCCESS; 40 } 41 catch (...) 42 { 43 std::cerr << "Unknown exception" << std::endl; 44 BOOST_TEST(false); 45 } 46 return boost::report_errors(); 47 } 48