Commit ab6e2272 authored by Victor Zverovich's avatar Victor Zverovich

Clarify shifts encoding

parent e4728409
...@@ -1320,6 +1320,8 @@ FMT_CONSTEXPR auto write_padded(OutputIt out, ...@@ -1320,6 +1320,8 @@ FMT_CONSTEXPR auto write_padded(OutputIt out,
static_assert(align == align::left || align == align::right, ""); static_assert(align == align::left || align == align::right, "");
unsigned spec_width = to_unsigned(specs.width); unsigned spec_width = to_unsigned(specs.width);
size_t padding = spec_width > width ? spec_width - width : 0; size_t padding = spec_width > width ? spec_width - width : 0;
// Shifts are encoded as string literals because static constexpr is not
// supported in constexpr functions.
auto* shifts = align == align::left ? "\x1f\x1f\x00\x01" : "\x00\x1f\x00\x01"; auto* shifts = align == align::left ? "\x1f\x1f\x00\x01" : "\x00\x1f\x00\x01";
size_t left_padding = padding >> shifts[specs.align]; size_t left_padding = padding >> shifts[specs.align];
size_t right_padding = padding - left_padding; size_t right_padding = padding - left_padding;
......
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