sml
sml copied to clipboard
Code fails to compile after #397
Expected Behavior
Code does compile
Actual Behavior
Code doesn't compile
Steps to Reproduce the Problem
Compiling the following code
#include <queue>
#include <sml/sml.hpp>
struct Process {};
struct MainSM {
struct s1 {};
struct s2 {};
auto operator()() noexcept {
using namespace boost::sml;
return make_transition_table(*state<s1> + event<Process> = state<s2>);
}
};
struct ObserverSM {
struct s1 {};
auto operator()() noexcept {
using namespace boost::sml;
return make_transition_table(
*state<s1> + event<Process> / [](sm<MainSM, process_queue<std::queue>> const &) {});
}
};
int main() {
using namespace boost::sml;
auto state_machine = sm<MainSM, process_queue<std::queue>>{};
auto observer_state_machine = sm<ObserverSM>{state_machine};
}
Specifications
- Version:
sml.hpp
of #397 - Platform: Ubuntu 20.04
- Compilers: gcc-10, clang-11
I also got this with GCC 9.3, clang 10, and clang 11.
It has something to do with defining an sm with process_queue<std::queue>
specifically since that commit (2014829), because if I take out process_queue<std::queue>
from the example code, it compiles.
Log of error in GCC:
In file included from /usr/include/c++/9/deque:66,
from /usr/include/c++/9/queue:60,
from test.cpp:1:
/usr/include/c++/9/bits/stl_uninitialized.h: In instantiation of ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process>&, const boost::ext::sml::v1_1_4::back::queue_event<Process>*>; _ForwardIterator = std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, boost::ext::sml::v1_1_4::back::queue_event<Process>&, boost::ext::sml::v1_1_4::back::queue_event<Process>*>]’:
/usr/include/c++/9/bits/stl_uninitialized.h:307:37: required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process>&, const boost::ext::sml::v1_1_4::back::queue_event<Process>*>; _ForwardIterator = std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, boost::ext::sml::v1_1_4::back::queue_event<Process>&, boost::ext::sml::v1_1_4::back::queue_event<Process>*>; _Tp = boost::ext::sml::v1_1_4::back::queue_event<Process>]’
/usr/include/c++/9/bits/stl_deque.h:977:36: required from ‘std::deque<_Tp, _Alloc>::deque(const std::deque<_Tp, _Alloc>&) [with _Tp = boost::ext::sml::v1_1_4::back::queue_event<Process>; _Alloc = std::allocator<boost::ext::sml::v1_1_4::back::queue_event<Process> >]’
/usr/include/c++/9/bits/stl_queue.h:96:11: required from ‘boost::ext::sml::v1_1_4::back::sm< <template-parameter-1-1> >::sm(TDeps&&) [with TDeps = const boost::ext::sml::v1_1_4::back::sm<boost::ext::sml::v1_1_4::back::sm_policy<MainSM, boost::ext::sml::v1_1_4::back::policies::process_queue<std::queue> > >; typename boost::ext::sml::v1_1_4::aux::enable_if<(! boost::ext::sml::v1_1_4::aux::is_same<typename boost::ext::sml::v1_1_4::aux::remove_reference<TDeps>::type, boost::ext::sml::v1_1_4::back::sm< <template-parameter-1-1> > >::value), int>::type <anonymous> = 0; TSM = boost::ext::sml::v1_1_4::back::sm_policy<MainSM, boost::ext::sml::v1_1_4::back::policies::process_queue<std::queue> >]’
boost/sml.hpp:357:8: required from here
/usr/include/c++/9/bits/stl_uninitialized.h:127:72: error: static assertion failed: result type must be constructible from value type of input range
127 | static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
| ^~~~~
Log of error in clang:
In file included from test.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/queue:60:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/deque:66:
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:127:7: error: static_assert failed due to requirement 'is_constructible<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process> &>::value' "result type must be constructible from value type of input range"
static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:307:19: note: in instantiation of function template specialization 'std::uninitialized_copy<std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process> &, const boost::ext::sml::v1_1_4::back::queue_event<Process> *>, std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, boost::ext::sml::v1_1_4::back::queue_event<Process> &, boost::ext::sml::v1_1_4::back::queue_event<Process> *> >' requested here
{ return std::uninitialized_copy(__first, __last, __result); }
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_deque.h:977:14: note: in instantiation of function template specialization 'std::__uninitialized_copy_a<std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process> &, const boost::ext::sml::v1_1_4::back::queue_event<Process> *>, std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, boost::ext::sml::v1_1_4::back::queue_event<Process> &, boost::ext::sml::v1_1_4::back::queue_event<Process> *>, boost::ext::sml::v1_1_4::back::queue_event<Process> >' requested here
{ std::__uninitialized_copy_a(__x.begin(), __x.end(),
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_queue.h:96:11: note: in instantiation of member function 'std::deque<boost::ext::sml::v1_1_4::back::queue_event<Process>, std::allocator<boost::ext::sml::v1_1_4::back::queue_event<Process> > >::deque' requested here
class queue
^
./boost/sml.hpp:1715:75: note: in instantiation of function template specialization 'boost::ext::sml::v1_1_4::aux::pool<boost::ext::sml::v1_1_4::back::sm_impl<boost::ext::sml::v1_1_4::back::sm_policy<ObserverSM> > >::pool<boost::ext::sml::v1_1_4::back::sm<boost::ext::sml::v1_1_4::back::sm_policy<MainSM, boost::ext::sml::v1_1_4::back::policies::process_queue<queue> > > &>' requested here
explicit sm(TDeps &&deps) : deps_{aux::init{}, aux::pool<TDeps>{deps}}, sub_sms_{aux::pool<TDeps>{deps}} {
^
test.cpp:28:33: note: in instantiation of function template specialization 'boost::ext::sml::v1_1_4::back::sm<boost::ext::sml::v1_1_4::back::sm_policy<ObserverSM> >::sm<boost::ext::sml::v1_1_4::back::sm<boost::ext::sml::v1_1_4::back::sm_policy<MainSM, boost::ext::sml::v1_1_4::back::policies::process_queue<queue> > > &, 0>' requested here
auto observer_state_machine = sm<ObserverSM>{state_machine};
^
In file included from test.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/queue:60:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/deque:65:
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_construct.h:75:38: error: call to deleted constructor of 'boost::ext::sml::v1_1_4::back::queue_event<Process>'
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:83:8: note: in instantiation of function template specialization 'std::_Construct<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process> &>' requested here
std::_Construct(std::__addressof(*__cur), *__first);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:140:2: note: in instantiation of function template specialization 'std::__uninitialized_copy<false>::__uninit_copy<std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process> &, const boost::ext::sml::v1_1_4::back::queue_event<Process> *>, std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, boost::ext::sml::v1_1_4::back::queue_event<Process> &, boost::ext::sml::v1_1_4::back::queue_event<Process> *> >' requested here
__uninit_copy(__first, __last, __result);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:307:19: note: in instantiation of function template specialization 'std::uninitialized_copy<std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process> &, const boost::ext::sml::v1_1_4::back::queue_event<Process> *>, std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, boost::ext::sml::v1_1_4::back::queue_event<Process> &, boost::ext::sml::v1_1_4::back::queue_event<Process> *> >' requested here
{ return std::uninitialized_copy(__first, __last, __result); }
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_deque.h:977:14: note: in instantiation of function template specialization 'std::__uninitialized_copy_a<std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, const boost::ext::sml::v1_1_4::back::queue_event<Process> &, const boost::ext::sml::v1_1_4::back::queue_event<Process> *>, std::_Deque_iterator<boost::ext::sml::v1_1_4::back::queue_event<Process>, boost::ext::sml::v1_1_4::back::queue_event<Process> &, boost::ext::sml::v1_1_4::back::queue_event<Process> *>, boost::ext::sml::v1_1_4::back::queue_event<Process> >' requested here
{ std::__uninitialized_copy_a(__x.begin(), __x.end(),
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_queue.h:96:11: note: in instantiation of member function 'std::deque<boost::ext::sml::v1_1_4::back::queue_event<Process>, std::allocator<boost::ext::sml::v1_1_4::back::queue_event<Process> > >::deque' requested here
class queue
^
./boost/sml.hpp:1715:75: note: in instantiation of function template specialization 'boost::ext::sml::v1_1_4::aux::pool<boost::ext::sml::v1_1_4::back::sm_impl<boost::ext::sml::v1_1_4::back::sm_policy<ObserverSM> > >::pool<boost::ext::sml::v1_1_4::back::sm<boost::ext::sml::v1_1_4::back::sm_policy<MainSM, boost::ext::sml::v1_1_4::back::policies::process_queue<queue> > > &>' requested here
explicit sm(TDeps &&deps) : deps_{aux::init{}, aux::pool<TDeps>{deps}}, sub_sms_{aux::pool<TDeps>{deps}} {
^
test.cpp:28:33: note: in instantiation of function template specialization 'boost::ext::sml::v1_1_4::back::sm<boost::ext::sml::v1_1_4::back::sm_policy<ObserverSM> >::sm<boost::ext::sml::v1_1_4::back::sm<boost::ext::sml::v1_1_4::back::sm_policy<MainSM, boost::ext::sml::v1_1_4::back::policies::process_queue<queue> > > &, 0>' requested here
auto observer_state_machine = sm<ObserverSM>{state_machine};
^
./boost/sml.hpp:636:3: note: 'queue_event' has been explicitly marked deleted here
queue_event(const queue_event &) = delete;
^
2 errors generated.