summaryrefslogtreecommitdiff
path: root/absl/numeric/int128.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2018-02-06 06:42:19 -0800
committerGravatar katzdm <katzdm@google.com>2018-02-06 15:03:47 -0500
commit3917120a4c6ba8c401714c1655b4a6d7ace3d049 (patch)
tree19793d9bcfa24105d7569b6af17b6d76f26d088a /absl/numeric/int128.cc
parentbf7fc9986e20f664958fc227547fd8d2fdcf863e (diff)
Changes imported from Abseil "staging" branch:
- b7ac57541b07fadc3ed054cc3d62bc192a2098a7 Redefine arithmetic assign operators in terms of the bina... by Alex Strelnikov <strel@google.com> - bb2bf3fd86eb9f24420376aad1b9fe84068ad7e4 Cmake CI for Ubuntu by Jon Cohen <cohenjon@google.com> - 3ff3e6d6b4d99627f0785cad5b562362bdf1ae37 Fix internal namespace (debug_internal -> debugging_inter... by Derek Mauro <dmauro@google.com> - b50753d757c95a3430cc2d6cfc0272af1e5c219c Internal change. by Alex Strelnikov <strel@google.com> GitOrigin-RevId: b7ac57541b07fadc3ed054cc3d62bc192a2098a7 Change-Id: I7561639e296d1cc5dc7ee75e6645e8dae3f1bf97
Diffstat (limited to 'absl/numeric/int128.cc')
-rw-r--r--absl/numeric/int128.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/absl/numeric/int128.cc b/absl/numeric/int128.cc
index b32d8095..f24b785c 100644
--- a/absl/numeric/int128.cc
+++ b/absl/numeric/int128.cc
@@ -20,6 +20,7 @@
#include <iostream> // NOLINT(readability/streams)
#include <sstream>
#include <string>
+#include <type_traits>
namespace absl {
@@ -128,19 +129,17 @@ uint128::uint128(float v) : uint128(MakeUint128FromFloat(v)) {}
uint128::uint128(double v) : uint128(MakeUint128FromFloat(v)) {}
uint128::uint128(long double v) : uint128(MakeUint128FromFloat(v)) {}
-uint128& uint128::operator/=(uint128 other) {
+uint128 operator/(uint128 lhs, uint128 rhs) {
uint128 quotient = 0;
uint128 remainder = 0;
- DivModImpl(*this, other, &quotient, &remainder);
- *this = quotient;
- return *this;
+ DivModImpl(lhs, rhs, &quotient, &remainder);
+ return quotient;
}
-uint128& uint128::operator%=(uint128 other) {
+uint128 operator%(uint128 lhs, uint128 rhs) {
uint128 quotient = 0;
uint128 remainder = 0;
- DivModImpl(*this, other, &quotient, &remainder);
- *this = remainder;
- return *this;
+ DivModImpl(lhs, rhs, &quotient, &remainder);
+ return remainder;
}
namespace {