Skip to content

Commit

Permalink
C++ interface: Support std::byte if it's available. (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
shlevy authored Sep 6, 2024
1 parent 21fc8ef commit 9d0fb14
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/crc32c/crc32c.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ inline uint32_t Crc32c(const char* data, size_t count) {
return Extend(0, reinterpret_cast<const uint8_t*>(data), count);
}

#ifdef __cpp_lib_byte
// Computes the CRC32C of "count" bytes in the buffer pointed by "data".
inline uint32_t Crc32c(const std::byte* data, size_t count) {
return Extend(0, reinterpret_cast<const uint8_t*>(data), count);
}
#endif

// Computes the CRC32C of the string's content.
inline uint32_t Crc32c(const std::string& string) {
return Crc32c(reinterpret_cast<const uint8_t*>(string.data()),
Expand Down

0 comments on commit 9d0fb14

Please sign in to comment.