Fix compilation with older gcc

This commit is contained in:
Victor Zverovich 2018-10-22 21:05:59 -07:00
parent 1ec0272303
commit 2d2326a76d
3 changed files with 26 additions and 20 deletions

View File

@ -68,7 +68,7 @@ include(CheckCXXCompilerFlag)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(PEDANTIC_COMPILE_FLAGS -pedantic-errors -Wall -Wextra -pedantic
-Wold-style-cast -Wlogical-op -Wundef
-Wold-style-cast -Wundef
-Wredundant-decls -Wshadow -Wwrite-strings -Wpointer-arith
-Wcast-qual -Wformat=2 -Wmissing-include-dirs
-Wcast-align -Wnon-virtual-dtor

View File

@ -603,6 +603,15 @@ FMT_FUNC void write_exponent(int exp, Handler &&h) {
}
}
struct fill {
size_t n;
void operator()(char *buffer) const {
buffer[0] = '0';
buffer[1] = '.';
std::uninitialized_fill_n(buffer + 2, n, '0');
}
};
// The number is given as v = f * pow(10, exp), where f has size digits.
template <typename Handler>
FMT_FUNC void grisu2_prettify(const gen_digits_params &params,
@ -642,14 +651,6 @@ FMT_FUNC void grisu2_prettify(const gen_digits_params &params,
}
} else {
// 1234e-6 -> 0.001234
struct fill {
size_t n;
void operator()(char *buffer) const {
buffer[0] = '0';
buffer[1] = '.';
std::uninitialized_fill_n(buffer + 2, n, '0');
}
};
handler.insert(0, 2 - full_exp, fill{to_unsigned(-full_exp)});
}
}

View File

@ -1779,8 +1779,9 @@ struct arg_ref {
FMT_CONSTEXPR arg_ref() : kind(NONE), index(0) {}
FMT_CONSTEXPR explicit arg_ref(unsigned index) : kind(INDEX), index(index) {}
explicit arg_ref(basic_string_view<Char> name)
: kind(NAME), name{name.data(), name.size()} {}
explicit arg_ref(basic_string_view<Char> nm) : kind(NAME) {
name = {nm.data(), nm.size()};
}
FMT_CONSTEXPR arg_ref &operator=(unsigned idx) {
kind = INDEX;
@ -3401,24 +3402,27 @@ struct format_to_n_result {
};
template <typename OutputIt, typename Char = typename OutputIt::value_type>
using format_to_n_context = typename fmt::format_context_t<
fmt::internal::truncating_iterator<OutputIt>, Char>::type;
struct format_to_n_context :
format_context_t<fmt::internal::truncating_iterator<OutputIt>, Char> {};
template <typename OutputIt, typename Char = typename OutputIt::value_type>
using format_to_n_args =
fmt::basic_format_args<format_to_n_context<OutputIt, Char>>;
struct format_to_n_args {
typedef basic_format_args<
typename format_to_n_context<OutputIt, Char>::type> type;
};
template <typename OutputIt, typename Char, typename ...Args>
inline format_arg_store<format_to_n_context<OutputIt, Char>, Args...>
inline format_arg_store<
typename format_to_n_context<OutputIt, Char>::type, Args...>
make_format_to_n_args(const Args &... args) {
return format_arg_store<
format_to_n_context<OutputIt, Char>, Args...>(args...);
typename format_to_n_context<OutputIt, Char>::type, Args...>(args...);
}
template <typename OutputIt, typename Char, typename... Args>
inline format_to_n_result<OutputIt> vformat_to_n(
OutputIt out, std::size_t n, basic_string_view<Char> format_str,
format_to_n_args<OutputIt, Char> args) {
typename format_to_n_args<OutputIt, Char>::type args) {
typedef internal::truncating_iterator<OutputIt> It;
auto it = vformat_to(It(out, n), format_str, args);
return {it.base(), it.count()};
@ -3437,9 +3441,10 @@ inline FMT_ENABLE_IF_STRING(S, format_to_n_result<OutputIt>)
const Args &... args) {
internal::check_format_string<Args...>(format_str);
typedef FMT_CHAR(S) Char;
format_arg_store<format_to_n_context<OutputIt, Char>, Args...> as(args...);
format_arg_store<
typename format_to_n_context<OutputIt, Char>::type, Args...> as(args...);
return vformat_to_n(out, n, to_string_view(format_str),
format_to_n_args<OutputIt, Char>(as));
typename format_to_n_args<OutputIt, Char>::type(as));
}
template <typename Char>