5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_VECTOR_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_VECTOR_HPP_
18#include "arene/base/detail/exceptions.hpp"
19#include "arene/base/detail/wrapped_iterator.hpp"
20#include "arene/base/inline_container/detail/unsafe_element_storage.hpp"
27#include "arene/base/stdlib_choice/cstddef.hpp"
28#include "arene/base/stdlib_choice/enable_if.hpp"
29#include "arene/base/stdlib_choice/forward.hpp"
30#include "arene/base/stdlib_choice/initializer_list.hpp"
31#include "arene/base/stdlib_choice/integral_constant.hpp"
32#include "arene/base/stdlib_choice/is_assignable.hpp"
33#include "arene/base/stdlib_choice/is_constructible.hpp"
34#include "arene/base/stdlib_choice/is_copy_assignable.hpp"
35#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
36#include "arene/base/stdlib_choice/is_default_constructible.hpp"
37#include "arene/base/stdlib_choice/is_destructible.hpp"
38#include "arene/base/stdlib_choice/is_move_assignable.hpp"
39#include "arene/base/stdlib_choice/is_move_constructible.hpp"
40#include "arene/base/stdlib_choice/is_same.hpp"
41#include "arene/base/stdlib_choice/iterator_traits.hpp"
42#include "arene/base/stdlib_choice/min_value_overload.hpp"
43#include "arene/base/stdlib_choice/move.hpp"
44#include "arene/base/stdlib_choice/move_iterator.hpp"
81template <
typename T, std::
size_t Capacity>
84namespace inline_vector_detail {
91 class iterator_passkey {
94 constexpr explicit iterator_passkey() noexcept = default;
101 using size_type = std::
size_t;
103 using value_type = T;
105 using reference = value_type&;
107 using const_reference = value_type const&;
109 using pointer = value_type*;
111 using const_pointer = value_type const*;
113 using iterator = ::arene::base::detail::wrapped_iterator<pointer, iterator_passkey>;
115 using const_iterator = ::arene::base::detail::wrapped_iterator<const_pointer, iterator_passkey>;
117 using reverse_iterator = ::arene::base::reverse_iterator<iterator>;
119 using const_reverse_iterator = ::arene::base::reverse_iterator<const_iterator>;
121 using difference_type = typename iterator::difference_type;
130constexpr
bool allow_constexpr_vector_v =
131 std::is_trivially_default_constructible<T>::value && std::is_trivially_move_assignable<T>::value;
137template <typename T, std::
size_t Capacity,
bool = std::is_trivially_destructible<T>::value>
139class inline_vector_internal_non_constexpr_storage {
142 inline_vector_internal_non_constexpr_storage(inline_vector_internal_non_constexpr_storage
const&) =
delete;
144 inline_vector_internal_non_constexpr_storage(inline_vector_internal_non_constexpr_storage&&) =
delete;
147 auto operator=(inline_vector_internal_non_constexpr_storage
const&)
148 -> inline_vector_internal_non_constexpr_storage& =
delete;
150 auto operator=(inline_vector_internal_non_constexpr_storage&&)
151 -> inline_vector_internal_non_constexpr_storage& =
delete;
160 using value_type = T;
164 constexpr inline_vector_internal_non_constexpr_storage() =
default;
168 ~inline_vector_internal_non_constexpr_storage() {
170 for (
auto& value : values()) {
179 constexpr auto values() noexcept -> span<value_type> {
182 return {&values_.front().object,
std::min(size_, Capacity)};
187 constexpr auto values() const noexcept -> span<value_type const> {
190 return {&values_.front().object,
std::min(size_, Capacity)};
195 constexpr void shrink_to(size_type new_size)
noexcept {
196 if (new_size < this->size_) {
198 for (
auto& value : values().last(size_ - new_size)) {
213 using element_storage = inline_container::detail::unsafe_element_storage<T>;
217 static_assert(
alignof(element_storage) ==
alignof(T),
"Alignment must be the same");
218 static_assert(
sizeof(element_storage) ==
sizeof(T),
"Size must be the same");
225 arene::base::array<element_storage, Capacity> values_{};
236template <
typename T, std::
size_t Capacity>
238class inline_vector_internal_non_constexpr_storage<T, Capacity, true> {
246 using value_type = T;
251 constexpr auto values() noexcept -> span<value_type> {
254 return {&values_.front().object,
std::min(size_, Capacity)};
259 constexpr auto values() const noexcept -> span<value_type const> {
262 return {&values_.front().object,
std::min(size_, Capacity)};
267 constexpr void shrink_to(size_type new_size)
noexcept {
268 if (new_size < this->size_) {
280 using element_storage = inline_container::detail::unsafe_element_storage<T>;
284 static_assert(
alignof(element_storage) ==
alignof(T),
"Alignment must be the same");
285 static_assert(
sizeof(element_storage) ==
sizeof(T),
"Size must be the same");
292 arene::base::array<element_storage, Capacity> values_{};
306template <
typename T, std::
size_t Capacity,
bool = Capacity != 0 && allow_constexpr_vector_v<T>>
308class inline_vector_internal_storage :
public inline_vector_internal_non_constexpr_storage<T, Capacity> {
310 using non_constexpr_storage_base = inline_vector_internal_non_constexpr_storage<T, Capacity>;
315 using copy_constructor_arg =
316 conditional_t<std::is_copy_constructible<T>::value, inline_vector_internal_storage, non_constructible_dummy>;
323 inline_vector_internal_storage,
324 non_constructible_dummy>;
329 using move_constructor_arg =
330 conditional_t<std::is_move_constructible<T>::value, inline_vector_internal_storage, non_constructible_dummy>;
337 inline_vector_internal_storage,
338 non_constructible_dummy>;
343 using size_type =
typename non_constexpr_storage_base::size_type;
347 using value_type =
typename non_constexpr_storage_base::value_type;
352 static constexpr std::integral_constant<std::size_t, Capacity> capacity{};
356 static constexpr std::integral_constant<std::size_t, Capacity> max_size{};
360 constexpr inline_vector_internal_storage() =
default;
368 constexpr inline_vector_internal_storage(copy_constructor_arg
const& other
370 : non_constexpr_storage_base{} {
371 for (
auto& value : other.values()) {
372 internal_emplace_back(value);
386 constexpr inline_vector_internal_storage(move_constructor_arg&& other
388 : non_constexpr_storage_base{} {
389 for (
auto& value : other.values()) {
410 constexpr auto operator=(copy_assignment_arg
const& other
412 -> inline_vector_internal_storage& {
413 if (&other !=
this) {
414 auto our_values = this->values();
415 auto other_values = other.values();
416 inline_vector_internal_storage::size_type idx{0U};
417 for (; (idx < our_values.size()) && (idx < other_values.size()); ++idx) {
418 our_values[idx] = other_values[idx];
420 for (; idx < other_values.size(); ++idx) {
421 internal_emplace_back(other_values[idx]);
423 this->shrink_to(idx);
444 constexpr auto operator=(move_assignment_arg&& other
446 -> inline_vector_internal_storage& {
447 if (&other !=
this) {
448 auto our_values = this->values();
449 auto other_values = other.values();
450 inline_vector_internal_storage::size_type idx{0U};
451 for (; (idx < our_values.size()) && (idx < other_values.size()); ++idx) {
452 our_values[idx] =
std::move(other_values[idx]);
454 for (; idx < other_values.size(); ++idx) {
455 internal_emplace_back(
std::move(other_values[idx]));
457 this->shrink_to(idx);
468 ~inline_vector_internal_storage() =
default;
474 template <
typename... Args>
475 constexpr void internal_emplace_back(Args&&... args)
noexcept(std::is_nothrow_constructible<T, Args...>::value) {
491template <
typename T, std::
size_t Capacity>
492class inline_vector_internal_storage<T, Capacity, true> {
500 using value_type = T;
505 static constexpr std::integral_constant<size_type, Capacity> capacity{};
509 static constexpr std::integral_constant<size_type, Capacity> max_size{};
514 constexpr auto values() noexcept -> span<value_type> {
517 return {&values_.front(),
std::min(size_, Capacity)};
521 constexpr auto values() const noexcept -> span<value_type const> {
524 return {&values_.front(),
std::min(size_, Capacity)};
531 template <
typename... Args>
532 constexpr void internal_emplace_back(Args&&... args)
noexcept(std::is_nothrow_constructible<T, Args...>::value) {
541 constexpr void shrink_to(size_type new_size)
noexcept {
542 if (new_size < size_) {
552 arene::base::array<value_type, Capacity> values_{};
560class inline_vector_internal_storage<T, 0, false> {
568 using value_type = T;
573 static constexpr std::integral_constant<size_type, 0> capacity{};
577 static constexpr std::integral_constant<size_type, 0> max_size{};
582 static constexpr auto values() noexcept -> span<value_type> {
return {}; }
585 template <
typename... Args>
586 static constexpr void internal_emplace_back(Args&&...) noexcept {
591 static constexpr void shrink_to(size_type new_size)
noexcept {
ARENE_PRECONDITION(new_size == 0U); }
594template <
typename T, std::
size_t Capacity,
bool NonEmptyConstexpr>
595constexpr std::integral_constant<std::size_t, Capacity>
596 inline_vector_internal_storage<T, Capacity, NonEmptyConstexpr>::capacity;
598template <
typename T, std::
size_t Capacity,
bool NonEmptyConstexpr>
599constexpr std::integral_constant<std::size_t, Capacity>
600 inline_vector_internal_storage<T, Capacity, NonEmptyConstexpr>::max_size;
602template <
typename T, std::
size_t Capacity>
603constexpr std::integral_constant<std::size_t, Capacity> inline_vector_internal_storage<T, Capacity, true>::capacity;
605template <
typename T, std::
size_t Capacity>
606constexpr std::integral_constant<std::size_t, Capacity> inline_vector_internal_storage<T, Capacity, true>::max_size;
609constexpr std::integral_constant<std::size_t, 0> inline_vector_internal_storage<T, 0, false>::capacity;
612constexpr std::integral_constant<std::size_t, 0> inline_vector_internal_storage<T, 0, false>::max_size;
684template <
typename Storage>
686class vector_interface
687 :
public vector_base<typename Storage::value_type>
688 ,
public detail::mixin_at<vector_interface<Storage>, typename vector_base<typename Storage::value_type>::size_type>
689 ,
protected Storage {
691 using vector_base_type = vector_base<typename Storage::value_type>;
695 using typename vector_base_type::const_iterator;
696 using typename vector_base_type::const_pointer;
697 using typename vector_base_type::const_reference;
698 using typename vector_base_type::const_reverse_iterator;
699 using typename vector_base_type::difference_type;
700 using typename vector_base_type::iterator;
701 using typename vector_base_type::pointer;
702 using typename vector_base_type::reference;
703 using typename vector_base_type::reverse_iterator;
704 using typename vector_base_type::size_type;
705 using typename vector_base_type::value_type;
707 using Storage::capacity;
717 constexpr void do_swap(vector_interface& other
719 auto our_values = this->values();
720 auto other_values = other.values();
721 auto const swap_count =
std::min<>(size(), other.size());
722 for (vector_interface::size_type i{0U}; i < swap_count; ++i) {
725 if (size() < other.size()) {
726 for (vector_interface::size_type i{swap_count}; i < other.size(); ++i) {
727 this->internal_emplace_back(
std::move(other_values[i]));
729 other.shrink_to(swap_count);
731 for (vector_interface::size_type i{swap_count}; i < size(); ++i) {
732 other.internal_emplace_back(
std::move(our_values[i]));
734 this->shrink_to(swap_count);
739 class move_construction_tag {
742 explicit move_construction_tag() =
default;
746 constexpr vector_interface(vector_interface
const&) =
default;
748 constexpr vector_interface(vector_interface&&) =
default;
751 constexpr auto operator=(vector_interface
const&) -> vector_interface& =
default;
753 constexpr auto operator=(vector_interface&&) -> vector_interface& =
default;
757 constexpr vector_interface() noexcept = default;
760 ~vector_interface() = default;
769 typename U = value_type,
771 std::enable_if_t<std::is_same<U, value_type>::value>,
772 std::enable_if_t<std::is_copy_constructible<U>::value>> =
nullptr>
773 constexpr vector_interface(std::initializer_list<value_type> initial_values
774 ) noexcept(std::is_nothrow_copy_constructible<value_type>::value)
775 : vector_interface() {
778 for (
auto& value : initial_values) {
781 this->internal_emplace_back(value);
793 typename U = value_type,
795 std::enable_if_t<std::is_same<U, value_type>::value>,
796 std::enable_if_t<std::is_default_constructible<U>::value>> =
nullptr>
797 constexpr explicit vector_interface(vector_interface::size_type
const count
799 : vector_interface() {
801 for (vector_interface::size_type i{count}; i != 0U; --i) {
802 this->internal_emplace_back();
816 typename U = value_type,
818 std::enable_if_t<std::is_same<U, value_type>::value>,
819 std::enable_if_t<std::is_copy_constructible<U>::value>> =
nullptr>
820 constexpr explicit vector_interface(vector_interface::size_type
const count, value_type
const& source)
noexcept(
823 : vector_interface() {
825 for (vector_interface::size_type i{count}; i != 0U; --i) {
826 this->internal_emplace_back(source);
843 vector_interface(Iterator first, Iterator last)
noexcept(
844 denotes_nothrow_iterable_range_v<Iterator> &&
845 std::is_nothrow_constructible<value_type, typename std::iterator_traits<Iterator>::reference>::value
847 : vector_interface() {
865 std::is_constructible<value_type, typename std::iterator_traits<Iterator>::reference>::value>> =
nullptr>
866 constexpr vector_interface(Iterator first, Iterator last)
noexcept(
867 denotes_nothrow_iterable_range_v<Iterator> &&
868 std::is_nothrow_constructible<value_type, typename std::iterator_traits<Iterator>::reference>::value
870 : vector_interface() {
874 this->internal_emplace_back(
std::forward<
decltype(elem)>(elem));
888 template <
typename SourceContainer>
889 constexpr explicit vector_interface(move_construction_tag, SourceContainer&& other)
noexcept(
892 : vector_interface() {
895 for (
auto& elem : other) {
897 this->internal_emplace_back(
std::move(elem));
907 constexpr auto empty() const noexcept ->
bool {
return size() == 0U; }
912 constexpr auto size() const noexcept -> size_type {
return this->values().size(); }
918 constexpr auto back() noexcept -> reference {
return this->values().back(); }
922 constexpr auto back() const noexcept -> const_reference {
return this->values().back(); }
927 constexpr auto front() noexcept -> reference {
return this->values().front(); }
931 constexpr auto front() const noexcept -> const_reference {
return this->values().front(); }
947 constexpr void assign(Iterator first, Iterator last)
noexcept(
948 denotes_nothrow_iterable_range_v<Iterator> &&
949 std::is_nothrow_constructible<value_type, typename std::iterator_traits<Iterator>::reference>::value &&
950 std::is_nothrow_assignable<value_type&, typename std::iterator_traits<Iterator>::reference>::value
952 auto our_values = this->values();
953 vector_interface::size_type idx{0U};
954 while ((idx < our_values.size()) && (first != last)) {
955 our_values[idx] = *first++;
958 while (first != last) {
962 this->shrink_to(idx);
974 template <
typename Iterator, constra
ints<std::enable_if_t<arene::base::is_forward_iterator_v<Iterator>>> =
nullptr>
975 constexpr void assign(Iterator
const first, Iterator
const last)
noexcept(
976 denotes_nothrow_iterable_range_v<Iterator> &&
977 std::is_nothrow_constructible<value_type, typename std::iterator_traits<Iterator>::reference>::value &&
978 std::is_nothrow_assignable<value_type&, typename std::iterator_traits<Iterator>::reference>::value
981 auto const source_size =
static_cast<size_type
>(source_distance);
985 Iterator current_source{first};
986 for (
auto& elem_to_overwrite : this->values()) {
988 if (current_source == last) {
991 elem_to_overwrite = *current_source;
997 for (
auto&& source_elem :
make_subrange(current_source, last)) {
998 this->internal_emplace_back(
std::forward<
decltype(source_elem)>(source_elem));
1000 this->shrink_to(source_size);
1008 void assign(std::initializer_list<value_type> source_values)
noexcept(
1011 assign(source_values.begin(), source_values.end());
1020 void assign(size_type count, value_type
const& value)
noexcept(
1024 auto our_values = this->values();
1025 for (vector_interface::size_type i{0U}; (i < our_values.size()) && (i < count); ++i) {
1026 our_values[i] = value;
1028 resize(count, value);
1037 while (size() < count) {
1038 this->internal_emplace_back();
1040 this->shrink_to(count);
1049 constexpr void resize(size_type count, value_type
const& value)
noexcept(
1053 while (size() < count) {
1054 this->internal_emplace_back(value);
1056 this->shrink_to(count);
1065 this->internal_emplace_back(value);
1074 this->internal_emplace_back(
std::move(value));
1083 template <
typename... Args>
1084 constexpr auto emplace_back(Args&&... args)
noexcept(std::is_nothrow_constructible<value_type, Args&&...>::value)
1092 constexpr void clear() noexcept { this->shrink_to(size_type{}); }
1096 constexpr auto data() noexcept -> pointer {
return this->values().data(); }
1100 constexpr auto data() const noexcept -> const_pointer {
return this->values().data(); }
1107 constexpr auto operator[](size_type index)
noexcept -> reference {
return this->values()[index]; }
1113 constexpr auto operator[](size_type index)
const noexcept -> const_reference {
return this->values()[index]; }
1119 constexpr auto begin() noexcept -> iterator {
1120 return {
typename vector_base_type::iterator_passkey{}, this->values().begin().base()};
1124 constexpr auto end() noexcept -> iterator {
1125 return {
typename vector_base_type::iterator_passkey{}, this->values().end().base()};
1132 constexpr auto begin() const noexcept -> const_iterator {
return cbegin(); }
1138 constexpr auto end() const noexcept -> const_iterator {
return cend(); }
1143 constexpr auto cbegin() const noexcept -> const_iterator {
1144 return {
typename vector_base_type::iterator_passkey{}, this->values().cbegin().base()};
1148 constexpr auto cend() const noexcept -> const_iterator {
1149 return {
typename vector_base_type::iterator_passkey{}, this->values().cend().base()};
1154 constexpr auto rbegin() noexcept -> reverse_iterator {
return reverse_iterator(
end()); }
1157 constexpr auto rend() noexcept -> reverse_iterator {
return reverse_iterator(
begin()); }
1161 constexpr auto rbegin() const noexcept -> const_reverse_iterator {
return crbegin(); }
1164 constexpr auto rend() const noexcept -> const_reverse_iterator {
return crend(); }
1168 constexpr auto crbegin() const noexcept -> const_reverse_iterator {
return const_reverse_iterator(
cend()); }
1171 constexpr auto crend() const noexcept -> const_reverse_iterator {
return const_reverse_iterator(
cbegin()); }
1182 constexpr auto insert(const_iterator pos, value_type&& value)
noexcept(
1185 return internal_insert(pos, 1U,
std::move(value));
1195 constexpr auto insert(const_iterator pos, value_type
const& value)
noexcept(
1199 return internal_insert(pos, 1U, value);
1210 constexpr auto insert(const_iterator pos, size_type count, value_type
const& value)
noexcept(
1214 return internal_insert(pos, count, value);
1228 typename InputIterator,
1229 constraints<std::enable_if_t<arene::base::is_input_iterator_v<InputIterator>>> =
nullptr>
1230 constexpr auto insert(const_iterator pos, InputIterator first, InputIterator last)
noexcept(
1233 std::is_nothrow_constructible<value_type, typename std::iterator_traits<InputIterator>::reference>::value
1235 return internal_insert(pos, first, last);
1247 template <
typename... Args>
1248 constexpr auto emplace(const_iterator pos, Args&&... args)
noexcept(
1250 std::is_nothrow_constructible<value_type, Args&&...>::value
1262 return erase(pos, pos + 1);
1270 constexpr auto erase(const_iterator first, const_iterator last)
noexcept(
1274 auto count = last - first;
1276 for (
auto next = ncpos + count, endpos =
end();
next != endpos; ++
next) {
1280 this->shrink_to(size() -
static_cast<size_type
>(count));
1286 constexpr void pop_back() noexcept {
1288 this->shrink_to(size() - size_type{1U});
1294 constexpr auto free_space() const noexcept -> std::
size_t {
return this->capacity() - size(); }
1305 template <
typename Source>
1306 constexpr auto internal_do_insert(const_iterator pos, size_type count, Source source) -> iterator {
1310 vector_interface::iterator original_end{
end()};
1316 for (vector_interface::size_type i{0U}; i < count; ++i) {
1317 this->internal_emplace_back(source.next());
1319 arene::base::rotate(mutable_pos, original_end,
end());
1334 template <
typename Arg>
1335 constexpr auto internal_insert(const_iterator pos, size_type count, Arg&& arg) -> iterator {
1338 class fixed_source {
1343 constexpr explicit fixed_source(Arg& arg) noexcept
1347 return internal_do_insert(pos, count, fixed_source{arg});
1361 constraints<std::enable_if_t<arene::base::is_bidirectional_iterator_v<Iterator>>> =
nullptr>
1362 constexpr auto internal_insert(const_iterator pos, Iterator first, Iterator last) -> iterator {
1365 class iterator_source {
1369 constexpr explicit iterator_source(Iterator base)
1372 constexpr auto next() ->
decltype(*current_) {
return *current_++; }
1374 return internal_do_insert(pos, insert_count, iterator_source{first});
1389 constexpr auto internal_insert(const_iterator pos, Iterator first, Iterator last) -> iterator {
1391 for (; first != last; ++first) {
1392 internal_insert(pos++, 1, *first);
1408template <
typename T,
typename Container>
1409constexpr bool is_inline_vector_of_t_v =
false;
1415template <
typename T, std::
size_t Capacity>
1416constexpr bool is_inline_vector_of_t_v<T, inline_vector<T, Capacity>> =
true;
1427template <
typename T, std::
size_t Capacity>
1429 :
public inline_vector_detail::vector_interface<inline_vector_detail::inline_vector_internal_storage<T, Capacity>>
1435 using interface_base =
1436 inline_vector_detail::vector_interface<inline_vector_detail::inline_vector_internal_storage<T, Capacity>>;
1441 using typename interface_base::const_iterator;
1442 using typename interface_base::const_pointer;
1443 using typename interface_base::const_reference;
1444 using typename interface_base::const_reverse_iterator;
1445 using typename interface_base::difference_type;
1446 using typename interface_base::iterator;
1447 using typename interface_base::pointer;
1448 using typename interface_base::reference;
1449 using typename interface_base::reverse_iterator;
1450 using typename interface_base::size_type;
1451 using typename interface_base::value_type;
1453 using interface_base::assign;
1454 using interface_base::back;
1455 using interface_base::begin;
1456 using interface_base::capacity;
1457 using interface_base::cbegin;
1458 using interface_base::cend;
1459 using interface_base::clear;
1460 using interface_base::crbegin;
1461 using interface_base::crend;
1462 using interface_base::data;
1463 using interface_base::emplace_back;
1464 using interface_base::empty;
1465 using interface_base::end;
1466 using interface_base::erase;
1467 using interface_base::front;
1468 using interface_base::insert;
1469 using interface_base::max_size;
1470 using interface_base::push_back;
1471 using interface_base::rbegin;
1472 using interface_base::rend;
1473 using interface_base::resize;
1474 using interface_base::size;
1475 using interface_base::operator[];
1476 using interface_base::interface_base;
1492 size_type OtherCapacity,
1509 template <
size_type OtherCapacity, constra
ints<std::enable_if_t<OtherCapacity != Capacity>> =
nullptr>
1541 typename InitElement,
1552 if (init_list.size() >
capacity()) {
1555 return {in_place, init_list.begin(), init_list.end()};
1572 if (container.size() >
capacity()) {
1575 return {in_place, container};
1591 if (container.size() >
capacity()) {
1613 return {in_place, count};
1633 return {in_place, count, source};
1658 return {in_place, first, last};
1683 if (res->size() == interface_base::capacity()) {
1686 res->internal_emplace_back(elem);
1700 this->assign(source_values);
1711 size_type OtherCapacity,
1719 this->assign(other.begin(), other.end());
1731 template <
size_type OtherCapacity, constra
ints<std::enable_if_t<OtherCapacity != Capacity>> =
nullptr>
1752 template <
typename U = value_type, constra
ints<std::enable_if_t<is_swappable_v<U>>> =
nullptr>
1755 this->do_swap(other);
1770 template <
typename U = value_type, constra
ints<std::enable_if_t<is_swappable_v<U>>> =
nullptr>
1787 template <
typename U = value_type, constra
ints<std::enable_if_t<is_equality_comparable_v<U>>> =
nullptr>
1789 return ::arene::base::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
1803 template <
typename U = value_type, constra
ints<std::enable_if_t<is_less_than_comparable_v<U>>> =
nullptr>
1805 return ::arene::base::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
constexpr full_ordering_operators_from_less_than_and_equals() noexcept=default
A container similar to std::vector<T> that has a fixed capacity. The storage for the elements is held...
Definition vector.hpp:1430
static constexpr auto try_construct() noexcept -> optional< inline_vector >
Default construct a vector.
Definition vector.hpp:1530
static constexpr auto try_construct(Container const &container) noexcept(std::is_nothrow_constructible< inline_vector, Container const & >::value) -> optional< inline_vector >
Construct a vector initialized with the specified paramters.
Definition vector.hpp:1570
static constexpr auto try_construct(size_type count, T const &source) noexcept(std::is_nothrow_copy_constructible< T >::value) -> optional< inline_vector >
Construct a vector with the specified number of elements copied from the provided source.
Definition vector.hpp:1627
constexpr auto operator=(inline_vector &&) -> inline_vector &=default
Default move assignment.
constexpr inline_vector(inline_vector &&)=default
Default move constructor.
constexpr inline_vector(inline_vector< T, OtherCapacity > &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
Move construct from a vector with a different capacity.
Definition vector.hpp:1510
static constexpr auto try_construct(Container &&container) noexcept(std::is_nothrow_constructible< inline_vector, Container && >::value) -> optional< inline_vector >
Construct a vector initialized with the specified paramters.
Definition vector.hpp:1589
constexpr void swap(inline_vector &other) noexcept(is_nothrow_swappable_v< value_type > &&std::is_nothrow_move_constructible< value_type >::value)
swaps all the elements between this vector and another.
Definition vector.hpp:1753
constexpr inline_vector(inline_vector const &)=default
Default copy constructor.
constexpr inline_vector(inline_vector< T, OtherCapacity > const &other) noexcept(std::is_nothrow_copy_constructible< T >::value)
Copy construct from a vector with a different capacity.
Definition vector.hpp:1498
static constexpr auto try_construct(std::initializer_list< InitElement > const &init_list) noexcept(std::is_nothrow_constructible< inline_vector, typename std::initializer_list< InitElement >::const_iterator, typename std::initializer_list< InitElement >::const_iterator >::value) -> optional< inline_vector >
Construct a vector initialized with the specified parameters.
Definition vector.hpp:1546
auto operator=(inline_vector< U, OtherCapacity > const &other) noexcept(std::is_nothrow_copy_constructible< U >::value &&std::is_nothrow_copy_assignable< U >::value) -> inline_vector &
Copy-assign to the vector from the elements of a vector with a different capacity....
Definition vector.hpp:1716
friend constexpr auto operator==(inline_vector const &lhs, inline_vector const &rhs) noexcept -> bool
Compare two vectors for equality.
Definition vector.hpp:1788
constexpr inline_vector()=default
Construct an empty vector.
friend constexpr auto operator<(inline_vector const &lhs, inline_vector const &rhs) noexcept -> bool
Compare two vectors for lexicographical ordering.
Definition vector.hpp:1804
auto operator=(std::initializer_list< T > source_values) noexcept(std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_copy_assignable< T >::value) -> inline_vector &
Assign to the vector from the elements of an initializer list. Assigns over existing elements,...
Definition vector.hpp:1697
static constexpr auto try_construct(size_type count) noexcept(std::is_nothrow_default_constructible< T >::value) -> optional< inline_vector >
Construct a vector with the specified number of default-constructed elements.
Definition vector.hpp:1608
~inline_vector()=default
Default destructor.
static constexpr auto try_construct(Iterator first, Iterator last) noexcept(denotes_nothrow_iterable_range_v< Iterator > &&std::is_nothrow_constructible< T, typename std::iterator_traits< Iterator >::reference >::value) -> optional< inline_vector >
Construct a vector from a bidrectional iterator range.
Definition vector.hpp:1651
auto operator=(inline_vector< T, OtherCapacity > &&other) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value) -> inline_vector &
Move-assign to the vector from the elements of a vector with a different capacity....
Definition vector.hpp:1732
friend constexpr void swap(inline_vector &lhs, inline_vector &rhs) noexcept(noexcept(lhs.swap(rhs)))
swaps all the elements between two vectors.
Definition vector.hpp:1771
constexpr auto operator=(inline_vector const &) -> inline_vector &=default
Default copy assignment.
Implementation of std::optional for pre-C++17 compilers, and which replaces defined undefined behavio...
Definition optional.hpp:122
Implementation of std::initializer_list for brace initialization.
Definition initializer_list.hpp:21
iterator const_iterator
The type of the iterator.
Definition initializer_list.hpp:32
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 a type is constructible from arguments of the specified types and is noexcept...
Definition is_constructible.hpp:84
#define ARENE_INVARIANT_UNREACHABLE(message)
Terminate the application if this line is ever executed. The supplied message will be output in that ...
Definition contract.hpp:170
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Provides implementation of a backport of C++20's version of std::equal.
Provides backports of std::in_place_t, std::in_place_type_t, and std::in_place_index_t from C++17.
Provides an implementation of a backport of std::lexicographical_compare from C++20.
static ARENE_MAYBE_UNUSED constexpr auto const & swap
A Customization Point Object implementation of the constexpr compatible std::swap from C++17.
Definition swap.hpp:130
constexpr auto empty() -> bool
Get whether the type list is empty.
Definition size.hpp:111
Definition accumulate.hpp:37
constexpr bool is_nothrow_swappable_v
Trait query indicating if a type can be noexcept-swapped.
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
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
constexpr auto distance(Iterator first, Iterator last) noexcept(noexcept(distance_impl::do_distance(first, last, typename std::iterator_traits< Iterator >::iterator_category{}))) -> typename std::iterator_traits< Iterator >::difference_type
Find the number of elements between first and last.
Definition distance.hpp:79
constexpr bool denotes_nothrow_iterable_range_v
Check if an iterator/sentinel pair form an iterable range that can be iterated without throwing.
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
constexpr std::integral_constant< typename inline_map< Key, Value, Capacity, Compare >::size_type, Capacity > inline_map< Key, Value, Capacity, Compare >::capacity
Definition map.hpp:2305
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
Definition accumulate.hpp:36
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
::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
auto make_move_iterator(Iterator iter) -> std::move_iterator< Iterator >
Create a move_iterator with the specified underlying iterator.
Definition move_iterator.hpp:353
constexpr auto end(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the one-past-the-end element of the array.
Definition end.hpp:28
constexpr auto min(initializer_list< T > list, Compare comp) noexcept(noexcept(comp(std::declval< T & >(), std::declval< T & >())) &&std::is_nothrow_copy_constructible_v< T >) -> T
Returns the smallest value in the std::initializer_list.
Definition min_initializer_list_overload.hpp:50
constexpr auto cend(Container const &cont) noexcept(noexcept(::std::end(std::declval< Container const & >()))) ->
Equivalent to invoking end(cont) on a const container.
Definition end.hpp:66
constexpr auto begin(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the first element of the array.
Definition begin.hpp:28
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
constexpr auto cbegin(Container const &cont) noexcept(noexcept(::std::begin(std::declval< Container const & >()))) ->
Equivalent to invoking begin(cont) on a const container.
Definition begin.hpp:64
Provides a backport of the constexpr implementation of std::reverse_iterator .