Skip to content

Commit 7ad6782

Browse files
authored
Fixed Docs (#10)
* Improved example * Fixed docs * Added end of the namespace * Using this->cend() * Renewed godbolt link * Using only cend()
1 parent 4258bb7 commit 7ad6782

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static constexpr burda::ct::hash_map<2, const char *, int> map
4242
// capacity and iterators
4343
static_assert(map.size() == 2);
4444
static_assert(std::size(map) == 2);
45-
const auto it = map.find("key1");
45+
static constexpr auto it = map.find("key1");
4646
static_assert(it != std::cend(map));
4747
static_assert(it->second == 1); // it->second holds the value
4848
static_assert(!std::empty(map));

include/constexpr_hash_map/constexpr_hash_map.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace burda::ct
1010
{
1111
/// @brief Compile-time hash-map (associative key-value container) that performs all operations in constexpr context.
1212
/// This means that keys and values have to be constexpr and noexcept constructible and provide constexpr noexcept operator=.
13-
/// @brief Behaviour is undefined, if there are multiple keys.
13+
/// @brief Behaviour is undefined, if there are multiple same keys.
1414
/// @brief There's actually no hash function needed, see details section.
1515
/// @details Implemented as an std::array containing pairs, so no hashing is involved.
1616
/// @tparam N total number of elements
@@ -81,7 +81,7 @@ class hash_map
8181
/// @return boolean that denotes key's existence
8282
[[nodiscard]] constexpr bool contains(const K& key) const noexcept
8383
{
84-
return search<0, N>(key) != std::cend(data);
84+
return search<0, N>(key) != cend();
8585
}
8686

8787
/// @brief Retrieves size of a hash-map, might also be called indirectly using the std::size(...)
@@ -143,13 +143,13 @@ class hash_map
143143
{
144144
if (equal(data[L].first, key))
145145
{
146-
return std::next(std::cbegin(data), L);
146+
return std::next(cbegin(), L);
147147
}
148148

149149
return search<L+1, R>(key);
150150
}
151151

152-
return std::cend(data);
152+
return cend();
153153
}
154154

155155
/// @private generic implementation that compares keys
@@ -168,6 +168,6 @@ class hash_map
168168
private:
169169
data_type data;
170170
};
171-
}
171+
} // namespace burda::ct
172172

173173
#endif // BURDA_CONSTEXPR_HASH_MAP_HPP

0 commit comments

Comments
 (0)