Commit 522de7b5 authored by Victor Zverovich's avatar Victor Zverovich

Replace using with typedef for compatibility with gcc-4.6

parent 0b508fd2
...@@ -168,8 +168,8 @@ class basic_string_view { ...@@ -168,8 +168,8 @@ class basic_string_view {
size_t size_; size_t size_;
public: public:
using char_type = Char; typedef Char char_type;
using iterator = const Char *; typedef const Char *iterator;
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(0), size_(0) {} FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(0), size_(0) {}
...@@ -242,8 +242,8 @@ class basic_string_view { ...@@ -242,8 +242,8 @@ class basic_string_view {
#endif #endif
namespace fmt { namespace fmt {
using string_view = basic_string_view<char>; typedef basic_string_view<char> string_view;
using wstring_view = basic_string_view<wchar_t>; typedef basic_string_view<wchar_t> wstring_view;
template <typename Context> template <typename Context>
class basic_arg; class basic_arg;
...@@ -285,7 +285,7 @@ class basic_buffer { ...@@ -285,7 +285,7 @@ class basic_buffer {
virtual void grow(std::size_t capacity) = 0; virtual void grow(std::size_t capacity) = 0;
public: public:
using value_type = T; typedef T value_type;
virtual ~basic_buffer() {} virtual ~basic_buffer() {}
...@@ -335,8 +335,8 @@ class basic_buffer { ...@@ -335,8 +335,8 @@ class basic_buffer {
const T &operator[](std::size_t index) const { return ptr_[index]; } const T &operator[](std::size_t index) const { return ptr_[index]; }
}; };
using buffer = basic_buffer<char>; typedef basic_buffer<char> buffer;
using wbuffer = basic_buffer<wchar_t>; typedef basic_buffer<wchar_t> wbuffer;
// A container-backed buffer. // A container-backed buffer.
template <typename Container> template <typename Container>
...@@ -443,7 +443,7 @@ struct custom_value { ...@@ -443,7 +443,7 @@ struct custom_value {
template <typename Context> template <typename Context>
class value { class value {
public: public:
using char_type = typename Context::char_type; typedef typename Context::char_type char_type;
union { union {
int int_value; int int_value;
...@@ -499,7 +499,7 @@ class value { ...@@ -499,7 +499,7 @@ class value {
// Get the formatter type through the context to allow different contexts // Get the formatter type through the context to allow different contexts
// have different extension points, e.g. `formatter<T>` for `format` and // have different extension points, e.g. `formatter<T>` for `format` and
// `printf_formatter<T>` for `printf`. // `printf_formatter<T>` for `printf`.
typename Context::template formatter_type<T> f; typename Context::template formatter_type<T>::type f;
auto &&parse_ctx = ctx.parse_context(); auto &&parse_ctx = ctx.parse_context();
parse_ctx.advance_to(f.parse(parse_ctx)); parse_ctx.advance_to(f.parse(parse_ctx));
ctx.advance_to(f.format(*static_cast<const T*>(arg), ctx)); ctx.advance_to(f.format(*static_cast<const T*>(arg), ctx));
...@@ -531,12 +531,11 @@ FMT_MAKE_VALUE(UINT, unsigned, unsigned) ...@@ -531,12 +531,11 @@ FMT_MAKE_VALUE(UINT, unsigned, unsigned)
// To minimize the number of types we need to deal with, long is translated // 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. // either to int or to long long depending on its size.
using long_type = typedef std::conditional<sizeof(long) == sizeof(int), int, long long>::type
std::conditional<sizeof(long) == sizeof(int), int, long long>::type; long_type;
FMT_MAKE_VALUE((sizeof(long) == sizeof(int) ? INT : LONG_LONG), long, long_type) FMT_MAKE_VALUE((sizeof(long) == sizeof(int) ? INT : LONG_LONG), long, long_type)
using ulong_type = typedef std::conditional<sizeof(unsigned long) == sizeof(unsigned),
std::conditional<sizeof(unsigned long) == sizeof(unsigned), unsigned, unsigned long long>::type ulong_type;
unsigned, unsigned long long>::type;
FMT_MAKE_VALUE((sizeof(unsigned long) == sizeof(unsigned) ? UINT : ULONG_LONG), FMT_MAKE_VALUE((sizeof(unsigned long) == sizeof(unsigned) ? UINT : ULONG_LONG),
unsigned long, ulong_type) unsigned long, ulong_type)
...@@ -628,7 +627,7 @@ class basic_arg { ...@@ -628,7 +627,7 @@ class basic_arg {
friend class basic_format_args<Context>; friend class basic_format_args<Context>;
friend class internal::arg_map<Context>; friend class internal::arg_map<Context>;
using char_type = typename Context::char_type; typedef typename Context::char_type char_type;
public: public:
class handle { class handle {
...@@ -663,8 +662,8 @@ class basic_parse_context : private ErrorHandler { ...@@ -663,8 +662,8 @@ class basic_parse_context : private ErrorHandler {
int next_arg_id_; int next_arg_id_;
public: public:
using char_type = Char; typedef Char char_type;
using iterator = typename basic_string_view<Char>::iterator; typedef typename basic_string_view<Char>::iterator iterator;
explicit FMT_CONSTEXPR basic_parse_context( explicit FMT_CONSTEXPR basic_parse_context(
basic_string_view<Char> format_str, ErrorHandler eh = ErrorHandler()) basic_string_view<Char> format_str, ErrorHandler eh = ErrorHandler())
...@@ -704,8 +703,8 @@ class basic_parse_context : private ErrorHandler { ...@@ -704,8 +703,8 @@ class basic_parse_context : private ErrorHandler {
FMT_CONSTEXPR ErrorHandler error_handler() const { return *this; } FMT_CONSTEXPR ErrorHandler error_handler() const { return *this; }
}; };
using parse_context = basic_parse_context<char>; typedef basic_parse_context<char> parse_context;
using wparse_context = basic_parse_context<wchar_t>; typedef basic_parse_context<wchar_t> wparse_context;
namespace internal { namespace internal {
// A map from argument names to their values for named arguments. // A map from argument names to their values for named arguments.
...@@ -714,7 +713,7 @@ class arg_map { ...@@ -714,7 +713,7 @@ class arg_map {
private: private:
FMT_DISALLOW_COPY_AND_ASSIGN(arg_map); FMT_DISALLOW_COPY_AND_ASSIGN(arg_map);
using char_type = typename Context::char_type; typedef typename Context::char_type char_type;
struct entry { struct entry {
basic_string_view<char_type> name; basic_string_view<char_type> name;
...@@ -748,7 +747,7 @@ class arg_map { ...@@ -748,7 +747,7 @@ class arg_map {
template <typename OutputIt, typename Context, typename Char> template <typename OutputIt, typename Context, typename Char>
class context_base { class context_base {
public: public:
using iterator = OutputIt; typedef OutputIt iterator;
private: private:
basic_parse_context<Char> parse_context_; basic_parse_context<Char> parse_context_;
...@@ -756,8 +755,8 @@ class context_base { ...@@ -756,8 +755,8 @@ class context_base {
basic_format_args<Context> args_; basic_format_args<Context> args_;
protected: protected:
using char_type = Char; typedef Char char_type;
using format_arg = basic_arg<Context>; typedef basic_arg<Context> format_arg;
context_base(OutputIt out, basic_string_view<char_type> format_str, context_base(OutputIt out, basic_string_view<char_type> format_str,
basic_format_args<Context> args) basic_format_args<Context> args)
...@@ -801,7 +800,7 @@ class context_base { ...@@ -801,7 +800,7 @@ class context_base {
// Extracts a reference to the container from back_insert_iterator. // Extracts a reference to the container from back_insert_iterator.
template <typename Container> template <typename Container>
inline Container &get_container(std::back_insert_iterator<Container> it) { inline Container &get_container(std::back_insert_iterator<Container> it) {
using iterator = std::back_insert_iterator<Container>; typedef std::back_insert_iterator<Container> iterator;
struct accessor: iterator { struct accessor: iterator {
accessor(iterator it) : iterator(it) {} accessor(iterator it) : iterator(it) {}
using iterator::container; using iterator::container;
...@@ -816,11 +815,11 @@ class output_range { ...@@ -816,11 +815,11 @@ class output_range {
OutputIt it_; OutputIt it_;
// Unused yet. // Unused yet.
using sentinel = void; typedef void sentinel;
sentinel end() const; sentinel end() const;
public: public:
using value_type = T; typedef T value_type;
explicit output_range(OutputIt it): it_(it) {} explicit output_range(OutputIt it): it_(it) {}
OutputIt begin() const { return it_; } OutputIt begin() const { return it_; }
...@@ -832,18 +831,19 @@ class basic_context : ...@@ -832,18 +831,19 @@ class basic_context :
public internal::context_base<OutputIt, basic_context<OutputIt, Char>, Char> { public internal::context_base<OutputIt, basic_context<OutputIt, Char>, Char> {
public: public:
/** The character type for the output. */ /** The character type for the output. */
using char_type = Char; typedef Char char_type;
// using formatter_type = formatter<T, char_type>;
template <typename T> template <typename T>
using formatter_type = formatter<T, char_type>; struct formatter_type { typedef formatter<T, char_type> type; };
private: private:
internal::arg_map<basic_context> map_; internal::arg_map<basic_context> map_;
FMT_DISALLOW_COPY_AND_ASSIGN(basic_context); FMT_DISALLOW_COPY_AND_ASSIGN(basic_context);
using base = internal::context_base<OutputIt, basic_context, Char>; typedef internal::context_base<OutputIt, basic_context, Char> base;
using format_arg = typename base::format_arg; typedef typename base::format_arg format_arg;
using base::get_arg; using base::get_arg;
public: public:
...@@ -872,8 +872,8 @@ class basic_context : ...@@ -872,8 +872,8 @@ class basic_context :
template <typename Char> template <typename Char>
using buffer_context_t = basic_context< using buffer_context_t = basic_context<
std::back_insert_iterator<internal::basic_buffer<Char>>, Char>; std::back_insert_iterator<internal::basic_buffer<Char>>, Char>;
using context = buffer_context_t<char>; typedef buffer_context_t<char> context;
using wcontext = buffer_context_t<wchar_t>; typedef buffer_context_t<wchar_t> wcontext;
namespace internal { namespace internal {
template <typename Context, typename T> template <typename Context, typename T>
...@@ -882,7 +882,7 @@ class get_type { ...@@ -882,7 +882,7 @@ class get_type {
static const T& val(); static const T& val();
public: public:
using value_type = decltype(make_value<Context>(val())); typedef decltype(make_value<Context>(val())) value_type;
static const type value = value_type::type_tag; static const type value = value_type::type_tag;
}; };
...@@ -923,8 +923,8 @@ class arg_store { ...@@ -923,8 +923,8 @@ class arg_store {
// Packed is a macro on MinGW so use IS_PACKED instead. // Packed is a macro on MinGW so use IS_PACKED instead.
static const bool IS_PACKED = NUM_ARGS < internal::MAX_PACKED_ARGS; static const bool IS_PACKED = NUM_ARGS < internal::MAX_PACKED_ARGS;
using value_type = typename std::conditional< typedef typename std::conditional<
IS_PACKED, internal::value<Context>, basic_arg<Context>>::type; IS_PACKED, internal::value<Context>, basic_arg<Context>>::type value_type;
// If the arguments are not packed, add one more element to mark the end. // 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)]; value_type data_[NUM_ARGS + (IS_PACKED && NUM_ARGS != 0 ? 0 : 1)];
...@@ -959,8 +959,8 @@ inline arg_store<context, Args...> make_args(const Args & ... args) { ...@@ -959,8 +959,8 @@ inline arg_store<context, Args...> make_args(const Args & ... args) {
template <typename Context> template <typename Context>
class basic_format_args { class basic_format_args {
public: public:
using size_type = unsigned; typedef unsigned size_type;
using format_arg = basic_arg<Context> ; typedef basic_arg<Context> format_arg;
private: private:
// To reduce compiled code size per formatting function call, types of first // To reduce compiled code size per formatting function call, types of first
...@@ -1028,8 +1028,8 @@ class basic_format_args { ...@@ -1028,8 +1028,8 @@ class basic_format_args {
} }
}; };
using format_args = basic_format_args<context>; typedef basic_format_args<context> format_args;
using wformat_args = basic_format_args<wcontext>; typedef basic_format_args<wcontext> wformat_args;
namespace internal { namespace internal {
template <typename Char> template <typename Char>
......
...@@ -575,11 +575,11 @@ FMT_CONSTEXPR const Char *pointer_from(null_terminating_iterator<Char> it); ...@@ -575,11 +575,11 @@ FMT_CONSTEXPR const Char *pointer_from(null_terminating_iterator<Char> it);
template <typename Char> template <typename Char>
class null_terminating_iterator { class null_terminating_iterator {
public: public:
using difference_type = std::ptrdiff_t; typedef std::ptrdiff_t difference_type;
using value_type = Char; typedef Char value_type;
using pointer = const Char*; typedef const Char* pointer;
using reference = const Char&; typedef const Char& reference;
using iterator_category = std::random_access_iterator_tag; typedef std::random_access_iterator_tag iterator_category;
null_terminating_iterator() : ptr_(0), end_(0) {} null_terminating_iterator() : ptr_(0), end_(0) {}
...@@ -667,11 +667,11 @@ class counting_iterator { ...@@ -667,11 +667,11 @@ class counting_iterator {
mutable T blackhole_; mutable T blackhole_;
public: public:
using iterator_category = std::output_iterator_tag; typedef std::output_iterator_tag iterator_category;
using value_type = T; typedef T value_type;
using difference_type = std::ptrdiff_t; typedef std::ptrdiff_t difference_type;
using pointer = T*; typedef T* pointer;
using reference = T&; typedef T& reference;
explicit counting_iterator(std::size_t &count): count_(count) {} explicit counting_iterator(std::size_t &count): count_(count) {}
counting_iterator(const counting_iterator &other): count_(other.count_) {} counting_iterator(const counting_iterator &other): count_(other.count_) {}
...@@ -998,7 +998,7 @@ struct monostate {}; ...@@ -998,7 +998,7 @@ struct monostate {};
template <typename Visitor, typename Context> template <typename Visitor, typename Context>
FMT_CONSTEXPR typename std::result_of<Visitor(int)>::type FMT_CONSTEXPR typename std::result_of<Visitor(int)>::type
visit(Visitor &&vis, basic_arg<Context> arg) { visit(Visitor &&vis, basic_arg<Context> arg) {
using char_type = typename Context::char_type; typedef typename Context::char_type char_type;
switch (arg.type_) { switch (arg.type_) {
case internal::NONE: case internal::NONE:
return vis(monostate()); return vis(monostate());
...@@ -1058,7 +1058,7 @@ class format_spec { ...@@ -1058,7 +1058,7 @@ class format_spec {
}; };
// template <typename Char> // template <typename Char>
// using fill_spec = format_spec<Char, fill_tag>; // typedef format_spec<Char, fill_tag> fill_spec;
template <typename Char> template <typename Char>
class fill_spec : public format_spec<Char, fill_tag> { class fill_spec : public format_spec<Char, fill_tag> {
public: public:
...@@ -1323,11 +1323,11 @@ void arg_map<Context>::init(const basic_format_args<Context> &args) { ...@@ -1323,11 +1323,11 @@ void arg_map<Context>::init(const basic_format_args<Context> &args) {
template <typename Range> template <typename Range>
class arg_formatter_base { class arg_formatter_base {
public: public:
using char_type = typename Range::value_type; typedef typename Range::value_type char_type;
using format_specs = basic_format_specs<char_type>; typedef basic_format_specs<char_type> format_specs;
private: private:
using writer_type = basic_writer<Range>; typedef basic_writer<Range> writer_type;
writer_type writer_; writer_type writer_;
format_specs &specs_; format_specs &specs_;
...@@ -1717,7 +1717,7 @@ template <typename ParseContext> ...@@ -1717,7 +1717,7 @@ template <typename ParseContext>
class dynamic_specs_handler : class dynamic_specs_handler :
public specs_setter<typename ParseContext::char_type> { public specs_setter<typename ParseContext::char_type> {
public: public:
using char_type = typename ParseContext::char_type; typedef typename ParseContext::char_type char_type;
FMT_CONSTEXPR dynamic_specs_handler( FMT_CONSTEXPR dynamic_specs_handler(
dynamic_format_specs<char_type> &specs, ParseContext &ctx) dynamic_format_specs<char_type> &specs, ParseContext &ctx)
...@@ -1742,7 +1742,7 @@ class dynamic_specs_handler : ...@@ -1742,7 +1742,7 @@ class dynamic_specs_handler :
} }
private: private:
using arg_ref_type = arg_ref<char_type>; typedef arg_ref<char_type> arg_ref_type;
template <typename Id> template <typename Id>
FMT_CONSTEXPR arg_ref_type make_arg_ref(Id arg_id) { FMT_CONSTEXPR arg_ref_type make_arg_ref(Id arg_id) {
...@@ -1760,7 +1760,7 @@ class dynamic_specs_handler : ...@@ -1760,7 +1760,7 @@ class dynamic_specs_handler :
template <typename Iterator, typename IDHandler> template <typename Iterator, typename IDHandler>
FMT_CONSTEXPR Iterator parse_arg_id(Iterator it, IDHandler &&handler) { FMT_CONSTEXPR Iterator parse_arg_id(Iterator it, IDHandler &&handler) {
using char_type = typename std::iterator_traits<Iterator>::value_type; typedef typename std::iterator_traits<Iterator>::value_type char_type;
char_type c = *it; char_type c = *it;
if (c == '}' || c == ':') { if (c == '}' || c == ':') {
handler(); handler();
...@@ -1830,7 +1830,7 @@ struct precision_adapter { ...@@ -1830,7 +1830,7 @@ struct precision_adapter {
// format specifiers. // format specifiers.
template <typename Iterator, typename SpecHandler> template <typename Iterator, typename SpecHandler>
FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) { FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) {
using char_type = typename std::iterator_traits<Iterator>::value_type; typedef typename std::iterator_traits<Iterator>::value_type char_type;
// Parse fill and alignment. // Parse fill and alignment.
if (char_type c = *it) { if (char_type c = *it) {
alignment align = ALIGN_DEFAULT; alignment align = ALIGN_DEFAULT;
...@@ -1949,7 +1949,7 @@ struct id_adapter { ...@@ -1949,7 +1949,7 @@ struct id_adapter {
template <typename Iterator, typename Handler> template <typename Iterator, typename Handler>
FMT_CONSTEXPR void parse_format_string(Iterator it, Handler &&handler) { FMT_CONSTEXPR void parse_format_string(Iterator it, Handler &&handler) {
using char_type = typename std::iterator_traits<Iterator>::value_type; typedef typename std::iterator_traits<Iterator>::value_type char_type;
auto start = it; auto start = it;
while (*it) { while (*it) {
char_type ch = *it++; char_type ch = *it++;
...@@ -2025,7 +2025,7 @@ class format_string_checker { ...@@ -2025,7 +2025,7 @@ class format_string_checker {
} }
private: private:
using parse_context_type = basic_parse_context<Char, ErrorHandler>; typedef basic_parse_context<Char, ErrorHandler> parse_context_type;
enum { NUM_ARGS = sizeof...(Args) }; enum { NUM_ARGS = sizeof...(Args) };
FMT_CONSTEXPR void check_arg_id() { FMT_CONSTEXPR void check_arg_id() {
...@@ -2034,7 +2034,7 @@ class format_string_checker { ...@@ -2034,7 +2034,7 @@ class format_string_checker {
} }
// Format specifier parsing function. // Format specifier parsing function.
using parse_func = const Char *(*)(parse_context_type &); typedef const Char *(*parse_func)(parse_context_type &);
int arg_id_ = -1; int arg_id_ = -1;
parse_context_type context_; parse_context_type context_;
...@@ -2065,7 +2065,7 @@ struct format_enum : std::integral_constant<bool, std::is_enum<T>::value> {}; ...@@ -2065,7 +2065,7 @@ struct format_enum : std::integral_constant<bool, std::is_enum<T>::value> {};
template <template <typename> class Handler, typename Spec, typename Context> template <template <typename> class Handler, typename Spec, typename Context>
void handle_dynamic_spec( void handle_dynamic_spec(
Spec &value, arg_ref<typename Context::char_type> ref, Context &ctx) { Spec &value, arg_ref<typename Context::char_type> ref, Context &ctx) {
using char_type = typename Context::char_type; typedef typename Context::char_type char_type;
switch (ref.kind) { switch (ref.kind) {
case arg_ref<char_type>::NONE: case arg_ref<char_type>::NONE:
break; break;
...@@ -2085,16 +2085,16 @@ void handle_dynamic_spec( ...@@ -2085,16 +2085,16 @@ void handle_dynamic_spec(
template <typename Range> template <typename Range>
class arg_formatter: public internal::arg_formatter_base<Range> { class arg_formatter: public internal::arg_formatter_base<Range> {
private: private:
using char_type = typename Range::value_type; typedef typename Range::value_type char_type;
using iterator = decltype(std::declval<Range>().begin()); typedef decltype(std::declval<Range>().begin()) iterator;
using base = internal::arg_formatter_base<Range>; typedef internal::arg_formatter_base<Range> base;
using context_type = basic_context<iterator, char_type>; typedef basic_context<iterator, char_type> context_type;
context_type &ctx_; context_type &ctx_;
public: public:
using range = Range; typedef Range range;
using format_specs = typename base::format_specs; typedef typename base::format_specs format_specs;
/** /**
\rst \rst
...@@ -2183,9 +2183,9 @@ FMT_API void format_system_error(fmt::internal::buffer &out, int error_code, ...@@ -2183,9 +2183,9 @@ FMT_API void format_system_error(fmt::internal::buffer &out, int error_code,
template <typename Range> template <typename Range>
class basic_writer { class basic_writer {
public: public:
using char_type = typename Range::value_type; typedef typename Range::value_type char_type;
using iterator = decltype(std::declval<Range>().begin()); typedef decltype(std::declval<Range>().begin()) iterator;
using format_specs = basic_format_specs<char_type>; typedef basic_format_specs<char_type> format_specs;
private: private:
// Output iterator. // Output iterator.
...@@ -2196,11 +2196,11 @@ class basic_writer { ...@@ -2196,11 +2196,11 @@ class basic_writer {
FMT_DISALLOW_COPY_AND_ASSIGN(basic_writer); FMT_DISALLOW_COPY_AND_ASSIGN(basic_writer);
#if FMT_SECURE_SCL #if FMT_SECURE_SCL
using pointer_type = stdext::checked_array_iterator<char_type*>; typedef stdext::checked_array_iterator<char_type*> pointer_type;
// Returns pointer value. // Returns pointer value.
static char_type *get(pointer_type p) { return p.base(); } static char_type *get(pointer_type p) { return p.base(); }
#else #else
using pointer_type = char_type*; typedef char_type* pointer_type;
static char_type *get(char_type *p) { return p; } static char_type *get(char_type *p) { return p; }
#endif #endif
...@@ -2260,7 +2260,7 @@ class basic_writer { ...@@ -2260,7 +2260,7 @@ class basic_writer {
// Writes a decimal integer. // Writes a decimal integer.
template <typename Int> template <typename Int>
void write_decimal(Int value) { void write_decimal(Int value) {
using main_type = typename internal::int_traits<Int>::main_type; typedef typename internal::int_traits<Int>::main_type main_type;
main_type abs_value = static_cast<main_type>(value); main_type abs_value = static_cast<main_type>(value);
bool is_negative = internal::is_negative(value); bool is_negative = internal::is_negative(value);
if (is_negative) if (is_negative)
...@@ -2275,7 +2275,7 @@ class basic_writer { ...@@ -2275,7 +2275,7 @@ class basic_writer {
// The handle_int_type_spec handler that writes an integer. // The handle_int_type_spec handler that writes an integer.
template <typename Int, typename Spec> template <typename Int, typename Spec>
struct int_writer { struct int_writer {
using unsigned_type = typename internal::int_traits<Int>::main_type; typedef typename internal::int_traits<Int>::main_type unsigned_type;
basic_writer<Range> &writer; basic_writer<Range> &writer;
const Spec &spec; const Spec &spec;
...@@ -2731,16 +2731,16 @@ void basic_writer<Range>::write_double(T value, const format_specs &spec) { ...@@ -2731,16 +2731,16 @@ void basic_writer<Range>::write_double(T value, const format_specs &spec) {
template <typename Container> template <typename Container>
class back_insert_range: class back_insert_range:
public output_range<std::back_insert_iterator<Container>> { public output_range<std::back_insert_iterator<Container>> {
using base = output_range<std::back_insert_iterator<Container>>; typedef output_range<std::back_insert_iterator<Container>> base;
public: public:
using value_type = typename Container::value_type; typedef typename Container::value_type value_type;
using base::base; using base::base;
back_insert_range(Container &c): base(std::back_inserter(c)) {} back_insert_range(Container &c): base(std::back_inserter(c)) {}
}; };
using writer = basic_writer<back_insert_range<internal::buffer>>; typedef basic_writer<back_insert_range<internal::buffer>> writer;
using wwriter = basic_writer<back_insert_range<internal::wbuffer>>; typedef basic_writer<back_insert_range<internal::wbuffer>> wwriter;
// Reports a system error without throwing an exception. // Reports a system error without throwing an exception.
// Can be used to report errors from destructors. // Can be used to report errors from destructors.
...@@ -2878,7 +2878,7 @@ class FormatInt { ...@@ -2878,7 +2878,7 @@ class FormatInt {
// write a terminating null character. // write a terminating null character.
template <typename T> template <typename T>
inline void format_decimal(char *&buffer, T value) { inline void format_decimal(char *&buffer, T value) {
using main_type = typename internal::int_traits<T>::main_type; typedef typename internal::int_traits<T>::main_type main_type;
main_type abs_value = static_cast<main_type>(value); main_type abs_value = static_cast<main_type>(value);
if (internal::is_negative(value)) { if (internal::is_negative(value)) {
*buffer++ = '-'; *buffer++ = '-';
...@@ -2911,7 +2911,7 @@ struct formatter< ...@@ -2911,7 +2911,7 @@ struct formatter<
template <typename ParseContext> template <typename ParseContext>
FMT_CONSTEXPR typename ParseContext::iterator parse(ParseContext &ctx) { FMT_CONSTEXPR typename ParseContext::iterator parse(ParseContext &ctx) {
auto it = internal::null_terminating_iterator<Char>(ctx); auto it = internal::null_terminating_iterator<Char>(ctx);
using handler_type = internal::dynamic_specs_handler<ParseContext>; typedef internal::dynamic_specs_handler<ParseContext> handler_type;
auto type = internal::get_type<buffer_context_t<Char>, T>::value; auto type = internal::get_type<buffer_context_t<Char>, T>::value;
internal::specs_checker<handler_type> internal::specs_checker<handler_type>
handler(handler_type(specs_, ctx), type); handler(handler_type(specs_, ctx), type);
...@@ -2964,8 +2964,8 @@ struct formatter< ...@@ -2964,8 +2964,8 @@ struct formatter<
specs_.width_, specs_.width_ref, ctx); specs_.width_, specs_.width_ref, ctx);
internal::handle_dynamic_spec<internal::precision_checker>( internal::handle_dynamic_spec<internal::precision_checker>(
specs_.precision_, specs_.precision_ref, ctx); specs_.precision_, specs_.precision_ref, ctx);
using range = output_range< typedef output_range<typename FormatContext::iterator,
typename FormatContext::iterator, typename FormatContext::char_type>; typename FormatContext::char_type> range;
visit(arg_formatter<range>(ctx, specs_), visit(arg_formatter<range>(ctx, specs_),
internal::make_arg<FormatContext>(val)); internal::make_arg<FormatContext>(val));
return ctx.begin(); return ctx.begin();
...@@ -2988,7 +2988,7 @@ struct formatter<T, Char, ...@@ -2988,7 +2988,7 @@ struct formatter<T, Char,
// A formatter for types known only at run time such as variant alternatives. // A formatter for types known only at run time such as variant alternatives.
// //
// Usage: // Usage:
// using variant = std::variant<int, std::string>; // typedef std::variant<int, std::string> variant;
// template <> // template <>
// struct formatter<variant>: dynamic_formatter<> { // struct formatter<variant>: dynamic_formatter<> {
// void format(buffer &buf, const variant &v, context &ctx) { // void format(buffer &buf, const variant &v, context &ctx) {
...@@ -3033,8 +3033,8 @@ struct dynamic_formatter { ...@@ -3033,8 +3033,8 @@ struct dynamic_formatter {
} }
if (specs_.precision_ != -1) if (specs_.precision_ != -1)
checker.end_precision(); checker.end_precision();
using range = output_range< typedef output_range<typename FormatContext::iterator,
typename FormatContext::iterator, typename FormatContext::char_type>; typename FormatContext::char_type> range;
visit(arg_formatter<range>(ctx, specs_), visit(arg_formatter<range>(ctx, specs_),
internal::make_arg<FormatContext>(val)); internal::make_arg<FormatContext>(val));
return ctx.begin(); return ctx.begin();
...@@ -3067,8 +3067,8 @@ template <typename ArgFormatter, typename Char, typename Context> ...@@ -3067,8 +3067,8 @@ template <typename ArgFormatter, typename Char, typename Context>
typename Context::iterator do_vformat_to(typename ArgFormatter::range out, typename Context::iterator do_vformat_to(typename ArgFormatter::range out,
basic_string_view<Char> format_str, basic_string_view<Char> format_str,
basic_format_args<Context> args) { basic_format_args<Context> args) {
using iterator = internal::null_terminating_iterator<Char>; typedef internal::null_terminating_iterator<Char> iterator;
using range = typename ArgFormatter::range; typedef typename ArgFormatter::range range;
struct handler : internal::error_handler { struct handler : internal::error_handler {
handler(range r, basic_string_view<Char> str, handler(range r, basic_string_view<Char> str,
...@@ -3171,7 +3171,7 @@ struct formatter<arg_join<It, Char>, Char>: ...@@ -3171,7 +3171,7 @@ struct formatter<arg_join<It, Char>, Char>:
formatter<typename std::iterator_traits<It>::value_type, Char> { formatter<typename std::iterator_traits<It>::value_type, Char> {
template <typename FormatContext> template <typename FormatContext>
auto format(const arg_join<It, Char> &value, FormatContext &ctx) { auto format(const arg_join<It, Char> &value, FormatContext &ctx) {
using base = formatter<typename std::iterator_traits<It>::value_type, Char>; typedef formatter<typename std::iterator_traits<It>::value_type, Char> base;
auto it = value.begin; auto it = value.begin;
auto out = ctx.begin(); auto out = ctx.begin();
if (it != value.end) { if (it != value.end) {
...@@ -3244,13 +3244,13 @@ std::basic_string<Char> to_string(const basic_memory_buffer<Char> &buffer) { ...@@ -3244,13 +3244,13 @@ std::basic_string<Char> to_string(const basic_memory_buffer<Char> &buffer) {
inline void vformat_to(internal::buffer &buf, string_view format_str, inline void vformat_to(internal::buffer &buf, string_view format_str,
format_args args) { format_args args) {
using range = back_insert_range<internal::buffer>; typedef back_insert_range<internal::buffer> range;
do_vformat_to<arg_formatter<range>>(buf, format_str, args); do_vformat_to<arg_formatter<range>>(buf, format_str, args);
} }
inline void vformat_to(internal::wbuffer &buf, wstring_view format_str, inline void vformat_to(internal::wbuffer &buf, wstring_view format_str,
wformat_args args) { wformat_args args) {
using range = back_insert_range<internal::wbuffer>; typedef back_insert_range<internal::wbuffer> range;
do_vformat_to<arg_formatter<range>>(buf, format_str, args); do_vformat_to<arg_formatter<range>>(buf, format_str, args);
} }
...@@ -3275,7 +3275,7 @@ using format_args_t = basic_format_args<context_t<OutputIt, Char>>; ...@@ -3275,7 +3275,7 @@ using format_args_t = basic_format_args<context_t<OutputIt, Char>>;
template <typename OutputIt, typename... Args> template <typename OutputIt, typename... Args>
inline OutputIt vformat_to(OutputIt out, string_view format_str, inline OutputIt vformat_to(OutputIt out, string_view format_str,
format_args_t<OutputIt> args) { format_args_t<OutputIt> args) {
using range = output_range<OutputIt, char>; typedef output_range<OutputIt, char> range;
return do_vformat_to<arg_formatter<range>>(range(out), format_str, args); return do_vformat_to<arg_formatter<range>>(range(out), format_str, args);
} }
......
...@@ -309,7 +309,7 @@ class basic_printf_context : ...@@ -309,7 +309,7 @@ class basic_printf_context :
using char_type = Char; using char_type = Char;
template <typename T> template <typename T>
using formatter_type = printf_formatter<T>; struct formatter_type { typedef printf_formatter<T> type; };
private: private:
using base = internal::context_base<OutputIt, basic_printf_context, Char>; using base = internal::context_base<OutputIt, basic_printf_context, Char>;
......
...@@ -440,15 +440,17 @@ struct custom_context { ...@@ -440,15 +440,17 @@ struct custom_context {
template <typename T> template <typename T>
struct formatter_type { struct formatter_type {
template <typename ParseContext> struct type {
auto parse(ParseContext &ctx) -> decltype(ctx.begin()) { template <typename ParseContext>
return ctx.begin(); auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
} return ctx.begin();
}
const char *format(const T &, custom_context& ctx) {
ctx.called = true; const char *format(const T &, custom_context& ctx) {
return 0; ctx.called = true;
} return 0;
}
};
}; };
bool called; bool called;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment