Skip to content

Commit

Permalink
Added test for #9303.
Browse files Browse the repository at this point in the history
  • Loading branch information
viboes committed Mar 1, 2014
1 parent 143adde commit 7d4f485
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions test/test_9303.cpp
Expand Up @@ -6,18 +6,18 @@
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
//#include <boost/asio.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/thread/future.hpp>

#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#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
Expand Down Expand Up @@ -106,7 +106,7 @@
{
boost::packaged_task<std::string(std::string&)> example(string_with_params);
boost::future<std::string> 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();
Expand All @@ -120,7 +120,7 @@
boost::packaged_task<std::string(std::string&)> example
{ boost::bind(&string_with_params, ans) };
boost::future<std::string> 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();
Expand All @@ -133,8 +133,9 @@
// packagedTestTest.cpp:95:37: error: incomplete type ‘task_t {aka boost::packaged_task<std::basic_string<char>(std::basic_string<char>&)>}’ used in nested name specifier
// boost/thread/future.hpp:1320:11: error: declaration of ‘class boost::packaged_task<std::basic_string<char>(std::basic_string<char>&)>’
{
typedef boost::packaged_task<std::string(std::string&)> task_t;
boost::shared_ptr<task_t> example = boost::make_shared<task_t>(boost::bind(&string_with_params, ans));
//typedef boost::packaged_task<std::string(std::string&)> task_t;
typedef boost::packaged_task<std::string()> task_t;
boost::shared_ptr<task_t> example = boost::make_shared<task_t>(boost::bind(&string_with_params, boost::ref(ans)));
boost::future<std::string> f = example->get_future();
boost::thread task(boost::bind(&task_t::operator(), example));
std::string answer = f.get();
Expand All @@ -158,7 +159,7 @@
threads.create_thread(boost::bind(&boost::asio::io_service::run,
&io_service));
}
typedef boost::packaged_task<std::string(std::string&)> task_t;
typedef boost::packaged_task<std::string()> task_t;
boost::shared_ptr<task_t> example = boost::make_shared<task_t>(boost::bind(&string_with_params, ans));
boost::future<std::string> f = example->get_future();
io_service.post(boost::bind(&task_t::operator(), example));
Expand Down

0 comments on commit 7d4f485

Please sign in to comment.