diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index a92f196b1f..4dec076fbe 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -159,7 +159,7 @@ inline bool same_type(const std::type_info &lhs, const std::type_info &rhs) { } struct type_hash { - size_t operator()(const std::type_index &t) const { + size_t operator()(const std::type_index &t) const noexcept { size_t hash = 5381; const char *ptr = t.name(); while (auto c = static_cast(*ptr++)) { @@ -170,7 +170,7 @@ struct type_hash { }; struct type_equal_to { - bool operator()(const std::type_index &lhs, const std::type_index &rhs) const { + bool operator()(const std::type_index &lhs, const std::type_index &rhs) const noexcept { return lhs.name() == rhs.name() || std::strcmp(lhs.name(), rhs.name()) == 0; } }; @@ -186,7 +186,7 @@ template using type_map = std::unordered_map; struct override_hash { - size_t operator()(const std::pair &v) const { + size_t operator()(const std::pair &v) const noexcept { size_t value = std::hash()(v.first); value ^= std::hash()(v.second) + 0x9e3779b9 + (value << 6) + (value >> 2); return value;