9#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_SET_HPP_
10#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_SET_HPP_
22#include "arene/base/inline_container/detail/compare.hpp"
23#include "arene/base/inline_container/detail/index_array.hpp"
24#include "arene/base/inline_container/detail/lower_bound_index.hpp"
30#include "arene/base/stdlib_choice/cstddef.hpp"
31#include "arene/base/stdlib_choice/enable_if.hpp"
32#include "arene/base/stdlib_choice/forward.hpp"
33#include "arene/base/stdlib_choice/ignore.hpp"
34#include "arene/base/stdlib_choice/initializer_list.hpp"
35#include "arene/base/stdlib_choice/integer_sequence.hpp"
36#include "arene/base/stdlib_choice/integral_constant.hpp"
37#include "arene/base/stdlib_choice/is_assignable.hpp"
38#include "arene/base/stdlib_choice/is_constructible.hpp"
39#include "arene/base/stdlib_choice/is_copy_assignable.hpp"
40#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
41#include "arene/base/stdlib_choice/is_destructible.hpp"
42#include "arene/base/stdlib_choice/is_integral.hpp"
43#include "arene/base/stdlib_choice/is_move_assignable.hpp"
44#include "arene/base/stdlib_choice/is_move_constructible.hpp"
45#include "arene/base/stdlib_choice/iterator_tags.hpp"
46#include "arene/base/stdlib_choice/iterator_traits.hpp"
47#include "arene/base/stdlib_choice/move.hpp"
48#include "arene/base/stdlib_choice/pair.hpp"
66template <
typename Value, std::
size_t Capacity,
typename Compare>
70namespace inline_set_detail {
72struct inline_set_comparator_tag {};
78 explicit set_passkey() =
default;
82 template <
typename Value, std::
size_t Capacity,
typename Compare>
83 friend class ::arene::base::inline_set;
107template <
typename Value, std::
size_t Capacity,
typename Compare = compare_three_way>
110 : inline_container::detail::compare_wrapper<Compare, Value>
117 "Compare must be invocable with two Values, and yield either a bool or a strong_ordering"
125 template <
typename OtherKey>
126 static constexpr bool
132 using comparator_base = inline_container::detail::compare_wrapper<Compare, Value>;
143 template <
typename OtherKey = Value>
144 static constexpr bool comparison_is_noexcept{comparator_base::template comparison_is_noexcept<OtherKey>};
205 index_type element_index_{0};
236 iterator_impl() noexcept
237 : iterator_impl(inline_set_detail::set_passkey{},
nullptr, 0U) {}
247 iterator_impl(inline_set_detail::set_passkey,
inline_set const* set_to_iterate, index_type element) noexcept
249 set_(set_to_iterate),
250 element_index_(element) {}
258 auto operator*()
const noexcept ->
reference {
260 return *(set_->values_[set_->indices_[element_index_]]);
267 auto operator->()
const noexcept ->
pointer {
return &**
this; }
273 auto operator++()
noexcept -> iterator_impl& {
284 auto operator++(
int)
noexcept -> iterator_impl {
296 auto operator--()
noexcept -> iterator_impl& {
308 auto operator--(
int)
noexcept -> iterator_impl {
337 auto is_for(
inline_set const* set_to_check)
const noexcept ->
bool {
return set_ == set_to_check; }
343 auto index(inline_set_detail::set_passkey)
const noexcept -> index_type {
return element_index_; }
429 : comparator_base(comp),
473 if (!res->insert_elements_if_they_fit(init.begin(), init.end())) {
491 if (!res->insert_elements_if_they_fit(init.begin(), init.end())) {
514 std::enable_if_t<std::is_constructible<Value, typename std::iterator_traits<Iterator>::reference>::value>> =
543 inline_set(Iterator first, Iterator last, Compare
const& comp)
noexcept(
572 if (!res->insert_elements_if_they_fit(first, last)) {
594 std::enable_if_t<std::is_constructible<Value, typename std::iterator_traits<Iterator>::reference>::value>> =
600 if (!res->insert_elements_if_they_fit(first, last)) {
689 if (other.
size() <= Capacity) {
709 : comparator_base(
std::
move(static_cast<comparator_base&>(other))),
711 number_of_active_elements_(other.number_of_active_elements_),
712 values_(move_values(other,
std::make_index_sequence<Capacity>())),
713 indices_(
std::
move(other.indices_)) {}
791 if (other.size() <= Capacity) {
815 if (
this != &other) {
816 static_cast<comparator_base&
>(*this) = other;
842 static_cast<comparator_base&
>(*this) = other.
get_comparator_base(inline_set_detail::set_passkey{});
864 static_cast<comparator_base&
>(*this) = other.
get_comparator_base(inline_set_detail::set_passkey{});
889 if (
this != &other) {
890 static_cast<comparator_base&
>(*this) =
std::move(other);
950 auto size() const noexcept ->
std::
size_t {
return number_of_active_elements_; }
973 return comparator_base::get_comparator();
979 return comparator_base::get_comparator();
986 auto find(Value
const& value_to_find)
noexcept(comparison_is_noexcept<>) ->
iterator {
987 return do_find(value_to_find);
994 return do_find(value_to_find);
1002 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1003 auto find(OtherKey
const& value)
noexcept(comparison_is_noexcept<OtherKey>) ->
iterator {
1004 return do_find(value);
1012 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1014 return do_find(value);
1022 auto contains(Value
const& value_to_check)
const noexcept(comparison_is_noexcept<>) ->
bool {
1023 return do_contains(value_to_check);
1032 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1033 auto contains(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>) ->
bool {
1034 return do_contains(value);
1041 auto count(Value
const& value_to_count)
const noexcept(comparison_is_noexcept<>) ->
std::size_t {
1042 return do_count(value_to_count);
1050 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1051 auto count(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>) ->
std::size_t {
1052 return do_count(value);
1061 return do_lower_bound(value_to_find);
1069 return do_lower_bound(value_to_find);
1078 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1080 return do_lower_bound(value);
1089 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1091 return do_lower_bound(value);
1100 return do_upper_bound(value_to_find);
1109 return do_upper_bound(value_to_find);
1118 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1120 return do_upper_bound(value);
1129 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1131 return do_upper_bound(value);
1140 auto equal_range(Value
const& value_to_find)
noexcept(comparison_is_noexcept<>) -> std::pair<iterator, iterator> {
1141 return do_equal_range(value_to_find);
1149 auto equal_range(Value
const& value_to_find)
const noexcept(comparison_is_noexcept<>)
1150 -> std::pair<const_iterator, const_iterator> {
1151 return do_equal_range(value_to_find);
1161 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1162 auto equal_range(OtherKey
const& value)
noexcept(comparison_is_noexcept<OtherKey>) -> std::pair<iterator, iterator> {
1163 return do_equal_range(value);
1173 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1174 auto equal_range(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>)
1175 -> std::pair<const_iterator, const_iterator> {
1176 return do_equal_range(value);
1194 -> std::pair<iterator, bool> {
1195 return internal_insert(value_to_insert);
1213 -> std::pair<iterator, bool> {
1214 return internal_insert(
std::move(value_to_insert));
1232 typename SfinaeKey = Value,
1239 -> std::pair<iterator, bool> {
1284 auto end() const noexcept ->
const_iterator {
return make_iterator(*
this, number_of_active_elements_); }
1287 auto cend() const noexcept ->
const_iterator {
return make_iterator(*
this, number_of_active_elements_); }
1316 typename... ArgTypes,
1318 auto emplace(ArgTypes&&... args) -> std::pair<iterator, bool> {
1319 if (number_of_active_elements_ == Capacity) {
1321 auto const pos_info = lower_bound_index(value);
1323 return {make_iterator(*
this, pos_info.index),
false};
1325 auto const new_index = indices_[number_of_active_elements_];
1326 auto& potentially_inserted_element = values_[new_index];
1329 auto const pos_info = lower_bound_index(*potentially_inserted_element);
1330 bool const do_insert{pos_info.order != strong_ordering::equal};
1332 insert_index_at(pos_info.index, new_index);
1333 destroy_if_not_inserted.dismiss();
1335 return {make_iterator(*
this, pos_info.index), do_insert};
1347 auto erase(Value
const& value_to_erase)
noexcept(comparison_is_noexcept<>) ->
size_type {
1348 return do_erase(value_to_erase);
1355 template <
typename OtherKey, constra
ints<std::enable_if_t<transparent_comparison_supported_for<OtherKey>>> =
nullptr>
1356 auto erase(OtherKey
const& value)
noexcept(comparison_is_noexcept<OtherKey>) ->
size_type {
1357 return do_erase(value);
1366 auto const index = pos.index(inline_set_detail::set_passkey{});
1379 index_type
const first_index{first.index(inline_set_detail::set_passkey{})};
1380 index_type
const last_index{last.index(inline_set_detail::set_passkey{})};
1382 erase_index_range(first_index,
static_cast<index_type
>(last_index - first_index));
1389 void clear() noexcept { erase_index_range(0U, number_of_active_elements_); }
1399 template <
size_type OtherCapacity>
1430 return ::arene::base::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
1445 auto get_comparator_base(inline_set_detail::set_passkey)
const noexcept -> comparator_base
const& {
return *
this; }
1454 auto entry_at_index(inline_set_detail::set_passkey, index_type index)
noexcept -> entry_type& {
1455 return values_[indices_[index]];
1465 auto entry_at_index(inline_set_detail::set_passkey, index_type index)
const noexcept -> entry_type
const& {
1466 return values_[indices_[index]];
1476 index_type number_of_active_elements_{0};
1479 storage_type values_{};
1484 array<index_type, Capacity> indices_{inline_container_detail::make_index_array<index_type, Capacity>()};
1498 std::enable_if_t<std::is_constructible<Value, typename std::iterator_traits<Iterator>::reference>::value>> =
1500 auto insert_elements_if_they_fit(Iterator first, Iterator last)
noexcept(
1503 while (first != last) {
1504 if (
size() < Capacity) {
1511 arene::base::advance(first, 1);
1526 template <
typename SelfType, constra
ints<std::enable_if_t<decays_to_v<SelfType, inline_set>>> =
nullptr>
1527 static auto make_iterator(SelfType&& self, index_type index)
noexcept ->
iterator {
1528 return iterator_impl{inline_set_detail::set_passkey{}, &self, index};
1543 template <
typename SelfType, constra
ints<std::enable_if_t<decays_to_v<SelfType, inline_set>>> =
nullptr>
1545 make_find_iterator(SelfType&& self, inline_container::detail::lower_bound_index_info<index_type> lb_info)
noexcept
1547 if (lb_info.order == strong_ordering::equal) {
1559 template <
typename OtherKey>
1560 auto do_find(OtherKey
const& value)
const ->
iterator {
1561 return make_find_iterator(*
this, lower_bound_index(value));
1570 template <
typename OtherKey>
1571 auto do_contains(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>) ->
bool {
1572 return do_find(value) !=
end();
1580 template <
typename OtherKey>
1581 auto do_count(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>) ->
std::size_t {
1582 return static_cast<std::size_t>(do_contains(value));
1590 template <
typename OtherKey>
1591 auto do_lower_bound(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>) ->
iterator {
1592 return make_iterator(*
this, lower_bound_index(value).index);
1603 template <
typename SelfType, constra
ints<std::enable_if_t<decays_to_v<SelfType, inline_set>>> =
nullptr>
1604 static auto make_upper_bound_iterator(
1606 inline_container::detail::lower_bound_index_info<index_type> lb_info
1608 if (lb_info.order == strong_ordering::equal) {
1621 template <
typename OtherKey>
1622 auto do_upper_bound(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>) ->
iterator {
1623 return make_upper_bound_iterator(*
this, lower_bound_index(value));
1639 template <
typename SelfType, constra
ints<std::enable_if_t<decays_to_v<SelfType, inline_set>>> =
nullptr>
1641 make_equal_range_iterator(SelfType&& self, inline_container::detail::lower_bound_index_info<index_type> lb_info)
1642 -> std::pair<iterator, iterator> {
1661 template <
typename OtherKey>
1662 auto do_equal_range(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>)
1663 -> std::pair<iterator, iterator> {
1664 return make_equal_range_iterator(*
this, lower_bound_index(value));
1674 template <
typename OtherKey>
1675 auto lower_bound_index(OtherKey
const& value)
const noexcept(comparison_is_noexcept<OtherKey>)
1676 -> inline_container::detail::lower_bound_index_info<index_type> {
1677 auto const compare = [
this](
key_type const& lhs, OtherKey
const& rhs)
noexcept(comparison_is_noexcept<OtherKey>) {
1678 return this->key_ordering(lhs, rhs);
1680 auto const accessor = [
this](index_type
const index)
noexcept ->
key_type const& {
1681 return *(this->
entry_at_index(inline_set_detail::set_passkey{}, index));
1683 return inline_container::detail::lower_bound_index<key_type, OtherKey, index_type>(
1685 number_of_active_elements_,
1696 template <
typename OtherKey>
1697 auto do_erase(OtherKey
const& value)
noexcept(comparison_is_noexcept<OtherKey>) ->
size_type {
1698 return erase_at_index(do_find(value).index(inline_set_detail::set_passkey{}));
1707 template <
typename V>
1709 auto const new_index = indices_[number_of_active_elements_];
1711 insert_index_at(pos, new_index);
1720 void insert_index_at(index_type pos, index_type new_index)
noexcept {
1721 for (index_type i{number_of_active_elements_}; i != pos; --i) {
1722 indices_[i] = indices_[
static_cast<index_type
>(i - 1U)];
1724 indices_[pos] = new_index;
1725 ++number_of_active_elements_;
1741 template <
typename V>
1742 auto internal_insert(V&& value
1744 -> std::pair<iterator, bool> {
1745 auto const pos_info = lower_bound_index(value);
1746 auto const do_insert = pos_info.order != strong_ordering::equal;
1750 return {make_iterator(*
this, pos_info.index), do_insert};
1759 auto erase_at_index(index_type index)
noexcept ->
size_type {
1760 if (index < number_of_active_elements_) {
1761 erase_index_range(index, 1U);
1771 auto erase_index_range(index_type from, index_type count_to_erase)
noexcept ->
void {
1772 index_type last_index{
static_cast<index_type
>(from + count_to_erase)};
1773 for (index_type index{from}; index < last_index; ++index) {
1777 indices_.begin() + from,
1778 indices_.begin() + last_index,
1779 indices_.begin() + number_of_active_elements_
1781 number_of_active_elements_ =
static_cast<index_type
>(number_of_active_elements_ - (last_index - from));
1806 auto const clear_on_exit = clear_on_scope_exit(source);
1808 return {{move_value(source.values_[Indices])...}};
1822 auto const clear_on_exit = clear_on_scope_exit(source);
1823 return {{move_value(source.entry_at_index(inline_set_detail::set_passkey{}, Indices))...}};
1832 template <std::
size_t OtherCapacity>
1835 [&source]()
noexcept { source.clear(); }
1847 auto reset_trailing_values_on_scope_exit(index_type end_index)
noexcept ->
decltype(
auto) {
1849 for (index_type idx = this->number_of_active_elements_; idx < end_index; ++idx) {
1850 this->
entry_at_index(inline_set_detail::set_passkey{}, idx).reset();
1867 template <
typename OtherSet>
1868 void do_copy(OtherSet
const& other
1870 do_assignment(other);
1885 template <
typename OtherSet>
1886 void do_move(OtherSet&& other
1889 auto const clear_on_exit = clear_on_scope_exit(other);
1908 template <
typename OtherSet>
1909 void do_assignment(OtherSet&& other)
noexcept(
1914 auto const reset_trailing_values = reset_trailing_values_on_scope_exit(number_of_active_elements_);
1916 number_of_active_elements_ = 0U;
1917 while (number_of_active_elements_ != other.
size()) {
1918 this->
entry_at_index(inline_set_detail::set_passkey{}, number_of_active_elements_)
1920 *other.
entry_at_index(inline_set_detail::set_passkey{}, number_of_active_elements_)
1922 ++number_of_active_elements_;
1935template <
typename T, std::
size_t Capacity,
typename Compare>
1939template <
typename T, std::
size_t Capacity,
typename Compare>
Provides a backport of C++17's constexpr std::advance.
A fixed-size array of T objects.
Definition array.hpp:77
constexpr generic_ordering_from_three_way_compare() noexcept=default
A non-allocating fixed-capacity associative container storing elements of type Value .
Definition set.hpp:111
auto find(OtherKey const &value) noexcept(comparison_is_noexcept< OtherKey >) -> iterator
Obtain an iterator referring to the element equivalent to the supplied value, if there is one.
Definition set.hpp:1003
auto insert(Value &&value_to_insert) noexcept(comparison_is_noexcept<> &&std::is_nothrow_move_constructible< Value >::value) -> std::pair< iterator, bool >
Attempt to insert an element into the set.
Definition set.hpp:1211
auto crbegin() const noexcept -> const_reverse_iterator
Obtain an iterator referring to the beginning of a reversed traversal of the sorted range of elements...
Definition set.hpp:1294
Compare key_compare
The type of the comparator for the key.
Definition set.hpp:365
auto cbegin() const noexcept -> const_iterator
Obtain an iterator referring to the beginning of the sorted range of elements.
Definition set.hpp:1280
auto lower_bound(OtherKey const &value) const noexcept(comparison_is_noexcept< OtherKey >) -> const_iterator
Find the first element which is not less than a given value.
Definition set.hpp:1090
auto operator=(deleted_copy_assign_source const &other) -> inline_set &=delete
Deleted copy-assignment operator where the set is not copy-assignable.
value_type const * const_pointer
A pointer to a const value.
Definition set.hpp:375
Value key_type
The type of the key in the set, which is the same as the value.
Definition set.hpp:360
inline_set(inline_set< Value, OtherCapacity, Compare > &&other)
move construct from a set with a larger capacity
Definition set.hpp:731
auto emplace(ArgTypes &&... args) -> std::pair< iterator, bool >
Construct a new element from the specified initialization arguments, and then attempt to insert it.
Definition set.hpp:1318
static ARENE_NODISCARD auto try_construct(std::initializer_list< Value > init) noexcept(noexcept(inline_set{init}) &&std::is_nothrow_move_constructible< inline_set >::value) -> optional< inline_set >
Attempt to construct a set from the specified list of values.
Definition set.hpp:469
void insert(std::initializer_list< Value > init)
Attempt to insert the elements in the provided initializer list into the set.
Definition set.hpp:1272
Value value_type
The type of the value in the set.
Definition set.hpp:350
::arene::base::reverse_iterator< iterator > reverse_iterator
A reverse iterator for the set.
Definition set.hpp:410
auto erase(Value const &value_to_erase) noexcept(comparison_is_noexcept<>) -> size_type
Erase any elements with a value equivalent to the supplied element.
Definition set.hpp:1347
auto upper_bound(OtherKey const &value) noexcept(comparison_is_noexcept< OtherKey >) -> iterator
Find the first element which is greater than a given value.
Definition set.hpp:1119
static ARENE_NODISCARD auto try_construct(inline_set< Value, OtherCapacity, Compare > &&other) noexcept(noexcept(inline_set{other})) -> optional< inline_set >
Attempts to construct a set via move-construction from a set with a larger capacity.
Definition set.hpp:789
Compare value_compare
The type of the comparator for the value.
Definition set.hpp:355
inline_set()=default
Construct a set with no elements and a default-constructed comparator.
auto count(OtherKey const &value) const noexcept(comparison_is_noexcept< OtherKey >) -> std::size_t
Return the number of elements in the set equivalent to a specific value.
Definition set.hpp:1051
static ARENE_NODISCARD auto try_construct(Iterator first, Iterator last, Compare const &comp) noexcept(noexcept(inline_set{first, last, comp}) &&std::is_nothrow_move_constructible< inline_set >::value) -> optional< inline_set >
Attempt to construct a set from the specified sequence of values and a comparator.
Definition set.hpp:596
std::ptrdiff_t difference_type
The type of the difference between two iterators.
Definition set.hpp:395
static constexpr std::integral_constant< size_type, Capacity > capacity
The maximum number of elements that can be held in the set.
Definition set.hpp:957
static constexpr std::integral_constant< size_type, Capacity > max_size
Get the maximum number of elements in the set.
Definition set.hpp:966
auto insert(Value const &value_to_insert) noexcept(comparison_is_noexcept<> &&std::is_nothrow_copy_constructible< Value >::value) -> std::pair< iterator, bool >
Attempt to insert an element into the set.
Definition set.hpp:1192
auto lower_bound(Value const &value_to_find) const noexcept(comparison_is_noexcept<>) -> const_iterator
Find the first element which is not less than a given value.
Definition set.hpp:1068
auto rbegin() const noexcept -> const_reverse_iterator
Obtain an iterator referring to the beginning of a reversed traversal of the sorted range of elements...
Definition set.hpp:1291
ARENE_NODISCARD auto empty() const noexcept -> bool
Check if the set is empty.
Definition set.hpp:946
auto find(Value const &value_to_find) noexcept(comparison_is_noexcept<>) -> iterator
Obtain an iterator referring to the element equivalent to the supplied value, if there is one.
Definition set.hpp:986
auto count(Value const &value_to_count) const noexcept(comparison_is_noexcept<>) -> std::size_t
Return the number of elements in the set equivalent to a specific value.
Definition set.hpp:1041
auto key_comp() const noexcept(std::is_nothrow_copy_constructible< Compare >::value) -> key_compare
Get the comparator.
Definition set.hpp:972
static ARENE_NODISCARD auto try_construct(std::initializer_list< Value > init, Compare const &comp) noexcept(noexcept(inline_set{init, comp}) &&std::is_nothrow_move_constructible< inline_set >::value) -> optional< inline_set >
Attempt to construct a set from the specified list of values and a comparator.
Definition set.hpp:487
auto erase(iterator first, iterator last) noexcept -> iterator
Erase all the elements referred to be the specified iterator range.
Definition set.hpp:1377
~inline_set()=default
Default destructor; destroys all stored elements.
inline_set(Iterator first, Iterator last) noexcept(std::is_nothrow_constructible< Value, typename std::iterator_traits< Iterator >::reference >::value &&std::is_nothrow_constructible< Compare >::value)
Construct a set from the elements in the provided iterator range.
Definition set.hpp:516
auto crend() const noexcept -> const_reverse_iterator
Obtain an iterator referring to one past the last element in a reversed traversal of the sorted range...
Definition set.hpp:1303
auto erase(OtherKey const &value) noexcept(comparison_is_noexcept< OtherKey >) -> size_type
Erase any elements with a value equivalent to the supplied element.
Definition set.hpp:1356
auto insert(OtherKey &&value) noexcept(comparison_is_noexcept< OtherKey > &&std::is_nothrow_constructible< Value, OtherKey && >::value) -> std::pair< iterator, bool >
Attempt to insert an element into the set.
Definition set.hpp:1237
auto find(Value const &value_to_find) const noexcept(comparison_is_noexcept<>) -> const_iterator
Obtain an iterator referring to the element equivalent to the supplied value, if there is one.
Definition set.hpp:993
static ARENE_NODISCARD auto three_way_compare(inline_set const &lhs, inline_set< Value, OtherCapacity, Compare > const &rhs) noexcept -> strong_ordering
Compares two sets lexicographically .
Definition set.hpp:1428
auto value_comp() const noexcept(std::is_nothrow_copy_constructible< Compare >::value) -> value_compare
Get the comparator.
Definition set.hpp:978
inline_set(inline_set< Value, OtherCapacity, Compare > const &other) noexcept(std::is_nothrow_copy_constructible< Value >::value &&std::is_nothrow_copy_constructible< Compare >::value)
copy construct from a set with a larger capacity
Definition set.hpp:649
auto operator=(deleted_move_assign_source &&) -> inline_set &=delete
The move assignment operator is deleted if move assignment is not supported.
auto operator=(inline_set< Value, OtherCapacity, Compare > &&other) noexcept(std::is_nothrow_move_assignable< inline_set< Value, OtherCapacity, Compare > >::value) -> inline_set &
move-assignment operator from an inline_set with a smaller capacity
Definition set.hpp:937
inline_set(move_construct_source &&other) noexcept(std::is_nothrow_move_constructible< Value >::value &&std::is_nothrow_constructible< Compare >::value)
move ctor
Definition set.hpp:707
inline_set(inline_set const &)=default
copy ctor.
auto cend() const noexcept -> const_iterator
Obtain an iterator referring to one past the last element in the sorted range of elements.
Definition set.hpp:1287
std::size_t size_type
The type of the size of the container.
Definition set.hpp:390
auto begin() const noexcept -> const_iterator
Obtain an iterator referring to the beginning of the sorted range of elements.
Definition set.hpp:1277
auto erase(iterator pos) noexcept -> iterator
Erase the element referred to be the specified iterator.
Definition set.hpp:1364
inline_set(std::initializer_list< Value > init, Compare const &comp) noexcept(std::is_nothrow_copy_constructible< Value >::value &&std::is_nothrow_copy_constructible< Compare >::value)
Construct a set from the specified list of values and a specified comparator instance .
Definition set.hpp:455
auto lower_bound(OtherKey const &value) noexcept(comparison_is_noexcept< OtherKey >) -> iterator
Find the first element which is not less than a given value.
Definition set.hpp:1079
auto rend() const noexcept -> const_reverse_iterator
Obtain an iterator referring to one past the last element in a reversed traversal of the sorted range...
Definition set.hpp:1299
auto entry_at_index(inline_set_detail::set_passkey, index_type index) noexcept -> entry_type &
Gets a reference to the element corrsponding to a given index.
Definition set.hpp:1454
auto equal_range(Value const &value_to_find) noexcept(comparison_is_noexcept<>) -> std::pair< iterator, iterator >
Finds the sequence of values which compare equivalent to a given value.
Definition set.hpp:1140
inline_set(inline_set< Value, OtherCapacity, Compare > const &other) noexcept(std::is_nothrow_copy_constructible< Value >::value &&std::is_nothrow_copy_constructible< Compare >::value)
copy construct from a set with a smaller capacity
Definition set.hpp:627
iterator const_iterator
A const iterator for the set: the same as iterator, since elements are const.
Definition set.hpp:405
auto upper_bound(OtherKey const &value) const noexcept(comparison_is_noexcept< OtherKey >) -> const_iterator
Find the first element which is greater than a given value.
Definition set.hpp:1130
auto contains(OtherKey const &value) const noexcept(comparison_is_noexcept< OtherKey >) -> bool
Check if the set contains a value equivalent to a specific value.
Definition set.hpp:1033
auto find(OtherKey const &value) const noexcept(comparison_is_noexcept< OtherKey >) -> const_iterator
Obtain an iterator referring to the element equivalent to the supplied value, if there is one.
Definition set.hpp:1013
static ARENE_NODISCARD auto try_construct(inline_set< Value, OtherCapacity, Compare > const &other) noexcept(noexcept(inline_set{other})) -> optional< inline_set >
Attempts to construct a set via copy-construction from a set with the same or smaller capacity.
Definition set.hpp:669
void clear() noexcept
Erase all the elements in *this.
Definition set.hpp:1389
value_type const & const_reference
A reference to a const value.
Definition set.hpp:385
auto operator=(inline_set< Value, OtherCapacity, Compare > const &other) noexcept(std::is_nothrow_copy_assignable< inline_set< Value, OtherCapacity, Compare > >::value) -> inline_set &
copy-assignment operator for copying from a set with a smaller capacity
Definition set.hpp:862
inline_set(Compare const &comp) noexcept(std::is_nothrow_copy_constructible< Compare >::value)
Construct a set with no elements, using the specified comparator.
Definition set.hpp:428
auto upper_bound(Value const &value_to_find) noexcept(comparison_is_noexcept<>) -> iterator
Find the first element which is greater than a given value.
Definition set.hpp:1099
iterator_impl iterator
The iterator type for the set.
Definition set.hpp:400
inline_set(inline_set< Value, OtherCapacity, Compare > &&other) noexcept(std::is_nothrow_move_constructible< Value >::value &&std::is_nothrow_move_constructible< Compare >::value)
move construct from a set with a smaller capacity
Definition set.hpp:751
static ARENE_NODISCARD auto try_construct(inline_set< Value, OtherCapacity, Compare > const &other) noexcept(noexcept(inline_set{other})) -> optional< inline_set >
Attempts to construct a set from a set with a larger capacity.
Definition set.hpp:687
auto equal_range(OtherKey const &value) noexcept(comparison_is_noexcept< OtherKey >) -> std::pair< iterator, iterator >
Finds the sequence of values which compare equivalent to a given value.
Definition set.hpp:1162
value_type * pointer
A pointer to the value.
Definition set.hpp:370
auto upper_bound(Value const &value_to_find) const noexcept(comparison_is_noexcept<>) -> const_iterator
Find the first element which is greater than a given value.
Definition set.hpp:1108
::arene::base::reverse_iterator< const_iterator > const_reverse_iterator
A const reverse iterator for the set.
Definition set.hpp:415
inline_set(Iterator first, Iterator last, Compare const &comp) noexcept(std::is_nothrow_constructible< Value, typename std::iterator_traits< Iterator >::reference >::value &&std::is_nothrow_copy_constructible< Compare >::value)
Construct a set from the elements in the provided iterator range and comparator.
Definition set.hpp:543
auto equal_range(OtherKey const &value) const noexcept(comparison_is_noexcept< OtherKey >) -> std::pair< const_iterator, const_iterator >
Finds the sequence of values which compare equivalent to a given value.
Definition set.hpp:1174
auto operator=(copy_assign_source const &other) noexcept(std::is_nothrow_copy_constructible< Value >::value &&std::is_nothrow_copy_assignable< Compare >::value) -> inline_set &
copy-assignment operator.
Definition set.hpp:812
auto equal_range(Value const &value_to_find) const noexcept(comparison_is_noexcept<>) -> std::pair< const_iterator, const_iterator >
Finds the sequence of values which compare equivalent to a given value.
Definition set.hpp:1149
auto contains(Value const &value_to_check) const noexcept(comparison_is_noexcept<>) -> bool
Check if the set contains a specific value.
Definition set.hpp:1022
auto operator=(move_assign_source &&other) noexcept(std::is_nothrow_move_constructible< Value >::value &&std::is_nothrow_move_assignable< Compare >::value) -> inline_set &
move-assignment operator
Definition set.hpp:886
auto lower_bound(Value const &value_to_find) noexcept(comparison_is_noexcept<>) -> iterator
Find the first element which is not less than a given value.
Definition set.hpp:1060
auto end() const noexcept -> const_iterator
Obtain an iterator referring to one past the last element in the sorted range of elements.
Definition set.hpp:1284
auto get_comparator_base(inline_set_detail::set_passkey) noexcept -> comparator_base &
Get the comparator base.
Definition set.hpp:1438
auto size() const noexcept -> std::size_t
Get the number of elements in the set.
Definition set.hpp:950
static ARENE_NODISCARD auto try_construct(inline_set< Value, OtherCapacity, Compare > &&other) noexcept(noexcept(inline_set{std::move(other)})) -> optional< inline_set >
Attempts to construct a set via move-construction from a set with a capacity that is less than or equ...
Definition set.hpp:771
auto entry_at_index(inline_set_detail::set_passkey, index_type index) const noexcept -> entry_type const &
Gets a reference to the element corrsponding to a given index.
Definition set.hpp:1465
static ARENE_NODISCARD auto try_construct(Iterator first, Iterator last) noexcept(noexcept(inline_set{first, last}) &&std::is_nothrow_move_constructible< inline_set >::value) -> optional< inline_set >
Attempt to construct a set from the specified sequence of values.
Definition set.hpp:568
auto get_comparator_base(inline_set_detail::set_passkey) const noexcept -> comparator_base const &
Get the comparator base.
Definition set.hpp:1445
void insert(Iterator first, Iterator last) noexcept(std::is_nothrow_constructible< Value, >::value)
Insert all the elements in the provided iterator range into the set, if there are not already equival...
Definition set.hpp:1258
value_type & reference
A reference to a value.
Definition set.hpp:380
inline_set(std::initializer_list< Value > init) noexcept(std::is_nothrow_copy_constructible< Value >::value &&std::is_nothrow_constructible< Compare >::value)
Construct a set from the specified list of values.
Definition set.hpp:440
static ARENE_NODISCARD auto fast_inequality_check(inline_set const &lhs, inline_set< Value, OtherCapacity, Compare > const &rhs) noexcept -> inequality_heuristic
Fast inequality heuristic to shortcut on different sized containers.
Definition set.hpp:1401
A special dummy class that cannot be constructed. It can be used as a substitute argument for copy/mo...
Definition non_constructible_dummy.hpp:16
A simple class that resets an optional value in its destructor, unless dismissed.
Definition optional_resetter.hpp:29
Implementation of std::optional for pre-C++17 compilers, and which replaces defined undefined behavio...
Definition optional.hpp:122
A backport of the constexpr std::reverse_iterator from C++17.
Definition reverse_iterator.hpp:188
An empty tag type corresponding to a bidirectional iterator.
Definition iterator_tags.hpp:25
Implementation of std::initializer_list for brace initialization.
Definition initializer_list.hpp:21
constexpr auto end() const noexcept -> iterator
Get a pointer to one-past-the-last element.
Definition initializer_list.hpp:51
constexpr auto begin() const noexcept -> iterator
Get a pointer to the first element.
Definition initializer_list.hpp:46
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
static constexpr value_type value
Definition integral_constant.hpp:34
Type trait to detect if a type is constructible from arguments of the specified types.
Definition is_constructible.hpp:29
Type trait to detect if an instance of T is copy assignable.
Definition is_copy_assignable.hpp:59
Type trait to detect if an instance of T is copy constructible.
Definition is_copy_constructible.hpp:60
Type trait to detect if an instance of T is move assignable.
Definition is_move_assignable.hpp:60
Type trait to detect if a type is constructible from arguments of the specified types and is noexcept...
Definition is_constructible.hpp:84
Type trait to detect if an instance of T is copy assignable without throwing.
Definition is_copy_assignable.hpp:69
Type trait to detect if an instance of T is move assignable without throwing.
Definition is_move_assignable.hpp:70
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Provides the decays_to_v<T, U> trait.
Implementation of a backport of std::forward_like.
Provides backports of std::in_place_t, std::in_place_type_t, and std::in_place_index_t from C++17.
Provides implementation of arene::base::is_transparent_comparator_for.
Provides an implementation of a backport of std::lexicographical_compare from C++20.
Definition accumulate.hpp:37
constexpr auto move(InIterator first, InIterator last, OutIterator output) noexcept(noexcept(*first++) &&noexcept(output++) &&//CODEQLFP(EXP52-CPP) CODEQLFP(A5-2-6) noexcept(first !=last) &&//CODEQLFP(A5-2-6) std::is_nothrow_assignable<, typename std::iterator_traits< InIterator >::value_type >::value) -> OutIterator
Moves the elements in the range [first, last), to another range beginning at output,...
Definition move.hpp:46
ARENE_NODISCARD constexpr auto next(Iterator itr, typename std::iterator_traits< Iterator >::difference_type steps=1) noexcept(noexcept(::arene::base::advance(itr, steps))) -> Iterator
Produces the Nth successor (or predecessor if steps is negative) of an iterator.
Definition next.hpp:38
strong_ordering_detail::strong_ordering strong_ordering
The enumeration specifying the result of an ordering comparison.
Definition strong_ordering.hpp:147
typename static_if< B >::template then_else< T, F > conditional_t
lazily select between two types based on a boolean condition
Definition conditional.hpp:28
three_way_compare_detail::compare_three_way compare_three_way
Function object that does a three-way comparison between operands, equivalent to std::compare_three_w...
Definition compare_three_way.hpp:214
constexpr bool is_invocable_r_v
Determine if a functor type is invocable with the specified return and argument types.
conditional_t<(MaxValue<=smallest_integer_for_detail::max_uint8), std::uint8_t, conditional_t<(MaxValue<=smallest_integer_for_detail::max_uint16), std::uint16_t, conditional_t<(MaxValue<=smallest_integer_for_detail::max_uint32), std::uint32_t, std::uint64_t > > > smallest_unsigned_integer_for
Calculates the smallest unsigned integer type that can be used to hold values up to and including Max...
Definition smallest_integer_for.hpp:38
constexpr auto make_subrange(Iterator iterator, Sentinel sentinel) noexcept(std::is_nothrow_move_constructible< Iterator >::value &&//std::is_nothrow_move_constructible< Sentinel >::value) -> make_subrange_detail::iterator_range< Iterator, Sentinel >
Combine an iterator and sentinel into a range type that can be used with range-based for loops.
Definition make_subrange.hpp:98
ARENE_NODISCARD auto on_scope_exit(CallableType &&func) noexcept(std::is_nothrow_constructible< remove_cvref_t< CallableType >, CallableType >::value) -> scope_guard< remove_cvref_t< CallableType > >
Declarative helper for constructing scope_guard instances.
Definition scope_guard.hpp:122
constexpr bool is_transparent_three_way_comparator_for_v
Trait to determine if a given type is a transparent comparator that performs a three-way comparison f...
constexpr auto forward_like
A backport of C++23's std::forward_like, which allows forwarding a type with the same reference and c...
constexpr bool is_transparent_comparator_for_v
Trait to determine if a given type is a transparent comparator for a given set of operands.
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
inequality_heuristic
An enumeration used for the return value of fast_inequality_check functions to indicate if two values...
Definition operators.hpp:696
@ may_be_equal_or_not_equal
The values checked may or may not be equal to each other; a more detailed check is required.
Definition operators.hpp:700
@ definitely_not_equal
The two values checked are definitely not equal to each other.
Definition operators.hpp:698
Definition accumulate.hpp:36
::ptrdiff_t ptrdiff_t
A type suitable for holding the difference between two pointers.
Definition cstddef.hpp:31
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
constexpr auto make_pair(T1 &&first, T2 &&second) noexcept(is_nothrow_constructible_v< pair_detail::deduced_pair_type_t< T1, T2 >, T1, T2 >) -> pair_detail::deduced_pair_type_t< T1, T2 >
Creates a std::pair object, deducing the target type from the types of arguments.
Definition pair.hpp:611
integer_sequence< size_t, Ints... > index_sequence
A helper alias template for integer_sequence<size_t, Ints>
Definition integer_sequence.hpp:218
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
static constexpr auto const & ignore
An object to which anything can be assigned, which ignores the assigned value.
Definition ignore.hpp:72
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24
#define ARENE_NODISCARD
An alias for [[nodiscard]] , or a no-op if the attribute is not supported.
Definition nodiscard.hpp:26
Provides a backport of the constexpr implementation of std::reverse_iterator .