From ab6e2272cc636279fff2bb092118e0802ed733e7 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 6 Sep 2021 18:45:34 -0700 Subject: [PATCH] Clarify shifts encoding --- include/fmt/format.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/fmt/format.h b/include/fmt/format.h index 86afaefe..049b14f0 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1320,6 +1320,8 @@ FMT_CONSTEXPR auto write_padded(OutputIt out, static_assert(align == align::left || align == align::right, ""); unsigned spec_width = to_unsigned(specs.width); 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"; size_t left_padding = padding >> shifts[specs.align]; size_t right_padding = padding - left_padding;