Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
map.hpp
Go to the documentation of this file.
1// parasoft-begin-suppress AUTOSAR-A2_8_1-a-2 AUTOSAR-A8_4_2-a CERT_C-MSC37-a CERT_CPP-MSC52-a
2// "inline_container/map.hpp is clear enough for inline_map and
3// ARENE_PRECONDITION terminates, so does not need a return"
4
5// Copyright 2024, Toyota Motor Corporation
6//
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8
9#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_MAP_HPP_
10#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_MAP_HPP_
11
12// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
13#include "arene/base/algorithm/equal.hpp"
14#include "arene/base/algorithm/lexicographical_compare.hpp"
15#include "arene/base/algorithm/rotate.hpp"
16#include "arene/base/array/array.hpp"
17#include "arene/base/compare/compare_three_way.hpp"
18#include "arene/base/compare/operators.hpp"
19#include "arene/base/compare/strong_ordering.hpp"
20#include "arene/base/compiler_support/attributes.hpp"
21#include "arene/base/constraints/constraints.hpp"
22#include "arene/base/contracts/contract.hpp"
23#include "arene/base/detail/exceptions.hpp"
24#include "arene/base/inline_container/detail/compare.hpp"
25#include "arene/base/inline_container/detail/container_base_type.hpp"
26#include "arene/base/inline_container/detail/iterator_interface.hpp"
27#include "arene/base/inline_container/detail/lower_bound_index.hpp"
28#include "arene/base/integer_sequences/sequential_values.hpp"
29#include "arene/base/iterator/distance.hpp"
30#include "arene/base/iterator/next.hpp"
31#include "arene/base/iterator/reverse_iterator.hpp"
32#include "arene/base/optional/optional.hpp"
33#include "arene/base/optional/optional_resetter.hpp"
34#include "arene/base/stdlib_choice/cstddef.hpp"
35#include "arene/base/stdlib_choice/cstdint.hpp"
36#include "arene/base/stdlib_choice/enable_if.hpp"
37#include "arene/base/stdlib_choice/forward.hpp"
38#include "arene/base/stdlib_choice/ignore.hpp"
39#include "arene/base/stdlib_choice/initializer_list.hpp"
40#include "arene/base/stdlib_choice/integer_sequence.hpp"
41#include "arene/base/stdlib_choice/integral_constant.hpp"
42#include "arene/base/stdlib_choice/is_assignable.hpp"
43#include "arene/base/stdlib_choice/is_const.hpp"
44#include "arene/base/stdlib_choice/is_constructible.hpp"
45#include "arene/base/stdlib_choice/is_copy_assignable.hpp"
46#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
47#include "arene/base/stdlib_choice/is_default_constructible.hpp"
48#include "arene/base/stdlib_choice/is_integral.hpp"
49#include "arene/base/stdlib_choice/is_move_assignable.hpp"
50#include "arene/base/stdlib_choice/is_move_constructible.hpp"
51#include "arene/base/stdlib_choice/is_same.hpp"
52#include "arene/base/stdlib_choice/iterator_tags.hpp"
53#include "arene/base/stdlib_choice/move.hpp"
54#include "arene/base/stdlib_choice/pair.hpp"
55#include "arene/base/stdlib_choice/remove_reference.hpp"
56#include "arene/base/stdlib_choice/tuple.hpp"
57#include "arene/base/type_manipulation/non_constructible_dummy.hpp"
58#include "arene/base/type_manipulation/smallest_integer_for.hpp"
59#include "arene/base/type_traits/comparison_traits.hpp"
60#include "arene/base/type_traits/conditional.hpp"
61#include "arene/base/type_traits/decays_to.hpp"
62#include "arene/base/type_traits/is_instantiation_of.hpp"
63#include "arene/base/type_traits/is_transparent_comparator_for.hpp"
64#include "arene/base/type_traits/remove_cvref.hpp"
65#include "arene/base/utility/forward_like.hpp"
66#include "arene/base/utility/in_place.hpp"
67// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
68
69// parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
70// parasoft-begin-suppress AUTOSAR-M2_10_1-a-2 "Similar names permitted by M2-10-1 Permit #1"
71// parasoft-begin-suppress AUTOSAR-A2_10_1-e-2 "False Positive: A2-10-1 exempts identifiers at class/namespace scope"
72// parasoft-begin-suppress AUTOSAR-A13_5_5-b-2 "Mixed comparisons permitted by A13-5-5 Permit #1"
73// parasoft-begin-suppress AUTOSAR-A7_1_5-a "Trailing return syntax permitted by A7-1-5 Permit #1 v1.0.0"
74
75namespace arene {
76namespace base {
77namespace inline_map_detail {
78
79// parasoft-begin-suppress AUTOSAR-A15_4_5-a "False positive: The exception type that can be thrown is documented."
80/// @brief Implementation helper for conditional disablement of throwing when compiling with @c -fno-exceptions.
81/// @throws @c std::out_of_range if @c detail::are_exceptions_enabled_v is @c true .
82ARENE_NORETURN void throw_out_of_range();
83// parasoft-end-suppress AUTOSAR-A15_4_5-a "False positive: The exception type that can be thrown is documented."
84
85/// @brief base type for @c inline_map, allowing erasure of the @c Capacity value
86/// @tparam Key The key type for the map
87/// @tparam Value The mapped type for the map
88/// @tparam Compare The comparison function
89/// @pre The comparison must provide a strict ordering over the values of @c Key
90///
91template <typename Key, typename Value, typename Compare = compare_three_way>
92class inline_map_base {
93 public:
94 /// @brief key type of the map
95 using key_type = Key;
96 /// @brief mapped type of the map
97 using mapped_type = Value;
98 /// @brief value type of the map
99 using value_type = std::pair<Key const, Value>;
100 /// @brief compare type of the map
101 using compare_type = Compare;
102 /// @brief The size type of the map
103 using size_type = std::size_t;
104};
105
106/// @brief provides private access for the family of types related to an @c inline_map
107/// @tparam MapBase common tag across @c inline_map and related types
108///
109template <class MapBase>
110class inline_map_passkey_base {
111 static_assert(
112 is_instantiation_of_v<MapBase, inline_map_base>,
113 "'MapBase' must be an instantiation of 'inline_map_base'."
114 );
115
116 protected:
117 /// @brief tag type used to limit access to a family of associated types
118 ///
119 class inline_map_passkey {
120 public:
121 /// @brief default constructor
122 ///
123 explicit inline_map_passkey() = default;
124 };
125};
126
127} // namespace inline_map_detail
128
129// parasoft-begin-suppress AUTOSAR-A12_0_1-b-2 "False positive: copy assignment defined or deleted as appropriate"
130// parasoft-begin-suppress AUTOSAR-A12_0_1-a-2 "False positive: copy assignment defined or deleted as appropriate"
131// parasoft-begin-suppress AUTOSAR-A1_1_1-b-2 "False positive: copy assignment defined or deleted as appropriate"
132// parasoft-begin-suppress AUTOSAR-A10_1_1-a-2 "False positive: the ordering base class is empty"
133// parasoft-begin-suppress AUTOSAR-A13_5_1-a-2 "False positive: This follows the std::map interface. The non-const
134// overload inserts a new element in the map if not present; the const overload cannot do that so is not provided"
135/// @brief A container similar to @c std::map that has a fixed capacity.
136///
137/// The storage is held internally in the object. Any attempt to store more than @c Capacity elements will either result
138/// in a precondition failure (and thus process termination), or an error being returned. The comparison function
139/// specified with the @c Compare template parameter can either return @c bool, in which case it is assumed to be a
140/// simple ordering comparison like @c std::less, or it can return @c strong_ordering, in which case it is assumed to be
141/// a three-way comparison operator. The default comparison is @c three_way_compare.
142/// @tparam Key The key type for the map
143/// @tparam Value The mapped type for the map
144/// @tparam Capacity The maximum number of elements that can be stored in the map
145/// @tparam Compare The comparison function
146/// @pre The comparison must provide a strict ordering over the values of @c Key
147template <typename Key, typename Value, std::size_t Capacity, typename Compare = compare_three_way>
148// NOLINTNEXTLINE(hicpp-special-member-functions,cppcoreguidelines-special-member-functions)
150 : public inline_map_detail::inline_map_base<Key, Value, Compare>
151 , inline_map_detail::inline_map_passkey_base<inline_map_detail::inline_map_base<Key, Value, Compare>>
154 // AUTOSAR exceptions:
155 // A11-3-1: Friend declarations shall not be used
156 // The inline_map class template declares other instantiations of the same
157 // template to be friends, so that copy and move operations between maps with
158 // different capacities work nicely.
159 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Friendship allows copy and move between maps with different
160 // capacities"
161 template <typename OtherKey, typename OtherValue, std::size_t OtherCapacity, typename OtherCompare>
162 friend class inline_map;
163 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
164
165 /// @brief helper trait for determining if transparent comparison is supported in a type-dependent context
166 /// @tparam OtherKey Dummy parameter to make this type-dependent as it's used for SFINAE.
167 /// @return bool Equivalent to @c ::arene::base::is_transparent_comparator_v<Compare>
168 template <typename OtherKey>
169 static constexpr bool transparent_comparison_supported{::arene::base::is_transparent_comparator_v<Compare>};
170
171 /// @brief helper trait for determining if transparent insertion is supported in a type-dependent context
172 /// @tparam OtherKey Dummy parameter to make this type-dependent as it's used for SFINAE.
173 /// @return bool Equivalent to @c transparent_comparison_supported<Compare>&&!std::is_integral<Key>::value
174 template <typename OtherKey>
175 static constexpr bool transparent_insertion_supported{
177 };
178
179 /// @brief helper trait for determining if the comparator supports transparent comparisons.
180 /// @tparam OtherKey the type of the other operand to test for validity against.
181 /// @return bool @c true If @c Compare satisfies either @c is_transparent_comparator_for_v or
182 /// @c is_transparent_three_way_comparator_for_v with @c Key and @c OtherKey , else @c false .
183 template <typename OtherKey>
184 static constexpr bool
185 transparent_comparison_supported_for{::arene::base::is_transparent_comparator_for_v<Compare, Key const&, OtherKey const&> || ::arene::base::is_transparent_three_way_comparator_for_v<Compare, Key const&, OtherKey const&>};
186
187 /// @brief The base class that holds the comparator
189
190 /// @brief The base class for ordering
192
193 /// @brief Can comparisons throw?
194 /// @tparam OtherKey The type of the rhs operand to a comparison.
195 /// @return bool alias for @c comparator_base::template comparison_is_noexcept<OtherKey>
196 template <typename OtherKey = Key>
197 static constexpr bool comparison_is_noexcept{comparator_base::template comparison_is_noexcept<OtherKey>};
198
199 /// @brief Base type of this @c inline_map type
200 using map_base_type = inline_map_detail::inline_map_base<Key, Value, Compare>;
201
202 /// @brief The type of an index which is the smallest that can fit @c Capacity .
204
205 /// @brief alias to the passkey type
206 using inline_map_passkey = typename inline_map_detail::inline_map_passkey_base<map_base_type>::inline_map_passkey;
207
208 /// @brief An iterator for a map; if @c IsConst is @c true this is a @c
209 /// const_iterator, otherwise an @c iterator.
210 /// @tparam IsConst Is this a const iterator?
211 template <bool IsConst>
212 class iterator_impl
213 : public inline_container_detail::iterator_interface<iterator_impl<IsConst>>
214 , inline_map_detail::inline_map_passkey_base<map_base_type> {
215 /// @brief Alias for interface base
216 using iterator_interface = inline_container_detail::iterator_interface<iterator_impl>;
217
218 /// @brief alias to the passkey type
219 using inline_map_passkey = typename inline_map_detail::inline_map_passkey_base<map_base_type>::inline_map_passkey;
220
221 /// @brief The type of the associated map: if this is a const iterator, we can use
222 /// a const map
223 using map_type = conditional_t<IsConst, inline_map const, inline_map>;
224 /// @brief Pointer to the referenced map
225 map_type* map_;
226 /// @brief The index of the pointed-to element
227 index_type pos_;
228
229 /// @brief The corresponding non-const iterator
230 using non_const_iterator = iterator_impl<false>;
231 /// @brief The source of an implicit conversion: const iterators can be implicitly
232 /// constructed from non-const iterators
233 using implicit_conversion_type = conditional_t<IsConst, non_const_iterator, non_constructible_dummy>;
234
235 // parasoft-begin-suppress AUTOSAR-A7_1_1-a "Declaring 'iter' as reference to const changes semantics"
236 // parasoft-begin-suppress AUTOSAR-M7_1_2-c "Declaring 'iter' as reference to const changes semantics"
237 // parasoft-begin-suppress AUTOSAR-A8_4_9-a "Declaring 'iter' as reference to const changes semantics"
238
239 // parasoft-begin-suppress AUTOSAR-A11_3_1-a "Use of a friend function with
240 // passkey improves encapsulation. It allows data members to remain private
241 // and does not unnecessarily expose a public member function."
242
243 // parasoft-begin-suppress AUTOSAR-A0_1_3-a "False positive: Function is namespace scope and used in other
244 // translation units"
245
246 /// @brief basis function for increment
247 /// @param iter iterator to increment
248 ///
249 friend auto step_forward(inline_container_detail::iterator_interface_tag, iterator_impl& iter) noexcept -> void {
250 ++iter.pos_;
251 }
252
253 /// @brief basis function for decrement
254 /// @param iter iterator to increment
255 ///
256 friend auto step_backward(inline_container_detail::iterator_interface_tag, iterator_impl& iter) noexcept -> void {
257 --iter.pos_;
258 }
259
260 // parasoft-end-suppress AUTOSAR-A11_3_1-a
261 // parasoft-end-suppress AUTOSAR-A0_1_3-a
262 // parasoft-end-suppress AUTOSAR-A7_1_1-a
263 // parasoft-end-suppress AUTOSAR-M7_1_2-c
264 // parasoft-end-suppress AUTOSAR-A8_4_9-a
265
266 public:
267 /// @brief Default construct an iterator that does not refer to any map element
268 iterator_impl() noexcept
269 : map_(nullptr),
270 pos_(0) {}
271
272 /// @brief Default copy constructor
273 /// @param other The source
274 iterator_impl(iterator_impl const& other) = default;
275 /// @brief Default move constructor
276 /// @param other The source
277 iterator_impl(iterator_impl&& other) = default;
278 /// @brief Default copy assignment
279 /// @param other The source
280 auto operator=(iterator_impl const& other) -> iterator_impl& = default;
281 /// @brief Default move assignment
282 /// @param other The source
283 auto operator=(iterator_impl&& other) -> iterator_impl& = default;
284
285 /// @brief Default destructor
286 ~iterator_impl() = default;
287
288 /// @brief Construct an iterator from a map and a position; only callable from @c
289 /// inline_map members.
290 /// @param map The map
291 /// @param pos The position
292 iterator_impl(inline_map_passkey, map_type* map, index_type pos) noexcept
293 : iterator_interface{},
294 map_(map),
295 pos_(pos) {}
296
297 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
298 // initialize the base class"
299 /// @brief Implicitly convert from a non-const iterator, if this
300 /// is a const iterator.
301 /// @param other The source iterator
302 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
303 iterator_impl(implicit_conversion_type other) noexcept
304 : iterator_impl(
305 inline_map_passkey{},
306 other.get_map(inline_map_passkey{}),
307 other.get_index(inline_map_passkey{})
308 ) {}
309 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
310
311 /// @brief The iterator category
312 using iterator_category = std::bidirectional_iterator_tag;
313 /// @brief The iterator value type
314 using value_type = std::pair<Key const, Value>;
315 /// @brief The iterator difference type
316 using difference_type = std::ptrdiff_t;
317 /// @brief The pointer type
318 using pointer = conditional_t<IsConst, value_type const*, value_type*>;
319 /// @brief The reference type
320 using reference = conditional_t<IsConst, value_type const&, value_type&>;
321
322 /// @brief The associated @c inline_map type
323 using inline_map_type = inline_map;
324
325 // parasoft-begin-suppress AUTOSAR-M9_3_1-a-2 "False positive: It returns a reference to the map element"
326 /// @brief Dereference the iterator
327 /// @return A reference to the referenced element
328 /// @pre The iterator must have been constructed referring to a map, otherwise the behaviour is undefined
329 auto operator*() const noexcept -> reference { return *map_->entry_at_index(pos_); }
330 // parasoft-end-suppress AUTOSAR-M9_3_1-a-2
331
332 // parasoft-begin-suppress AUTOSAR-A11_3_1-a "Hidden friends permitted by A11-3-1 Permit #2 v1.0.0"
333 // parasoft-begin-suppress AUTOSAR-A0_1_3-a "False positive: Function is namespace scope and used in other
334 // translation units"
335
336 /// @brief equality
337 /// @param lhs The first iterator to compare
338 /// @param rhs The second iterator to compare
339 /// @return @c true if @c lhs is equal to @c rhs, otherwise @c false
340 /// @pre The iterators must refer to the same map, otherwise the result is meaningless
341 friend auto operator==(iterator_impl const& lhs, iterator_impl const& rhs) noexcept -> bool {
342 return lhs.pos_ == rhs.pos_;
343 }
344
345 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
346 // parasoft-end-suppress AUTOSAR-A0_1_3-a
347
348 /// @brief Check if this is an iterator for a given map.
349 /// @param map A pointer to the map we are looking for
350 /// @return true If @c this was produced from @c map
351 /// @return false Otherwise.
352 auto is_iterator_for(map_type* map) const noexcept -> bool { return map == map_; }
353
354 /// @brief Get the map this iterator references. Can only be called by members of
355 /// @c inline_map
356 /// @return A pointer to the referenced map
357 auto get_map(inline_map_passkey) const noexcept -> map_type* { return map_; }
358
359 /// @brief Get the position this iterator references within a map. Can only be
360 /// called by members of @c inline_map
361 /// @return The index position of the referenced element
362 auto get_index(inline_map_passkey) const noexcept -> index_type { return pos_; }
363 };
364
365 public:
366 /// @brief The value type of the map
367 using value_type = typename map_base_type::value_type;
368 /// @brief The key type of the map
369 using key_type = typename map_base_type::key_type;
370 /// @brief The mapped type of the map
371 using mapped_type = typename map_base_type::mapped_type;
372 /// @brief The comparator of the map
373 using key_compare = typename map_base_type::compare_type;
374 /// @brief The size type of the map
375 using size_type = typename map_base_type::size_type;
376 /// @brief The type of a pointer to the value type of the map
377 using pointer = value_type*;
378 /// @brief The type of a @c const pointer to the value type of the map
379 using const_pointer = value_type const*;
380 /// @brief The type of a reference to the value type of the map
381 using reference = value_type&;
382 /// @brief The type of a @c const reference to the value type of the map
383 using const_reference = value_type const&;
384
385 /// @brief The type of an iterator that provides non- @c const access to the elements
386 using iterator = iterator_impl<false>;
387 /// @brief The type of an iterator that provides @c const access to the elements
388 using const_iterator = iterator_impl<true>;
389
390 /// @brief The type of an iterator that provides non- @c const access to the elements
391 /// and iterates in reverse through the elements
393 /// @brief The type of an iterator that provides @c const access to the elements
394 /// and iterates in reverse through the elements
396
397 /// @brief The difference type of the map
398 using difference_type = typename iterator::difference_type;
399
400 // parasoft-begin-suppress AUTOSAR-M11_0_1-a-2 "False positive: this is not 'member data', it is a public property"
401 /// @brief map capacity
403 // parasoft-end-suppress AUTOSAR-M11_0_1-a-2
404
405 /// @brief @c inline_map_base type
406 using inline_map_base_type = map_base_type;
407
408 private:
409 /// @brief A type for the source of the copy-assignment operator: if the comparator
410 /// is copy assignable and the values are copy-constructible, then this the
411 /// map is copy-assignable, so this is @c inline_map, otherwise it is @c
412 /// non_constructible_dummy so the copy-assignment operator is deleted.
417
418 /// @brief A type to use for a deleted assignment operator: if the map should not be
419 /// copy-assignable, this is @c inline_map, otherwise @c
420 /// non_constructible_dummy
425
426 /// @brief A type for the source of the move-assignment operator: if the comparator
427 /// is move assignable and the values are move-constructible, then this the
428 /// map is move-assignable, so this is @c inline_map, otherwise it is @c
429 /// non_constructible_dummy so the move-assignment operator is deleted.
434 /// @brief A type to use for a deleted assignment operator: if the map should not be
435 /// move-assignable, this is @c inline_map, otherwise @c
436 /// non_constructible_dummy
441
442 /// @brief A type for the source of the move constructor: if the comparator
443 /// is move constructible and the values are move-constructible, then this the
444 /// map is move-constructible, so this is @c inline_map, otherwise it is @c
445 /// non_constructible_dummy so the move constructor is deleted.
450
451 public:
452 /// @brief Construct an empty map with a default-constructed comparator
453 /// @tparam C The comparator type of the map, used for constraints
454 /// @throws Any exception thrown by the default constructor of the comparator,
455 /// @return optional<inline_map> holding a default-constructed map
456 template <typename C = Compare, constraints<std::enable_if_t<std::is_default_constructible<C>::value>> = nullptr>
461
462 /// @brief Construct a map with a comparator copied from the supplied value
463 /// @tparam C The comparator type of the map, used so this function is not viable if @c Compare cannot be copy
464 /// constructed.
465 /// @param comparator A comparator instance to copy
466 /// @throws Any exception thrown by the copy constructor of the comparator
467 /// @return optional<inline_map> holding a map constructed from the comparator
468 template <typename C = Compare, constraints<std::enable_if_t<std::is_copy_constructible<C>::value>> = nullptr>
473
474 /// @brief Copy construct a map
475 /// @tparam V The value type of the map, used for constraints
476 /// @tparam C The comparator type of the map, used for constraints
477 /// @param other The source container
478 /// @throws Any exception thrown by the copy constructor of the comparator, or the values
479 /// @return optional<inline_map> holding a copy-constructed map
480 template <
481 typename V = value_type,
482 typename C = Compare,
491
492 /// @brief Copy construct a map with a different size
493 /// @tparam OtherCapacity The capacity of the other map
494 /// @tparam V The value_type
495 /// @tparam C The comparator type
496 /// @param other The source map
497 /// @throws Any exception thrown by the copy constructors of the comparator, keys or values
498 /// @return optional<inline_map> holding the copied map, or @c nullopt if there were too many elements
499 template <
501 typename V = value_type,
502 typename C = Compare,
515
516 /// @brief Move construct a map
517 /// @tparam K The key type
518 /// @tparam V The value type
519 /// @tparam C The comparator type of the map, used for constraints
520 /// @param other The source container
521 /// @throws Any exception thrown by the move constructor of the comparator, or the values
522 /// @return optional<inline_map> holding a move-constructed map
523 template <
524 typename K = Key,
525 typename V = Value,
526 typename C = Compare,
537
538 /// @brief Move construct a map with a different size
539 /// @tparam OtherCapacity The capacity of the other map
540 /// @tparam K The key type
541 /// @tparam V The value type
542 /// @tparam C The comparator type
543 /// @param other The source map
544 /// @throws Any exception thrown by the copy constructor of the comparator, or the move constructor of the keys or
545 /// values
546 /// @return optional<inline_map> holding the copied map, or @c nullopt if there were too many elements
547 template <
549 typename K = Key,
550 typename V = Value,
551 typename C = Compare,
566
567 /// @brief Construct a map with a default-constructed comparator and copies of the elements from the provided
568 /// initializer list. If there are too many elements, return an empty @c optional
569 /// @tparam T The value type of the map, used so this function is not viable if @c value_type cannot be copy
570 /// constructed.
571 /// @tparam C The comparator type of the map, used so this function is not viable if @c Compare cannot be default
572 /// constructed.
573 /// @param init_list The initializer list
574 /// @throws Any exception thrown by the default constructor of the comparator,
575 /// the copy constructor of the keys or values, or the comparisons
576 /// @return optional<inline_map> holding a map constructed with the elements from the initializer list, or @c
577 /// nullopt if there were too many elements.
578 template <
579 typename T = value_type,
580 typename C = Compare,
594
595 /// @brief Construct a map with a comparator copied from the supplied value and copies of the elements from the
596 /// provided initializer list. If there are too many elements, return an empty @c optional
597 /// @tparam T The value type of the map, used so this function is not viable if @c value_type cannot be copy
598 /// constructed.
599 /// @tparam C The comparator type of the map, used so this function is not viable if @c Compare cannot be default
600 /// constructed.
601 /// @param init_list The initializer list
602 /// @param comparator A comparator instance to copy
603 /// @throws Any exception thrown by the copy constructor of the comparator,
604 /// the copy constructor of the keys or values, or the comparisons
605 /// @return optional<inline_map> holding a map constructed with the elements from the initializer list, or @c
606 /// nullopt if there were too many elements.
607 template <
608 typename T = value_type,
609 typename C = Compare,
613 ARENE_NODISCARD static auto
624
625 /// @brief Construct the map with a default-constructed comparator and no elements
626 /// @throws Any exception thrown by the default constructor of the comparator
627 inline_map() = default;
628
629 /// @brief Default destructor
630 ~inline_map() = default;
631
632 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
633 // initialize the base class"
634 /// @brief Construct the map with a default-constructed comparator and copies of the elements from the provided
635 /// initializer list
636 /// @tparam T The value type of the map, used so this constructor is not viable if @c value_type cannot be copy
637 /// constructed.
638 /// @tparam C The comparator type of the map, used so this constructor is not viable if @c Compare cannot be default
639 /// constructed.
640 /// @param init_list The initializer list
641 /// @throws Any exception thrown by the default constructor of the comparator,
642 /// the copy constructor of the keys or values, or the comparisons
643 /// @pre There are no more than @c Capacity elements in @c init_list with unique keys, else @c ARENE_PRECONDITION
644 /// violation.
645 template <
646 typename T = value_type,
647 typename C = Compare,
657 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
658
659 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
660 // initialize the base class"
661 /// @brief Construct the map with a copy of the specified comparator and copies of
662 /// the elements from the provided initializer list
663 /// @tparam T The value type of the map, used so this constructor is not
664 /// viable if @c value_type cannot be copy constructed.
665 /// @tparam C The comparator type of the map, used so this constructor is not
666 /// viable if @c Compare cannot be copy constructed.
667 /// @param init_list The initializer list
668 /// @param compare The comparator to copy
669 /// @throws Any exception thrown by the copy-constructor of the comparator,
670 /// the copy constructor of the keys or values, or the comparisons
671 /// @pre There are no more than @c Capacity elements in @c init_list with unique keys, else @c ARENE_PRECONDITION
672 /// violation.
673 template <
674 typename T = Value,
675 typename C = Compare,
685 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
686
687 /// @brief Construct the map with a copy of the specified comparator and no elements.
688 /// @param compare The comparator to copy#
689 /// @throws Any exception thrown by the copy-constructor of the comparator
693
694 /// @brief Copy the source map, so the new map has the same size, comparator and
695 /// elements as the source.
696 /// @param other The instance to be copied.
697 /// @throws Any exception thrown by the copy constructor of the comparator,
698 /// the keys, or values
699 inline_map(inline_map const& other) = default;
700
701 // parasoft-begin-suppress AUTOSAR-A15_5_1-b-2 "False positive: Conditionally noxecept"
702 /// @brief Move the source map into the new instance, so the new map has the same
703 /// size, comparator and elements as the source did before-hand.
704 ///
705 /// All the keys from the source map are copy-constructed, and all
706 /// the mapped values are move-constructed.
707 /// @param other The instance to be copied.
708 /// @throws Any exception thrown by the copy constructor of the comparator or
709 /// the keys, or the move-constructor of the values
710 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
720 // parasoft-end-suppress AUTOSAR-A15_5_1-b-2
721
722 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
723 // initialize the base class"
724 /// @brief Copy from a map with a different capacity
725 /// @tparam OtherCapacity The capacity of the other map
726 /// @tparam SfinaeKey Dummy key type for SFINAE
727 /// @tparam SfinaeValue Dummy value type for SFINAE
728 /// @tparam SfinaeCompare Dummy compare type for SFINAE
729 /// @param other The source map
730 /// @throws Any exception thrown by the copy constructors of the comparator, keys or values
731 /// @pre @c other.size()<=Capacity, else @c ARENE_PRECONDITION violation.
732 template <
734 typename SfinaeKey = Key,
735 typename SfinaeValue = Value,
736 typename SfinaeCompare = Compare,
742 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
750 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
751
752 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
753 // initialize the base class"
754 // parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "False positive: Elements are moved"
755 // parasoft-begin-suppress AUTOSAR-A8_4_5-a-2 "False positive: Elements are moved"
756 // parasoft-begin-suppress AUTOSAR-A12_8_4-a-2 "False positive: Elements are moved"
757 /// @brief Move from a map with a different capacity
758 /// @tparam OtherCapacity The capacity of the other map
759 /// @tparam SfinaeKey Dummy key type for SFINAE
760 /// @tparam SfinaeValue Dummy value type for SFINAE
761 /// @tparam SfinaeCompare Dummy compare type for SFINAE
762 /// @param other The source map
763 /// @throws Any exception thrown by the copy constructors of the comparator or keys or the move constructor of the
764 /// values
765 /// @pre @c other.size()<=Capacity, else @c ARENE_PRECONDITION violation.
766 template <
768 typename SfinaeKey = Key,
769 typename SfinaeValue = Value,
770 typename SfinaeCompare = Compare,
776 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
780 // parasoft-begin-suppress AUTOSAR-M0_1_3-a-2 "False positive: RAII class"
782 // parasoft-end-suppress AUTOSAR-M0_1_3-a-2
783 for (auto& element : other) {
785 }
786 }
787 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
788 // parasoft-end-suppress AUTOSAR-A8_4_6-a-2
789 // parasoft-end-suppress AUTOSAR-A8_4_5-a-2
790 // parasoft-end-suppress AUTOSAR-A12_8_4-a-2
791
792 /// @brief Deleted copy-assignment if the map should not be copy-assignable
793 auto operator=(dummy_copy_assign_source const&) -> inline_map& = delete;
794
795 /// @brief Deleted move-assignment if the map should not be move-assignable
796 auto operator=(dummy_move_assign_source&&) -> inline_map& = delete;
797
798 /// @brief copy-assignment of a map with the same capacity.
799 ///
800 /// If an exception is thrown then @c *this is left in a valid state containing the subset of elements copied from the
801 /// source prior to the exception being thrown.
802 /// @param other The instance to be copied.
803 /// @return inline_map& A reference to @c *this
804 /// @throws Any exception thrown by the copy assignment of the comparator, or
805 /// the copy constructors of the keys, or values
806 auto operator=(copy_assign_source const& other) noexcept(
809 ) -> inline_map& {
810 if (this != &other) {
811 do_copy(other);
812 }
813 return *this;
814 }
815
816 /// @brief copy-assignment of a map with a greater capacity.
817 ///
818 /// If an exception is thrown then @c *this is left in a valid state containing the subset of elements copied from the
819 /// source prior to the exception being thrown.
820 /// @tparam OtherCapacity The capacity of the other map
821 /// @tparam SfinaeCompare Dummy key type for SFINAE
822 /// @tparam SfinaeValue Dummy value type for SFINAE
823 /// @tparam SfinaeCompare Dummy compare type for SFINAE
824 /// @param other The instance to be copied.
825 /// @return inline_map& A reference to @c *this
826 /// @throws Any exception thrown by the copy assignment of the comparator, or
827 /// the copy constructors of the keys, or values.
828 /// @pre @c other.size()<=Capacity, else @c ARENE_PRECONDITION violation.
829 template <
831 typename SfinaeKey = Key,
832 typename SfinaeValue = Value,
833 typename SfinaeCompare = Compare,
841 do_copy(other);
842 return *this;
843 }
844
845 /// @brief copy-assignment of a map with a smaller capacity.
846 ///
847 /// If an exception is thrown then @c *this is left in a valid state containing the subset of elements copied from the
848 /// source prior to the exception being thrown.
849 /// @tparam OtherCapacity The capacity of the other map
850 /// @tparam SfinaeKey Dummy key type for SFINAE
851 /// @tparam SfinaeValue Dummy value type for SFINAE
852 /// @tparam SfinaeCompare Dummy comparator type for SFINAE
853 /// @param other The instance to be copied.
854 /// @return inline_map& A reference to @c *this
855 /// @throws Any exception thrown by the copy assignment of the comparator, or the copy constructors of the keys, or
856 /// values
857 template <
859 typename SfinaeKey = Key,
860 typename SfinaeValue = Value,
861 typename SfinaeCompare = Compare,
868 do_copy(other);
869 return *this;
870 }
871
872 // parasoft-begin-suppress AUTOSAR-A15_5_1-b-2 "False positive: Conditionally noxecept"
873 /// @brief Move-assignment of a map with the same capacity.
874 ///
875 /// All the keys from the source map are copy-constructed, and all the mapped values are move-constructed. The source
876 /// map is cleared, so all elements are destroyed and this size is zero. If an exception is thrown then @c *this is
877 /// left in a valid state containing the subset of elements moved from the source prior to the exception being thrown,
878 /// and the source is left empty.
879 /// @param other The instance to be moved.
880 /// @return inline_map& A reference to @c *this
881 /// @throws Any exception thrown by the move-assignment of the comparator or the copy-constructor of the keys, or the
882 /// move-constructor of the values
885 -> inline_map& {
886 if (this != &other) {
888 }
889 return *this;
890 }
891 // parasoft-end-suppress AUTOSAR-A15_5_1-b-2
892
893 // parasoft-begin-suppress AUTOSAR-A0_1_4-a "False positive: parameter 'other' is used"
894
895 /// @brief Move-assignment of a map with a greater capacity.
896 ///
897 /// All the keys from the source map are copy-constructed, and all the mapped values are move-constructed. The source
898 /// map is cleared, so all elements are destroyed and this size is zero. If an exception is thrown then @c *this is
899 /// left in a valid state containing the subset of elements moved from the source prior to the exception being thrown,
900 /// and the source is left empty.
901 /// @tparam OtherCapacity The capacity of the other map
902 /// @tparam SfinaeKey Dummy key type for SFINAE
903 /// @tparam SfinaeValue Dummy value type for SFINAE
904 /// @tparam SfinaeCompare Dummy comparator type for SFINAE
905 /// @param other The instance to be moved.
906 /// @return inline_map& A reference to @c *this
907 /// @pre @c other.size()<=Capacity, else @c ARENE_PRECONDITION violation.
908 /// @throws Any exception thrown by the move-assignment of the comparator or the copy-constructor of the keys, or the
909 /// move-constructor of the values
910 template <
912 typename SfinaeKey = Key,
913 typename SfinaeValue = Value,
914 typename SfinaeCompare = Compare,
925
926 // parasoft-end-suppress AUTOSAR-A0_1_4-a
927
928 /// @brief Move-assignment of a map with a lesser capacity.
929 ///
930 /// All the keys from the source map are copy-constructed, and all the mapped values are move-constructed. The source
931 /// map is cleared, so all elements are destroyed and this size is zero. If an exception is thrown then @c *this is
932 /// left in a valid state containing the subset of elements moved from the source prior to the exception being thrown,
933 /// and the source is left empty.
934 /// @tparam OtherCapacity The capacity of the other map
935 /// @tparam SfinaeKey Dummy key type for SFINAE
936 /// @tparam SfinaeValue Dummy value type for SFINAE
937 /// @tparam SfinaeCompare Dummy comparator type for SFINAE
938 /// @param other The instance to be moved.
939 /// @return inline_map& A reference to @c *this
940 /// @throws Any exception thrown by the move-assignment of the comparator or the copy-constructor of the keys, or the
941 /// move-constructor of the values
942 template <
944 typename SfinaeKey = Key,
945 typename SfinaeValue = Value,
946 typename SfinaeCompare = Compare,
954 return *this;
955 }
956
957 /// @brief Obtain a copy of the comparator
958 /// @return The comparator
959 /// @throws Any exception thrown by the copy-constructor of the comparator
963
964 /// @brief Check if the map is empty
965 /// @return @c true if the map is empty, @c false otherwise
966 ARENE_NODISCARD auto empty() const noexcept -> bool { return size_ == 0U; }
967 /// @brief Get the number of elements in the map
968 /// @return The number of elements
969 ARENE_NODISCARD auto size() const noexcept -> size_type { return size_; }
970 // parasoft-begin-suppress AUTOSAR-M11_0_1-a-2 "False positive: this is not 'member data', it is a public property,
971 /// @brief Get the maximum number of elements in the map, @c Capacity
973 // parasoft-end-suppress AUTOSAR-M11_0_1-a-2
974
975 /// @brief Obtain an iterator referring to the element equivalent to the supplied key, if there is one.
976 ///
977 /// @param key The key to find
978 /// @return iterator to the equivalent element, or @c end() if the element is not found
979 auto find(Key const& key) noexcept(comparison_is_noexcept<>) -> iterator { return do_find(*this, key); }
980 /// @brief Obtain an iterator referring to the element equivalent to the supplied key, if there is one.
981 ///
982 /// @param key The key to find
983 /// @return const_iterator to the equivalent element, or @c end() if the element is not found
984 auto find(Key const& key) const noexcept(comparison_is_noexcept<>) -> const_iterator { return do_find(*this, key); }
985 /// @brief Obtain an iterator referring to the element equivalent to the supplied key, if there is one.
986 ///
987 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
988 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
989 /// @param key The key to find
990 /// @return iterator to the equivalent element, or @c end() if the element is not found
993 static_assert(
995 "Compare must provide a valid comparison for (const Key&, const K&)"
996 );
997 return do_find(*this, key);
998 }
999 /// @brief Obtain an iterator referring to the element equivalent to the supplied key, if there is one.
1000 ///
1001 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1002 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1003 /// @param key The key to find
1004 /// @return const_iterator to the equivalent element, or @c end() if the element is not found
1007 static_assert(
1009 "Compare must provide a valid comparison for (const Key&, const K&)"
1010 );
1011 return do_find(*this, key);
1012 }
1013
1014 /// @brief Check if the set contains a specific key
1015 ///
1016 /// @param key The key to search for
1017 /// @return true if @c find(key)!=end() .
1018 /// @return false if @c find(key)==end() .
1019 auto contains(Key const& key) const noexcept(comparison_is_noexcept<>) -> bool { return do_contains(key); }
1020 /// @brief Check if the set contains a key equivalent to a specific value.
1021 ///
1022 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1023 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1024 /// @param key The key to search for
1025 /// @return true if @c find(key)!=end() .
1026 /// @return false if @c find(key)==end() .
1028 auto contains(OtherKey const& key) const noexcept(comparison_is_noexcept<OtherKey>) -> bool {
1029 static_assert(
1031 "Compare must provide a valid comparison for (const Key&, const K&)"
1032 );
1033 return do_contains(key);
1034 }
1035
1036 /// @brief Return the number of elements in the map equivalent to a specific key.
1037 ///
1038 /// @param key The key to search for.
1039 /// @return std::size_t @c 0 if the element was not in the map, else @c 1 .
1040 auto count(Key const& key) const noexcept(comparison_is_noexcept<>) -> size_type { return do_count(key); }
1041 /// @brief Return the number of elements in the map equivalent to a specific key.
1042 ///
1043 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1044 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1045 /// @param key The key to search for.
1046 /// @return std::size_t @c 0 if the element was not in the map, else @c 1 .
1048 auto count(OtherKey const& key) const noexcept(comparison_is_noexcept<OtherKey>) -> size_type {
1049 static_assert(
1051 "Compare must provide a valid comparison for (const Key&, const K&)"
1052 );
1053 return do_count(key);
1054 }
1055
1056 /// @brief Find the first element which is _not less than_ a given key.
1057 ///
1058 /// @param key The key to find the lower bound for.
1059 /// @return iterator to the first element which is _not less than_ @c key , or @c end() if there is no
1060 /// such element.
1061 auto lower_bound(Key const& key) noexcept(comparison_is_noexcept<>) -> iterator { return do_lower_bound(*this, key); }
1062 /// @brief Find the first element which is _not less than_ a given key.
1063 ///
1064 /// @param key The key to find the lower bound for.
1065 /// @return const_iterator to the first element which is _not less than_ @c key , or @c end() if there is no
1066 /// such element.
1067 auto lower_bound(Key const& key) const noexcept(comparison_is_noexcept<>) -> const_iterator {
1068 return do_lower_bound(*this, key);
1069 }
1070 /// @brief Find the first element which is _not less than_ a given key.
1071 ///
1072 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1073 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1074 /// @param key The key to find the lower bound for.
1075 /// @return iterator to the first element which is _not less than_ @c key , or @c end() if there is no such element.
1078 static_assert(
1080 "Compare must provide a valid comparison for (const Key&, const K&)"
1081 );
1082 return do_lower_bound(*this, key);
1083 }
1084 /// @brief Find the first element which is _not less than_ a given key.
1085 ///
1086 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1087 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1088 /// @param key The key to find the lower bound for.
1089 /// @return const_iterator to the first element which is _not less than_ @c key , or @c end() if there is no such
1090 /// element.
1093 static_assert(
1095 "Compare must provide a valid comparison for (const Key&, const K&)"
1096 );
1097 return do_lower_bound(*this, key);
1098 }
1099
1100 /// @brief Find the first element which is _greater than_ a given key.
1101 ///
1102 /// @param key The key to search for.
1103 /// @return iterator to the first element which is _greater than_ @c key , or @c end() if there is no such element.
1104 auto upper_bound(Key const& key) noexcept(comparison_is_noexcept<>) -> iterator { return do_upper_bound(*this, key); }
1105 /// @brief Find the first element which is _greater than_ a given key.
1106 ///
1107 /// @param key The key to search for.
1108 /// @return const_iterator to the first element which is _greater than_ @c key , or @c end() if there is no such
1109 /// element.
1110 auto upper_bound(Key const& key) const noexcept(comparison_is_noexcept<>) -> const_iterator {
1111 return do_upper_bound(*this, key);
1112 }
1113 /// @brief Find the first element which is _greater than_ a given key.
1114 ///
1115 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1116 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1117 /// @param key The key to search for.
1118 /// @return iterator to the first element which is _greater than_ @c key , or @c end() if there is no such element.
1121 static_assert(
1123 "Compare must provide a valid comparison for (const Key&, const K&)"
1124 );
1125 return do_upper_bound(*this, key);
1126 }
1127 /// @brief Find the first element which is _greater than_ a given key.
1128 ///
1129 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1130 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1131 /// @param key The key to search for.
1132 /// @return const_iterator to the first element which is _greater than_ @c key , or @c end() if there is no such
1133 /// element.
1136 static_assert(
1138 "Compare must provide a valid comparison for (const Key&, const K&)"
1139 );
1140 return do_upper_bound(*this, key);
1141 }
1142
1143 /// @brief Finds the sequence of elements whose keys compare equivalent to a given key.
1144 ///
1145 /// @param key The key to search for
1146 /// @return std::pair<iterator, iterator> A pair of iterators such that all elements in the range @c [first,second)
1147 /// have keys which compare equal to @c key if there was a key equivalent to @c key in the map. Otherwise both
1148 /// iterators will be @c end() .
1150 return do_equal_range(*this, key);
1151 }
1152 /// @brief Finds the sequence of elements whose keys compare equivalent to a given key.
1153 ///
1154 /// @param key The key to search for
1155 /// @return std::pair<iterator, iterator> A pair of iterators such that all elements in the range @c [first,second)
1156 /// have keys which compare equal to @c key if there was a key equivalent to @c key in the map. Otherwise both
1157 /// iterators will be @c end() .
1158 auto equal_range(Key const& key) const noexcept(comparison_is_noexcept<>)
1160 return do_equal_range(*this, key);
1161 }
1162 /// @brief Finds the sequence of elements whose keys compare equivalent to a given key.
1163 ///
1164 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1165 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1166 /// @param key The key to search for
1167 /// @return std::pair<iterator, iterator> A pair of iterators such that all elements in the range @c [first,second)
1168 /// have keys which compare equal to @c key if there was a key equivalent to @c key in the map. Otherwise both
1169 /// iterators will be @c end() .
1172 static_assert(
1174 "Compare must provide a valid comparison for (const Key&, const K&)"
1175 );
1176 return do_equal_range(*this, key);
1177 }
1178 /// @brief Finds the sequence of elements whose keys compare equivalent to a given key.
1179 ///
1180 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1181 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1182 /// @param key The key to search for
1183 /// @return std::pair<const_iterator, const_iterator> A pair of iterators such that all elements in the range @c
1184 /// [first,second) have keys which compare equal to @c key if there was a key equivalent to @c key in the map.
1185 /// Otherwise both iterators will be @c end() .
1189 static_assert(
1191 "Compare must provide a valid comparison for (const Key&, const K&)"
1192 );
1193 return do_equal_range(*this, key);
1194 }
1195
1196 /// @brief Obtain a reference to the mapped value for the specified key
1197 ///
1198 /// @param key The key to obtain the value for
1199 /// @return A reference to the mapped value. If @c key did not exist in the map, then a default constructed @c Value
1200 /// is inserted into the map at @c key and a reference to it is returned.
1201 /// @throws Any exception thrown by the comparisons, and exception throw by the copy-constructor of @c Key, or the
1202 /// default-constructor of @c Value
1203 /// @pre @c size()<Capacity if @c key is not in @c *this
1204 auto operator[](Key const& key) -> Value& { return do_operator_index(key); }
1205 /// @brief Obtain a reference to the mapped value for the specified key
1206 ///
1207 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1208 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> , and
1209 /// <c>std::is_constructible<Key,const K&></c> .
1210 /// @param key The key to obtain the value for
1211 /// @return A reference to the mapped value. If @c key did not exist in the map, then a default constructed @c Value
1212 /// is inserted into the map at @c key and a reference to it is returned.
1213 /// @throws Any exception thrown by the comparisons, and exception throw by the copy-constructor of @c Key, or the
1214 /// default-constructor of @c Value, or
1215 /// @pre @c size()<Capacity if @c key is not in @c *this
1216 template <
1217 typename OtherKey,
1220 std::enable_if_t<std::is_constructible<Key, OtherKey const&>::value>> = nullptr>
1221 auto operator[](OtherKey const& key) -> Value& {
1222 static_assert(
1224 "Compare must provide a valid comparison for (const Key&, const K&)"
1225 );
1226 return do_operator_index(key);
1227 }
1228
1229 /// @brief Obtain a reference to the mapped value for the specified key or throw.
1230 ///
1231 /// @param key The key to obtain the value for
1232 /// @return Value& A reference to the mapped value
1233 /// @throws std::out_of_range if @c find(key)==end() .
1234 /// @throws Any exception thrown by the comparisons
1235 template <
1238 ARENE_NODISCARD auto at(Key const& key) -> Value& {
1239 return do_at(*this, key);
1240 }
1241 /// @brief Obtain a reference to the mapped value for the specified key or throw.
1242 ///
1243 /// @param key The key to obtain the value for
1244 /// @return Value const& A reference to the mapped value
1245 /// @throws std::out_of_range if @c find(key)==end() .
1246 /// @throws Any exception thrown by the comparisons
1247 template <
1250 ARENE_NODISCARD auto at(Key const& key) const -> Value const& {
1251 return do_at(*this, key);
1252 }
1253
1254 /// @brief Obtain a reference to the mapped value for the specified key or throw.
1255 ///
1256 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1257 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1258 /// @param key The key to obtain the value for
1259 /// @return Value& A reference to the mapped value
1260 /// @throws std::out_of_range if @c find(key)==end() .
1261 /// @throws Any exception thrown by the comparisons
1262 template <
1263 typename OtherKey,
1269 static_assert(
1271 "Compare must provide a valid comparison for (const Key&, const K&)"
1272 );
1273 return do_at(*this, key);
1274 }
1275 /// @brief Obtain a reference to the mapped value for the specified key or throw.
1276 ///
1277 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1278 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1279 /// @param key The key to obtain the value for
1280 /// @return Value& A reference to the mapped value
1281 /// @throws std::out_of_range if @c find(key)==end() .
1282 /// @throws Any exception thrown by the comparisons
1283 template <
1284 typename OtherKey,
1289 ARENE_NODISCARD auto at(OtherKey const& key) const -> Value const& {
1290 static_assert(
1292 "Compare must provide a valid comparison for (const Key&, const K&)"
1293 );
1294 return do_at(*this, key);
1295 }
1296
1297 // parasoft-begin-suppress AUTOSAR-A13_3_1-a-2 "Constrained via SFINAE, permitted by A13-3-1 Permit #1"
1298 /// @brief Insert a new element in the map if there is not already one with the corresponding key.
1299 ///
1300 /// Copy constructs the provided value into the new element if an appropriate element does not already exist.
1301 /// @tparam SfinaeKey Dummy key type for SFINAE.
1302 /// @tparam SfinaeValue Dummy value type for SFINAE.
1303 /// @param value The value to insert
1304 /// @return std::pair<iterator, bool> whose first element is the key equivalent to @c v.first, and whose second
1305 /// element is a boolean with a value of @c true if the element was inserted, or @c false otherwise.
1306 /// @pre @c contains(value.first) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1307 /// @throws Any exception thrown by the comparisons, or the copy constructor of @c value_type
1308 template <
1309 typename SfinaeKey = Key,
1310 typename SfinaeValue = Value,
1314 auto insert(value_type const& value) -> std::pair<iterator, bool> {
1316 }
1317 // parasoft-end-suppress AUTOSAR-A13_3_1-a-2
1318
1319 /// @brief Insert a new element in the map if there is not already one with the corresponding key.
1320 ///
1321 /// If an element does not already exist with the given key, the key is copy-constructed into the map while the value
1322 /// is move-constructed.
1323 /// @tparam SfinaeKey Dummy key type for SFINAE.
1324 /// @tparam SfinaeValue Dummy value type for SFINAE.
1325 /// @param value The value to insert
1326 /// @return std::pair<iterator, bool> whose first element is the key equivalent to @c v.first, and whose second
1327 /// element is a boolean with a value of @c true if the element was inserted, or @c false otherwise.
1328 /// @pre @c contains(value.first) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1329 /// @throws Any exception thrown by the comparisons, or the copy constructor of @c value_type
1330 template <
1331 typename SfinaeKey = Key,
1332 typename SfinaeValue = Value,
1338 }
1339
1340 /// @brief Insert a new element in the map if there is not already one with the corresponding key.
1341 ///
1342 /// If an element does not already exist with the given key, the key is copy-constructed into the map while the value
1343 /// is move-constructed.
1344 /// @tparam P The type of the provided initializer
1345 /// @param value The value to insert
1346 /// @return std::pair<iterator, bool> whose first element is the key equivalent to @c v.first, and whose second
1347 /// element is a boolean with a value of @c true if the element was inserted, or @c false otherwise.
1348 /// @pre @c contains(value.first) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1349 /// @throws Any exception thrown by the comparisons, or the copy constructor of @c value_type
1350 template <
1351 typename P,
1355 auto insert(P&& value) -> std::pair<iterator, bool> {
1356 return emplace(std::forward<P>(value));
1357 }
1358
1359 /// @brief Insert a new element in the map if there is not already one with the corresponding key, otherwise assigns
1360 /// the new value to the existing one.
1361 ///
1362 /// Perfectly forwards the provided key and value into the constructor of the new element if an appropriate element
1363 /// does not already exist; perfectly forwards into the assignment operator for the existing element if there is one.
1364 /// @tparam OtherMapped The type of the initializer for the mapped type
1365 /// @tparam SfinaeKey The key type, used to delete this overload if the key is not copy constructible
1366 /// @param key The key for which to insert or assign an element
1367 /// @param mapped_value The value with which to construct or assign the mapped value
1368 /// @return A pair of an iterator to the element with a key equivalent to @c key, and a boolean with a value of
1369 /// @c true if the element was inserted, or @c false otherwise.
1370 /// @pre @c contains(key) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1371 /// @throws Any exception thrown by the comparisons, the move constructor of @c Key or the constructor or assignment
1372 /// operator of @c Value .
1373 template <
1374 typename OtherMapped,
1375 typename SfinaeKey = Key,
1383 /// @brief Insert a new element in the map if there is not already one with the corresponding key, otherwise assigns
1384 /// the new value to the existing one.
1385 ///
1386 /// Perfectly forwards the provided key and value into the constructor of the new element if an appropriate element
1387 /// does not already exist; perfectly forwards into the assignment operator for the existing element if there is one.
1388 /// @tparam OtherMapped The type of the initializer for the mapped type
1389 /// @tparam SfinaeKey The key type, used to delete this overload if the key is not move constructible
1390 /// @param key The key for which to insert or assign an element
1391 /// @param mapped_value The value with which to construct or assign the mapped value
1392 /// @return A pair of an iterator to the element with a key equivalent to @c key, and a boolean with a value of
1393 /// @c true if the element was inserted, or @c false otherwise.
1394 /// @pre @c contains(key) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1395 /// @throws Any exception thrown by the comparisons, the move constructor of @c Key or the constructor or assignment
1396 /// operator of @c Value .
1397 template <
1398 typename OtherMapped,
1399 typename SfinaeKey = Key,
1407 /// @brief Insert a new element in the map if there is not already one with an equivalent key, otherwise assigns the
1408 /// new value to the existing one.
1409 ///
1410 /// Perfectly forwards the provided key and value into the constructor of the new element if an appropriate element
1411 /// does not already exist; perfectly forwards into the assignment operator for the existing element if there is one.
1412 /// @tparam OtherKey The key type. Must satisfy <c>decays_to_v<K, Key> || transparent_comparison_supported<K></c> and
1413 /// <c>std::is_constructible<Key, K&&></c>
1414 /// @tparam OtherMapped The type of the initializer for the mapped type
1415 /// @param key The key for which to insert or assign an element
1416 /// @param mapped_value The value with which to construct or assign the mapped value
1417 /// @return A pair of an iterator to the element with a key equivalent to @c key, and a boolean with a value of
1418 /// @c true if the element was inserted, or @c false otherwise.
1419 /// @pre @c contains(key) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1420 /// @throws Any exception thrown by the comparisons, the move constructor of @c Key or the constructor or assignment
1421 /// operator of @c Value .
1422 template <
1423 typename OtherKey,
1424 typename OtherMapped,
1431 static_assert(
1433 "Compare must provide a valid comparison for (const Key&, const K&)"
1434 );
1436 }
1437
1438 /// @brief Try to emplace a new element in the map if there is not already one with the corresponding key.
1439 ///
1440 /// Perfectly forwards the provided arguments into the constructor of the key and value if an appropriate element does
1441 /// not already exist.
1442 /// @tparam Args The types of the initializers for the mapped type. Must satisfy <c>std::is_constructible<Value,
1443 /// Args&&...></c>.
1444 /// @tparam SfinaeKey The key type, used to delete this overload if the key is not copy/move constructible
1445 /// @param key The key for which to insert or assign an element
1446 /// @param args The values with which to construct the mapped value
1447 /// @return std::pair<iterator, bool> A pair whose second element will be @c true if the emplace happened. The first
1448 /// element will be an iterator pointing to the element corresponding to @c key : the existing element if
1449 /// the insert did not happen, or the new element if it did.
1450 /// @pre @c contains(key) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1451 /// @throws Any exception thrown by the comparisons or constructors of @c Key and @c Value .
1452 template <
1453 typename... Args,
1454 typename SfinaeKey = Key,
1457 std::enable_if_t<std::is_constructible<Value, Args&&...>::value>> = nullptr>
1458 auto try_emplace(Key const& key, Args&&... args) -> std::pair<iterator, bool> {
1459 return do_try_emplace(key, std::forward<Args>(args)...);
1460 }
1461 /// @brief Try to emplace a new element in the map if there is not already one with the corresponding key.
1462 ///
1463 /// Perfectly forwards the provided arguments into the constructor of the key and value if an appropriate element does
1464 /// not already exist.
1465 /// @tparam Args The types of the initializers for the mapped type. Must satisfy <c>std::is_constructible<Value,
1466 /// Args&&...></c>.
1467 /// @tparam SfinaeKey The key type, used to delete this overload if the key is not copy/move constructible
1468 /// @param key The key for which to insert or assign an element
1469 /// @param args The values with which to construct the mapped value
1470 /// @return std::pair<iterator, bool> A pair whose second element will be @c true if the emplace happened. The first
1471 /// element will be an iterator pointing to the element corresponding to @c key : the existing element if
1472 /// the insert did not happen, or the new element if it did.
1473 /// @pre @c contains(key) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1474 /// @throws Any exception thrown by the comparisons or constructors of @c Key and @c Value .
1475 template <
1476 typename... Args,
1477 typename SfinaeKey = Key,
1480 std::enable_if_t<std::is_constructible<Value, Args&&...>::value>> = nullptr>
1481 auto try_emplace(Key&& key, Args&&... args) -> std::pair<iterator, bool> {
1482 return do_try_emplace(std::move(key), std::forward<Args>(args)...);
1483 }
1484 /// @brief Try to emplace a new element in the map if there is not already one with an equivalent key.
1485 ///
1486 /// Perfectly forwards the provided arguments into the constructor of the key and value if an appropriate element does
1487 /// not already exist.
1488 /// @tparam Args The types of the initializers for the mapped type. Must satisfy <c>std::is_constructible<Value,
1489 /// Args&&...></c>.
1490 /// @tparam OtherKey The key type. Must satisfy <c>decays_to_v<K, Key> || transparent_comparison_supported<K></c> and
1491 /// <c>std::is_constructible<Key, K&&></c>
1492 /// @param key The key for which to insert or assign an element
1493 /// @param args The values with which to construct the mapped value
1494 /// @return std::pair<iterator, bool> A pair whose second element will be @c true if the emplace happened. The first
1495 /// element will be an iterator pointing to the element corresponding to @c key : the existing element if
1496 /// the insert did not happen, or the new element if it did.
1497 /// @pre @c contains(key) is @c true, or @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1498 /// @throws Any exception thrown by the comparisons or constructors of @c Key and @c Value .
1499 template <
1500 typename OtherKey,
1501 typename... Args,
1506 std::enable_if_t<std::is_constructible<Value, Args&&...>::value>> = nullptr>
1507 auto try_emplace(OtherKey&& key, Args&&... args) -> std::pair<iterator, bool> {
1508 static_assert(
1510 "Compare must provide a valid comparison for (const Key&, const K&)"
1511 );
1513 }
1514
1515 /// @brief Construct a new @c value_type object and try to insert it in the map if
1516 /// there is not already one with the corresponding key.
1517 ///
1518 /// Perfectly forwards the provided arguments into the constructor
1519 /// of the new element if an appropriate element does not already
1520 /// exist.
1521 /// @tparam Args The types of the initializers for the value type
1522 /// @param args The values with which to construct the value value
1523 /// @return A pair of an iterator to the element with a key equivalent to @c
1524 /// key, and a boolean with a value of @c true if the element was
1525 /// inserted, or @c false otherwise.
1526 /// @throws Any exception thrown by the comparisons, the constructor
1527 /// of @c value_type
1528 /// @pre @c size()<Capacity or there is already a corresponding element in the map, else @c ARENE_PRECONDITION
1529 /// violation.
1530 template <
1531 typename... Args,
1552
1553 /// @brief Erase the element with the corresponding key, if there is one.
1554 ///
1555 /// @param key The key to erase.
1556 /// @return iterator An iterator which points to the position after the removed element.
1557 auto erase(Key const& key) noexcept(comparison_is_noexcept<>) -> iterator { return do_erase(key); }
1558 /// @brief Erase the element with the corresponding key, if there is one.
1559 ///
1560 /// @tparam OtherKey the type of the key to find. Must satisfy @c is_transparent_comparator_for<Compare,Key,K> or
1561 /// @c is_transparent_three_way_comparator_for<Compare,Key,K> .
1562 /// @param key The key to erase.
1563 /// @return iterator An iterator which points to the position after the removed element.
1566 static_assert(
1568 "Compare must provide a valid comparison for (const Key&, const K&)"
1569 );
1570 return do_erase(key);
1571 }
1572
1573 /// @brief Erase the element at the specified position.
1574 /// @param pos An iterator referring to the element to erase
1575 /// @return An iterator referring to the element after the erased element, or
1576 /// @c end() if there is no such element.
1577 /// @pre @c pos must be a valid dereferencable iterator referring to an element in @c *this, else @c
1578 /// ARENE_PRECONDITION violation.
1584
1585 /// @brief Erase the element at the specified position.
1586 /// @param pos An iterator referring to the element to erase
1587 /// @return An iterator referring to the element after the erased element, or
1588 /// @c end() if there is no such element.
1589 /// @pre @c pos must be a valid dereferencable iterator referring to an element in @c *this, else @c
1590 /// ARENE_PRECONDITION violation.
1596
1597 /// @brief Erase all the elements in the specified iterator range
1598 /// @param first An iterator referring to the start of the range to erase
1599 /// @param last An iterator referring to the end of the range to erase
1600 /// @return An iterator referring to the element after the erased elements,
1601 /// or @c end() if there is no such element.
1602 /// @pre @c [first,last) must be a valid iterator range referring to @c *this, else @c ARENE_PRECONDITION violation.
1603 // NOLINTNEXTLINE(readability-function-cognitive-complexity)
1612
1613 /// @brief Destroy all elements in @c *this and set the size to zero.
1614 /// @post @c size()==0 .
1615 /// @post The destructors of all elements in the range @c [begin(),end()) will have been called once.
1616 void clear() noexcept {
1617 for (index_type index{0U}; index < size_; ++index) {
1619 }
1620 size_ = 0U;
1621 }
1622
1623 /// @brief Obtain an iterator referring to the beginning of the sorted range of elements.
1624 /// @return iterator Points to the first element in the sequence, or @c end() if @c empty() .
1625 ARENE_NODISCARD auto begin() noexcept -> iterator { return make_iterator(*this, 0U); }
1626 /// @brief Obtain an iterator referring to the beginning of the sorted range of elements.
1627 /// @return const_iterator Points to the first element in the sequence, or @c end() if @c empty() .
1628 ARENE_NODISCARD auto begin() const noexcept -> const_iterator { return make_iterator(*this, 0U); }
1629 /// @brief Obtain an iterator referring to the beginning of the sorted range of elements.
1630 /// @return const_iterator Points to the first element in the sequence, or @c end() if @c empty() .
1631 ARENE_NODISCARD auto cbegin() const noexcept -> const_iterator { return make_iterator(*this, 0U); }
1632
1633 /// @brief Obtain an iterator referring to one past the last element in the sorted range of elements.
1634 /// @return iterator An iterator pointing to one past the last element in the sequence.
1635 ARENE_NODISCARD auto end() noexcept -> iterator { return make_iterator(*this, size_); }
1636 /// @brief Obtain an iterator referring to one past the last element in the sorted range of elements.
1637 /// @return const_iterator Points to one past the last element in the sequence.
1638 ARENE_NODISCARD auto end() const noexcept -> const_iterator { return make_iterator(*this, size_); }
1639 /// @brief Obtain an iterator referring to one past the last element in the sorted range of elements.
1640 /// @return const_iterator Points to one past the last element in the sequence.
1641 ARENE_NODISCARD auto cend() const noexcept -> const_iterator { return make_iterator(*this, size_); }
1642
1643 /// @brief Obtain an iterator referring to the beginning of a reversed traversal of the sorted range of elements.
1644 /// @return reverse_iterator Points to the last element in the sequence, or @c rend() if @c empty() .
1646 /// @brief Obtain an iterator referring to the beginning of a reversed traversal of the sorted range of elements.
1647 /// @return const_reverse_iterator Points to the last element in the sequence, or @c rend() if @c empty() .
1649 /// @brief Obtain an iterator referring to the beginning of a reversed traversal of the sorted range of elements.
1650 /// @return const_reverse_iterator Points to the last element in the sequence, or @c rend() if @c empty() .
1652
1653 /// @brief Obtain an iterator referring to one past the last element in a reversed traversal of the sorted range of
1654 /// elements.
1655 /// @return reverse_iterator An iterator pointing to one before the first element in the sequence.
1657 /// @brief Obtain an iterator referring to one past the last element in a reversed traversal of the sorted range of
1658 /// elements.
1659 /// @return const_reverse_iterator An iterator pointing to one before the first element in the sequence.
1661 /// @brief Obtain an iterator referring to one past the last element in a reversed traversal of the sorted range of
1662 /// elements.
1663 /// @return const_reverse_iterator An iterator pointing to one before the first element in the sequence.
1665
1666 /// @brief Fast inequality heuristic to shortcut on different sized containers.
1667 ///
1668 /// @tparam OtherCapacity the capacity of @c rhs
1669 /// @param lhs The left-hand operand to the check
1670 /// @param rhs The right-hand operand to the check
1671 /// @return inequality_heuristic::may_be_equal_or_not_equal if @c lhs.size()==rhs.size()
1672 /// @return inequality_heuristic::definitely_not_equal if @c lhs.size()!=rhs.size()
1673 template <size_type OtherCapacity>
1674 ARENE_NODISCARD static auto
1680
1681 /// @brief Compares two maps lexicographically .
1682 ///
1683 /// @note Lexicographic comparison between maps ignores the order of keys as defined by @c Compare . That is, it is
1684 /// a lexicographic comparison between the @c value_type elements of each container, in iteration order, using the
1685 /// standard @c compare_three_way facility. This means that for all possible maps which result in element sequences
1686 /// <c>{{1,"a"}, {2, "b"}, {3,"c"}}</c> and <c>{{1,"a"}, {2, "b"}, {5,"d"}}</c>, when compared against each other
1687 /// the result of the comparison will always be the same, @c strong_ordering::less.
1688 ///
1689 /// @tparam OtherCapacity the capacity of @c rhs
1690 /// @tparam SfinaeKey dummy template parameter to disable the operator if @c key_Type is not three way comparable.
1691 /// @tparam SfinaeMappedType dummy template parameter to disable the operator if @c mapped_type is not three way
1692 /// comparable.
1693 /// @param lhs The left hand operand to the comparison.
1694 /// @param rhs The right hand operand to the comparison.
1695 /// @return strong_ordering Equivalent to
1696 /// @c arene::base::lexicographical_compare_three_way(lhs.begin(),lhs.end(),rhs.begin(),rhs.end())
1697 template <
1699 typename SfinaeKey = key_type,
1700 typename SfinaeMappedType = mapped_type,
1704 ARENE_NODISCARD static auto
1709
1710 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "False positive: It is allowed to declare comparison operators as
1711 // friend functions"
1712 // parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
1713 /// @brief Compares two maps for equality of _elements_ when @c mapped_value is not three-way-comparable.
1714 ///
1715 ///
1716 /// @tparam OtherCapacity the capacity of @c rhs
1717 /// @tparam SfinaeValue dummy template parameter to disable the operator if @c value_type is not equality comparable.
1718 /// @tparam SfinaeKey dummy template parameter to enable the operator if @c key_type is not three way comparable.
1719 /// @tparam SfinaeMappedType dummy template parameter to enable the operator if @c mapped_type is not three way
1720 /// comparable.
1721 /// @param lhs The left hand operand to the comparison.
1722 /// @param rhs The right hand operand to the comparison.
1723 /// @return bool Equivalent to @c arene::base::equal(lhs.begin(),lhs.end(),rhs.begin(),rhs.end())
1724 template <
1726 typename SfinaeValue = value_type,
1728 ARENE_NODISCARD friend auto
1733 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
1734 // parasoft-end-suppress AUTOSAR-M3_3_2-a-2
1735
1736 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "False positive: It is allowed to declare comparison operators as
1737 // friend functions"
1738 // parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
1739 /// @brief Compares two maps for inequality of _elements_ when @c mapped_value is not three-way-comparable.
1740 ///
1741 /// @tparam OtherCapacity the capacity of @c rhs
1742 /// @tparam SfinaeValue dummy template parameter to disable the operator if @c value_type is not equality comparable.
1743 /// @tparam SfinaeKey dummy template parameter to enable the operator if @c key_Type is not three way comparable.
1744 /// @tparam SfinaeMappedType dummy template parameter to enable the operator if @c mapped_type is not three way
1745 /// comparable.
1746 /// @param lhs The left hand operand to the comparison.
1747 /// @param rhs The right hand operand to the comparison.
1748 /// @return bool Equivalent to @c !arene::base::equal(lhs.begin(),lhs.end(),rhs.begin(),rhs.end())
1749 template <
1751 typename SfinaeValue = value_type,
1753 ARENE_NODISCARD friend auto
1754 operator!=(inline_map const& lhs, inline_map<Key, Value, OtherCapacity, Compare> const& rhs) noexcept -> bool {
1755 return !(lhs == rhs);
1756 }
1757 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
1758 // parasoft-end-suppress AUTOSAR-M3_3_2-a-2
1759
1760 private:
1761 /// @brief The type of the storage for each entry
1763
1764 /// @brief Insert the values from @c init_list into the map.
1765 /// @param init_list The elements to insert
1766 /// @throws Any exception thrown by the copy constructor of the keys or values, or the comparisons
1767 /// @return bool @c true if the values fit, @c false if there is insufficient capacity
1768 auto insert_elements_if_they_fit(std::initializer_list<value_type> const& init_list) noexcept(
1769 comparison_is_noexcept<> && std::is_nothrow_copy_constructible<Key>::value &&
1770 std::is_nothrow_copy_constructible<Value>::value
1771 ) -> bool {
1772 for (auto const& element : init_list) {
1773 auto pos_info = lower_bound_index(element.first);
1774 if (pos_info.order == strong_ordering::equal) {
1775 continue;
1776 }
1777 if (size() == Capacity) {
1778 return false;
1779 }
1780 std::ignore = insert_at(pos_info.index, element.first, element.second);
1781 }
1782 return true;
1783 }
1784
1785 /// @brief Gets a reference to the entry corrsponding to a given index.
1786 /// @param index Index of the element in iteration order.
1787 /// @return A reference to the element for the given index.
1788 /// @pre @c index<indicies.size()
1789 auto entry_at_index(index_type index) noexcept -> entry_type& { return values_[indices_[index]]; }
1790 /// @brief Gets a reference to the entry corrsponding to a given index.
1791 /// @param index Index of the element in iteration order.
1792 /// @return A reference to the element for the given index.
1793 /// @pre @c index<indicies.size()
1794 auto entry_at_index(index_type index) const noexcept -> entry_type const& { return values_[indices_[index]]; }
1795
1796 // parasoft-begin-suppress AUTOSAR-A11_3_1-a "Use of a friend function with
1797 // passkey improves encapsulation. It allows data members to remain private
1798 // and does not unnecessarily expose a public member function."
1799
1800 // parasoft-begin-suppress AUTOSAR-M3_3_2-a "False positive: inline function used in multiple translation units"
1801
1802 /// @brief Gets the value at an index
1803 /// @tparam Self Deduced-this type of the map.
1804 /// @param self The map
1805 /// @param index the index in the map
1806 /// @return reference to the value at the given index
1807 /// @note this is primarily used to provide minimal access to @c inline_map_reference_iterator
1808 ///
1809 template <typename Self, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
1814
1815 // parasoft-end-suppress AUTOSAR-M3_3_2-a
1816 // parasoft-end-suppress AUTOSAR-A11_3_1-a
1817
1818 /// @brief Insert a new element at the specified position, constructed by perfectly forwarding the key and
1819 /// initialization arguments.
1820 ///
1821 /// @tparam OtherKey The type of the key to insert
1822 /// @tparam Args The types of the initialization arguments for the mapped type
1823 /// @param pos The position of the new element
1824 /// @param key The key for the element to insert
1825 /// @param args The initialization arguments for the mapped type
1826 /// @return A reference to the newly constructed element
1827 /// @pre @c size()<Capacity, else @c ARENE_PRECONDITION violation.
1828 template <typename OtherKey, typename... Args>
1829 auto insert_at(index_type pos, OtherKey&& key, Args&&... args) -> entry_type& {
1832 auto& entry = values_[new_index];
1833 entry.emplace(
1836 std::tuple<Args&&...>(std::forward<Args&&>(args)...)
1837 );
1839 return entry;
1840 }
1841
1842 /// @brief Insert a new index at the specified position
1843 /// @param pos The position for the new index
1844 /// @param new_index The new index value to insert
1846 for (index_type i{size_}; i > pos; --i) {
1847 indices_[i] = indices_[static_cast<index_type>(i - 1U)];
1848 }
1850 ++size_;
1851 }
1852
1853 /// @brief Obtain the index of the first entry such that @c entry.first < @c key
1854 ///
1855 /// @tparam OtherKey the type of the key to search for
1856 /// @param key The key to search for
1857 /// @return inline_container::detail::lower_bound_index_info<index_type> The index of the element, and the
1858 /// strong_ordering between that element and @c key . If @c key is greater than all elements, then the index
1859 /// is @c size() and the ordering is @c strong_ordering::greater .
1860 /// @throws Any exception thrown by the comparisons
1861 template <typename OtherKey>
1862 auto lower_bound_index(OtherKey const& key) const noexcept(comparison_is_noexcept<OtherKey>)
1864 auto const compare = [this](key_type const& lhs, OtherKey const& rhs) noexcept(comparison_is_noexcept<OtherKey>) {
1865 return this->key_ordering(lhs, rhs);
1866 };
1867 auto const accessor = [this](index_type const index) noexcept -> key_type const& {
1868 return this->entry_at_index(index)->first;
1869 };
1871 }
1872
1873 /// @brief A type alias for the appropriate iterator for @c Self
1874 /// @tparam Self the type of the container
1875 template <typename Self>
1877
1878 // parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "The universal reference is used to detect the value category"
1879 // parasoft-begin-suppress AUTOSAR-A8_4_5-a-2 "False positive: Self is a template parameter"
1880 // parasoft-begin-suppress AUTOSAR-A12_8_4-a-2 "False positive: this is not a move constructor"
1881 /// @brief Deduced-this helper for universally constructing iterators.
1882 ///
1883 /// @tparam Self Deduced-this type of the map.
1884 /// @param self The map
1885 /// @param index The index to construct the iterator pointing to.
1886 /// @return auto An iterator of the correct constness for @c Self which points to @c index .
1887 template <typename Self, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
1888 static auto make_iterator(Self&& self, index_type index) noexcept -> self_iterator<Self> {
1889 return {inline_map_passkey{}, &self, index};
1890 }
1891 // parasoft-end-suppress AUTOSAR-A8_4_6-a-2
1892 // parasoft-end-suppress AUTOSAR-A8_4_5-a-2
1893 // parasoft-end-suppress AUTOSAR-A12_8_4-a-2
1894
1895 /// @brief Deduced-this helper that detemplitizes find iterator generation from key type.
1896 ///
1897 /// @tparam Self Deduced-this type of the map.
1898 /// @param self The map
1899 /// @param lb_info An instance of the return from @c lower_bound_index()
1900 /// @return auto If @c lb_info.order==strong_ordering::equal , then an iterator constructed as if via @c
1901 /// make_iterator(self,lb_info.index) , otherwise @c self.end() .
1902 template <typename Self, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
1904 -> self_iterator<Self> {
1907 }
1908 return self.end();
1909 }
1910
1911 /// @brief Deduced-this helper implementation for @c find() which works for all comparators and iterator types.
1912 ///
1913 /// @tparam OtherKey the type of the key to search for.
1914 /// @tparam Self Deduced-this type of the map.
1915 /// @param self The map
1916 /// @param key The key to search for.
1917 /// @return The iterator at the position of @c value if it is found, else @c end() .
1918 template <typename Self, typename OtherKey, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
1919 static auto do_find(Self&& self, OtherKey const& key) noexcept(comparison_is_noexcept<OtherKey>)
1920 -> self_iterator<Self> {
1922 }
1923
1924 /// @brief Helper implementation for @c contains which works for all comparators.
1925 ///
1926 /// @tparam OtherKey the type of the key to find
1927 /// @param key The value to search for
1928 /// @return true if @c find(key)!=end() .
1929 /// @return false if @c find(key)==end() .
1930 template <typename OtherKey>
1931 auto do_contains(OtherKey const& key) const noexcept(comparison_is_noexcept<OtherKey>) -> bool {
1933 }
1934
1935 /// @brief Helper implementation for @c count which works for all comparators.
1936 ///
1937 /// @tparam OtherKey the type of the key to find.
1938 /// @param key The value to search for.
1939 /// @return std::size_t @c 0 if the element was not in the map, else @c 1 .
1940 template <typename OtherKey>
1941 auto do_count(OtherKey const& key) const noexcept(comparison_is_noexcept<OtherKey>) -> std::size_t {
1942 return static_cast<std::size_t>(do_contains(key));
1943 }
1944
1945 // parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "The universal reference is used to detect the value category"
1946 // parasoft-begin-suppress AUTOSAR-A8_4_5-a-2 "False Positive: Self is a template parameter"
1947 // parasoft-begin-suppress AUTOSAR-A12_8_4-a-2 "False positive: this is not a move constructor"
1948 /// @brief Helper implementation for @c lower_bound which works for all comparators and iterator types.
1949 ///
1950 /// @tparam OtherKey the type of the key to find.
1951 /// @tparam Self Deduced-this type of the map.
1952 /// @param self The map
1953 /// @param key The key to find the lower bound for.
1954 /// @return iterator An iterator to the first element which is _not less than_ @c value.
1955 template <typename Self, typename OtherKey, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
1956 static auto do_lower_bound(Self&& self, OtherKey const& key) noexcept(comparison_is_noexcept<OtherKey>)
1957 -> self_iterator<Self> {
1959 }
1960 // parasoft-end-suppress AUTOSAR-A8_4_6-a-2
1961 // parasoft-end-suppress AUTOSAR-A8_4_5-a-2
1962 // parasoft-end-suppress AUTOSAR-A12_8_4-a-2
1963
1964 /// @brief Deduced-this helper that detemplitizes upper_bound iterator generation from key type.
1965 ///
1966 /// @tparam Self Deduced-this type of the map.
1967 /// @param self The instance of the map to operate on.
1968 /// @param lb_info An instance of the return from @c lower_bound_index()
1969 /// @return auto If @c lb_info.order==strong_ordering::equal , then an iterator constructed as if via @c
1970 /// make_iterator(self,lb_info.index + 1) , otherwise @c make_iterator(self,lb_info.index) .
1971 template <typename Self, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
1972 static auto
1974 -> self_iterator<Self> {
1976 ++lb_info.index;
1977 }
1979 }
1980
1981 /// @brief Helper implementation for @c upper_bound which works for all comparators and iterator types.
1982 ///
1983 /// @tparam OtherKey the type of the key to find
1984 /// @tparam Self Deduced-this type of the map.
1985 /// @param self The map
1986 /// @param key The key to search for.
1987 /// @return An iterator to the first element which is _greater than_ @c key , or @c end() if there is no such
1988 /// element.
1989 template <typename Self, typename OtherKey, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
1990 static auto do_upper_bound(Self&& self, OtherKey const& key) noexcept(comparison_is_noexcept<OtherKey>)
1991 -> self_iterator<Self> {
1993 }
1994
1995 /// @brief Deduced-this helper that detemplitizes equal_range iterator generation from key type.
1996 ///
1997 /// @tparam Self Deduced-this type of the map.
1998 /// @param self The map
1999 /// @param lb_info An instance of the return from @c lower_bound_index()
2000 /// @return auto A pair of iterators where the first element is @c make_find_iterator(self,lb_info) , and the second
2001 /// element is either that iterator incremented by one if the iterator was not @c self.end() , otherwise @c self.end()
2002 template <typename Self, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
2003 static auto
2007 auto last = first == self.end() ? first : ::arene::base::next(first);
2008 return std::make_pair(first, last);
2009 }
2010
2011 /// @brief Helper implementation for @c equal_range which works for all comparators and iterator types.
2012 ///
2013 /// @tparam OtherKey the type of the value to find
2014 /// @tparam Self Deduced-this type of the map.
2015 /// @param self The map
2016 /// @param key The value to search for
2017 /// @return std::pair<iterator, iterator> A pair of iterators such that all values in the range @c [first,second)
2018 /// compare equal to @c value if there was an element equivalent to @c value in the set. Otherwise both
2019 /// iterators will be @c end() .
2020 template <typename Self, typename OtherKey, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
2021 static auto do_equal_range(Self&& self, OtherKey const& key) noexcept(comparison_is_noexcept<OtherKey>)
2024 }
2025
2026 // parasoft-begin-suppress AUTOSAR-A7_5_1-a-2 "False positive: Returns reference to element"
2027 /// @brief Helper implementation for @c operator[] which works for all comparators.
2028 ///
2029 /// @tparam OtherKey the type of the key to find.
2030 /// @param key The key to obtain the value for
2031 /// @return Value& A reference to the mapped value. If @c key did not exist in the map, then a default constructed
2032 /// @c Value is inserted into the map at @c key and a reference to it is returned.
2033 template <typename OtherKey>
2034 auto do_operator_index(OtherKey const& key) -> Value& {
2038 }
2039 return insert_at(pos_info.index, key)->second;
2040 }
2041 // parasoft-end-suppress AUTOSAR-A7_5_1-a-2
2042
2043 // parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "The universal reference is used to detect the value category"
2044 // parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "The universal reference is used to detect the value category"
2045 // parasoft-begin-suppress AUTOSAR-A8_4_5-a-2 "False positive: Self is a template parameter"
2046 // parasoft-begin-suppress AUTOSAR-A12_8_4-a-2 "False positive: this is not a move constructor"
2047 /// @brief Helper implementation for @c at which works for all comparators and const-ness.
2048 ///
2049 /// @tparam OtherKey the type of the key to find
2050 /// @tparam Self Deduced-this type of the map.
2051 /// @param self The map
2052 /// @param key The key to obtain the value for
2053 /// @return A reference to the mapped value
2054 /// @throws std::out_of_range if @c find(key)==end() .
2055 /// @throws Any exception thrown by the comparisons
2056 template <typename Self, typename OtherKey, constraints<std::enable_if_t<decays_to_v<Self, inline_map>>> = nullptr>
2057 ARENE_NODISCARD static auto do_at(Self&& self, OtherKey const& key)
2059 auto maybe_element = do_find(self, key);
2060 if (maybe_element == self.end()) {
2062 }
2063 return maybe_element->second;
2064 }
2065 // parasoft-end-suppress AUTOSAR-A8_4_6-a-2
2066 // parasoft-end-suppress AUTOSAR-A8_4_5-a-2
2067 // parasoft-end-suppress AUTOSAR-A12_8_4-a-2
2068
2069 /// @brief Helper for @c insert_or_assign which works for all comparators and key types.
2070 ///
2071 /// Perfectly forwards the provided key and value into the constructor of the new element if an appropriate element
2072 /// does not already exist; perfectly forwards into the assignment operator for the existing element if there is one.
2073 /// @tparam OtherKey The key type.
2074 /// @tparam OtherMapped The type of the initializer for the mapped type
2075 /// @param key The key for which to insert or assign an element
2076 /// @param mapped_value The value with which to construct or assign the mapped value
2077 /// @return A pair of an iterator to the element with a key equivalent to @c key, and a boolean with a value of
2078 /// @c true if the element was inserted, or @c false otherwise.
2079 /// @throws Any exception thrown by the comparisons, the move constructor of @c Key or the constructor or assignment
2080 /// operator of @c Value .
2081 /// @throws std::length_error if there is insufficient space to insert a new element.
2082 template <typename OtherKey, typename OtherMapped>
2085 if (!res.second) {
2087 }
2088 return res;
2089 }
2090
2091 /// @brief Helper for @c try_emplace which works for all comparators and keys.
2092 ///
2093 /// Perfectly forwards the provided arguments into the constructor of the key and value if an appropriate element does
2094 /// not already exist.
2095 /// @tparam Args The types of the initializers for the mapped type.
2096 /// @tparam OtherKey The key type.
2097 /// @param key The key for which to insert or assign an element
2098 /// @param args The values with which to construct the mapped value
2099 /// @return std::pair<iterator, bool> A pair whose second element will be @c true if the emplace happened. The first
2100 /// element will be an iterator pointing to the element corresponding to @c key : the existing element if
2101 /// the insert did not happen, or the new element if it did.
2102 /// @throws std::length_error if there is insufficient space to insert a new element.
2103 /// @throws Any exception thrown by the comparisons or constructors of @c Key and @c Value .
2104 template <typename OtherKey, typename... Args>
2105 auto do_try_emplace(OtherKey&& key, Args&&... args) -> std::pair<iterator, bool> {
2106 auto const pos_info = lower_bound_index(key);
2108 if (needs_insert) {
2110 }
2111 // parasoft-begin-suppress AUTOSAR-A8_4_2-a CERT_C-MSC37-a CERT_CPP-MSC52-a "False positive: returns a value"
2112 return {make_iterator(*this, pos_info.index), needs_insert};
2113 // parasoft-end-suppress AUTOSAR-A8_4_2-a CERT_C-MSC37-a CERT_CPP-MSC52-a
2114 }
2115
2116 /// @brief helper for @c erase(key) which works for all comparators.
2117 ///
2118 /// @tparam OtherKey The type of the key to find
2119 /// @param key The key to erase.
2120 /// @return iterator An iterator which points to the position after the removed element.
2121 template <typename OtherKey>
2122 auto do_erase(OtherKey const& key) noexcept(comparison_is_noexcept<OtherKey>) -> iterator {
2124 }
2125
2126 /// @brief Erase the element at the specified index.
2127 ///
2128 /// @param index The index of the element to erase
2129 /// @return An iterator to the element after the erased element, or @c end() if @c index>=size_.
2130 auto erase_at_index(index_type index) noexcept -> iterator {
2131 return index < size_ ? erase_index_range(index, 1U) : end();
2132 }
2133
2134 /// @brief Erase the elements in the specified index range.
2135 ///
2136 /// @param from The position in the index of the first element to erase
2137 /// @param erase_count The number of elements to erase
2138 /// @return An iterator to the element after the specified elements, or @c end() if there is no such element.
2139 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
2141 // We used this odd syntax because GCC8/9 are convinced that from + erase_count results in integer promotion, even
2142 // though they're guaranteed to be the same type.
2143 auto const last_index = static_cast<index_type>(from + erase_count);
2144 for (auto index = from; index < last_index; ++index) {
2146 }
2148 size_ = static_cast<index_type>(size_ - (last_index - from));
2149
2150 return make_iterator(*this, from);
2151 }
2152
2153 /// @brief Move-construct a new element from the specified element, and clear the old
2154 /// element.
2155 /// @param other The element to move from
2156 /// @return The new element
2157 /// @throws Any exception thrown by the copy-constructor of @c Key or the
2158 /// move-constructor of @c Value
2159 static auto move_value(entry_type& other
2161 -> entry_type {
2163 other.reset();
2164 return res;
2165 }
2166
2167 /// @brief Create a new array of elements which is a move-constructed copy of the
2168 /// elements from the provided map.
2169 /// @tparam Indices The indices of the elements from @c 0 to @c Capacity-1
2170 /// @param other The source map
2171 /// @return A new value array
2172 /// @throws Any exception thrown by the copy-constructor of @c Key or the
2173 /// move-constructor of @c Value
2174 template <std::size_t... Indices>
2175 static auto move_values(inline_map& other, std::index_sequence<Indices...>) noexcept(
2177 ) -> array<entry_type, Capacity> {
2178 // parasoft-begin-suppress AUTOSAR-M0_1_3-a-2 "False positive: RAII class"
2180 // parasoft-end-suppress AUTOSAR-M0_1_3-a-2
2182 return res;
2183 }
2184
2185 // parasoft-begin-suppress AUTOSAR-A7_1_5-a-2 "Return type cannot be named"
2186 /// @brief Helper to create a scope-guard which clears the input source on scope exit.
2187 ///
2188 /// @param source The container to clear on scope exit.
2189 /// @return A @c scope_guard which will call @c clear() on @c source .
2190 template <std::size_t OtherCapacity>
2192 return on_scope_exit([&source]() noexcept { //
2193 source.clear();
2194 });
2195 }
2196 // parasoft-end-suppress AUTOSAR-A7_1_5-a-2
2197
2198 // parasoft-begin-suppress AUTOSAR-M9_3_3-a-2 "False positive: Uses this"
2199 // parasoft-begin-suppress AUTOSAR-A7_1_5-a-2 "Return type cannot be named"
2200 /// @brief Helper to create a scope-guard which resets all values between the current size_ and an index.
2201 ///
2202 /// @param end_index One past the last index to reset to.
2203 /// @return A @c scope_guard which will call @c reset() on every element fetched via @c entry_at_index() in the range
2204 /// @c [size_,end) .
2206 return on_scope_exit([this, end_index]() noexcept {
2207 for (index_type idx = this->size_; idx < end_index; ++idx) {
2208 this->entry_at_index(idx).reset();
2209 }
2210 });
2211 }
2212 // parasoft-end-suppress AUTOSAR-A7_1_5-a-2
2213 // parasoft-end-suppress AUTOSAR-M9_3_3-a-2
2214
2215 /// @brief Copy the elements from the other map over those in the current set.
2216 ///
2217 /// @tparam OtherMap The type of the map to copy from
2218 /// @param other The source map to copy from.
2219 /// @throws Any exception thrown by the copy of the elements or comparator
2220 /// @post @c size()==other.size() , or the index of the first element which throws during copy construction if a throw
2221 /// occurs.
2222 /// @post @c The elements from @c other will have been copy-emplaced into @c this , up to the first element which
2223 /// threw during move-construction, if any.
2224 /// @post @c The elements in the range @c [size(),other.size()) will have been reset if @c other.size() was smaller
2225 /// than the original size of @c this .
2226 template <typename OtherMap>
2227 void do_copy(OtherMap const& other
2230 }
2231
2232 // parasoft-begin-suppress AUTOSAR-A0_1_4-a "False positive: parameter 'other' is used"
2233 // parasoft-begin-suppress AUTOSAR-M0_1_8-b "False positive: function 'do_move' is not empty"
2234
2235 /// @brief Move the elements from the other map over those in the current map.
2236 ///
2237 /// @tparam OtherMap The type of the map to move from,
2238 /// @param other The source map to move from.
2239 /// @throws Any exception thrown by the move of the elements or comparator.
2240 /// @post @c size()==other.size() , or the index of the first element which throws during move construction if a throw
2241 /// occurs.
2242 /// @post @c other.clear() will have been executed.
2243 /// @post @c The elements from @c other will have been move-emplaced into @c this , up to the first element which
2244 /// threw during move-construction, if any.
2245 /// @post @c The elements in the range @c [size(),other.size()) will have been reset if @c other.size() was smaller
2246 /// than the original size of @c this .
2247 template <typename OtherMap>
2248 void do_move(OtherMap&& other
2250 // parasoft-begin-suppress AUTOSAR-M0_1_3-a-2 "False positive: RAII class"
2252 // parasoft-end-suppress AUTOSAR-M0_1_3-a-2
2254 }
2255
2256 // parasoft-end-suppress AUTOSAR-A0_1_4-a
2257 // parasoft-end-suppress AUTOSAR-M0_1_8-b
2258
2259 // parasoft-begin-suppress AUTOSAR-A0_1_4-a "False positive: parameter 'other' is used"
2260 // parasoft-begin-suppress AUTOSAR-M0_1_8-b "False positive: function 'do_assignment' is not empty"
2261
2262 /// @brief Helper for @c do_copy and @c do_move with non-copy/move dependent logic.
2263 ///
2264 /// @tparam OtherMap The type of the map to copy/move from
2265 /// @param other The source map top copy/move from.
2266 /// @throws Any exception thrown by the copy/move of the elements or comparator.
2267 /// @post @c size()==other.size() , or the index of the first element which throws during move construction if a throw
2268 /// occurs.
2269 /// @post @c The elements from @c other will have been move-emplaced into @c this , up to the first element which
2270 /// threw during copy/move-construction, if any.
2271 /// @post @c The elements in the range @c [size(),other.size()) will have been reset if @c other.size() was smaller
2272 /// than the original size of @c this .
2273 template <typename OtherMap>
2274 void do_assignment(OtherMap&& other) noexcept(
2277 ) {
2278 static_cast<comparator_base&>(*this) = std::forward<OtherMap>(other);
2279 // parasoft-begin-suppress AUTOSAR-M0_1_3-a-2 "False positive: RAII class"
2281 // parasoft-end-suppress AUTOSAR-M0_1_3-a-2
2282 size_ = 0U;
2283 while (size_ != other.size_) {
2285 ++size_;
2286 }
2287 }
2288
2289 // parasoft-end-suppress AUTOSAR-A0_1_4-a
2290 // parasoft-end-suppress AUTOSAR-M0_1_8-b
2291
2292 /// @brief The current number of elements in the map
2293 index_type size_{0};
2294 /// @brief The indices of the elements in sorted order
2295 array<index_type, Capacity> indices_{sequential_values<index_type, Capacity>};
2296 // parasoft-begin-suppress AUTOSAR-M8_5_2-b-2 "False Positive: all elements default-initialized"
2297 /// @brief The storage of the actual elements themselves
2298 array<entry_type, Capacity> values_{};
2299 // parasoft-end-suppress AUTOSAR-M8_5_2-b-2
2300};
2301// parasoft-end-suppress AUTOSAR-A13_5_1-a-2
2302// parasoft-end-suppress AUTOSAR-A10_1_1-a-2
2303// parasoft-end-suppress AUTOSAR-A12_0_1-b-2
2304// parasoft-end-suppress AUTOSAR-A12_0_1-a-2
2305// parasoft-end-suppress AUTOSAR-A1_1_1-b-2
2306
2307template <typename Key, typename Value, std::size_t Capacity, typename Compare>
2309 inline_map<Key, Value, Capacity, Compare>::capacity;
2310
2311template <typename Key, typename Value, std::size_t Capacity, typename Compare>
2313 inline_map<Key, Value, Capacity, Compare>::max_size;
2314
2316namespace detail {
2317
2318/// @brief specialization for @c inline_map
2319/// @tparam Key key type of @c inline_map
2320/// @tparam Value mapped type of @c inline_map
2321/// @tparam Capacity capacity of @c inline_map
2322/// @tparam Compare compare type of @c inline_map
2323///
2324template <class Key, class Value, std::size_t Capacity, class Compare>
2325struct container_base_type<inline_map<Key, Value, Capacity, Compare>> {
2326 /// @brief container capacity-erased base type
2327 ///
2328 using type = inline_map_detail::inline_map_base<Key, Value, Compare>;
2329};
2330
2331} // namespace detail
2332} // namespace inline_container
2333
2334} // namespace base
2335} // namespace arene
2336
2337// parasoft-end-suppress AUTOSAR-M2_10_1-a-2
2338// parasoft-end-suppress AUTOSAR-A13_5_5-b-2
2339
2340#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_MAP_HPP_
A container similar to std::map that has a fixed capacity.
Definition map.hpp:153
~inline_map()=default
Default destructor.
inline_map(move_construct_source &&other) noexcept(std::is_nothrow_move_constructible< Compare >::value &&std::is_nothrow_copy_constructible< Key >::value &&std::is_nothrow_move_constructible< Value >::value)
Move the source map into the new instance, so the new map has the same size, comparator and elements ...
Definition map.hpp:711
auto find(Key const &key) const noexcept(comparison_is_noexcept<>) -> const_iterator
Obtain an iterator referring to the element equivalent to the supplied key, if there is one.
Definition map.hpp:984
auto operator=(dummy_move_assign_source &&) -> inline_map &=delete
Deleted move-assignment if the map should not be move-assignable.
static constexpr std::integral_constant< size_type, Capacity > capacity
map capacity
Definition map.hpp:402
auto operator=(copy_assign_source const &other) noexcept(std::is_nothrow_copy_assignable< Compare >::value &&std::is_nothrow_copy_constructible< Key >::value &&std::is_nothrow_copy_constructible< Value >::value) -> inline_map &
copy-assignment of a map with the same capacity.
Definition map.hpp:806
auto find(Key const &key) noexcept(comparison_is_noexcept<>) -> iterator
Obtain an iterator referring to the element equivalent to the supplied key, if there is one.
Definition map.hpp:979
Definition map.hpp:2315
Definition array_exceptions_disabled.cpp:11
constexpr std::integral_constant< typename inline_map< Key, Value, Capacity, Compare >::size_type, Capacity > inline_map< Key, Value, Capacity, Compare >::max_size
Definition map.hpp:2313
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10