diff options
Diffstat (limited to 'libs/thread/example')
-rw-r--r-- | libs/thread/example/executor.cpp | 16 | ||||
-rw-r--r-- | libs/thread/example/lambda_future.cpp | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/libs/thread/example/executor.cpp b/libs/thread/example/executor.cpp index 7f6b1ce3e0..10c77a0007 100644 --- a/libs/thread/example/executor.cpp +++ b/libs/thread/example/executor.cpp @@ -28,6 +28,10 @@ #include <string> #include <iostream> +boost::future<void> p(boost::future<void>) { + return boost::make_ready_future(); +} + void p1() { // std::cout << BOOST_CONTEXTOF << std::endl; @@ -147,4 +151,16 @@ int test_executor_adaptor() int main() { return test_executor_adaptor(); + +#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \ + && defined BOOST_THREAD_PROVIDES_EXECUTORS \ + && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES + + // compiles + boost::make_ready_future().then(&p); + + boost::basic_thread_pool executor; + // doesn't compile + boost::make_ready_future().then(executor, &p); +#endif } diff --git a/libs/thread/example/lambda_future.cpp b/libs/thread/example/lambda_future.cpp index 6df1cee7f7..fd15d44840 100644 --- a/libs/thread/example/lambda_future.cpp +++ b/libs/thread/example/lambda_future.cpp @@ -42,6 +42,14 @@ int main() int result = f2.get(); BOOST_THREAD_LOG << "f2 " << result << BOOST_THREAD_END_LOG; } +#if ! defined BOOST_NO_CXX14_GENERIC_LAMBDAS + { + boost::future<int> f1 = boost::async(boost::launch::async, []() {return 123;}); + boost::future<int> f2 = f1.then([](auto f) {return 2*f.get(); }); + int result = f2.get(); + BOOST_THREAD_LOG << "f2 " << result << BOOST_THREAD_END_LOG; + } +#endif } catch (std::exception& ex) { |