From 522de7b55dc9fc46496e4dac721503f235edef04 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 11 Feb 2018 08:32:02 -0800 Subject: [PATCH] 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