From 8671689449acfd7b960e8adee302c29c2e643aff Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 8 Sep 2018 09:06:54 -0700 Subject: [PATCH] Update docs and formatting --- doc/api.rst | 7 +++---- include/fmt/format.h | 15 +++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/api.rst b/doc/api.rst index f6fd27d2..04122488 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -253,11 +253,10 @@ custom argument formatter class:: using arg_formatter::operator(); - void operator()(int value) { + auto operator()(int value) { if (spec().type() == 'x') - (*this)(static_cast(value)); // convert to unsigned and format - else - arg_formatter::operator()(value); + return (*this)(static_cast(value)); // convert to unsigned and format + return arg_formatter::operator()(value); } }; diff --git a/include/fmt/format.h b/include/fmt/format.h index f3b438e2..619402ce 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2145,7 +2145,7 @@ FMT_CONSTEXPR void parse_format_string( auto end = begin + format_str.size(); for (;;) { // Doing two passes with memchr (one for '{' and another for '}') is up to - // 2.5x faster than the naive one-pass implementation on long format strings. + // 2.5x faster than the naive one-pass implementation on big format strings. const Char *p = FMT_NULL; if (!find(begin, end, '{', p)) { if (begin != end) @@ -2217,7 +2217,8 @@ class format_string_checker { FMT_CONSTEXPR const Char *on_format_specs(iterator it) { auto p = pointer_from(it); context_.advance_to(p); - return to_unsigned(arg_id_) < NUM_ARGS ? parse_funcs_[arg_id_](context_) : p; + return to_unsigned(arg_id_) < NUM_ARGS ? + parse_funcs_[arg_id_](context_) : p; } FMT_CONSTEXPR void on_error(const char *message) { @@ -2747,7 +2748,8 @@ class basic_writer { } template - typename std::enable_if::value>::type write(const T* p) { + typename std::enable_if::value>::type + write(const T *p) { format_specs specs; specs.flags_ = HASH_FLAG; specs.type_ = 'x'; @@ -3525,8 +3527,8 @@ inline format_to_n_result vformat_to_n( /** \rst Formats arguments, writes up to ``n`` characters of the result to the output - iterator ``out`` and returns the total output size and the iterator past the end - of the output range. + iterator ``out`` and returns the total output size and the iterator past the + end of the output range. \endrst */ template @@ -3537,7 +3539,8 @@ inline format_to_n_result format_to_n( } template inline format_to_n_result format_to_n( - OutputIt out, std::size_t n, wstring_view format_str, const Args &... args) { + OutputIt out, std::size_t n, wstring_view format_str, + const Args &... args) { typedef internal::truncating_iterator It; auto it = vformat_to(It(out, n), format_str, make_format_args::type>(args...));