diff options
Diffstat (limited to 'absl/crc/crc32c.h')
-rw-r--r-- | absl/crc/crc32c.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/absl/crc/crc32c.h b/absl/crc/crc32c.h index ba09e52a..362861e4 100644 --- a/absl/crc/crc32c.h +++ b/absl/crc/crc32c.h @@ -29,6 +29,7 @@ #include <ostream> #include "absl/crc/internal/crc32c_inline.h" +#include "absl/strings/str_format.h" #include "absl/strings/string_view.h" namespace absl { @@ -61,10 +62,16 @@ class crc32c_t final { friend bool operator!=(crc32c_t lhs, crc32c_t rhs) { return !(lhs == rhs); } + template <typename Sink> + friend void AbslStringify(Sink& sink, crc32c_t crc) { + absl::Format(&sink, "%08x", static_cast<uint32_t>(crc)); + } + private: uint32_t crc_; }; + namespace crc_internal { // Non-inline code path for `absl::ExtendCrc32c()`. Do not call directly. // Call `absl::ExtendCrc32c()` (defined below) instead. @@ -174,7 +181,7 @@ crc32c_t RemoveCrc32cSuffix(crc32c_t full_string_crc, crc32c_t suffix_crc, // // Streams the CRC32C value `crc` to the stream `os`. inline std::ostream& operator<<(std::ostream& os, crc32c_t crc) { - return os << static_cast<uint32_t>(crc); + return os << absl::StreamFormat("%08x", static_cast<uint32_t>(crc)); } ABSL_NAMESPACE_END |