Remove iterator_t

This commit is contained in:
Victor Zverovich 2024-09-10 19:42:49 -07:00
parent 2ba6785d8f
commit 0cc20f5639
3 changed files with 4 additions and 10 deletions

View File

@ -2125,6 +2125,7 @@ template <typename T, typename Char> struct type_is_unformattable_for;
template <typename Char> struct string_value {
const Char* data;
size_t size;
auto str() const -> basic_string_view<Char> { return {data, size}; }
};
template <typename Char> struct named_arg_value {
@ -2542,10 +2543,8 @@ template <typename Context> class basic_format_arg {
case detail::type::double_type: return vis(value_.double_value);
case detail::type::long_double_type: return vis(value_.long_double_value);
case detail::type::cstring_type: return vis(value_.string.data);
case detail::type::string_type:
using sv = basic_string_view<char_type>;
return vis(sv(value_.string.data, value_.string.size));
case detail::type::pointer_type: return vis(value_.pointer);
case detail::type::string_type: return vis(value_.string.str());
case detail::type::pointer_type: return vis(value_.pointer);
case detail::type::custom_type:
return vis(typename basic_format_arg<Context>::handle(value_.custom));
}

View File

@ -534,11 +534,6 @@ FMT_INLINE void assume(bool condition) {
#endif
}
// An approximation of iterator_t for pre-C++20 systems.
template <typename T>
using iterator_t = decltype(std::begin(std::declval<T&>()));
template <typename T> using sentinel_t = decltype(std::end(std::declval<T&>()));
// A workaround for std::string not having mutable data() until C++17.
template <typename Char>
inline auto get_data(std::basic_string<Char>& s) -> Char* {

View File

@ -144,7 +144,7 @@ auto join(It begin, Sentinel end, wstring_view sep)
template <typename Range>
auto join(Range&& range, wstring_view sep)
-> join_view<detail::iterator_t<Range>, detail::sentinel_t<Range>,
-> join_view<decltype(std::begin(range)), decltype(std::end(range)),
wchar_t> {
return join(std::begin(range), std::end(range), sep);
}