From ea5546d7c89080297b9fee20fadc339e0883af19 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 3 Dec 2019 19:00:58 +0300 Subject: [PATCH] Added noexcept specifier to hash functions --- src/active_item_cache.h | 2 +- src/color.h | 2 +- src/int_id.h | 2 +- src/point.h | 4 ++-- src/savegame_legacy.cpp | 2 +- src/string_id.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/active_item_cache.h b/src/active_item_cache.h index 3b93d04470e76..5417dd6ef77c1 100644 --- a/src/active_item_cache.h +++ b/src/active_item_cache.h @@ -27,7 +27,7 @@ namespace std { template <> struct hash { - std::size_t operator()( const special_item_type &k ) const { + std::size_t operator()( const special_item_type &k ) const noexcept { return static_cast( k ); } }; diff --git a/src/color.h b/src/color.h index 28c0e27c97ff6..ecab2fc3ab6ae 100644 --- a/src/color.h +++ b/src/color.h @@ -382,7 +382,7 @@ namespace std { template<> struct hash { - std::size_t operator()( const nc_color &v ) const { + std::size_t operator()( const nc_color &v ) const noexcept { return hash()( v.operator int() ); } }; diff --git a/src/int_id.h b/src/int_id.h index 359637cb50491..a3a5bfbae5464 100644 --- a/src/int_id.h +++ b/src/int_id.h @@ -119,7 +119,7 @@ namespace std { template struct hash< int_id > { - std::size_t operator()( const int_id &v ) const { + std::size_t operator()( const int_id &v ) const noexcept { return hash()( v.to_i() ); } }; diff --git a/src/point.h b/src/point.h index 589d26803d8ab..b228bf7423ebb 100644 --- a/src/point.h +++ b/src/point.h @@ -318,7 +318,7 @@ namespace std { template <> struct hash { - std::size_t operator()( const point &k ) const { + std::size_t operator()( const point &k ) const noexcept { constexpr uint64_t a = 2862933555777941757; size_t result = k.y; result *= a; @@ -334,7 +334,7 @@ namespace std { template <> struct hash { - std::size_t operator()( const tripoint &k ) const { + std::size_t operator()( const tripoint &k ) const noexcept { constexpr uint64_t a = 2862933555777941757; size_t result = k.z; result *= a; diff --git a/src/savegame_legacy.cpp b/src/savegame_legacy.cpp index 1d31fcaa65951..2b608b44b128f 100644 --- a/src/savegame_legacy.cpp +++ b/src/savegame_legacy.cpp @@ -36,7 +36,7 @@ namespace std template <> struct hash { // Operator overload required by std API. - std::size_t operator()( const talk_topic_enum &k ) const { + std::size_t operator()( const talk_topic_enum &k ) const noexcept { return k; // the most trivial hash of them all } }; diff --git a/src/string_id.h b/src/string_id.h index 06ccc2e30b5c3..5b2a396f89ca9 100644 --- a/src/string_id.h +++ b/src/string_id.h @@ -202,7 +202,7 @@ namespace std { template struct hash< string_id > { - std::size_t operator()( const string_id &v ) const { + std::size_t operator()( const string_id &v ) const noexcept { return hash()( v.str() ); } };