diff --git a/include/boost/sml.hpp b/include/boost/sml.hpp index 9ca63b88..b0f6174c 100644 --- a/include/boost/sml.hpp +++ b/include/boost/sml.hpp @@ -466,6 +466,20 @@ const char *get_type_name() { return detail::get_type_name(__PRETTY_FUNCTION__, make_index_sequence{}); #endif } +#if defined(__cpp_nontype_template_parameter_class) +template +struct fixed_string { + static constexpr auto size = N; + char data[N + 1]{}; + constexpr fixed_string(char const *str) { + for (auto i = 0; i < N; ++i) { + data[i] = str[i]; + } + } +}; +template +fixed_string(char const (&)[N]) -> fixed_string; +#endif template struct string; template @@ -2614,7 +2628,18 @@ template typename front::state_sm::type state __BOOST_SML_VT_INIT; #endif inline namespace literals { -#if !(defined(_MSC_VER) && !defined(__clang__)) +#if defined(__cpp_nontype_template_parameter_class) +template +constexpr auto operator""_s() { + return [](aux::index_sequence) { return front::state>{}; } + (aux::make_index_sequence{}); +} +template +constexpr auto operator""_e() { + return [](aux::index_sequence) { return event>; } + (aux::make_index_sequence{}); +} +#elif !(defined(_MSC_VER) && !defined(__clang__)) template constexpr auto operator""_s() { return front::state>{}; diff --git a/include/boost/sml/aux_/utility.hpp b/include/boost/sml/aux_/utility.hpp index 1dbd24ec..ce55e044 100644 --- a/include/boost/sml/aux_/utility.hpp +++ b/include/boost/sml/aux_/utility.hpp @@ -315,6 +315,22 @@ const char *get_type_name() { #endif // __pph__ } +#if defined(__cpp_nontype_template_parameter_class) // __pph__ +template +struct fixed_string { + static constexpr auto size = N; + char data[N + 1]{}; + + constexpr fixed_string(char const *str) { + for (auto i = 0; i < N; ++i) { + data[i] = str[i]; + } + } +}; +template +fixed_string(char const (&)[N]) -> fixed_string; +#endif // __pph__ + template struct string; diff --git a/include/boost/sml/transition_table.hpp b/include/boost/sml/transition_table.hpp index 3710ad75..57834800 100644 --- a/include/boost/sml/transition_table.hpp +++ b/include/boost/sml/transition_table.hpp @@ -55,7 +55,18 @@ typename front::state_sm::type state __BOOST_SML_VT_INIT; #endif // __pph__ inline namespace literals { -#if !(defined(_MSC_VER) && !defined(__clang__)) // __pph__ +#if defined(__cpp_nontype_template_parameter_class) // __pph__ +template +constexpr auto operator""_s() { + return [](aux::index_sequence) { return front::state>{}; } + (aux::make_index_sequence{}); +} +template +constexpr auto operator""_e() { + return [](aux::index_sequence) { return event>; } + (aux::make_index_sequence{}); +} +#elif !(defined(_MSC_VER) && !defined(__clang__)) // __pph__ template constexpr auto operator""_s() { return front::state>{}; @@ -64,8 +75,7 @@ template constexpr auto operator""_e() { return event>; } -#endif // __pph__ - +#endif // __pph__ } // literals __BOOST_SML_UNUSED static front::state X;