From d8ef8a9e9b416150d4127fd9998dcf2665712c27 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 11 Feb 2018 06:23:43 -0800 Subject: [PATCH 01/62] Cleanup --- include/fmt/core.h | 6 +-- test/container-test.cc | 94 ------------------------------------------ test/format-test.cc | 2 +- 3 files changed, 3 insertions(+), 99 deletions(-) delete mode 100644 test/container-test.cc diff --git a/include/fmt/core.h b/include/fmt/core.h index 0944973e..5da04ed0 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -24,7 +24,7 @@ # define FMT_HAS_FEATURE(x) 0 #endif -#if defined(__has_include) +#ifdef __has_include # define FMT_HAS_INCLUDE(x) __has_include(x) #else # define FMT_HAS_INCLUDE(x) 0 @@ -36,7 +36,7 @@ # define FMT_GCC_VERSION 0 #endif -#if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__ +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) # define FMT_HAS_GXX_CXX11 FMT_GCC_VERSION #else # define FMT_HAS_GXX_CXX11 0 @@ -82,8 +82,6 @@ # endif #endif -#define FMT_USE_STRONG_ENUMS FMT_HAS_FEATURE(cxx_strong_enums) - // Check if exceptions are disabled. #if defined(__GNUC__) && !defined(__EXCEPTIONS) # define FMT_EXCEPTIONS 0 diff --git a/test/container-test.cc b/test/container-test.cc deleted file mode 100644 index 8cafb3d0..00000000 --- a/test/container-test.cc +++ /dev/null @@ -1,94 +0,0 @@ -/* - Tests of container utilities - - Copyright (c) 2012 - 2016, Victor Zverovich - All rights reserved. - - For the license information refer to format.h. - */ - -#include "fmt/container.h" -#include "gtest/gtest.h" - -using fmt::internal::ContainerBuffer; - -TEST(ContainerBufferTest, Empty) { - std::string data; - ContainerBuffer buffer(data); - EXPECT_EQ(0u, buffer.size()); - EXPECT_EQ(0u, buffer.capacity()); -} - -TEST(ContainerBufferTest, Reserve) { - std::string data; - ContainerBuffer buffer(data); - std::size_t capacity = std::string().capacity() + 10; - buffer.reserve(capacity); - EXPECT_EQ(0u, buffer.size()); - EXPECT_EQ(capacity, buffer.capacity()); -} - -TEST(ContainerBufferTest, Resize) { - std::string data; - ContainerBuffer buffer(data); - std::size_t size = std::string().capacity() + 10; - buffer.resize(size); - EXPECT_EQ(size, buffer.size()); - EXPECT_EQ(size, buffer.capacity()); -} - -TEST(ContainerBufferTest, Append) { - std::string data("Why so"); - const std::string serious(" serious"); - ContainerBuffer buffer(data); - buffer.append(serious.c_str(), serious.c_str() + serious.length()); - EXPECT_EQ("Why so serious", data); - EXPECT_EQ(data.length(), buffer.size()); -} - -TEST(BasicContainerWriterTest, String) { - std::string data; - fmt::BasicContainerWriter out(data); - out << "The answer is " << 42 << "\n"; - EXPECT_EQ("The answer is 42\n", data); - EXPECT_EQ(17u, out.size()); -} - -TEST(BasicContainerWriterTest, WString) { - std::wstring data; - fmt::BasicContainerWriter out(data); - out << "The answer is " << 42 << "\n"; - EXPECT_EQ(L"The answer is 42\n", data); - EXPECT_EQ(17u, out.size()); -} - -TEST(BasicContainerWriterTest, Vector) { - std::vector data; - fmt::BasicContainerWriter > out(data); - out << "The answer is " << 42 << "\n"; - EXPECT_EQ(17u, data.size()); - EXPECT_EQ(out.size(), data.size()); -} - -TEST(BasicContainerWriterTest, StringAppend) { - std::string data("The"); - fmt::BasicContainerWriter out(data); - EXPECT_EQ(3u, data.size()); - EXPECT_EQ(3u, out.size()); - out << " answer is " << 42 << "\n"; - EXPECT_EQ("The answer is 42\n", data); - EXPECT_EQ(17u, out.size()); -} - -TEST(BasicContainerWriterTest, VectorAppend) { - std::vector data; - data.push_back('T'); - data.push_back('h'); - data.push_back('e'); - fmt::BasicContainerWriter > out(data); - EXPECT_EQ(3u, data.size()); - EXPECT_EQ(3u, out.size()); - out << " answer is " << 42 << "\n"; - EXPECT_EQ(17u, data.size()); - EXPECT_EQ(17u, out.size()); -} diff --git a/test/format-test.cc b/test/format-test.cc index 30b59fc2..54fe79ac 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1508,7 +1508,7 @@ TEST(FormatTest, Enum) { EXPECT_EQ("0", fmt::format("{}", A)); } -#if FMT_USE_STRONG_ENUMS +#if FMT_HAS_FEATURE(cxx_strong_enums) enum TestFixedEnum : short { B }; TEST(FormatTest, FixedEnum) { From 78166ccd363fb7088ce86c0bcc839a7fe2457a19 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 11 Feb 2018 06:50:56 -0800 Subject: [PATCH 02/62] Get rid of generic lambdas --- include/fmt/format.h | 82 ++++++++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 2e94fab0..687c1745 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2216,6 +2216,22 @@ class basic_writer { template void write_padded(std::size_t size, const align_spec &spec, F f); + template + struct padded_int_writer { + string_view prefix; + wchar_t fill; + unsigned padding; + F f; + + template + void operator()(It &&it) const { + if (prefix.size() != 0) + it = std::copy_n(prefix.data(), prefix.size(), it); + it = std::fill_n(it, padding, fill); + f(it); + } + }; + // Writes an integer in the format // // where are written by f(it). @@ -2238,12 +2254,7 @@ class basic_writer { align_spec as = spec; if (spec.align() == ALIGN_DEFAULT) as.align_ = ALIGN_RIGHT; - write_padded(size, as, [prefix, fill, padding, f](auto &&it) { - if (prefix.size() != 0) - it = std::copy_n(prefix.data(), prefix.size(), it); - it = std::fill_n(it, padding, fill); - f(it); - }); + write_padded(size, as, padded_int_writer{prefix, fill, padding, f}); } // Writes a decimal integer. @@ -2368,16 +2379,54 @@ class basic_writer { int_writer(*this, value, spec)); } + enum {INF_SIZE = 3}; // This is an enum to workaround a bug in MSVC. + + struct inf_or_nan_writer { + char sign; + const char *str; + + template + void operator()(It &&it) const { + if (sign) + *it++ = sign; + it = std::copy_n(str, static_cast(INF_SIZE), it); + } + }; + + struct double_writer { + unsigned n; + char sign; + basic_memory_buffer &buffer; + + template + void operator()(It &&it) { + if (sign) { + *it++ = sign; + --n; + } + it = std::copy_n(buffer.begin(), n, it); + } + }; + // Formats a floating-point number (double or long double). template void write_double(T value, const format_specs &spec); + template + struct str_writer { + const Char *s; + std::size_t size; + + template + void operator()(It &&it) const { + it = std::copy_n(s, size, it); + } + }; + // Writes a formatted string. template void write_str(const Char *s, std::size_t size, const align_spec &spec) { - write_padded(size, spec, [s, size](auto &&it) { - it = std::copy_n(s, size, it); - }); + write_padded(size, spec, str_writer{s, size}); } template @@ -2562,12 +2611,7 @@ void basic_writer::write_double(T value, const format_specs &spec) { } auto write_inf_or_nan = [this, &spec, sign](const char *str) { - enum {SIZE = 3}; // This is an enum to workaround a bug in MSVC. - write_padded(SIZE + (sign ? 1 : 0), spec, [sign, str](auto &&it) { - if (sign) - *it++ = sign; - it = std::copy_n(str, static_cast(SIZE), it); - }); + write_padded(INF_SIZE + (sign ? 1 : 0), spec, inf_or_nan_writer{sign, str}); }; // Format NaN and ininity ourselves because sprintf's output is not consistent @@ -2646,13 +2690,7 @@ void basic_writer::write_double(T value, const format_specs &spec) { if (sign) ++n; } - write_padded(n, as, [n, sign, &buffer](auto &&it) mutable { - if (sign) { - *it++ = sign; - --n; - } - it = std::copy_n(buffer.begin(), n, it); - }); + write_padded(n, as, double_writer{n, sign, buffer}); } // A range where begin() returns back_insert_iterator. From 3239c518145bc10a9cf8ffdd42b5a259c71e3045 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 11 Feb 2018 07:05:14 -0800 Subject: [PATCH 03/62] Get rid of generic lambdas --- include/fmt/format.h | 72 ++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 687c1745..62716424 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2308,14 +2308,33 @@ class basic_writer { } } + struct dec_writer { + unsigned_type abs_value; + unsigned num_digits; + + template + void operator()(It &&it) const { + it = internal::format_decimal(it, abs_value, num_digits); + } + }; + void on_dec() { unsigned num_digits = internal::count_digits(abs_value); writer.write_int(num_digits, get_prefix(), spec, - [this, num_digits](auto &&it) { - it = internal::format_decimal(it, abs_value, num_digits); - }); + dec_writer{abs_value, num_digits}); } + struct hex_writer { + int_writer &self; + unsigned num_digits; + + template + void operator()(It &&it) const { + it = internal::format_uint<4>(it, self.abs_value, num_digits, + self.spec.type() != 'x'); + } + }; + void on_hex() { if (spec.flag(HASH_FLAG)) { prefix[prefix_size++] = '0'; @@ -2323,12 +2342,20 @@ class basic_writer { } unsigned num_digits = count_digits<4>(); writer.write_int(num_digits, get_prefix(), spec, - [this, num_digits](auto &&it) { - it = internal::format_uint<4>(it, abs_value, num_digits, - spec.type() != 'x'); - }); + hex_writer{*this, num_digits}); } + template + struct bin_writer { + unsigned_type abs_value; + unsigned num_digits; + + template + void operator()(It &&it) const { + it = internal::format_uint(it, abs_value, num_digits); + } + }; + void on_bin() { if (spec.flag(HASH_FLAG)) { prefix[prefix_size++] = '0'; @@ -2336,9 +2363,7 @@ class basic_writer { } unsigned num_digits = count_digits<1>(); writer.write_int(num_digits, get_prefix(), spec, - [this, num_digits](auto &&it) { - it = internal::format_uint<1>(it, abs_value, num_digits); - }); + bin_writer<1>{abs_value, num_digits}); } void on_oct() { @@ -2350,21 +2375,30 @@ class basic_writer { prefix[prefix_size++] = '0'; } writer.write_int(num_digits, get_prefix(), spec, - [this, num_digits](auto &&it) { - it = internal::format_uint<3>(it, abs_value, num_digits); - }); + bin_writer<3>{abs_value, num_digits}); } + enum { SEP_SIZE = 1 }; + + struct num_writer { + unsigned_type abs_value; + unsigned size; + char_type sep; + + template + void operator()(It &&it) const { + basic_string_view s(&sep, SEP_SIZE); + it = format_decimal(it, abs_value, size, + internal::add_thousands_sep(s)); + } + }; + void on_num() { unsigned num_digits = internal::count_digits(abs_value); char_type sep = internal::thousands_sep(writer.locale_.get()); - enum { SEP_SIZE = 1 }; unsigned size = num_digits + SEP_SIZE * ((num_digits - 1) / 3); - writer.write_int(size, get_prefix(), spec, [this, size, sep](auto &&it) { - basic_string_view s(&sep, SEP_SIZE); - it = format_decimal(it, abs_value, size, - internal::add_thousands_sep(s)); - }); + writer.write_int(size, get_prefix(), spec, + num_writer{abs_value, size, sep}); } void on_error() { From 1849735f127c86deed80d90521b7117d1ebb38da Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 11 Feb 2018 07:25:53 -0800 Subject: [PATCH 04/62] Fallback to c++11 if c++14 not available --- support/cmake/cxx14.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/support/cmake/cxx14.cmake b/support/cmake/cxx14.cmake index c86cf508..d725917a 100644 --- a/support/cmake/cxx14.cmake +++ b/support/cmake/cxx14.cmake @@ -40,6 +40,17 @@ if (FMT_USE_CPP14) check_cxx_compiler_flag(-std=c++1y HAVE_STD_CPP1Y_FLAG) if (HAVE_STD_CPP1Y_FLAG) set(CPP14_FLAG -std=c++1y) + else () + # Fallback on c++11 if c++14 is not available. + check_cxx_compiler_flag(-std=c++11 HAVE_STD_CPP11_FLAG) + if (HAVE_STD_CPP11_FLAG) + set(CPP14_FLAG -std=c++11) + else () + check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP11_FLAG) + if (HAVE_STD_CPP0X_FLAG) + set(CPP14_FLAG -std=c++0x) + endif () + endif () endif () endif () endif () From 0b508fd29d22b2535b9f641a49d886c9b2d85532 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 11 Feb 2018 07:32:22 -0800 Subject: [PATCH 05/62] Fix c++0x detection --- support/cmake/cxx14.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/cmake/cxx14.cmake b/support/cmake/cxx14.cmake index d725917a..eb2c77e9 100644 --- a/support/cmake/cxx14.cmake +++ b/support/cmake/cxx14.cmake @@ -46,7 +46,7 @@ if (FMT_USE_CPP14) if (HAVE_STD_CPP11_FLAG) set(CPP14_FLAG -std=c++11) else () - check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP11_FLAG) + check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP0X_FLAG) if (HAVE_STD_CPP0X_FLAG) set(CPP14_FLAG -std=c++0x) endif () From 522de7b55dc9fc46496e4dac721503f235edef04 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 11 Feb 2018 08:32:02 -0800 Subject: [PATCH 06/62] Replace using with typedef for compatibility with gcc-4.6 --- include/fmt/core.h | 78 +++++++++++++++---------------- include/fmt/format.h | 106 +++++++++++++++++++++---------------------- include/fmt/printf.h | 2 +- test/util-test.cc | 18 ++++---- 4 files changed, 103 insertions(+), 101 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 5da04ed0..1c56cd44 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -168,8 +168,8 @@ class basic_string_view { size_t size_; public: - using char_type = Char; - using iterator = const Char *; + typedef Char char_type; + typedef const Char *iterator; FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(0), size_(0) {} @@ -242,8 +242,8 @@ class basic_string_view { #endif namespace fmt { -using string_view = basic_string_view; -using wstring_view = basic_string_view; +typedef basic_string_view string_view; +typedef basic_string_view wstring_view; template class basic_arg; @@ -285,7 +285,7 @@ class basic_buffer { virtual void grow(std::size_t capacity) = 0; public: - using value_type = T; + typedef T value_type; virtual ~basic_buffer() {} @@ -335,8 +335,8 @@ class basic_buffer { const T &operator[](std::size_t index) const { return ptr_[index]; } }; -using buffer = basic_buffer; -using wbuffer = basic_buffer; +typedef basic_buffer buffer; +typedef basic_buffer wbuffer; // A container-backed buffer. template @@ -443,7 +443,7 @@ struct custom_value { template class value { public: - using char_type = typename Context::char_type; + typedef typename Context::char_type char_type; union { int int_value; @@ -499,7 +499,7 @@ class value { // Get the formatter type through the context to allow different contexts // have different extension points, e.g. `formatter` for `format` and // `printf_formatter` for `printf`. - typename Context::template formatter_type f; + typename Context::template formatter_type::type f; auto &&parse_ctx = ctx.parse_context(); parse_ctx.advance_to(f.parse(parse_ctx)); ctx.advance_to(f.format(*static_cast(arg), ctx)); @@ -531,12 +531,11 @@ FMT_MAKE_VALUE(UINT, unsigned, unsigned) // To minimize the number of types we need to deal with, long is translated // either to int or to long long depending on its size. -using long_type = - std::conditional::type; +typedef std::conditional::type + long_type; FMT_MAKE_VALUE((sizeof(long) == sizeof(int) ? INT : LONG_LONG), long, long_type) -using ulong_type = - std::conditional::type; +typedef std::conditional::type ulong_type; FMT_MAKE_VALUE((sizeof(unsigned long) == sizeof(unsigned) ? UINT : ULONG_LONG), unsigned long, ulong_type) @@ -628,7 +627,7 @@ class basic_arg { friend class basic_format_args; friend class internal::arg_map; - using char_type = typename Context::char_type; + typedef typename Context::char_type char_type; public: class handle { @@ -663,8 +662,8 @@ class basic_parse_context : private ErrorHandler { int next_arg_id_; public: - using char_type = Char; - using iterator = typename basic_string_view::iterator; + typedef Char char_type; + typedef typename basic_string_view::iterator iterator; explicit FMT_CONSTEXPR basic_parse_context( basic_string_view format_str, ErrorHandler eh = ErrorHandler()) @@ -704,8 +703,8 @@ class basic_parse_context : private ErrorHandler { FMT_CONSTEXPR ErrorHandler error_handler() const { return *this; } }; -using parse_context = basic_parse_context; -using wparse_context = basic_parse_context; +typedef basic_parse_context parse_context; +typedef basic_parse_context wparse_context; namespace internal { // A map from argument names to their values for named arguments. @@ -714,7 +713,7 @@ class arg_map { private: FMT_DISALLOW_COPY_AND_ASSIGN(arg_map); - using char_type = typename Context::char_type; + typedef typename Context::char_type char_type; struct entry { basic_string_view name; @@ -748,7 +747,7 @@ class arg_map { template class context_base { public: - using iterator = OutputIt; + typedef OutputIt iterator; private: basic_parse_context parse_context_; @@ -756,8 +755,8 @@ class context_base { basic_format_args args_; protected: - using char_type = Char; - using format_arg = basic_arg; + typedef Char char_type; + typedef basic_arg format_arg; context_base(OutputIt out, basic_string_view format_str, basic_format_args args) @@ -801,7 +800,7 @@ class context_base { // Extracts a reference to the container from back_insert_iterator. template inline Container &get_container(std::back_insert_iterator it) { - using iterator = std::back_insert_iterator; + typedef std::back_insert_iterator iterator; struct accessor: iterator { accessor(iterator it) : iterator(it) {} using iterator::container; @@ -816,11 +815,11 @@ class output_range { OutputIt it_; // Unused yet. - using sentinel = void; + typedef void sentinel; sentinel end() const; public: - using value_type = T; + typedef T value_type; explicit output_range(OutputIt it): it_(it) {} OutputIt begin() const { return it_; } @@ -832,18 +831,19 @@ class basic_context : public internal::context_base, Char> { public: /** The character type for the output. */ - using char_type = Char; + typedef Char char_type; + // using formatter_type = formatter; template - using formatter_type = formatter; + struct formatter_type { typedef formatter type; }; private: internal::arg_map map_; FMT_DISALLOW_COPY_AND_ASSIGN(basic_context); - using base = internal::context_base; - using format_arg = typename base::format_arg; + typedef internal::context_base base; + typedef typename base::format_arg format_arg; using base::get_arg; public: @@ -872,8 +872,8 @@ class basic_context : template using buffer_context_t = basic_context< std::back_insert_iterator>, Char>; -using context = buffer_context_t; -using wcontext = buffer_context_t; +typedef buffer_context_t context; +typedef buffer_context_t wcontext; namespace internal { template @@ -882,7 +882,7 @@ class get_type { static const T& val(); public: - using value_type = decltype(make_value(val())); + typedef decltype(make_value(val())) value_type; static const type value = value_type::type_tag; }; @@ -923,8 +923,8 @@ class arg_store { // Packed is a macro on MinGW so use IS_PACKED instead. static const bool IS_PACKED = NUM_ARGS < internal::MAX_PACKED_ARGS; - using value_type = typename std::conditional< - IS_PACKED, internal::value, basic_arg>::type; + typedef typename std::conditional< + IS_PACKED, internal::value, basic_arg>::type value_type; // If the arguments are not packed, add one more element to mark the end. value_type data_[NUM_ARGS + (IS_PACKED && NUM_ARGS != 0 ? 0 : 1)]; @@ -959,8 +959,8 @@ inline arg_store make_args(const Args & ... args) { template class basic_format_args { public: - using size_type = unsigned; - using format_arg = basic_arg ; + typedef unsigned size_type; + typedef basic_arg format_arg; private: // To reduce compiled code size per formatting function call, types of first @@ -1028,8 +1028,8 @@ class basic_format_args { } }; -using format_args = basic_format_args; -using wformat_args = basic_format_args; +typedef basic_format_args format_args; +typedef basic_format_args wformat_args; namespace internal { template diff --git a/include/fmt/format.h b/include/fmt/format.h index 62716424..2a66c9f6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -575,11 +575,11 @@ FMT_CONSTEXPR const Char *pointer_from(null_terminating_iterator it); template class null_terminating_iterator { public: - using difference_type = std::ptrdiff_t; - using value_type = Char; - using pointer = const Char*; - using reference = const Char&; - using iterator_category = std::random_access_iterator_tag; + typedef std::ptrdiff_t difference_type; + typedef Char value_type; + typedef const Char* pointer; + typedef const Char& reference; + typedef std::random_access_iterator_tag iterator_category; null_terminating_iterator() : ptr_(0), end_(0) {} @@ -667,11 +667,11 @@ class counting_iterator { mutable T blackhole_; public: - using iterator_category = std::output_iterator_tag; - using value_type = T; - using difference_type = std::ptrdiff_t; - using pointer = T*; - using reference = T&; + typedef std::output_iterator_tag iterator_category; + typedef T value_type; + typedef std::ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; explicit counting_iterator(std::size_t &count): count_(count) {} counting_iterator(const counting_iterator &other): count_(other.count_) {} @@ -998,7 +998,7 @@ struct monostate {}; template FMT_CONSTEXPR typename std::result_of::type visit(Visitor &&vis, basic_arg arg) { - using char_type = typename Context::char_type; + typedef typename Context::char_type char_type; switch (arg.type_) { case internal::NONE: return vis(monostate()); @@ -1058,7 +1058,7 @@ class format_spec { }; // template -// using fill_spec = format_spec; +// typedef format_spec fill_spec; template class fill_spec : public format_spec { public: @@ -1323,11 +1323,11 @@ void arg_map::init(const basic_format_args &args) { template class arg_formatter_base { public: - using char_type = typename Range::value_type; - using format_specs = basic_format_specs; + typedef typename Range::value_type char_type; + typedef basic_format_specs format_specs; private: - using writer_type = basic_writer; + typedef basic_writer writer_type; writer_type writer_; format_specs &specs_; @@ -1717,7 +1717,7 @@ template class dynamic_specs_handler : public specs_setter { public: - using char_type = typename ParseContext::char_type; + typedef typename ParseContext::char_type char_type; FMT_CONSTEXPR dynamic_specs_handler( dynamic_format_specs &specs, ParseContext &ctx) @@ -1742,7 +1742,7 @@ class dynamic_specs_handler : } private: - using arg_ref_type = arg_ref; + typedef arg_ref arg_ref_type; template FMT_CONSTEXPR arg_ref_type make_arg_ref(Id arg_id) { @@ -1760,7 +1760,7 @@ class dynamic_specs_handler : template FMT_CONSTEXPR Iterator parse_arg_id(Iterator it, IDHandler &&handler) { - using char_type = typename std::iterator_traits::value_type; + typedef typename std::iterator_traits::value_type char_type; char_type c = *it; if (c == '}' || c == ':') { handler(); @@ -1830,7 +1830,7 @@ struct precision_adapter { // format specifiers. template FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) { - using char_type = typename std::iterator_traits::value_type; + typedef typename std::iterator_traits::value_type char_type; // Parse fill and alignment. if (char_type c = *it) { alignment align = ALIGN_DEFAULT; @@ -1949,7 +1949,7 @@ struct id_adapter { template FMT_CONSTEXPR void parse_format_string(Iterator it, Handler &&handler) { - using char_type = typename std::iterator_traits::value_type; + typedef typename std::iterator_traits::value_type char_type; auto start = it; while (*it) { char_type ch = *it++; @@ -2025,7 +2025,7 @@ class format_string_checker { } private: - using parse_context_type = basic_parse_context; + typedef basic_parse_context parse_context_type; enum { NUM_ARGS = sizeof...(Args) }; FMT_CONSTEXPR void check_arg_id() { @@ -2034,7 +2034,7 @@ class format_string_checker { } // Format specifier parsing function. - using parse_func = const Char *(*)(parse_context_type &); + typedef const Char *(*parse_func)(parse_context_type &); int arg_id_ = -1; parse_context_type context_; @@ -2065,7 +2065,7 @@ struct format_enum : std::integral_constant::value> {}; template