Remove workarounds for pre-C++11 compilers
This commit is contained in:
parent
a9940192fb
commit
874d6727e4
@ -265,31 +265,9 @@ inline Dest bit_cast(const Source& source) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
// An implementation of begin and end for pre-C++11 compilers such as gcc 4.
|
||||
template <typename C>
|
||||
FMT_CONSTEXPR auto begin(const C& c) -> decltype(c.begin()) {
|
||||
return c.begin();
|
||||
}
|
||||
template <typename T, std::size_t N>
|
||||
FMT_CONSTEXPR T* begin(T (&array)[N]) FMT_NOEXCEPT {
|
||||
return array;
|
||||
}
|
||||
template <typename C> FMT_CONSTEXPR auto end(const C& c) -> decltype(c.end()) {
|
||||
return c.end();
|
||||
}
|
||||
template <typename T, std::size_t N>
|
||||
FMT_CONSTEXPR T* end(T (&array)[N]) FMT_NOEXCEPT {
|
||||
return array + N;
|
||||
}
|
||||
|
||||
// An implementation of iterator_t for pre-C++20 compilers such as gcc 4.
|
||||
// An implementation of iterator_t for pre-C++20 systems.
|
||||
template <typename T> struct iterator_t {
|
||||
typedef decltype(internal::begin(std::declval<const T&>())) type;
|
||||
};
|
||||
|
||||
// For std::result_of in gcc 4.4.
|
||||
template <typename Result> struct function {
|
||||
template <typename T> struct result { typedef Result type; };
|
||||
typedef decltype(std::begin(std::declval<const T&>())) type;
|
||||
};
|
||||
|
||||
template <typename Allocator>
|
||||
@ -1531,7 +1509,7 @@ FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char*& begin,
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename Context> class custom_formatter : public function<bool> {
|
||||
template <typename Context> class custom_formatter {
|
||||
private:
|
||||
typedef typename Context::char_type char_type;
|
||||
|
||||
@ -1558,8 +1536,7 @@ template <typename T> struct is_integer {
|
||||
};
|
||||
};
|
||||
|
||||
template <typename ErrorHandler>
|
||||
class width_checker : public function<unsigned long long> {
|
||||
template <typename ErrorHandler> class width_checker {
|
||||
public:
|
||||
explicit FMT_CONSTEXPR width_checker(ErrorHandler& eh) : handler_(eh) {}
|
||||
|
||||
@ -1579,8 +1556,7 @@ class width_checker : public function<unsigned long long> {
|
||||
ErrorHandler& handler_;
|
||||
};
|
||||
|
||||
template <typename ErrorHandler>
|
||||
class precision_checker : public function<unsigned long long> {
|
||||
template <typename ErrorHandler> class precision_checker {
|
||||
public:
|
||||
explicit FMT_CONSTEXPR precision_checker(ErrorHandler& eh) : handler_(eh) {}
|
||||
|
||||
@ -3339,13 +3315,13 @@ arg_join<It, wchar_t> join(It begin, It end, wstring_view sep) {
|
||||
template <typename Range>
|
||||
arg_join<typename internal::iterator_t<Range>::type, char> join(
|
||||
const Range& range, string_view sep) {
|
||||
return join(internal::begin(range), internal::end(range), sep);
|
||||
return join(std::begin(range), std::end(range), sep);
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
arg_join<typename internal::iterator_t<Range>::type, wchar_t> join(
|
||||
const Range& range, wstring_view sep) {
|
||||
return join(internal::begin(range), internal::end(range), sep);
|
||||
return join(std::begin(range), std::end(range), sep);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -38,7 +38,7 @@ template <> struct int_checker<true> {
|
||||
static bool fits_in_int(int) { return true; }
|
||||
};
|
||||
|
||||
class printf_precision_handler : public function<int> {
|
||||
class printf_precision_handler {
|
||||
public:
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
int operator()(T value) {
|
||||
@ -55,7 +55,7 @@ class printf_precision_handler : public function<int> {
|
||||
};
|
||||
|
||||
// An argument visitor that returns true iff arg is a zero integer.
|
||||
class is_zero_int : public function<bool> {
|
||||
class is_zero_int {
|
||||
public:
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
bool operator()(T value) {
|
||||
@ -72,8 +72,7 @@ template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
|
||||
|
||||
template <> struct make_unsigned_or_bool<bool> { typedef bool type; };
|
||||
|
||||
template <typename T, typename Context>
|
||||
class arg_converter : public function<void> {
|
||||
template <typename T, typename Context> class arg_converter {
|
||||
private:
|
||||
typedef typename Context::char_type Char;
|
||||
|
||||
@ -129,7 +128,7 @@ void convert_arg(basic_format_arg<Context>& arg, Char type) {
|
||||
}
|
||||
|
||||
// Converts an integer argument to char for printf.
|
||||
template <typename Context> class char_converter : public function<void> {
|
||||
template <typename Context> class char_converter {
|
||||
private:
|
||||
basic_format_arg<Context>& arg_;
|
||||
|
||||
@ -148,8 +147,7 @@ template <typename Context> class char_converter : public function<void> {
|
||||
|
||||
// Checks if an argument is a valid printf width specifier and sets
|
||||
// left alignment if it is negative.
|
||||
template <typename Char>
|
||||
class printf_width_handler : public function<unsigned> {
|
||||
template <typename Char> class printf_width_handler {
|
||||
private:
|
||||
typedef basic_format_specs<Char> format_specs;
|
||||
|
||||
|
@ -489,9 +489,7 @@ namespace detail {
|
||||
|
||||
template <typename Range>
|
||||
class arg_formatter
|
||||
: public fmt::internal::function<
|
||||
typename fmt::internal::arg_formatter_base<Range, error_handler>::iterator>,
|
||||
public fmt::internal::arg_formatter_base<Range, error_handler> {
|
||||
: public fmt::internal::arg_formatter_base<Range, error_handler> {
|
||||
private:
|
||||
using char_type = typename Range::value_type;
|
||||
using base = fmt::internal::arg_formatter_base<Range, error_handler>;
|
||||
|
@ -143,7 +143,7 @@ TEST(FPTest, GrisuFormatCompilesWithNonIEEEDouble) {
|
||||
grisu_format(4.2f, buf, -1, false, exp);
|
||||
}
|
||||
|
||||
template <typename T> struct ValueExtractor : fmt::internal::function<T> {
|
||||
template <typename T> struct value_extractor {
|
||||
T operator()(T value) { return value; }
|
||||
|
||||
template <typename U> FMT_NORETURN T operator()(U) {
|
||||
@ -157,7 +157,7 @@ TEST(FormatTest, ArgConverter) {
|
||||
fmt::visit_format_arg(
|
||||
fmt::internal::arg_converter<long long, fmt::format_context>(arg, 'd'),
|
||||
arg);
|
||||
EXPECT_EQ(value, fmt::visit_format_arg(ValueExtractor<long long>(), arg));
|
||||
EXPECT_EQ(value, fmt::visit_format_arg(value_extractor<long long>(), arg));
|
||||
}
|
||||
|
||||
TEST(FormatTest, FormatNegativeNaN) {
|
||||
|
@ -1890,9 +1890,7 @@ TEST(FormatTest, FixedEnum) { EXPECT_EQ("0", fmt::format("{}", B)); }
|
||||
typedef fmt::back_insert_range<fmt::internal::buffer<char>> buffer_range;
|
||||
|
||||
class mock_arg_formatter
|
||||
: public fmt::internal::function<
|
||||
fmt::internal::arg_formatter_base<buffer_range>::iterator>,
|
||||
public fmt::internal::arg_formatter_base<buffer_range> {
|
||||
: public fmt::internal::arg_formatter_base<buffer_range> {
|
||||
private:
|
||||
MOCK_METHOD1(call, void(long long value));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user