Skip to content

Commit 9df0549

Browse files
committed
more fixes for UINT64_C and uint64_t and size_t
1 parent 451eb40 commit 9df0549

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

include/ankerl/stl.h

-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
#include <type_traits> // for enable_if_t, declval, conditional_t, ena...
4646
#include <utility> // for forward, exchange, pair, as_const, piece...
4747
#include <vector> // for vector
48-
#if ANKERL_UNORDERED_DENSE_HAS_EXCEPTIONS() == 0
49-
# include <cstdlib> // for abort
50-
#endif
5148

5249
#if defined(__has_include)
5350
# if __has_include(<memory_resource>)

include/ankerl/unordered_dense.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ template <typename T>
250250
struct hash<T, typename std::hash<T>::is_avalanching> {
251251
using is_avalanching = void;
252252
auto operator()(T const& obj) const noexcept(noexcept(std::declval<std::hash<T>>().operator()(std::declval<T const&>())))
253-
-> uint64_t {
253+
-> std::uint64_t {
254254
return std::hash<T>{}(obj);
255255
}
256256
};
@@ -312,24 +312,24 @@ struct tuple_hash_helper {
312312
// Converts the value into 64bit. If it is an integral type, just cast it. Mixing is doing the rest.
313313
// If it isn't an integral we need to hash it.
314314
template <typename Arg>
315-
[[nodiscard]] constexpr static auto to64(Arg const& arg) -> uint64_t {
315+
[[nodiscard]] constexpr static auto to64(Arg const& arg) -> std::uint64_t {
316316
if constexpr (std::is_integral_v<Arg> || std::is_enum_v<Arg>) {
317-
return static_cast<uint64_t>(arg);
317+
return static_cast<std::uint64_t>(arg);
318318
} else {
319319
return hash<Arg>{}(arg);
320320
}
321321
}
322322

323-
[[nodiscard]] static auto mix64(uint64_t state, uint64_t v) -> uint64_t {
324-
return detail::wyhash::mix(state + v, uint64_t{0x9ddfea08eb382d69});
323+
[[nodiscard]] static auto mix64(std::uint64_t state, std::uint64_t v) -> std::uint64_t {
324+
return detail::wyhash::mix(state + v, std::uint64_t{0x9ddfea08eb382d69});
325325
}
326326

327327
// Creates a buffer that holds all the data from each element of the tuple. If possible we memcpy the data directly. If
328328
// not, we hash the object and use this for the array. Size of the array is known at compile time, and memcpy is optimized
329329
// away, so filling the buffer is highly efficient. Finally, call wyhash with this buffer.
330330
template <typename T, std::size_t... Idx>
331-
[[nodiscard]] static auto calc_hash(T const& t, std::index_sequence<Idx...>) noexcept -> uint64_t {
332-
auto h = uint64_t{};
331+
[[nodiscard]] static auto calc_hash(T const& t, std::index_sequence<Idx...>) noexcept -> std::uint64_t {
332+
auto h = std::uint64_t{};
333333
((h = mix64(h, to64(std::get<Idx>(t)))), ...);
334334
return h;
335335
}
@@ -338,15 +338,15 @@ struct tuple_hash_helper {
338338
template <typename... Args>
339339
struct hash<std::tuple<Args...>> : tuple_hash_helper<Args...> {
340340
using is_avalanching = void;
341-
auto operator()(std::tuple<Args...> const& t) const noexcept -> uint64_t {
341+
auto operator()(std::tuple<Args...> const& t) const noexcept -> std::uint64_t {
342342
return tuple_hash_helper<Args...>::calc_hash(t, std::index_sequence_for<Args...>{});
343343
}
344344
};
345345

346346
template <typename A, typename B>
347347
struct hash<std::pair<A, B>> : tuple_hash_helper<A, B> {
348348
using is_avalanching = void;
349-
auto operator()(std::pair<A, B> const& t) const noexcept -> uint64_t {
349+
auto operator()(std::pair<A, B> const& t) const noexcept -> std::uint64_t {
350350
return tuple_hash_helper<A, B>::calc_hash(t, std::index_sequence_for<A, B>{});
351351
}
352352
};
@@ -968,7 +968,7 @@ class table : public std::conditional_t<is_map_v<T>, base_table_type_map<T>, bas
968968
if constexpr (has_reserve<bucket_container_type>) {
969969
m_buckets.reserve(num_buckets);
970970
}
971-
for (size_t i = m_buckets.size(); i < num_buckets; ++i) {
971+
for (std::size_t i = m_buckets.size(); i < num_buckets; ++i) {
972972
m_buckets.emplace_back();
973973
}
974974
} else {

src/ankerl.unordered_dense.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ module;
55
// Put all implementation-provided headers into the global module fragment
66
// to prevent attachment to this module.
77

8-
#if !defined(ANKERL_UNORDERED_DENSE_USE_STD_IMPORT)
9-
# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
10-
# define ANKERL_UNORDERED_DENSE_HAS_EXCEPTIONS() 1 // NOLINT(cppcoreguidelines-macro-usage)
11-
# else
12-
# define ANKERL_UNORDERED_DENSE_HAS_EXCEPTIONS() 0 // NOLINT(cppcoreguidelines-macro-usage)
13-
# endif
8+
#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
9+
# define ANKERL_UNORDERED_DENSE_HAS_EXCEPTIONS() 1 // NOLINT(cppcoreguidelines-macro-usage)
10+
#else
11+
# define ANKERL_UNORDERED_DENSE_HAS_EXCEPTIONS() 0 // NOLINT(cppcoreguidelines-macro-usage)
12+
#endif
1413

14+
#if !defined(ANKERL_UNORDERED_DENSE_USE_STD_IMPORT)
1515
#include <ankerl/stl.h>
16+
#else
17+
#include <cstdint>
18+
#endif
19+
20+
#if ANKERL_UNORDERED_DENSE_HAS_EXCEPTIONS() == 0
21+
#include <cstdlib> // for abort and UINT64_C
1622
#endif
1723

1824
#define ANKERL_UNORDERED_DENSE_EXPORT export

0 commit comments

Comments
 (0)