Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/consthash/cityhash128.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ constexpr uint128_t city128(const char *s, size_t len) {
return __detail::CityHash128(s, len);
}

constexpr uint128_t city128(const char *s) {
return __detail::CityHash128(s, __detail::str_len(s));
}

constexpr uint128_t city128_seed(const char *s, size_t len, uint128_t seed) {
return __detail::CityHash128WithSeed(s, len, seed);
}
Expand Down
4 changes: 4 additions & 0 deletions include/consthash/cityhash32.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ constexpr uint32_t city32(const char* s, size_t len) {
return __detail::city32impl(s, len);
}

constexpr uint32_t city32(const char* s) {
return __detail::city32impl(s, __detail::str_len(s));
}

CONSTHASH_NAMESPACE_END;

#endif // _CONSTHASH_CITYHASH32_HXX
5 changes: 5 additions & 0 deletions include/consthash/cityhash64.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ constexpr uint64_t city64(const char *buf, size_t len)
return __detail::city64impl(buf, len);
}

constexpr uint64_t city64(const char *buf)
{
return __detail::city64impl(buf, __detail::str_len(buf));
}

// Hash function for a byte array. For convenience, a 64-bit seed is also
// hashed into the result.
constexpr uint64_t city64_seed(const char *buf, size_t len, uint64_t seed)
Expand Down
5 changes: 5 additions & 0 deletions include/consthash/common.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ struct ensure
static constexpr void ct() { }
};

constexpr size_t str_len(const char* const str)
{
return *str ? (1 + str_len(str + 1)) : 0;
}

}; // namespace __detail

CONSTHASH_NAMESPACE_END;
Expand Down
5 changes: 5 additions & 0 deletions include/consthash/crc32.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ constexpr uint32_t crc32(const char* str, size_t size)
return crc32impl(0xffffffff, str, size) ^ 0xffffffff;
}

constexpr uint32_t crc32(const char* str)
{
return crc32impl(0xffffffff, str, __detail::str_len(str)) ^ 0xffffffff;
}

CONSTHASH_NAMESPACE_END;

#endif // _CONSTHASH_CRC32_HXX
5 changes: 5 additions & 0 deletions include/consthash/crc64.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ constexpr uint64_t crc64(const char* str, size_t size)
return crc64impl(0xffffffff, str, size) ^ 0xffffffff;
}

constexpr uint64_t crc64(const char* str)
{
return crc64impl(0xffffffff, str, __detail::str_len(str)) ^ 0xffffffff;
}

CONSTHASH_NAMESPACE_END;

#endif // _CONSTHASH_CRC64_HXX