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