clang-format

This commit is contained in:
Walter Gray 2020-11-14 13:25:40 -08:00
parent fc3832ffa2
commit d5e3e3473e
2 changed files with 19 additions and 15 deletions

View File

@ -772,8 +772,10 @@ OutputIt format_duration_value(OutputIt out, Rep val, int) {
template <typename Char, typename Rep, typename OutputIt,
FMT_ENABLE_IF(std::is_floating_point<Rep>::value)>
OutputIt format_duration_value(OutputIt out, Rep val, int precision) {
static FMT_CONSTEXPR_DECL const Char pr_f[] = {'{', ':', '.', '{', '}', 'f', '}', 0};
if (precision >= 0) return format_to(out, compile_string_to_view(pr_f), val, precision);
static FMT_CONSTEXPR_DECL const Char pr_f[] = {'{', ':', '.', '{',
'}', 'f', '}', 0};
if (precision >= 0)
return format_to(out, compile_string_to_view(pr_f), val, precision);
static FMT_CONSTEXPR_DECL const Char fp_f[] = {'{', ':', 'g', '}', 0};
return format_to(out, compile_string_to_view(fp_f), val);
}
@ -796,9 +798,12 @@ OutputIt format_duration_unit(OutputIt out) {
if (const char* unit = get_units<Period>())
return copy_unit(string_view(unit), out, Char());
static FMT_CONSTEXPR_DECL const Char num_f[] = {'[', '{', '}', ']', 's', 0};
if (const_check(Period::den == 1)) return format_to(out, compile_string_to_view(num_f), Period::num);
static FMT_CONSTEXPR_DECL const Char num_def_f[] = {'[', '{', '}', '/', '{', '}', ']', 's', 0};
return format_to(out, compile_string_to_view(num_def_f), Period::num, Period::den);
if (const_check(Period::den == 1))
return format_to(out, compile_string_to_view(num_f), Period::num);
static FMT_CONSTEXPR_DECL const Char num_def_f[] = {'[', '{', '}', '/', '{',
'}', ']', 's', 0};
return format_to(out, compile_string_to_view(num_def_f), Period::num,
Period::den);
}
template <typename FormatContext, typename OutputIt, typename Rep,

View File

@ -355,22 +355,20 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) {
}
template <typename Allocator, size_t MaxSize>
class allocator_max_size: public Allocator {
class allocator_max_size : public Allocator {
public:
using typename Allocator::value_type;
size_t max_size() const FMT_NOEXCEPT {
return MaxSize;
}
size_t max_size() const FMT_NOEXCEPT { return MaxSize; }
value_type* allocate(size_t n) {
if (n > max_size()) {
throw std::length_error("size > max_size");
}
return std::allocator_traits<Allocator>::allocate(
*static_cast<Allocator *>(this), n);
*static_cast<Allocator*>(this), n);
}
void deallocate(value_type* p, size_t n) {
std::allocator_traits<Allocator>::deallocate(
*static_cast<Allocator *>(this), p, n);
std::allocator_traits<Allocator>::deallocate(*static_cast<Allocator*>(this),
p, n);
}
};
@ -383,7 +381,7 @@ TEST(MemoryBufferTest, AllocatorMaxSize) {
try {
// new_capacity = 128 + 128/2 = 192 > 160
buffer.resize(160);
} catch (const std::exception &) {
} catch (const std::exception&) {
throws_on_resize = true;
}
EXPECT_FALSE(throws_on_resize);
@ -395,7 +393,7 @@ TEST(MemoryBufferTest, AllocatorMaxSizeOverflow) {
bool throws_on_resize = false;
try {
buffer.resize(161);
} catch (const std::exception &) {
} catch (const std::exception&) {
throws_on_resize = true;
}
EXPECT_TRUE(throws_on_resize);
@ -1808,7 +1806,8 @@ fmt::string_view to_string_view(string_like) { return "foo"; }
constexpr char with_null[3] = {'{', '}', '\0'};
constexpr char no_null[2] = {'{', '}'};
static FMT_CONSTEXPR_DECL const char static_with_null[3] = {'{', '}', '\0'};
static FMT_CONSTEXPR_DECL const wchar_t static_with_null_wide[3] = {'{', '}', '\0'};
static FMT_CONSTEXPR_DECL const wchar_t static_with_null_wide[3] = {'{', '}',
'\0'};
static FMT_CONSTEXPR_DECL const char static_no_null[2] = {'{', '}'};
static FMT_CONSTEXPR_DECL const wchar_t static_no_null_wide[2] = {'{', '}'};