|
Boost Users : |
Subject: [Boost-users] packaged_task returning boost::any with BOOST_THREAD_VERSION>=3
From: Nicolas P (nicolasph_at_[hidden])
Date: 2013-07-22 11:49:13
Hello,
I'm trying to enable boost (1.54) thread version >=3 with my code and i run
into a package_task compilation issue
I reduced my issue to a minimal test program that compiles fine on windows
7, but fails to compile on osx and linux (compilers info bellow) with
BOOST_THREAD_VERSION = 3 or 4 (fine with boost thread version 2)
test succeded on
- Windows 7 with Visual 2010 Express sp1 with SDK 7.1 ok
test failed on
- Mac os x 10.6 Xcode 4.2 : gcc 4.2.1 and clang 3.0
- Mac os x 10.7 Xcode 4.4 : gcc and clang 4.0
- Ubuntu 13.04 gcc 4.7.4
The minimal test program :
#define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
#define BOOST_THREAD_VERSION 4
#include <boost/any.hpp>
#include <boost/thread.hpp>
#include <boost/function.hpp>
boost::any process()
{
return 1;
}
int main()
{
boost::function< boost::any () > f = &process ;
//boost::packaged_task< boost::any () > task(&process); // Works fine
boost::packaged_task< boost::any () > task(f);
return 0;
}
// Replacing 'boost::any' with 'int' make it compile.
Error log with clang on os x 10.6 :
In file included from /tmp/packaged_task_test/main.cpp:5:
In file included from boost/thread.hpp:24:
boost/thread/future.hpp:2298:27: error: no matching
member function for call to 'set_value_at_thread_exit'
this->set_value_at_thread_exit(f());
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
boost/thread/future.hpp:2857:33: note: in instantiation
of member function
'boost::detail::task_object<boost::function<boost::any ()>, boost::any
()>::do_apply' requested here
task = task_ptr(new task_object_type(f));
^
/tmp/packaged_task_test/main.cpp:17:43: note: in instantiation of function
template specialization
'boost::packaged_task<boost::any
()>::packaged_task<boost::function<boost::any ()> >' requested here
boost::packaged_task< boost::any () > task(f);
^
boost/thread/future.hpp:673:18: note: candidate function
not viable: no known conversion from 'result_type' (aka 'boost::any')
to 'source_reference_type' (aka 'boost::any &') for 1st argument
void set_value_at_thread_exit(source_reference_type result_)
^
boost/thread/future.hpp:687:18: note: candidate function
not viable: no known conversion from 'result_type' (aka 'boost::any')
to 'rvalue_source_type' (aka 'rv<boost::any> &') for 1st argument
void set_value_at_thread_exit(rvalue_source_type result_)
^
boost/thread/future.hpp:2329:25: error: no matching
member function for call to 'mark_finished_with_result'
this->mark_finished_with_result(f());
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
boost/thread/future.hpp:2857:33: note: in instantiation
of member function
'boost::detail::task_object<boost::function<boost::any ()>, boost::any
()>::do_run' requested here
task = task_ptr(new task_object_type(f));
^
/tmp/packaged_task_test/main.cpp:17:43: note: in instantiation of function
template specialization
'boost::packaged_task<boost::any
()>::packaged_task<boost::function<boost::any ()> >' requested here
boost::packaged_task< boost::any () > task(f);
^
boost/thread/future.hpp:627:18: note: candidate function
not viable: no known conversion from 'result_type' (aka 'boost::any')
to 'source_reference_type' (aka 'boost::any &') for 1st argument
void mark_finished_with_result(source_reference_type result_)
^
boost/thread/future.hpp:633:18: note: candidate function
not viable: no known conversion from 'result_type' (aka 'boost::any')
to 'rvalue_source_type' (aka 'rv<boost::any> &') for 1st argument
void mark_finished_with_result(rvalue_source_type result_)
^
2 errors generated.
Am i missing something ?
Regards,
Nicolas
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net