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> template <typename Char>
using buffer_context_t = basic_context< struct buffer_context {
std::back_insert_iterator<internal::basic_buffer<Char>>, Char>; typedef basic_context<
typedef buffer_context_t<char> context; std::back_insert_iterator<internal::basic_buffer<Char>>, Char> type;
typedef buffer_context_t<wchar_t> wcontext; };
typedef buffer_context<char>::type context;
typedef buffer_context<wchar_t>::type wcontext;
namespace internal { namespace internal {
template <typename Context, typename T> template <typename Context, typename T>

View File

@@ -2919,8 +2919,8 @@ inline void format_decimal(char *&buffer, T value) {
template <typename T, typename Char> template <typename T, typename Char>
struct formatter< struct formatter<
T, Char, T, Char,
typename std::enable_if< typename std::enable_if<internal::format_type<
internal::format_type<buffer_context_t<Char>, T>::value>::type> { typename buffer_context<Char>::type, T>::value>::type> {
// Parses format specifiers stopping either at the end of the range or at the // Parses format specifiers stopping either at the end of the range or at the
// terminating '}'. // terminating '}'.
@@ -2928,7 +2928,8 @@ struct formatter<
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);
typedef internal::dynamic_specs_handler<ParseContext> handler_type; 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> internal::specs_checker<handler_type>
handler(handler_type(specs_, ctx), type); handler(handler_type(specs_, ctx), type);
it = parse_format_specs(it, handler); 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> 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> 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> 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) { typename format_args_t<OutputIt>::type args) {
typedef output_range<OutputIt, char> range; 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);
} }
@@ -3298,7 +3303,8 @@ inline OutputIt vformat_to(OutputIt out, string_view format_str,
template <typename OutputIt, typename... Args> template <typename OutputIt, typename... Args>
inline OutputIt format_to(OutputIt out, string_view format_str, inline OutputIt format_to(OutputIt out, string_view format_str,
const Args & ... args) { 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> 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<<. // Formats an object of type T that has an overloaded ostream operator<<.
template <typename T, typename Char> template <typename T, typename Char>
struct formatter<T, Char, struct formatter<T, Char,
typename std::enable_if< typename std::enable_if<!internal::format_type<
!internal::format_type<buffer_context_t<Char>, T>::value>::type> typename buffer_context<Char>::type, T>::value>::type>
: formatter<basic_string_view<Char>, Char> { : formatter<basic_string_view<Char>, Char> {
template <typename Context> template <typename Context>

View File

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

View File

@@ -17,9 +17,9 @@ using fmt::printf_arg_formatter;
class CustomArgFormatter : class CustomArgFormatter :
public fmt::arg_formatter<fmt::back_insert_range<fmt::internal::buffer>> { public fmt::arg_formatter<fmt::back_insert_range<fmt::internal::buffer>> {
public: public:
using range = fmt::back_insert_range<fmt::internal::buffer>; typedef fmt::back_insert_range<fmt::internal::buffer> range;
using iterator = decltype(std::declval<range>().begin()); typedef decltype(std::declval<range>().begin()) iterator;
using base = fmt::arg_formatter<range>; typedef fmt::arg_formatter<range> base;
CustomArgFormatter(fmt::basic_context<iterator, char> &ctx, CustomArgFormatter(fmt::basic_context<iterator, char> &ctx,
fmt::format_specs &s) fmt::format_specs &s)

View File

@@ -89,7 +89,7 @@ void std_format(long double value, std::wstring &result) {
template <typename Char, typename T> template <typename Char, typename T>
::testing::AssertionResult check_write(const T &value, const char *type) { ::testing::AssertionResult check_write(const T &value, const char *type) {
fmt::basic_memory_buffer<Char> buffer; fmt::basic_memory_buffer<Char> buffer;
using range = fmt::back_insert_range<fmt::internal::basic_buffer<Char>>; typedef fmt::back_insert_range<fmt::internal::basic_buffer<Char>> range;
fmt::basic_writer<range> writer(buffer); fmt::basic_writer<range> writer(buffer);
writer.write(value); writer.write(value);
std::basic_string<Char> actual = to_string(buffer); std::basic_string<Char> actual = to_string(buffer);
@@ -1516,7 +1516,7 @@ TEST(FormatTest, FixedEnum) {
} }
#endif #endif
using buffer_range = fmt::back_insert_range<fmt::internal::buffer>; typedef fmt::back_insert_range<fmt::internal::buffer> buffer_range;
class mock_arg_formatter : class mock_arg_formatter :
public fmt::internal::arg_formatter_base<buffer_range> { public fmt::internal::arg_formatter_base<buffer_range> {
@@ -1524,8 +1524,8 @@ class mock_arg_formatter :
MOCK_METHOD1(call, void (int value)); MOCK_METHOD1(call, void (int value));
public: public:
using base = fmt::internal::arg_formatter_base<buffer_range>; typedef fmt::internal::arg_formatter_base<buffer_range> base;
using range = buffer_range; typedef buffer_range range;
mock_arg_formatter(fmt::context &ctx, fmt::format_specs &s) mock_arg_formatter(fmt::context &ctx, fmt::format_specs &s)
: base(fmt::internal::get_container(ctx.begin()), s) { : base(fmt::internal::get_container(ctx.begin()), s) {
@@ -1719,7 +1719,7 @@ FMT_CONSTEXPR test_format_specs_handler parse_test_specs(const char *s) {
} }
TEST(FormatTest, ConstexprParseFormatSpecs) { TEST(FormatTest, ConstexprParseFormatSpecs) {
using handler = test_format_specs_handler; typedef test_format_specs_handler handler;
static_assert(parse_test_specs("<").align == fmt::ALIGN_LEFT, ""); static_assert(parse_test_specs("<").align == fmt::ALIGN_LEFT, "");
static_assert(parse_test_specs("*^").fill == '*', ""); static_assert(parse_test_specs("*^").fill == '*', "");
static_assert(parse_test_specs("+").res == handler::PLUS, ""); static_assert(parse_test_specs("+").res == handler::PLUS, "");
@@ -1736,7 +1736,7 @@ TEST(FormatTest, ConstexprParseFormatSpecs) {
} }
struct test_context { struct test_context {
using char_type = char; typedef char char_type;
FMT_CONSTEXPR fmt::basic_arg<test_context> next_arg() { FMT_CONSTEXPR fmt::basic_arg<test_context> next_arg() {
return fmt::internal::make_arg<test_context>(11); return fmt::internal::make_arg<test_context>(11);
@@ -1817,7 +1817,7 @@ FMT_CONSTEXPR test_format_specs_handler check_specs(const char *s) {
} }
TEST(FormatTest, ConstexprSpecsChecker) { TEST(FormatTest, ConstexprSpecsChecker) {
using handler = test_format_specs_handler; typedef test_format_specs_handler handler;
static_assert(check_specs("<").align == fmt::ALIGN_LEFT, ""); static_assert(check_specs("<").align == fmt::ALIGN_LEFT, "");
static_assert(check_specs("*^").fill == '*', ""); static_assert(check_specs("*^").fill == '*', "");
static_assert(check_specs("+").res == handler::PLUS, ""); static_assert(check_specs("+").res == handler::PLUS, "");

View File

@@ -58,7 +58,7 @@ TEST(OStreamTest, Enum) {
EXPECT_EQ("0", fmt::format("{}", A)); EXPECT_EQ("0", fmt::format("{}", A));
} }
using range = fmt::back_insert_range<fmt::internal::buffer>; typedef fmt::back_insert_range<fmt::internal::buffer> range;
struct test_arg_formatter: fmt::arg_formatter<range> { struct test_arg_formatter: fmt::arg_formatter<range> {
test_arg_formatter(fmt::context &ctx, fmt::format_specs &s) test_arg_formatter(fmt::context &ctx, fmt::format_specs &s)

View File

@@ -81,7 +81,7 @@ struct formatter<Test, Char> {
return ctx.begin(); return ctx.begin();
} }
using iterator = std::back_insert_iterator<basic_buffer<Char>>; typedef std::back_insert_iterator<basic_buffer<Char>> iterator;
auto format(Test, basic_context<iterator, char> &ctx) auto format(Test, basic_context<iterator, char> &ctx)
-> decltype(ctx.begin()) { -> decltype(ctx.begin()) {
@@ -436,7 +436,7 @@ TEST(UtilTest, FormatArgs) {
} }
struct custom_context { struct custom_context {
using char_type = char; typedef char char_type;
template <typename T> template <typename T>
struct formatter_type { struct formatter_type {
@@ -525,7 +525,7 @@ VISIT_TYPE(float, double);
#define CHECK_ARG_(Char, expected, value) { \ #define CHECK_ARG_(Char, expected, value) { \
testing::StrictMock<MockVisitor<decltype(expected)>> visitor; \ testing::StrictMock<MockVisitor<decltype(expected)>> visitor; \
EXPECT_CALL(visitor, visit(expected)); \ EXPECT_CALL(visitor, visit(expected)); \
using iterator = std::back_insert_iterator<basic_buffer<Char>>; \ typedef std::back_insert_iterator<basic_buffer<Char>> iterator; \
fmt::visit(visitor, make_arg<fmt::basic_context<iterator, Char>>(value)); \ fmt::visit(visitor, make_arg<fmt::basic_context<iterator, Char>>(value)); \
} }
@@ -599,8 +599,8 @@ TEST(UtilTest, PointerArg) {
TEST(UtilTest, CustomArg) { TEST(UtilTest, CustomArg) {
::Test test; ::Test test;
using handle = typename fmt::basic_arg<fmt::context>::handle; typedef typename fmt::basic_arg<fmt::context>::handle handle;
using visitor = MockVisitor<handle>; typedef MockVisitor<handle> visitor;
testing::StrictMock<visitor> v; testing::StrictMock<visitor> v;
EXPECT_CALL(v, visit(_)).WillOnce(testing::Invoke([&](handle h) { EXPECT_CALL(v, visit(_)).WillOnce(testing::Invoke([&](handle h) {
fmt::memory_buffer buffer; fmt::memory_buffer buffer;