@@ -1062,33 +1062,57 @@ struct internal_event {
10621062struct anonymous : internal_event {
10631063 constexpr static auto c_str () { return " anonymous" ; }
10641064};
1065+ template <class T , class = void >
1066+ struct default_internal_event {
1067+ static const T &get () {
1068+ static_assert (aux::is_constructible<T>::value, " Default internal event requires a default-constructible payload type." );
1069+ return *static_cast <const T *>(nullptr );
1070+ }
1071+ };
1072+ template <class T >
1073+ struct default_internal_event <T, aux::enable_if_t <aux::is_constructible<T>::value>> {
1074+ constexpr static const T &get () { return value; }
1075+ static const T value;
1076+ };
1077+ template <class T >
1078+ const T default_internal_event<T, aux::enable_if_t <aux::is_constructible<T>::value>>::value{};
10651079template <class TEvent >
10661080struct completion : internal_event {
10671081 constexpr static auto c_str () { return " completion" ; }
1082+ template <class U = TEvent, __BOOST_SML_REQUIRES(aux::is_constructible<U>::value)>
1083+ constexpr completion () : event_(default_internal_event<TEvent>::get()) {}
10681084 constexpr explicit completion (const TEvent &event) : event_(event) {}
10691085 const TEvent &event_;
10701086};
10711087template <class T , class TEvent = T>
10721088struct on_entry : internal_event, entry_exit {
10731089 constexpr static auto c_str () { return " on_entry" ; }
1074- constexpr explicit on_entry (const TEvent &event = {}) : event_(event) {}
1090+ template <class U = TEvent, __BOOST_SML_REQUIRES(aux::is_constructible<U>::value)>
1091+ constexpr on_entry () : event_(default_internal_event<TEvent>::get()) {}
1092+ constexpr explicit on_entry (const TEvent &event) : event_(event) {}
10751093 const TEvent &event_;
10761094};
10771095template <class T , class TEvent = T>
10781096struct on_exit : internal_event, entry_exit {
10791097 constexpr static auto c_str () { return " on_exit" ; }
1080- constexpr explicit on_exit (const TEvent &event = {}) : event_(event) {}
1098+ template <class U = TEvent, __BOOST_SML_REQUIRES(aux::is_constructible<U>::value)>
1099+ constexpr on_exit () : event_(default_internal_event<TEvent>::get()) {}
1100+ constexpr explicit on_exit (const TEvent &event) : event_(event) {}
10811101 const TEvent &event_;
10821102};
10831103template <class T , class TException = T>
10841104struct exception : internal_event {
10851105 using type = TException;
1086- constexpr explicit exception (const TException &exception = {}) : exception_(exception) {}
1106+ template <class U = TException, __BOOST_SML_REQUIRES(aux::is_constructible<U>::value)>
1107+ constexpr exception () : exception_(default_internal_event<TException>::get()) {}
1108+ constexpr explicit exception (const TException &exception) : exception_(exception) {}
10871109 const TException &exception_;
10881110};
10891111template <class T , class TEvent = T>
10901112struct unexpected_event : internal_event, unexpected {
1091- constexpr explicit unexpected_event (const TEvent &event = {}) : event_(event) {}
1113+ template <class U = TEvent, __BOOST_SML_REQUIRES(aux::is_constructible<U>::value)>
1114+ constexpr unexpected_event () : event_(default_internal_event<TEvent>::get()) {}
1115+ constexpr explicit unexpected_event (const TEvent &event) : event_(event) {}
10921116 const TEvent &event_;
10931117};
10941118template <class TEvent >
@@ -2675,7 +2699,10 @@ struct event {
26752699 constexpr auto operator /(const T &t) const {
26762700 return transition_ea<event, aux::zero_wrapper<T>>{*this , aux::zero_wrapper<T>{t}};
26772701 }
2678- constexpr auto operator ()() const { return TEvent{}; }
2702+ template <class U = TEvent, __BOOST_SML_REQUIRES(aux::is_constructible<U>::value)>
2703+ constexpr auto operator ()() const {
2704+ return U{};
2705+ }
26792706};
26802707} // namespace front
26812708namespace front {
0 commit comments