Skip to content

Commit ae0168c

Browse files
author
Julian LALU
committed
replace inline constexpr by constrexpr
1 parent 4270130 commit ae0168c

107 files changed

Lines changed: 308 additions & 248 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

interface/core/atomics/atomics_gcc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,13 @@ namespace hud::gcc
210210
private:
211211

212212
private:
213-
static inline constexpr i32 to_gcc_order(memory_order_e order)
213+
static constexpr i32 to_gcc_order(memory_order_e order)
214214
{
215215
// Avoid switch statement to make this a constexpr.
216216
return order == memory_order_e::relaxed ? __ATOMIC_RELAXED : (order == memory_order_e::acquire ? __ATOMIC_ACQUIRE : (order == memory_order_e::release ? __ATOMIC_RELEASE : (order == memory_order_e::seq_cst ? __ATOMIC_SEQ_CST : (order == memory_order_e::acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_CONSUME))));
217217
}
218218

219-
static inline constexpr i32 to_gcc_failure_order(memory_order_e order)
219+
static constexpr i32 to_gcc_failure_order(memory_order_e order)
220220
{
221221
// Avoid switch statement to make this a constexpr.
222222
// This memory order cannot be __ATOMIC_RELEASE nor __ATOMIC_ACQ_REL. It also cannot be a stronger order than that specified by success_memorder.

interface/core/containers/hashset.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,18 @@ namespace hud
14481448
{
14491449
// Move elements to new buffer if any
14501450
// Relocate slots to newly allocated buffer
1451+
// iterate_over_full_slots(old_control_ptr, old_slot_ptr, [this](control_type *control_ptr, slot_type *slot_ptr)
1452+
// {
1453+
// // Compute the hash
1454+
// u64 hash {hasher_type {}(slot_ptr->key())};
1455+
// // Find H1 slot index
1456+
// u64 h1 {H1(hash)};
1457+
// usize slot_index {find_first_empty_or_deleted(control_ptr_, max_slot_count_, h1)};
1458+
// // Save h2 in control h1 index
1459+
// control::set_h2(control_ptr_, slot_index, H2(hash), max_slot_count_);
1460+
// // Move old slot to new slot
1461+
// hud::memory::move_or_copy_construct_object_then_destroy(slot_ptr_ + slot_index, hud::move(*slot_ptr)); });
1462+
14511463
auto [control_full_or_sentinel, slot_full_or_sentinel] = skip_empty_or_deleted(old_control_ptr, old_slot_ptr);
14521464
while (control_full_or_sentinel != old_control_ptr + old_max_slot_count)
14531465
{
@@ -1681,6 +1693,54 @@ namespace hud
16811693
}
16821694
}
16831695

1696+
constexpr void iterate_over_full_slots(control_type *control_ptr, auto *slot_ptr, auto callback) noexcept
1697+
{
1698+
// When max slot count is less than the probing group
1699+
// We have cloned control in the group
1700+
// In this case, we start probing at the sentinel instead of 0
1701+
if (max_slot_count_ < group_type::SLOT_PER_GROUP - 1)
1702+
{
1703+
group_type group {control_ptr_sentinel()};
1704+
1705+
// In the case of constant expression
1706+
// If the hashmap is empty, slot_ptr is nullptr, we don't want to decrement the pointer in the case
1707+
// In a non constant expression slot_ptr is located after control in the same memory layout,
1708+
// we can safely decrement as soon as we don't read the value
1709+
if (hud::is_constant_evaluated())
1710+
{
1711+
// Iterate over cloned control bytes
1712+
for (u32 full_index : group.mask_of_full_slot())
1713+
{
1714+
callback(control_ptr + full_index, slot_ptr + full_index);
1715+
}
1716+
}
1717+
else
1718+
{
1719+
--slot_ptr;
1720+
// Iterate over cloned control bytes
1721+
for (u32 full_index : group.mask_of_full_slot())
1722+
{
1723+
callback(control_ptr + full_index, slot_ptr + full_index);
1724+
}
1725+
}
1726+
}
1727+
else
1728+
{
1729+
size_t remaining_slots {count()};
1730+
while (remaining_slots != 0)
1731+
{
1732+
group_type group {control_ptr};
1733+
for (u32 full_index : group.mask_of_full_slot())
1734+
{
1735+
callback(control_ptr + full_index, slot_ptr + full_index);
1736+
--remaining_slots;
1737+
}
1738+
control_ptr += group_type::SLOT_PER_GROUP;
1739+
slot_ptr += group_type::SLOT_PER_GROUP;
1740+
}
1741+
}
1742+
}
1743+
16841744
template<typename slot_t>
16851745
[[nodiscard]] constexpr hud::pair<control_type *, slot_t *> skip_empty_or_deleted(control_type *control_ptr, slot_t *slot_ptr) const noexcept
16861746
{

interface/core/containers/optional.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ namespace hud
431431
};
432432

433433
/** Constant used to indicate optional type with uninitialized state. */
434-
inline constexpr nullopt_t nullopt {nullopt_t::tag {}};
434+
constexpr nullopt_t nullopt {nullopt_t::tag {}};
435435

436436
/**
437437
* Manages an optional contained value, i.e. a value that may or may not be present.

interface/core/containers/tuple.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace hud
192192
};
193193

194194
template<typename pair_t, typename tuple_t>
195-
inline constexpr bool is_pair_copy_constructible_to_tuple_v = is_pair_copy_constructible_to_tuple<pair_t, tuple_t>::value;
195+
constexpr bool is_pair_copy_constructible_to_tuple_v = is_pair_copy_constructible_to_tuple<pair_t, tuple_t>::value;
196196

197197
/**
198198
* Check if a tuple<T0,T1> is explicitly copy constructible from pair<first_type,second_type>.
@@ -211,7 +211,7 @@ namespace hud
211211
};
212212

213213
template<typename pair_t, typename tuple_t>
214-
inline constexpr bool is_pair_explicitly_copy_constructible_to_tuple_v = is_pair_explicitly_copy_constructible_to_tuple<pair_t, tuple_t>::value;
214+
constexpr bool is_pair_explicitly_copy_constructible_to_tuple_v = is_pair_explicitly_copy_constructible_to_tuple<pair_t, tuple_t>::value;
215215

216216
/**
217217
* @brief Check if a tuple<T0,T1> is move constructible from pair<first_type,second_type>.
@@ -233,7 +233,7 @@ namespace hud
233233
};
234234

235235
template<typename pair_t, typename tuple_t>
236-
inline constexpr bool is_pair_move_constructible_to_tuple_v = is_pair_move_constructible_to_tuple<pair_t, tuple_t>::value;
236+
constexpr bool is_pair_move_constructible_to_tuple_v = is_pair_move_constructible_to_tuple<pair_t, tuple_t>::value;
237237

238238
/**
239239
* Check if a tuple<T0,T1> is explicitly move constructible from pair<first_type,second_type>.
@@ -252,7 +252,7 @@ namespace hud
252252
};
253253

254254
template<typename pair_t, typename tuple_t>
255-
inline constexpr bool is_pair_explicitly_move_constructible_to_tuple_v = is_pair_explicitly_move_constructible_to_tuple<pair_t, tuple_t>::value;
255+
constexpr bool is_pair_explicitly_move_constructible_to_tuple_v = is_pair_explicitly_move_constructible_to_tuple<pair_t, tuple_t>::value;
256256

257257
/**
258258
* Recursively assign a tuple to another.

interface/core/containers/tuple_size.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace hud
7272

7373
/** Equalivent of tuple_size<tuple_like>::value. */
7474
template<typename tuple_like>
75-
inline constexpr usize tuple_size_v = tuple_size<tuple_like>::value;
75+
constexpr usize tuple_size_v = tuple_size<tuple_like>::value;
7676

7777
} // namespace hud
7878

interface/core/hash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ namespace hud
509509

510510
/** Equivalent of is_hashable<type_t>::value. */
511511
template<typename type_t>
512-
inline constexpr bool is_hashable_64_v = is_hashable_64<type_t>::value;
512+
constexpr bool is_hashable_64_v = is_hashable_64<type_t>::value;
513513

514514
// Traits used to check if a type is hashable
515515
template<typename type_t, typename = void>
@@ -526,7 +526,7 @@ namespace hud
526526

527527
/** Equivalent of is_hashable<type_t>::value. */
528528
template<typename type_t>
529-
inline constexpr bool is_hashable_32_v = is_hashable_32<type_t>::value;
529+
constexpr bool is_hashable_32_v = is_hashable_32<type_t>::value;
530530
} // namespace hud
531531

532532
#endif // HD_INC_CORE_HASH_H

interface/core/i128.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ namespace hud
149149
{
150150
}
151151

152-
static inline constexpr i128 i128_max = i128 {i64_max, u64_max};
153-
static inline constexpr i128 i128_min = i128 {i64_min, 0u};
152+
static constexpr i128 i128_max = i128 {i64_max, u64_max};
153+
static constexpr i128 i128_min = i128 {i64_min, 0u};
154154

155-
static inline constexpr u128 u128_max = u128 {u64_max, u64_max};
156-
static inline constexpr u128 u128_min = u128 {u64_min, 0u};
155+
static constexpr u128 u128_max = u128 {u64_max, u64_max};
156+
static constexpr u128 u128_min = u128 {u64_min, 0u};
157157

158158
template<> struct limits<i128>
159159
{

interface/core/i128/i128_portable.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,11 +1223,11 @@ namespace hud
12231223

12241224
} // namespace details::i128
12251225

1226-
// static inline constexpr details::i128::i128_impl i128_max = details::i128::i128_impl {i64_max, u64_max};
1227-
// static inline constexpr details::i128::i128_impl i128_min = details::i128::i128_impl {i64_min, 0u};
1226+
// static constexpr details::i128::i128_impl i128_max = details::i128::i128_impl {i64_max, u64_max};
1227+
// static constexpr details::i128::i128_impl i128_min = details::i128::i128_impl {i64_min, 0u};
12281228

1229-
// static inline constexpr details::i128::u128_impl u128_max = details::i128::u128_impl {u64_max, u64_max};
1230-
// static inline constexpr details::i128::u128_impl u128_min = details::i128::u128_impl {u64_min, 0u};
1229+
// static constexpr details::i128::u128_impl u128_max = details::i128::u128_impl {u64_max, u64_max};
1230+
// static constexpr details::i128::u128_impl u128_min = details::i128::u128_impl {u64_min, 0u};
12311231

12321232
// template<> struct limits<details::i128::i128_impl>
12331233
// {

interface/core/tag_in_place.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace hud
1111
};
1212

1313
/** Constant used to indicate to construct an object in-place. */
14-
inline constexpr tag_in_place in_place {};
14+
constexpr tag_in_place in_place {};
1515
} // namespace hud
1616

1717
#endif // HD_INC_CORE_INPLACE_H

interface/core/tag_init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace hud
1717
};
1818

1919
/** Constant used to indicate to initialize an object. */
20-
inline constexpr tag_init taginit {tag_init::tag {}};
20+
constexpr tag_init taginit {tag_init::tag {}};
2121

2222
} // namespace hud
2323

0 commit comments

Comments
 (0)