From 31ea064e417439204d31937d7a3d2acbad1b49df Mon Sep 17 00:00:00 2001 From: Matthew Parnell Date: Wed, 4 Dec 2019 17:28:39 +0000 Subject: [PATCH] Avoid usage of begin/end for member variables in format.h As with parent commit, begin and end are commonly member functions, not member variables. To fit in with the style of the project, `first` and `last` have been used as an alternative within the `arg_join` struct. `begin()` and `end()` member functions have been added to the struct, and the calling code modified; thus increasing consistency with surrounding code. --- include/fmt/format.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 600b0eba..3092aa9b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -33,8 +33,6 @@ #ifndef FMT_FORMAT_H_ #define FMT_FORMAT_H_ -#include "core.h" - #include #include #include @@ -43,6 +41,8 @@ #include #include +#include "core.h" + #ifdef __clang__ # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) #else @@ -3217,12 +3217,15 @@ template inline const void* ptr(const std::shared_ptr& p) { return p.get(); } -template struct arg_join : internal::view { - It begin; - It end; +template +struct arg_join : internal::view { + It first; + It last; basic_string_view sep; - arg_join(It b, It e, basic_string_view s) : begin(b), end(e), sep(s) {} + arg_join(It b, It e, basic_string_view s) : first(b), last(e), sep(s) {} + It begin() const { return first; } + It end() const { return last; } }; template @@ -3232,11 +3235,11 @@ struct formatter, Char> auto format(const arg_join& value, FormatContext& ctx) -> decltype(ctx.out()) { using base = formatter::value_type, Char>; - auto it = value.begin; + auto it = value.begin(); auto out = ctx.out(); - if (it != value.end) { + if (it != value.end()) { out = base::format(*it++, ctx); - while (it != value.end) { + while (it != value.end()) { out = std::copy(value.sep.begin(), value.sep.end(), out); ctx.advance_to(out); out = base::format(*it++, ctx); @@ -3272,14 +3275,14 @@ arg_join join(It begin, It end, wstring_view sep) { \endrst */ template -arg_join, char> join(const Range& range, - string_view sep) { +arg_join, char> +join(const Range& range, string_view sep) { return join(std::begin(range), std::end(range), sep); } template -arg_join, wchar_t> join(const Range& range, - wstring_view sep) { +arg_join, wchar_t> +join(const Range& range, wstring_view sep) { return join(std::begin(range), std::end(range), sep); }