Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constexpr uint128_wrapper #2215

Merged
merged 3 commits into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -901,14 +901,16 @@ struct FMT_EXTERN_TEMPLATE_API uint128_wrapper {
#if FMT_USE_INT128
uint128_t internal_;

uint128_wrapper(uint64_t high, uint64_t low) FMT_NOEXCEPT
constexpr uint128_wrapper(uint64_t high, uint64_t low) FMT_NOEXCEPT
: internal_{static_cast<uint128_t>(low) |
(static_cast<uint128_t>(high) << 64)} {}

uint128_wrapper(uint128_t u) : internal_{u} {}
constexpr uint128_wrapper(uint128_t u) : internal_{u} {}

uint64_t high() const FMT_NOEXCEPT { return uint64_t(internal_ >> 64); }
uint64_t low() const FMT_NOEXCEPT { return uint64_t(internal_); }
constexpr uint64_t high() const FMT_NOEXCEPT {
return uint64_t(internal_ >> 64);
}
constexpr uint64_t low() const FMT_NOEXCEPT { return uint64_t(internal_); }

uint128_wrapper& operator+=(uint64_t n) FMT_NOEXCEPT {
internal_ += n;
Expand All @@ -918,11 +920,12 @@ struct FMT_EXTERN_TEMPLATE_API uint128_wrapper {
uint64_t high_;
uint64_t low_;

uint128_wrapper(uint64_t high, uint64_t low) FMT_NOEXCEPT : high_{high},
low_{low} {}
constexpr uint128_wrapper(uint64_t high, uint64_t low) FMT_NOEXCEPT
: high_{high},
low_{low} {}

uint64_t high() const FMT_NOEXCEPT { return high_; }
uint64_t low() const FMT_NOEXCEPT { return low_; }
constexpr uint64_t high() const FMT_NOEXCEPT { return high_; }
constexpr uint64_t low() const FMT_NOEXCEPT { return low_; }

uint128_wrapper& operator+=(uint64_t n) FMT_NOEXCEPT {
# if defined(_MSC_VER) && defined(_M_X64)
Expand Down