Skip to content

Commit d607d03

Browse files
author
Hana Dusíková
committed
remove operator auto() for more explicit string_view conversion
1 parent 964da01 commit d607d03

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

include/ctre/return_type.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ template <size_t Id, typename Name = void> struct captured_content {
5151
return _matched;
5252
}
5353

54-
constexpr operator auto() const noexcept {
55-
return to_view();
56-
}
5754
constexpr CTRE_FORCE_INLINE auto to_view() const noexcept {
5855
return std::basic_string_view{_begin, static_cast<size_t>(std::distance(_begin, _end))};
5956
}
6057

58+
using string_view_type = decltype(std::basic_string_view{_begin, static_cast<size_t>(std::distance(_begin, _end))});
59+
60+
constexpr operator string_view_type() const noexcept {
61+
return to_view();
62+
}
63+
6164
constexpr CTRE_FORCE_INLINE static size_t get_id() noexcept {
6265
return Id;
6366
}
@@ -134,6 +137,8 @@ template <> struct captures<> {
134137
};
135138

136139
template <typename Iterator, typename... Captures> struct regex_results {
140+
using char_type = std::remove_reference_t<std::remove_const_t<decltype(*std::declval<Iterator>())>>;
141+
137142
captures<captured_content<0>::template storage<Iterator>, typename Captures::template storage<Iterator>...> _captures;
138143

139144
constexpr CTRE_FORCE_INLINE regex_results() noexcept { }
@@ -162,7 +167,10 @@ template <typename Iterator, typename... Captures> struct regex_results {
162167
constexpr CTRE_FORCE_INLINE operator bool() const noexcept {
163168
return bool(_captures.template select<0>());
164169
}
165-
constexpr operator auto() const noexcept {
170+
171+
using string_view_type = decltype(_captures.template select<0>().to_view());
172+
173+
constexpr operator string_view_type() const noexcept {
166174
return _captures.template select<0>().to_view();
167175
}
168176
constexpr auto to_view() const noexcept {

0 commit comments

Comments
 (0)