Skip to content

Commit 3a3ecf4

Browse files
static type hash: add noexcept, remove unused code
1 parent 0a85f22 commit 3a3ecf4

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

include/cista/type_hash/static_type_hash.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ struct count_map {
3131
key_type first;
3232
mapped_type second;
3333
};
34-
using iterator = typename std::array<value_type, Size>::iterator;
3534
using const_iterator = typename std::array<value_type, Size>::const_iterator;
3635

3736
constexpr count_map() = default;
3837

39-
constexpr std::pair<mapped_type, bool> add(key_type k) {
38+
constexpr std::pair<mapped_type, bool> add(key_type k) noexcept {
4039
auto const it = find(k);
4140
if (it == end()) {
4241
arr_[size_] = value_type{k, static_cast<mapped_type>(size_)};
@@ -48,7 +47,7 @@ struct count_map {
4847
}
4948
}
5049

51-
constexpr const_iterator find(key_type k) const {
50+
constexpr const_iterator find(key_type k) const noexcept {
5251
for (auto it = begin(); it != end(); ++it) {
5352
if (it->first == k) {
5453
return it;
@@ -57,8 +56,8 @@ struct count_map {
5756
return end();
5857
}
5958

60-
constexpr const_iterator begin() const { return std::begin(arr_); }
61-
constexpr const_iterator end() const {
59+
constexpr const_iterator begin() const noexcept { return std::begin(arr_); }
60+
constexpr const_iterator end() const noexcept {
6261
return std::next(
6362
begin(),
6463
static_cast<
@@ -72,7 +71,7 @@ struct count_map {
7271

7372
template <std::size_t NMaxTypes>
7473
struct hash_data {
75-
constexpr hash_data combine(hash_t const h) const {
74+
constexpr hash_data combine(hash_t const h) const noexcept {
7675
hash_data r;
7776
r.done_ = done_;
7877
r.h_ = hash_combine(h_, h);
@@ -92,14 +91,14 @@ constexpr hash_data<NMaxTypes> static_type_hash(T const*,
9291
hash_data<NMaxTypes>) noexcept;
9392

9493
template <typename Tuple, std::size_t NMaxTypes, std::size_t I>
95-
constexpr auto hash_tuple_element(hash_data<NMaxTypes> const h) {
94+
constexpr auto hash_tuple_element(hash_data<NMaxTypes> const h) noexcept {
9695
using element_type = std::decay_t<std::tuple_element_t<I, Tuple>>;
9796
return static_type_hash(null<element_type>(), h);
9897
}
9998

10099
template <typename Tuple, std::size_t NMaxTypes, std::size_t... I>
101100
constexpr auto hash_tuple(Tuple const*, hash_data<NMaxTypes> h,
102-
std::index_sequence<I...>) {
101+
std::index_sequence<I...>) noexcept {
103102
(hash_tuple_element<Tuple, NMaxTypes, I>(h), ...);
104103
return h;
105104
}
@@ -155,7 +154,8 @@ constexpr auto static_type_hash(std::chrono::time_point<Clock, Duration> const*,
155154
}
156155

157156
template <typename T, std::size_t Size, std::size_t NMaxTypes>
158-
constexpr auto static_type_hash(array<T, Size> const*, hash_data<NMaxTypes> h) {
157+
constexpr auto static_type_hash(array<T, Size> const*,
158+
hash_data<NMaxTypes> h) noexcept {
159159
h = static_type_hash(null<T>(), h);
160160
return h.combine(hash("array")).combine(Size);
161161
}

0 commit comments

Comments
 (0)