mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 03:17:53 +00:00
Replace using with typedef for compatibility with gcc-4.6
This commit is contained in:
parent
9710c058aa
commit
affb35cfb9
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -17,9 +17,9 @@ using fmt::printf_arg_formatter;
|
||||
class CustomArgFormatter :
|
||||
public fmt::arg_formatter<fmt::back_insert_range<fmt::internal::buffer>> {
|
||||
public:
|
||||
using range = fmt::back_insert_range<fmt::internal::buffer>;
|
||||
using iterator = decltype(std::declval<range>().begin());
|
||||
using base = fmt::arg_formatter<range>;
|
||||
typedef fmt::back_insert_range<fmt::internal::buffer> range;
|
||||
typedef decltype(std::declval<range>().begin()) iterator;
|
||||
typedef fmt::arg_formatter<range> base;
|
||||
|
||||
CustomArgFormatter(fmt::basic_context<iterator, char> &ctx,
|
||||
fmt::format_specs &s)
|
||||
|
@ -89,7 +89,7 @@ void std_format(long double value, std::wstring &result) {
|
||||
template <typename Char, typename T>
|
||||
::testing::AssertionResult check_write(const T &value, const char *type) {
|
||||
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);
|
||||
writer.write(value);
|
||||
std::basic_string<Char> actual = to_string(buffer);
|
||||
@ -1516,7 +1516,7 @@ TEST(FormatTest, FixedEnum) {
|
||||
}
|
||||
#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 :
|
||||
public fmt::internal::arg_formatter_base<buffer_range> {
|
||||
@ -1524,8 +1524,8 @@ class mock_arg_formatter :
|
||||
MOCK_METHOD1(call, void (int value));
|
||||
|
||||
public:
|
||||
using base = fmt::internal::arg_formatter_base<buffer_range>;
|
||||
using range = buffer_range;
|
||||
typedef fmt::internal::arg_formatter_base<buffer_range> base;
|
||||
typedef buffer_range range;
|
||||
|
||||
mock_arg_formatter(fmt::context &ctx, fmt::format_specs &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) {
|
||||
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("*^").fill == '*', "");
|
||||
static_assert(parse_test_specs("+").res == handler::PLUS, "");
|
||||
@ -1736,7 +1736,7 @@ TEST(FormatTest, ConstexprParseFormatSpecs) {
|
||||
}
|
||||
|
||||
struct test_context {
|
||||
using char_type = char;
|
||||
typedef char char_type;
|
||||
|
||||
FMT_CONSTEXPR fmt::basic_arg<test_context> next_arg() {
|
||||
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) {
|
||||
using handler = test_format_specs_handler;
|
||||
typedef test_format_specs_handler handler;
|
||||
static_assert(check_specs("<").align == fmt::ALIGN_LEFT, "");
|
||||
static_assert(check_specs("*^").fill == '*', "");
|
||||
static_assert(check_specs("+").res == handler::PLUS, "");
|
||||
|
@ -58,7 +58,7 @@ TEST(OStreamTest, Enum) {
|
||||
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> {
|
||||
test_arg_formatter(fmt::context &ctx, fmt::format_specs &s)
|
||||
|
@ -81,7 +81,7 @@ struct formatter<Test, Char> {
|
||||
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)
|
||||
-> decltype(ctx.begin()) {
|
||||
@ -436,7 +436,7 @@ TEST(UtilTest, FormatArgs) {
|
||||
}
|
||||
|
||||
struct custom_context {
|
||||
using char_type = char;
|
||||
typedef char char_type;
|
||||
|
||||
template <typename T>
|
||||
struct formatter_type {
|
||||
@ -525,7 +525,7 @@ VISIT_TYPE(float, double);
|
||||
#define CHECK_ARG_(Char, expected, value) { \
|
||||
testing::StrictMock<MockVisitor<decltype(expected)>> visitor; \
|
||||
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)); \
|
||||
}
|
||||
|
||||
@ -599,8 +599,8 @@ TEST(UtilTest, PointerArg) {
|
||||
|
||||
TEST(UtilTest, CustomArg) {
|
||||
::Test test;
|
||||
using handle = typename fmt::basic_arg<fmt::context>::handle;
|
||||
using visitor = MockVisitor<handle>;
|
||||
typedef typename fmt::basic_arg<fmt::context>::handle handle;
|
||||
typedef MockVisitor<handle> visitor;
|
||||
testing::StrictMock<visitor> v;
|
||||
EXPECT_CALL(v, visit(_)).WillOnce(testing::Invoke([&](handle h) {
|
||||
fmt::memory_buffer buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user