Replace using with typedef for compatibility with gcc-4.6

This commit is contained in:
Victor Zverovich
2018-02-11 09:23:47 -08:00
parent 9710c058aa
commit affb35cfb9
8 changed files with 63 additions and 49 deletions

View File

@@ -854,10 +854,12 @@ class basic_context :
};
template <typename Char>
using buffer_context_t = basic_context<
std::back_insert_iterator<internal::basic_buffer<Char>>, Char>;
typedef buffer_context_t<char> context;
typedef buffer_context_t<wchar_t> wcontext;
struct buffer_context {
typedef basic_context<
std::back_insert_iterator<internal::basic_buffer<Char>>, Char> type;
};
typedef buffer_context<char>::type context;
typedef buffer_context<wchar_t>::type wcontext;
namespace internal {
template <typename Context, typename T>

View File

@@ -2919,8 +2919,8 @@ inline void format_decimal(char *&buffer, T value) {
template <typename T, typename Char>
struct formatter<
T, Char,
typename std::enable_if<
internal::format_type<buffer_context_t<Char>, T>::value>::type> {
typename std::enable_if<internal::format_type<
typename buffer_context<Char>::type, T>::value>::type> {
// Parses format specifiers stopping either at the end of the range or at the
// terminating '}'.
@@ -2928,7 +2928,8 @@ struct formatter<
FMT_CONSTEXPR typename ParseContext::iterator parse(ParseContext &ctx) {
auto it = internal::null_terminating_iterator<Char>(ctx);
typedef internal::dynamic_specs_handler<ParseContext> handler_type;
auto type = internal::get_type<buffer_context_t<Char>, T>::value;
auto type = internal::get_type<
typename buffer_context<Char>::type, T>::value;
internal::specs_checker<handler_type>
handler(handler_type(specs_, ctx), type);
it = parse_format_specs(it, handler);
@@ -3283,14 +3284,18 @@ inline void format_to(wmemory_buffer &buf, wstring_view format_str,
}
template <typename OutputIt, typename Char = char>
using context_t = basic_context<OutputIt, Char>;
//using context_t = basic_context<OutputIt, Char>;
struct context_t { typedef basic_context<OutputIt, Char> type; };
template <typename OutputIt, typename Char = char>
using format_args_t = basic_format_args<context_t<OutputIt, Char>>;
//using format_args_t = basic_format_args<context_t<OutputIt, Char>>;
struct format_args_t {
typedef basic_format_args<typename context_t<OutputIt, Char>::type> type;
};
template <typename OutputIt, typename... Args>
inline OutputIt vformat_to(OutputIt out, string_view format_str,
format_args_t<OutputIt> args) {
typename format_args_t<OutputIt>::type args) {
typedef output_range<OutputIt, char> range;
return do_vformat_to<arg_formatter<range>>(range(out), format_str, args);
}
@@ -3298,7 +3303,8 @@ inline OutputIt vformat_to(OutputIt out, string_view format_str,
template <typename OutputIt, typename... Args>
inline OutputIt format_to(OutputIt out, string_view format_str,
const Args & ... args) {
return vformat_to(out, format_str, *make_args<context_t<OutputIt>>(args...));
return vformat_to(out, format_str,
*make_args<typename context_t<OutputIt>::type>(args...));
}
template <typename Container, typename... Args>

View File

@@ -104,8 +104,8 @@ struct format_enum<T,
// Formats an object of type T that has an overloaded ostream operator<<.
template <typename T, typename Char>
struct formatter<T, Char,
typename std::enable_if<
!internal::format_type<buffer_context_t<Char>, T>::value>::type>
typename std::enable_if<!internal::format_type<
typename buffer_context<Char>::type, T>::value>::type>
: formatter<basic_string_view<Char>, Char> {
template <typename Context>

View File

@@ -73,7 +73,7 @@ struct make_unsigned_or_bool : std::make_unsigned<T> {};
template <>
struct make_unsigned_or_bool<bool> {
using type = bool;
typedef bool type;
};
template <typename T, typename Context>
@@ -215,10 +215,10 @@ class basic_printf_context;
template <typename Range>
class printf_arg_formatter : public internal::arg_formatter_base<Range> {
private:
using char_type = typename Range::value_type;
using iterator = decltype(std::declval<Range>().begin());
using base = internal::arg_formatter_base<Range>;
using context_type = basic_printf_context<iterator, char_type>;
typedef typename Range::value_type char_type;
typedef decltype(std::declval<Range>().begin()) iterator;
typedef internal::arg_formatter_base<Range> base;
typedef basic_printf_context<iterator, char_type> context_type;
context_type &context_;
@@ -228,7 +228,7 @@ class printf_arg_formatter : public internal::arg_formatter_base<Range> {
}
public:
using format_specs = typename base::format_specs;
typedef typename base::format_specs format_specs;
/**
\rst
@@ -306,16 +306,16 @@ class basic_printf_context :
OutputIt, basic_printf_context<OutputIt, Char, ArgFormatter>, Char> {
public:
/** The character type for the output. */
using char_type = Char;
typedef Char char_type;
template <typename T>
struct formatter_type { typedef printf_formatter<T> type; };
private:
using base = internal::context_base<OutputIt, basic_printf_context, Char>;
using format_arg = typename base::format_arg;
using format_specs = basic_format_specs<char_type>;
using iterator = internal::null_terminating_iterator<char_type>;
typedef internal::context_base<OutputIt, basic_printf_context, Char> base;
typedef typename base::format_arg format_arg;
typedef basic_format_specs<char_type> format_specs;
typedef internal::null_terminating_iterator<char_type> iterator;
void parse_flags(format_specs &spec, iterator &it);
@@ -534,10 +534,13 @@ void printf(internal::basic_buffer<Char> &buf, basic_string_view<Char> format,
}
template <typename Buffer>
using printf_context = basic_printf_context<
std::back_insert_iterator<Buffer>, typename Buffer::value_type>;
struct printf_context {
typedef basic_printf_context<
std::back_insert_iterator<Buffer>, typename Buffer::value_type> type;
};
using printf_args = basic_format_args<printf_context<internal::buffer>>;
typedef basic_format_args<
typename printf_context<internal::buffer>::type> printf_args;
inline std::string vsprintf(string_view format, printf_args args) {
memory_buffer buffer;
@@ -557,12 +560,12 @@ inline std::string vsprintf(string_view format, printf_args args) {
template <typename... Args>
inline std::string sprintf(string_view format_str, const Args & ... args) {
return vsprintf(format_str,
make_args<printf_context<internal::buffer>>(args...));
make_args<typename printf_context<internal::buffer>::type>(args...));
}
inline std::wstring vsprintf(
wstring_view format,
basic_format_args<printf_context<internal::wbuffer>> args) {
basic_format_args<typename printf_context<internal::wbuffer>::type> args) {
wmemory_buffer buffer;
printf(buffer, format, args);
return to_string(buffer);
@@ -570,7 +573,8 @@ inline std::wstring vsprintf(
template <typename... Args>
inline std::wstring sprintf(wstring_view format_str, const Args & ... args) {
auto vargs = make_args<printf_context<internal::wbuffer>>(args...);
auto vargs = make_args<
typename printf_context<internal::wbuffer>::type>(args...);
return vsprintf(format_str, vargs);
}
@@ -593,7 +597,8 @@ inline int vfprintf(std::FILE *f, string_view format, printf_args args) {
*/
template <typename... Args>
inline int fprintf(std::FILE *f, string_view format_str, const Args & ... args) {
auto vargs = make_args<printf_context<internal::buffer>>(args...);
auto vargs = make_args<
typename printf_context<internal::buffer>::type>(args...);
return vfprintf(f, format_str, vargs);
}
@@ -613,7 +618,7 @@ inline int vprintf(string_view format, printf_args args) {
template <typename... Args>
inline int printf(string_view format_str, const Args & ... args) {
return vprintf(format_str,
make_args<printf_context<internal::buffer>>(args...));
make_args<typename printf_context<internal::buffer>::type>(args...));
}
inline int vfprintf(std::ostream &os, string_view format_str,
@@ -636,7 +641,8 @@ inline int vfprintf(std::ostream &os, string_view format_str,
template <typename... Args>
inline int fprintf(std::ostream &os, string_view format_str,
const Args & ... args) {
auto vargs = make_args<printf_context<internal::buffer>>(args...);
auto vargs = make_args<
typename printf_context<internal::buffer>::type>(args...);
return vfprintf(os, format_str, vargs);
}
} // namespace fmt