diff --git a/test/test_9303.cpp b/test/test_9303.cpp index 4a70dfe21..a49758a1a 100644 --- a/test/test_9303.cpp +++ b/test/test_9303.cpp @@ -6,7 +6,7 @@ #include #include #include - //#include + #include #include #include @@ -14,10 +14,10 @@ #define EXAMPLE_1 #define EXAMPLE_2 #define EXAMPLE_3 - //#define EXAMPLE_4 - //#define EXAMPLE_5 - //#define EXAMPLE_6 - //#define EXAMPLE_7 + #define EXAMPLE_4 + #define EXAMPLE_5 + #define EXAMPLE_6 + #define EXAMPLE_7 #else #define EXAMPLE_1 #define EXAMPLE_2 @@ -106,7 +106,7 @@ { boost::packaged_task example(string_with_params); boost::future f = example.get_future(); - boost::thread task(boost::move(example), ans); + boost::thread task(boost::move(example), boost::ref(ans)); std::string answer = f.get(); std::cout << "string_with_params: " << answer << std::endl; task.join(); @@ -120,7 +120,7 @@ boost::packaged_task example { boost::bind(&string_with_params, ans) }; boost::future f = example.get_future(); - boost::thread task(boost::move(example), ans); + boost::thread task(boost::move(example), boost::ref(ans)); std::string answer = f.get(); std::cout << "string_with_params: " << answer << std::endl; task.join(); @@ -133,8 +133,9 @@ // packagedTestTest.cpp:95:37: error: incomplete type ‘task_t {aka boost::packaged_task(std::basic_string&)>}’ used in nested name specifier // boost/thread/future.hpp:1320:11: error: declaration of ‘class boost::packaged_task(std::basic_string&)>’ { - typedef boost::packaged_task task_t; - boost::shared_ptr example = boost::make_shared(boost::bind(&string_with_params, ans)); + //typedef boost::packaged_task task_t; + typedef boost::packaged_task task_t; + boost::shared_ptr example = boost::make_shared(boost::bind(&string_with_params, boost::ref(ans))); boost::future f = example->get_future(); boost::thread task(boost::bind(&task_t::operator(), example)); std::string answer = f.get(); @@ -158,7 +159,7 @@ threads.create_thread(boost::bind(&boost::asio::io_service::run, &io_service)); } - typedef boost::packaged_task task_t; + typedef boost::packaged_task task_t; boost::shared_ptr example = boost::make_shared(boost::bind(&string_with_params, ans)); boost::future f = example->get_future(); io_service.post(boost::bind(&task_t::operator(), example));