From 4e78e645d060abd194e87ec495cf4c7134aba7e0 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 8 Dec 2023 16:58:17 -0800 Subject: [PATCH] No public description PiperOrigin-RevId: 589279414 --- mediapipe/framework/deps/strong_int.h | 33 ++++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/mediapipe/framework/deps/strong_int.h b/mediapipe/framework/deps/strong_int.h index b4bfef770..d3a0f77e2 100644 --- a/mediapipe/framework/deps/strong_int.h +++ b/mediapipe/framework/deps/strong_int.h @@ -31,14 +31,14 @@ // A StrongInt with a NullStrongIntValidator should compile away to a raw T // in optimized mode. What this means is that the generated assembly for: // -// int64 foo = 123; -// int64 bar = 456; -// int64 baz = foo + bar; -// constexpr int64 fubar = 789; +// int64_t foo = 123; +// int64_t bar = 456; +// int64_t baz = foo + bar; +// constexpr int64_t fubar = 789; // // ...should be identical to the generated assembly for: // -// DEFINE_STRONG_INT_TYPE(MyStrongInt, int64); +// DEFINE_STRONG_INT_TYPE(MyStrongInt, int64_t); // MyStrongInt foo(123); // MyStrongInt bar(456); // MyStrongInt baz = foo + bar; @@ -97,6 +97,7 @@ #ifndef MEDIAPIPE_DEPS_STRONG_INT_H_ #define MEDIAPIPE_DEPS_STRONG_INT_H_ +#include #include #include #include @@ -179,11 +180,11 @@ struct NullStrongIntValidator { } // Verify lhs << rhs. template - static void ValidateLeftShift(T lhs, int64 rhs) { /* do nothing */ + static void ValidateLeftShift(T lhs, int64_t rhs) { /* do nothing */ } // Verify lhs >> rhs. template - static void ValidateRightShift(T lhs, int64 rhs) { /* do nothing */ + static void ValidateRightShift(T lhs, int64_t rhs) { /* do nothing */ } // Verify lhs & rhs. template @@ -224,8 +225,8 @@ class StrongInt { // // Example: Assume you have two StrongInt types. // - // DEFINE_STRONG_INT_TYPE(Bytes, int64); - // DEFINE_STRONG_INT_TYPE(Megabytes, int64); + // DEFINE_STRONG_INT_TYPE(Bytes, int64_t); + // DEFINE_STRONG_INT_TYPE(Megabytes, int64_t); // // If you want to be able to (explicitly) construct an instance of Bytes from // an instance of Megabytes, simply define a converter function in the same @@ -337,12 +338,12 @@ class StrongInt { value_ %= arg; return *this; } - StrongInt &operator<<=(int64 arg) { // NOLINT(whitespace/operators) + StrongInt &operator<<=(int64_t arg) { // NOLINT(whitespace/operators) ValidatorType::template ValidateLeftShift(value_, arg); value_ <<= arg; return *this; } - StrongInt &operator>>=(int64 arg) { // NOLINT(whitespace/operators) + StrongInt &operator>>=(int64_t arg) { // NOLINT(whitespace/operators) ValidatorType::template ValidateRightShift(value_, arg); value_ >>= arg; return *this; @@ -378,19 +379,19 @@ std::ostream &operator<<(std::ostream &os, return os << arg.value(); } -// Provide the << operator, primarily for logging purposes. Specialized for int8 -// so that an integer and not a character is printed. +// Provide the << operator, primarily for logging purposes. Specialized for +// int8_t so that an integer and not a character is printed. template std::ostream &operator<<(std::ostream &os, - StrongInt arg) { + StrongInt arg) { return os << static_cast(arg.value()); } // Provide the << operator, primarily for logging purposes. Specialized for -// uint8 so that an integer and not a character is printed. +// uint8_t so that an integer and not a character is printed. template std::ostream &operator<<(std::ostream &os, - StrongInt arg) { + StrongInt arg) { return os << static_cast(arg.value()); }