Skip to content

Commit

Permalink
constexpr uint128_wrapper (#2215)
Browse files Browse the repository at this point in the history
* constexpr uint128_wrapper

* change FMT_CONSTEXPR to constexpr

* clang format

Co-authored-by: Jake Staahl <[email protected]>
  • Loading branch information
jstaahl and jstaahl-sc authored Apr 7, 2021
1 parent 2e0d64c commit 266107f
Showing 1 changed file with 11 additions and 8 deletions.
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

0 comments on commit 266107f

Please sign in to comment.