From 83f052930a2e5eae06372d6c15343e6913ebb5a4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 19 Jan 2019 09:10:57 -0800 Subject: [PATCH] Add code from p0645 --- CMakeLists.txt | 3 +- include/fmt/core.h | 14 +- include/fmt/format.h | 22 +- include/fmt/printf.h | 2 +- include/format | 823 +++++++++++++++++++++++++++++++++++++++++++ test/format-test.cc | 3 +- 6 files changed, 848 insertions(+), 19 deletions(-) create mode 100644 include/format diff --git a/CMakeLists.txt b/CMakeLists.txt index b6ff7251..5d2f56c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,8 @@ if (HAVE_OPEN) set(FMT_SOURCES ${FMT_SOURCES} src/posix.cc) endif () -add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst) +add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} include/format README.rst + ChangeLog.rst) add_library(fmt::fmt ALIAS fmt) if (FMT_WERROR) diff --git a/include/fmt/core.h b/include/fmt/core.h index 95b5f64b..3bbbcce4 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1042,7 +1042,7 @@ class context_base { // Checks if manual indexing is used and returns the argument with // specified index. - format_arg get_arg(unsigned arg_id) { + format_arg arg(unsigned arg_id) { return this->parse_context().check_arg_id(arg_id) ? this->do_get_arg(arg_id) : format_arg(); } @@ -1125,11 +1125,11 @@ class basic_format_context void operator=(const basic_format_context&) = delete; typedef internal::context_base base; - typedef typename base::format_arg format_arg; - using base::get_arg; + using base::arg; public: using typename base::iterator; + typedef typename base::format_arg format_arg; /** Constructs a ``basic_format_context`` object. References to the arguments are @@ -1143,11 +1143,15 @@ class basic_format_context format_arg next_arg() { return this->do_get_arg(this->parse_context().next_arg_id()); } - format_arg get_arg(unsigned arg_id) { return this->do_get_arg(arg_id); } + format_arg arg(unsigned arg_id) { return this->do_get_arg(arg_id); } // Checks if manual indexing is used and returns the argument with the // specified name. - format_arg get_arg(basic_string_view name); + format_arg arg(basic_string_view name); + + // DEPRECATED! + format_arg get_arg(unsigned arg_id) { return arg(arg_id); } + format_arg get_arg(basic_string_view name) { return arg(name); } }; template struct buffer_context { diff --git a/include/fmt/format.h b/include/fmt/format.h index aa5fe3de..e04391e4 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1662,10 +1662,9 @@ template class specs_checker : public Handler { numeric_specs_checker checker_; }; -template