From e9d5a88fe65c6606ce71cafb8bc20b369e3555ab Mon Sep 17 00:00:00 2001 From: Matthew Parnell Date: Wed, 4 Dec 2019 17:08:40 +0000 Subject: [PATCH] Avoid usage of begin/end for member variables in chrono.h begin and end are commonly used (within and outside the standard) for member functions. Due to the naming convensions of this project, common internal names such as `begin_` and `m_begin` are unfavourable for structs. This the alternative names `first` and `last` which are common for the interface of standard algorithms, have been chosen. `begin()` and `end()` member functions have been added to those structs, and the calling code modified; thus increasing consistency with surrounding code. --- include/fmt/chrono.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 9abe7c4f..284c6e86 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -8,14 +8,14 @@ #ifndef FMT_CHRONO_H_ #define FMT_CHRONO_H_ -#include "format.h" -#include "locale.h" - #include #include #include #include +#include "format.h" +#include "locale.h" + FMT_BEGIN_NAMESPACE // Enable safe chrono durations, unless explicitly disabled. @@ -1038,8 +1038,11 @@ struct formatter, Char> { using iterator = typename basic_format_parse_context::iterator; struct parse_range { - iterator begin; - iterator end; + iterator first; + iterator last; + + iterator begin() const { return first; } + iterator end() const { return last; } }; FMT_CONSTEXPR parse_range do_parse(basic_format_parse_context& ctx) { @@ -1067,8 +1070,8 @@ struct formatter, Char> { -> decltype(ctx.begin()) { auto range = do_parse(ctx); format_str = basic_string_view( - &*range.begin, internal::to_unsigned(range.end - range.begin)); - return range.end; + &*range.begin(), internal::to_unsigned(range.end() - range.begin())); + return range.end(); } template