File tree Expand file tree Collapse file tree
chaotic/include/userver/chaotic/sax_parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,20 +57,21 @@ class IntEnumParser : private formats::json::parser::Subscriber<std::int64_t> {
5757 formats::json::parser::Subscriber<IntEnum>* subscriber_{nullptr };
5858};
5959
60- template <typename Enum, typename = void >
61- struct IsStringEnum : std::false_type {};
62-
6360template <typename Enum>
64- struct IsStringEnum <Enum, utils::void_t <decltype (Convert(std::string_view{}, chaotic::convert::To<Enum>{}))>>
65- : std::true_type {};
61+ concept IsStringEnum = requires { Convert (std::string_view{}, chaotic::convert::To<Enum>{}); };
6662
6763} // namespace impl
6864
6965template <typename Enum>
70- std::enable_if_t <
71- std::is_enum_v<Enum>,
72- std::conditional_t <impl::IsStringEnum<Enum>::value, impl::StringEnumParser<Enum>, impl::IntEnumParser<Enum>>>
73- ParserOf (Type<Enum>);
66+ requires std::is_enum_v<Enum>
67+ auto ParserOf (Type<Enum>)
68+ {
69+ if constexpr (impl::IsStringEnum<Enum>) {
70+ return impl::StringEnumParser<Enum>{};
71+ } else {
72+ return impl::IntEnumParser<Enum>{};
73+ }
74+ }
7475
7576} // namespace chaotic::sax
7677
You can’t perform that action at this time.
0 commit comments