boost::shared_future<boost::shared_ptr<adam::firmware::ImageData> > get_image(adam::firmware::CameraEnums::CameraImageType type)
{
return enqueue(type);
}
#pragma once
#include <boost/thread/future.hpp>
#include <boost/statechart/asynchronous_state_machine.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
namespace adam
{
namespace firmware
{
namespace states
{
/**
* The InStateHandler allows a callback to be guarded based on the current state machine state. Use this in combination
* with the adam::infra::SchedulerExecutor to call the callback on the state machine's thread, to avoid race conditions.
*
* This handler defines an `operator()` method taking a boost::shared_future<TFutureResult> as parameter. The callback
* method must have the same signature. Passing a callback returning a non-void value is currently not supported.
*
* @tparam TState The state type that should be active when the callback is executed.
* @tparam TFutureResult The result of the future this continuation is used for.
*/
template<typename TState, typename TFutureResult>
struct InStateHandler
{
// result struct required to allow boost::result_of<>
template<typename> struct result;
template<typename F, typename T>
struct result<F(T)>
{
typedef void type;
};
/**
* Constructor.
*
* @param[in] machine The state machine to check. Typically, from within a state `&outermost_context()` is used.
* @param[in] callback The callback to call if the state machine is in the @c TState state when this handler is executed.
*/
InStateHandler(typename TState::outermost_context_type* machine, boost::function<void(boost::shared_future<TFutureResult>&)> callback)
: m_machine(machine)
, m_callback(callback)
{
}
void operator()(boost::shared_future<TFutureResult>& future)
{
if (m_machine->template state_cast<const TState*>() != NULL)
{
m_callback(future);
}
}
private:
typename TState::outermost_context_type* m_machine;
boost::function<void(boost::shared_future<TFutureResult>&)> m_callback;
};
void Preparing::schedule_exposure_check()
{
// First stabilize exposure
outermost_context().components.camera_component->get_image(CameraEnums::NextImage)
.then(outermost_context().continuation_executor,
InStateHandler<Preparing, boost::shared_ptr<adam::firmware::ImageData> >(
&outermost_context(),
boost::bind(
&Preparing::check_exposure_stability,
this,
_1)));
}
/home/lwx/firm161/application/control/states/preparing.cpp: In member function ‘void adam::firmware::states::Preparing::schedule_exposure_check()’:
/home/lwx/firm161/application/control/states/preparing.cpp:58:25: error: no matching function for call to ‘boost::shared_future<boost::shared_ptr<adam::firmware::ImageData> >::then(adam::infra::SchedulerExecutor<>&, adam::firmware::states::InStateHandler<adam::firmware::states::Preparing, boost::shared_ptr<adam::firmware::ImageData> >)’
_1)));
^
In file included from /usr/local/include/boost/thread.hpp:24:0,
from /home/lwx/firm161/hal/../infra/worker_service.h:9,
from /home/lwx/firm161/hal/../vision/tracking/template_scoring.h:5,
from /home/lwx/firm161/hal/../vision/tracking/position_enumeration.h:5,
from /home/lwx/firm161/hal/../vision/tracking/door_tracker.h:3,
from /home/lwx/firm161/hal/../application/image_data.h:20,
from /home/lwx/firm161/application/control/states/preparing.h:5,
from /home/lwx/firm161/application/control/states/preparing.cpp:2:
/usr/local/include/boost/thread/future.hpp:2130:9: note: candidate: template<class F> boost::future<typename boost::result_of<F(boost::shared_future<R>)>::type> boost::shared_future<R>::then(F&&) const [with F = F; R = boost::shared_ptr<adam::firmware::ImageData>]
then(BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION
^
/usr/local/include/boost/thread/future.hpp:2130:9: note: template argument deduction/substitution failed:
/home/lwx/firm161/application/control/states/preparing.cpp:58:25: note: candidate expects 1 argument, 2 provided
_1)));
^
In file included from /usr/local/include/boost/thread.hpp:24:0,
from /home/lwx/firm161/hal/../infra/worker_service.h:9,
from /home/lwx/firm161/hal/../vision/tracking/template_scoring.h:5,
from /home/lwx/firm161/hal/../vision/tracking/position_enumeration.h:5,
from /home/lwx/firm161/hal/../vision/tracking/door_tracker.h:3,
from /home/lwx/firm161/hal/../application/image_data.h:20,
from /home/lwx/firm161/application/control/states/preparing.h:5,
from /home/lwx/firm161/application/control/states/preparing.cpp:2:
/usr/local/include/boost/thread/future.hpp:2133:9: note: candidate: template<class F> boost::future<typename boost::result_of<F(boost::shared_future<R>)>::type> boost::shared_future<R>::then(boost::launch, F&&) const [with F = F; R = boost::shared_ptr<adam::firmware::ImageData>]
then(launch policy, BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION
^
/usr/local/include/boost/thread/future.hpp:2133:9: note: template argument deduction/substitution failed:
/home/lwx/firm161/application/control/states/preparing.cpp:52:35: note: cannot convert ‘((adam::firmware::states::Preparing*)this)->adam::firmware::states::Preparing::<anonymous>.boost::statechart::state<adam::firmware::states::Preparing, adam::firmware::states::Viewing>::<anonymous>.boost::statechart::simple_state<MostDerived, Context, InnerInitial, historyMode>::outermost_context<adam::firmware::states::Preparing, adam::firmware::states::Viewing, boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, (boost::statechart::history_mode)0u>().adam::firmware::StateMachine::continuation_executor’ (type ‘adam::infra::SchedulerExecutor<>’) to type ‘boost::launch’
.then(outermost_context().continuation_executor,
^
In file included from /usr/local/include/boost/thread.hpp:24:0,
from /home/lwx/firm161/hal/../infra/worker_service.h:9,
from /home/lwx/firm161/hal/../vision/tracking/template_scoring.h:5,
from /home/lwx/firm161/hal/../vision/tracking/position_enumeration.h:5,
from /home/lwx/firm161/hal/../vision/tracking/door_tracker.h:3,
from /home/lwx/firm161/hal/../application/image_data.h:20,
from /home/lwx/firm161/application/control/states/preparing.h:5,
from /home/lwx/firm161/application/control/states/preparing.cpp:2:
/usr/local/include/boost/thread/future.hpp:2137:9: note: candidate: template<class Ex, class F> boost::future<typename boost::result_of<F(boost::shared_future<R>)>::type> boost::shared_future<R>::then(Ex&, F&&) const [with Ex = Ex; F = F; R = boost::shared_ptr<adam::firmware::ImageData>]
then(Ex& ex, BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION
^
/usr/local/include/boost/thread/future.hpp:2137:9: note: template argument deduction/substitution failed:
/usr/local/include/boost/thread/future.hpp: In substitution of ‘template<class Ex, class F> boost::future<typename boost::result_of<F(boost::shared_future<R>)>::type> boost::shared_future<R>::then(Ex&, F&&) const [with Ex = adam::infra::SchedulerExecutor<>; F = adam::firmware::states::InStateHandler<adam::firmware::states::Preparing, boost::shared_ptr<adam::firmware::ImageData> >]’:
/home/lwx/firm161/application/control/states/preparing.cpp:58:25: required from here
/usr/local/include/boost/thread/future.hpp:5059:3: error: no type named ‘type’ in ‘struct boost::result_of<adam::firmware::states::InStateHandler<adam::firmware::states::Preparing, boost::shared_ptr<adam::firmware::ImageData> >(boost::shared_future<boost::shared_ptr<adam::firmware::ImageData> >)>’
shared_future<R>::then(Ex& ex, BOOST_THREAD_FWD_REF(F) func) const
^
/home/lwx/firm161/application/control/states/preparing.cpp: In member function ‘void adam::firmware::states::Preparing::check_exposure_stability(boost::shared_future<boost::shared_ptr<adam::firmware::ImageData> >)’:
问题:
在boost1.61.0+opencv3.1.0编译正常,在boost1.61+opencv4.6.0编译报如上错误,请问怎么解决future then问题,谢谢