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.
This commit is contained in:
Matthew Parnell 2019-12-04 17:08:40 +00:00
parent 123e7f7fc3
commit e9d5a88fe6

View File

@ -8,14 +8,14 @@
#ifndef FMT_CHRONO_H_
#define FMT_CHRONO_H_
#include "format.h"
#include "locale.h"
#include <chrono>
#include <ctime>
#include <locale>
#include <sstream>
#include "format.h"
#include "locale.h"
FMT_BEGIN_NAMESPACE
// Enable safe chrono durations, unless explicitly disabled.
@ -1038,8 +1038,11 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
using iterator = typename basic_format_parse_context<Char>::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<Char>& ctx) {
@ -1067,8 +1070,8 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
-> decltype(ctx.begin()) {
auto range = do_parse(ctx);
format_str = basic_string_view<Char>(
&*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 <typename FormatContext>