test_8674.cpp 815 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 <iostream>
  6. #define USE_STD 0
  7. #define USE_BOOST 1
  8. #define USED_THREAD_API USE_BOOST
  9. //#define USED_THREAD_API USE_STD
  10. #if USED_THREAD_API == USE_BOOST
  11. # define BOOST_THREAD_VERSION 4
  12. # include <boost/thread/future.hpp>
  13. using boost::future;
  14. using boost::async;
  15. #endif
  16. #if USED_THREAD_API == USE_STD
  17. # include <future>
  18. using std::future;
  19. using std::async;
  20. #endif
  21. future<void> do_something()
  22. {
  23. auto result = async( []{ std::cout<< "A\n"; } );
  24. std::cout << "B\n";
  25. return result; // error here
  26. }
  27. int main()
  28. {
  29. do_something().wait();
  30. std::cout << "Hello, World!" << std::endl;
  31. return 0;
  32. }