Commit e3f20d3e authored by Victor Zverovich's avatar Victor Zverovich

Remove gcc 4.4 workaround and use proper alias templates (#940)

parent b4388123
...@@ -3340,25 +3340,17 @@ inline typename buffer_context<Char>::iterator format_to( ...@@ -3340,25 +3340,17 @@ inline typename buffer_context<Char>::iterator format_to(
} }
template <typename OutputIt, typename Char = char> template <typename OutputIt, typename Char = char>
// using format_context_t = basic_format_context<OutputIt, Char>; using format_context_t = basic_format_context<OutputIt, Char>;
struct format_context_t {
typedef basic_format_context<OutputIt, Char> type;
};
template <typename OutputIt, typename Char = char> template <typename OutputIt, typename Char = char>
// using format_args_t = basic_format_args<format_context_t<OutputIt, Char>>; using format_args_t = basic_format_args<format_context_t<OutputIt, Char>>;
struct format_args_t {
typedef basic_format_args<typename format_context_t<OutputIt, Char>::type>
type;
};
template <typename S, typename OutputIt, typename... Args, template <typename S, typename OutputIt, typename... Args,
FMT_ENABLE_IF( FMT_ENABLE_IF(
internal::is_output_iterator<OutputIt>::value && internal::is_output_iterator<OutputIt>::value &&
!internal::is_contiguous_back_insert_iterator<OutputIt>::value)> !internal::is_contiguous_back_insert_iterator<OutputIt>::value)>
inline OutputIt vformat_to( inline OutputIt vformat_to(OutputIt out, const S& format_str,
OutputIt out, const S& format_str, format_args_t<OutputIt, char_t<S>> args) {
typename format_args_t<OutputIt, char_t<S>>::type args) {
typedef internal::output_range<OutputIt, char_t<S>> range; typedef internal::output_range<OutputIt, char_t<S>> range;
return vformat_to<arg_formatter<range>>(range(out), return vformat_to<arg_formatter<range>>(range(out),
to_string_view(format_str), args); to_string_view(format_str), args);
...@@ -3382,7 +3374,7 @@ inline OutputIt format_to(OutputIt out, const S& format_str, ...@@ -3382,7 +3374,7 @@ inline OutputIt format_to(OutputIt out, const S& format_str,
internal::is_string<S>::value, internal::is_string<S>::value,
""); "");
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef typename format_context_t<OutputIt, char_t<S>>::type context; typedef format_context_t<OutputIt, char_t<S>> context;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vformat_to(out, to_string_view(format_str), return vformat_to(out, to_string_view(format_str),
basic_format_args<context>(as)); basic_format_args<context>(as));
...@@ -3396,28 +3388,24 @@ template <typename OutputIt> struct format_to_n_result { ...@@ -3396,28 +3388,24 @@ template <typename OutputIt> struct format_to_n_result {
}; };
template <typename OutputIt, typename Char = typename OutputIt::value_type> template <typename OutputIt, typename Char = typename OutputIt::value_type>
struct format_to_n_context using format_to_n_context =
: format_context_t<fmt::internal::truncating_iterator<OutputIt>, Char> {}; format_context_t<fmt::internal::truncating_iterator<OutputIt>, Char>;
template <typename OutputIt, typename Char = typename OutputIt::value_type> template <typename OutputIt, typename Char = typename OutputIt::value_type>
struct format_to_n_args { using format_to_n_args = basic_format_args<format_to_n_context<OutputIt, Char>>;
typedef basic_format_args<typename format_to_n_context<OutputIt, Char>::type>
type;
};
template <typename OutputIt, typename Char, typename... Args> template <typename OutputIt, typename Char, typename... Args>
inline format_arg_store<typename format_to_n_context<OutputIt, Char>::type, inline format_arg_store<format_to_n_context<OutputIt, Char>, Args...>
Args...>
make_format_to_n_args(const Args&... args) { make_format_to_n_args(const Args&... args) {
return format_arg_store<typename format_to_n_context<OutputIt, Char>::type, return format_arg_store<format_to_n_context<OutputIt, Char>, Args...>(
Args...>(args...); args...);
} }
template <typename OutputIt, typename Char, typename... Args, template <typename OutputIt, typename Char, typename... Args,
FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value)> FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value)>
inline format_to_n_result<OutputIt> vformat_to_n( inline format_to_n_result<OutputIt> vformat_to_n(
OutputIt out, std::size_t n, basic_string_view<Char> format_str, OutputIt out, std::size_t n, basic_string_view<Char> format_str,
typename format_to_n_args<OutputIt, Char>::type args) { format_to_n_args<OutputIt, Char> args) {
typedef internal::truncating_iterator<OutputIt> It; typedef internal::truncating_iterator<OutputIt> It;
auto it = vformat_to(It(out, n), format_str, args); auto it = vformat_to(It(out, n), format_str, args);
return {it.base(), it.count()}; return {it.base(), it.count()};
...@@ -3438,10 +3426,9 @@ inline format_to_n_result<OutputIt> format_to_n(OutputIt out, std::size_t n, ...@@ -3438,10 +3426,9 @@ inline format_to_n_result<OutputIt> format_to_n(OutputIt out, std::size_t n,
const Args&... args) { const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
using Char = char_t<S>; using Char = char_t<S>;
format_arg_store<typename format_to_n_context<OutputIt, Char>::type, Args...> format_arg_store<format_to_n_context<OutputIt, Char>, Args...> as(args...);
as(args...);
return vformat_to_n(out, n, to_string_view(format_str), return vformat_to_n(out, n, to_string_view(format_str),
typename format_to_n_args<OutputIt, Char>::type(as)); format_to_n_args<OutputIt, Char>(as));
} }
template <typename Char> template <typename Char>
......
...@@ -54,7 +54,7 @@ template <typename S, typename OutputIt, typename... Args, ...@@ -54,7 +54,7 @@ template <typename S, typename OutputIt, typename... Args,
internal::is_output_iterator<OutputIt>::value, char_t<S>>> internal::is_output_iterator<OutputIt>::value, char_t<S>>>
inline OutputIt vformat_to(OutputIt out, const std::locale& loc, inline OutputIt vformat_to(OutputIt out, const std::locale& loc,
const S& format_str, const S& format_str,
typename format_args_t<OutputIt, Char>::type args) { format_args_t<OutputIt, Char> args) {
using range = internal::output_range<OutputIt, Char>; using range = internal::output_range<OutputIt, Char>;
return vformat_to<arg_formatter<range>>( return vformat_to<arg_formatter<range>>(
range(out), to_string_view(format_str), args, internal::locale_ref(loc)); range(out), to_string_view(format_str), args, internal::locale_ref(loc));
...@@ -66,7 +66,7 @@ template <typename OutputIt, typename S, typename... Args, ...@@ -66,7 +66,7 @@ template <typename OutputIt, typename S, typename... Args,
inline OutputIt format_to(OutputIt out, const std::locale& loc, inline OutputIt format_to(OutputIt out, const std::locale& loc,
const S& format_str, const Args&... args) { const S& format_str, const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
using context = typename format_context_t<OutputIt, char_t<S>>::type; using context = format_context_t<OutputIt, char_t<S>>;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vformat_to(out, loc, to_string_view(format_str), return vformat_to(out, loc, to_string_view(format_str),
basic_format_args<context>(as)); basic_format_args<context>(as));
......
...@@ -127,7 +127,7 @@ void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str, ...@@ -127,7 +127,7 @@ void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
*/ */
template <typename S, typename... Args, template <typename S, typename... Args,
typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline void print(std::basic_ostream<Char>& os, const S& format_str, void print(std::basic_ostream<Char>& os, const S& format_str,
const Args&... args) { const Args&... args) {
vprint(os, to_string_view(format_str), vprint(os, to_string_view(format_str),
{internal::make_args_checked(format_str, args...)}); {internal::make_args_checked(format_str, args...)});
......
...@@ -232,7 +232,7 @@ class prepared_format { ...@@ -232,7 +232,7 @@ class prepared_format {
template <typename OutputIt> template <typename OutputIt>
inline OutputIt format_to(OutputIt out, const Args&... args) const { inline OutputIt format_to(OutputIt out, const Args&... args) const {
typedef typename format_context_t<OutputIt, char_type>::type context; typedef format_context_t<OutputIt, char_type> context;
typedef output_range<OutputIt, char_type> range; typedef output_range<OutputIt, char_type> range;
format_arg_store<context, Args...> as(args...); format_arg_store<context, Args...> as(args...);
return this->vformat_to(range(out), basic_format_args<context>(as)); return this->vformat_to(range(out), basic_format_args<context>(as));
......
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