forked from fmtlib/fmt
arg_join -> join_view
This commit is contained in:
@@ -2506,18 +2506,21 @@ template <> struct formatter<bytes> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename It, typename Sentinel, typename Char>
|
template <typename It, typename Sentinel, typename Char = char>
|
||||||
struct arg_join : detail::view {
|
struct join_view : detail::view {
|
||||||
It begin;
|
It begin;
|
||||||
Sentinel end;
|
Sentinel end;
|
||||||
basic_string_view<Char> sep;
|
basic_string_view<Char> sep;
|
||||||
|
|
||||||
arg_join(It b, Sentinel e, basic_string_view<Char> s)
|
join_view(It b, Sentinel e, basic_string_view<Char> s)
|
||||||
: begin(b), end(e), sep(s) {}
|
: begin(b), end(e), sep(s) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename It, typename Sentinel, typename Char>
|
template <typename It, typename Sentinel, typename Char>
|
||||||
struct formatter<arg_join<It, Sentinel, Char>, Char> {
|
using arg_join FMT_DEPRECATED_ALIAS = join_view<It, Sentinel, Char>;
|
||||||
|
|
||||||
|
template <typename It, typename Sentinel, typename Char>
|
||||||
|
struct formatter<join_view<It, Sentinel, Char>, Char> {
|
||||||
private:
|
private:
|
||||||
using value_type = typename std::iterator_traits<It>::value_type;
|
using value_type = typename std::iterator_traits<It>::value_type;
|
||||||
using context = buffer_context<Char>;
|
using context = buffer_context<Char>;
|
||||||
@@ -2548,7 +2551,7 @@ struct formatter<arg_join<It, Sentinel, Char>, Char> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename FormatContext>
|
template <typename FormatContext>
|
||||||
auto format(const arg_join<It, Sentinel, Char>& value, FormatContext& ctx)
|
auto format(const join_view<It, Sentinel, Char>& value, FormatContext& ctx)
|
||||||
-> decltype(ctx.out()) {
|
-> decltype(ctx.out()) {
|
||||||
auto it = value.begin;
|
auto it = value.begin;
|
||||||
auto out = ctx.out();
|
auto out = ctx.out();
|
||||||
@@ -2569,7 +2572,7 @@ struct formatter<arg_join<It, Sentinel, Char>, Char> {
|
|||||||
elements separated by `sep`.
|
elements separated by `sep`.
|
||||||
*/
|
*/
|
||||||
template <typename It, typename Sentinel>
|
template <typename It, typename Sentinel>
|
||||||
arg_join<It, Sentinel, char> join(It begin, Sentinel end, string_view sep) {
|
auto join(It begin, Sentinel end, string_view sep) -> join_view<It, Sentinel> {
|
||||||
return {begin, end, sep};
|
return {begin, end, sep};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2590,8 +2593,8 @@ arg_join<It, Sentinel, char> join(It begin, Sentinel end, string_view sep) {
|
|||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename Range>
|
template <typename Range>
|
||||||
arg_join<detail::iterator_t<Range>, detail::sentinel_t<Range>, char> join(
|
auto join(Range&& range, string_view sep)
|
||||||
Range&& range, string_view sep) {
|
-> join_view<detail::iterator_t<Range>, detail::sentinel_t<Range>> {
|
||||||
return join(std::begin(range), std::end(range), sep);
|
return join(std::begin(range), std::end(range), sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -296,8 +296,8 @@ struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::value>> {
|
|||||||
}
|
}
|
||||||
formatting_tuple<Char>& formatting;
|
formatting_tuple<Char>& formatting;
|
||||||
size_t& i;
|
size_t& i;
|
||||||
typename std::add_lvalue_reference<decltype(
|
typename std::add_lvalue_reference<
|
||||||
std::declval<FormatContext>().out())>::type out;
|
decltype(std::declval<FormatContext>().out())>::type out;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -452,7 +452,7 @@ FMT_CONSTEXPR tuple_arg_join<wchar_t, T...> join(
|
|||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
arg_join<const T*, const T*, char> join(std::initializer_list<T> list,
|
join_view<const T*, const T*> join(std::initializer_list<T> list,
|
||||||
string_view sep) {
|
string_view sep) {
|
||||||
return join(std::begin(list), std::end(list), sep);
|
return join(std::begin(list), std::end(list), sep);
|
||||||
}
|
}
|
||||||
|
@@ -54,19 +54,21 @@ constexpr detail::udl_arg<wchar_t> operator"" _a(const wchar_t* s, size_t) {
|
|||||||
} // namespace literals
|
} // namespace literals
|
||||||
|
|
||||||
template <typename It, typename Sentinel>
|
template <typename It, typename Sentinel>
|
||||||
arg_join<It, Sentinel, wchar_t> join(It begin, Sentinel end, wstring_view sep) {
|
auto join(It begin, Sentinel end, wstring_view sep)
|
||||||
|
-> join_view<It, Sentinel, wchar_t> {
|
||||||
return {begin, end, sep};
|
return {begin, end, sep};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Range>
|
template <typename Range>
|
||||||
arg_join<detail::iterator_t<Range>, detail::sentinel_t<Range>, wchar_t> join(
|
auto join(Range&& range, wstring_view sep)
|
||||||
Range&& range, wstring_view sep) {
|
-> join_view<detail::iterator_t<Range>, detail::sentinel_t<Range>,
|
||||||
|
wchar_t> {
|
||||||
return join(std::begin(range), std::end(range), sep);
|
return join(std::begin(range), std::end(range), sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
arg_join<const T*, const T*, wchar_t> join(std::initializer_list<T> list,
|
auto join(std::initializer_list<T> list, wstring_view sep)
|
||||||
wstring_view sep) {
|
-> join_view<const T*, const T*, wchar_t> {
|
||||||
return join(std::begin(list), std::end(list), sep);
|
return join(std::begin(list), std::end(list), sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user