Workaround an issue with mixing std versions in gcc (#2017)
This commit is contained in:
parent
5555651ce0
commit
f81c14aa1e
@ -1174,8 +1174,8 @@ template <typename T = void> struct null {};
|
|||||||
template <typename Char> struct fill_t {
|
template <typename Char> struct fill_t {
|
||||||
private:
|
private:
|
||||||
enum { max_size = 4 };
|
enum { max_size = 4 };
|
||||||
Char data_[max_size];
|
Char data_[max_size] = {Char(' '), Char(0), Char(0), Char(0)};
|
||||||
unsigned char size_;
|
unsigned char size_ = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FMT_CONSTEXPR void operator=(basic_string_view<Char> s) {
|
FMT_CONSTEXPR void operator=(basic_string_view<Char> s) {
|
||||||
@ -1195,13 +1195,6 @@ template <typename Char> struct fill_t {
|
|||||||
FMT_CONSTEXPR const Char& operator[](size_t index) const {
|
FMT_CONSTEXPR const Char& operator[](size_t index) const {
|
||||||
return data_[index];
|
return data_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static FMT_CONSTEXPR fill_t<Char> make() {
|
|
||||||
auto fill = fill_t<Char>();
|
|
||||||
fill[0] = Char(' ');
|
|
||||||
fill.size_ = 1;
|
|
||||||
return fill;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@ -1233,8 +1226,7 @@ template <typename Char> struct basic_format_specs {
|
|||||||
type(0),
|
type(0),
|
||||||
align(align::none),
|
align(align::none),
|
||||||
sign(sign::none),
|
sign(sign::none),
|
||||||
alt(false),
|
alt(false) {}
|
||||||
fill(detail::fill_t<Char>::make()) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using format_specs = basic_format_specs<char>;
|
using format_specs = basic_format_specs<char>;
|
||||||
|
@ -358,9 +358,7 @@ template <typename Allocator, size_t MaxSize>
|
|||||||
class allocator_max_size : public Allocator {
|
class allocator_max_size : public Allocator {
|
||||||
public:
|
public:
|
||||||
using typename Allocator::value_type;
|
using typename Allocator::value_type;
|
||||||
size_t max_size() const FMT_NOEXCEPT {
|
size_t max_size() const FMT_NOEXCEPT { return MaxSize; }
|
||||||
return MaxSize;
|
|
||||||
}
|
|
||||||
value_type* allocate(size_t n) {
|
value_type* allocate(size_t n) {
|
||||||
if (n > max_size()) {
|
if (n > max_size()) {
|
||||||
throw std::length_error("size > max_size");
|
throw std::length_error("size > max_size");
|
||||||
@ -369,8 +367,8 @@ class allocator_max_size: public Allocator {
|
|||||||
*static_cast<Allocator*>(this), n);
|
*static_cast<Allocator*>(this), n);
|
||||||
}
|
}
|
||||||
void deallocate(value_type* p, size_t n) {
|
void deallocate(value_type* p, size_t n) {
|
||||||
std::allocator_traits<Allocator>::deallocate(
|
std::allocator_traits<Allocator>::deallocate(*static_cast<Allocator*>(this),
|
||||||
*static_cast<Allocator *>(this), p, n);
|
p, n);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2470,17 +2468,17 @@ TEST(FormatTest, CharTraitsIsNotAmbiguous) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus > 201103L
|
||||||
struct custom_char {
|
struct custom_char {
|
||||||
int value;
|
int value;
|
||||||
custom_char() = default;
|
custom_char() = default;
|
||||||
|
|
||||||
template <typename T> custom_char(T val) : value(static_cast<int>(val)) {}
|
template <typename T>
|
||||||
|
constexpr custom_char(T val) : value(static_cast<int>(val)) {}
|
||||||
|
|
||||||
operator int() const { return value; }
|
operator int() const { return value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
int to_ascii(custom_char c) { return c; }
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
FMT_BEGIN_NAMESPACE
|
||||||
template <> struct is_char<custom_char> : std::true_type {};
|
template <> struct is_char<custom_char> : std::true_type {};
|
||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
@ -2491,6 +2489,7 @@ TEST(FormatTest, FormatCustomChar) {
|
|||||||
EXPECT_EQ(result.size(), 1);
|
EXPECT_EQ(result.size(), 1);
|
||||||
EXPECT_EQ(result[0], custom_char('x'));
|
EXPECT_EQ(result[0], custom_char('x'));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Convert a char8_t string to std::string. Otherwise GTest will insist on
|
// Convert a char8_t string to std::string. Otherwise GTest will insist on
|
||||||
// inserting `char8_t` NTBS into a `char` stream which is disabled by P1423.
|
// inserting `char8_t` NTBS into a `char` stream which is disabled by P1423.
|
||||||
|
Loading…
Reference in New Issue
Block a user