Skip to content

Commit 3b6e076

Browse files
committed
🎨 Don't use nonstandard UDL extension where possible
GCC and clang allow a user-defined literal operator template with the signature: ```cpp template <typename T, T...> auto operator""_udl(); ``` This is a non-standard extension and for our purposes at least it is replaced in C++20 by using an operator template with a structural NTTP: ```cpp template <ct_string S> auto operator""_udl();
1 parent c7186ba commit 3b6e076

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

include/flow/step.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,16 @@ template <stdx::ct_string Name> [[nodiscard]] constexpr auto milestone() {
5858
}
5959

6060
inline namespace literals {
61-
template <class T, T... Cs> [[nodiscard]] constexpr auto operator""_action() {
62-
constexpr auto S = stdx::ct_string<sizeof...(Cs) + 1U>{{Cs..., 0}};
61+
template <stdx::ct_string S> [[nodiscard]] constexpr auto operator""_action() {
6362
return action<S>();
6463
}
6564

66-
template <class T, T... Cs> [[nodiscard]] constexpr auto operator""_step() {
67-
constexpr auto S = stdx::ct_string<sizeof...(Cs) + 1U>{{Cs..., 0}};
65+
template <stdx::ct_string S> [[nodiscard]] constexpr auto operator""_step() {
6866
return action<S>();
6967
}
7068

71-
template <class T, T... Cs>
69+
template <stdx::ct_string S>
7270
[[nodiscard]] constexpr auto operator""_milestone() {
73-
constexpr auto S = stdx::ct_string<sizeof...(Cs) + 1U>{{Cs..., 0}};
7471
return milestone<S>();
7572
}
7673
} // namespace literals

include/msg/message.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,13 @@ template <typename Name> struct field_name {
171171
} // namespace detail
172172

173173
inline namespace literals {
174-
template <class T, T... chars> constexpr auto operator""_field() {
175-
return detail::field_name<sc::string_constant<T, chars...>>{};
174+
template <stdx::ct_string S> constexpr auto operator""_field() {
175+
using Name = decltype(stdx::ct_string_to_type<S, sc::string_constant>());
176+
return detail::field_name<Name>{};
176177
}
177-
template <class T, T... chars> constexpr auto operator""_f() {
178-
return detail::field_name<sc::string_constant<T, chars...>>{};
178+
template <stdx::ct_string S> constexpr auto operator""_f() {
179+
using Name = decltype(stdx::ct_string_to_type<S, sc::string_constant>());
180+
return detail::field_name<Name>{};
179181
}
180182
} // namespace literals
181183

0 commit comments

Comments
 (0)