Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
map_reference.hpp
Go to the documentation of this file.
1// parasoft-begin-suppress AUTOSAR-A2_8_1-a-2 "inline_container/map_reference.hpp is clear enough for
2// inline_map_reference and const_inline_map_reference"
3
4// Copyright 2026, Toyota Motor Corporation
5//
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7
8#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_MAP_REFERENCE_HPP_
9#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_MAP_REFERENCE_HPP_
10
11// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
13#include "arene/base/detail/exceptions.hpp"
15#include "arene/base/inline_container/detail/compare.hpp"
16#include "arene/base/inline_container/detail/container_base_type.hpp"
17#include "arene/base/inline_container/detail/erased_member_function.hpp" // IWYU pragma: keep
21#include "arene/base/ranges/detail/range_interface.hpp"
23#include "arene/base/stdlib_choice/cstddef.hpp"
24#include "arene/base/stdlib_choice/enable_if.hpp"
25#include "arene/base/stdlib_choice/integral_constant.hpp"
26#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
27#include "arene/base/stdlib_choice/is_same.hpp"
28#include "arene/base/stdlib_choice/pair.hpp"
30// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
31
32// parasoft-begin-suppress CERT_C-EXP37-b "False positive: The rule does not mention naming all parameters"
33// parasoft-begin-suppress AUTOSAR-A7_1_5-a "Trailing return syntax permitted by A7-1-5 Permit #1 v1.0.0"
34// parasoft-begin-suppress CERT_C-EXP37-a "False positive: The rule does not mention naming all parameters"
35// parasoft-begin-suppress AUTOSAR-M2_10_1-a-2 "Similar names permitted by M2-10-1 Permit #1"
36
37namespace arene {
38namespace base {
39namespace inline_map_reference_detail {
40
41/// @brief determine if a comparison is @c noexcept
42/// @tparam Key key type of a map
43/// @tparam Compare compare type of a map
44///
45template <class Key, class Compare>
46extern constexpr bool comparison_is_noexcept_v{inline_container::detail::compare_wrapper<Compare, Key>::
47 template comparison_is_noexcept<Key>};
48/// @brief alias for a non-const iterator
49/// @tparam MapBase associated @c inline_map_base type
50///
51template <class MapBase>
52using iterator = inline_map_reference_iterator<MapBase, false>;
53
54/// @brief alias for a const iterator
55/// @tparam MapBase associated @c inline_map_base type
56///
57template <class MapBase>
58using const_iterator = inline_map_reference_iterator<MapBase, true>;
59
60/// @brief function pointers to dispatch to const member functions
61/// @tparam MapBase associated @c inline_map_base type
62///
63template <class MapBase>
64struct const_operations {
65 /// @brief type of the capacity-erased function
66 /// @tparam R function return type
67 /// @tparam Ts function argument types, excluding the map base
68 ///
69 template <class R, class... Ts>
70 using erased_op_type = auto (*)(MapBase const*, Ts...) -> R;
71
72 /// @brief The function pointer of the key_comp operation
73 erased_op_type<typename MapBase::compare_type> key_comp;
74 /// @brief The function pointer of the size operation
75 erased_op_type<typename MapBase::size_type> size;
76 /// @brief The function pointer of the capacity operation
77 erased_op_type<typename MapBase::size_type> capacity;
78 /// @brief The function pointer of the capacity operation
79 erased_op_type<typename MapBase::size_type> max_size;
80 /// @brief The function pointer of the find operation
81 erased_op_type<const_iterator<MapBase>, typename MapBase::key_type const&> find;
82 /// @brief The function pointer of the contains operation
83 erased_op_type<bool, typename MapBase::key_type const&> contains;
84 /// @brief The function pointer of the count operation
85 erased_op_type<typename MapBase::size_type, typename MapBase::key_type const&> count;
86 /// @brief The function pointer of the lower_bound operation
87 erased_op_type<const_iterator<MapBase>, typename MapBase::key_type const&> lower_bound;
88 /// @brief The function pointer of the upper_bound operation
89 erased_op_type<const_iterator<MapBase>, typename MapBase::key_type const&> upper_bound;
90 /// @brief The function pointer of the equal_range operation
91 erased_op_type<std::pair<const_iterator<MapBase>, const_iterator<MapBase>>, typename MapBase::key_type const&>
92 equal_range;
93 /// @brief The function pointer of the at operation
94 erased_op_type<typename MapBase::mapped_type const&, typename MapBase::key_type const&> at;
95 /// @brief The function pointer of the begin operation
96 erased_op_type<const_iterator<MapBase>> begin;
97 /// @brief The function pointer of the end operation
98 erased_op_type<const_iterator<MapBase>> end;
99};
100
101/// @brief function pointers to dispatch to non-const member functions
102/// @tparam MapBase associated @c inline_map_base type
103///
104template <class MapBase>
105struct operations {
106 /// @brief type of the capacity-erased function
107 /// @tparam R function return type
108 /// @tparam Ts function argument types, excluding the map base
109 ///
110 template <class R, class... Ts>
111 using erased_op_type = auto (*)(MapBase*, Ts...) -> R;
112
113 /// @brief pointer to the const operations associated with this set of
114 /// non-const operations
115 const_operations<MapBase> const* const_ops;
116 /// @brief The function pointer of the find operation
117 erased_op_type<iterator<MapBase>, typename MapBase::key_type const&> find;
118 /// @brief The function pointer of the lower_bound operation
119 erased_op_type<iterator<MapBase>, typename MapBase::key_type const&> lower_bound;
120 /// @brief The function pointer of the upper_bound operation
121 erased_op_type<iterator<MapBase>, typename MapBase::key_type const&> upper_bound;
122 /// @brief The function pointer of the equal_range operation
123 erased_op_type<std::pair<iterator<MapBase>, iterator<MapBase>>, typename MapBase::key_type const&> equal_range;
124 /// @brief The function pointer of the operator[] operation
125 erased_op_type<typename MapBase::mapped_type&, typename MapBase::key_type const&> operator_index;
126 /// @brief The function pointer of the at operation
127 erased_op_type<typename MapBase::mapped_type&, typename MapBase::key_type const&> at;
128 /// @brief The function pointer of the insert operation
129 erased_op_type<std::pair<iterator<MapBase>, bool>, typename MapBase::value_type const&> insert;
130 /// @brief The function pointer of the insert_or_assign operation
131 erased_op_type<
132 std::pair<iterator<MapBase>, bool>,
133 typename MapBase::key_type const&,
134 typename MapBase::mapped_type const&>
135 insert_or_assign;
136 /// @brief The function pointer of the erase operation, key overload
137 erased_op_type<iterator<MapBase>, typename MapBase::key_type const&> erase_key;
138 /// @brief The function pointer of the erase operation, iterator overload
139 erased_op_type<iterator<MapBase>, const_iterator<MapBase>> erase_pos;
140 /// @brief The function pointer of the erase operation, range overload
141 erased_op_type<iterator<MapBase>, const_iterator<MapBase>, const_iterator<MapBase>> erase_rng;
142 /// @brief The function pointer of the clear operation
143 erased_op_type<void> clear;
144 /// @brief The function pointer of the begin operation
145 erased_op_type<iterator<MapBase>> begin;
146 /// @brief The function pointer of the end operation
147 erased_op_type<iterator<MapBase>> end;
148};
149
150/// @brief "alias" to a capacity-erased member function helper
151/// @tparam MemFn member function pointer of the non-erased container type
152/// @tparam Func pointer to the member function
153/// @tparam Return return type of this helper, defaults to @c member_function_return_t<MemFn>
154///
155template <class MemFn, MemFn Func, class Return = member_function_return_t<MemFn>>
156extern constexpr auto erased_member_function = inline_container::detail::erased_member_function<MemFn, Func, Return>;
157
158// parasoft-begin-suppress AUTOSAR-M3_3_2-a "False positive: inline function used in multiple translation units"
159/// @brief capacity-erased function that returns a compile-time constant
160/// @tparam Map The associated @c inline_map type (used to deduce @c MapBase)
161/// @tparam T the type of the constant
162/// @tparam Value the compile-time constant to return
163/// @tparam MapBase deduced template param used to simplify definition
164/// @return Value
165template <class Map, class T, T Value, class MapBase = inline_container::detail::container_base_type_t<Map>>
166auto erased_integral_constant_function(MapBase const*) noexcept -> T {
167 return Value;
168}
169// parasoft-end-suppress AUTOSAR-M3_3_2-a
170
171/// @brief function pointers to dispatch to const member functions
172/// @tparam Map The associated @c inline_map type
173/// @tparam MapBase deduced template param used to simplify definition
174/// @tparam ComparisonIsNoexcept deduced template param used to simplify definition
175///
176/// Collection of member function pointers for a given instance of @c
177/// inline_map. Member function pointers are transformed to replace the implicit
178/// @c this parameter with a pointer to @c MapBase. Member function pointers
179/// that return an @c inline_map specific iterator type are also transformed to
180/// return a @c map_reference_iterator instead.
181///
182/// @note Older versions of GCC (e.g. GCC8) require the exact @c noexcept
183/// qualifier for the pointer to member function type. More recent versions
184/// may omit the @c noexcept qualifier and rely on an implicit conversion of
185/// a @c noexcept(true) function to a @c noexcept(false) function.
186///
187template <
188 class Map,
189 class MapBase = inline_container::detail::container_base_type_t<Map>,
190 bool ComparisonIsNoexcept = comparison_is_noexcept_v<typename Map::key_type, typename Map::compare_type>>
191extern constexpr auto const_map_operations_with_at = const_operations<MapBase>{
192 erased_member_function<decltype(&Map::key_comp), &Map::key_comp>,
193 erased_member_function<decltype(&Map::size), &Map::size>,
194 &erased_integral_constant_function<Map, std::size_t, Map::capacity>,
195 &erased_integral_constant_function<Map, std::size_t, Map::max_size>,
196 erased_member_function<
197 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::const_iterator,
198 &Map::find,
199 const_iterator<MapBase>>,
200 erased_member_function<
201 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->bool,
202 &Map::contains>,
203 erased_member_function<
204 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::size_type,
205 &Map::count>,
206 erased_member_function<
207 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::const_iterator,
208 &Map::lower_bound,
209 const_iterator<MapBase>>,
210 erased_member_function<
211 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::const_iterator,
212 &Map::upper_bound,
213 const_iterator<MapBase>>,
214 erased_member_function<
215 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)
216 ->std::pair<typename Map::const_iterator, typename Map::const_iterator>,
217 &Map::equal_range,
218 std::pair<const_iterator<MapBase>, const_iterator<MapBase>>>,
219 erased_member_function<
220 auto (Map::*)(typename Map::key_type const&) const noexcept(false)->typename Map::mapped_type const&,
221 &Map::at>,
222 erased_member_function<decltype(&Map::cbegin), &Map::begin, const_iterator<MapBase>>,
223 erased_member_function<decltype(&Map::cend), &Map::end, const_iterator<MapBase>>
224};
225
226/// @brief function pointers to dispatch to const member functions
227/// @tparam Map The associated @c inline_map type
228/// @tparam MapBase deduced template param used to simplify definition
229/// @tparam ComparisonIsNoexcept deduced template param used to simplify definition
230///
231/// Collection of member function pointers for a given instance of @c
232/// inline_map. Member function pointers are transformed to replace the implicit
233/// @c this parameter with a pointer to @c MapBase. Member function pointers
234/// that return an @c inline_map specific iterator type are also transformed to
235/// return a @c map_reference_iterator instead.
236///
237/// @note Older versions of GCC (e.g. GCC8) require the exact @c noexcept
238/// qualifier for the pointer to member function type. More recent versions
239/// may omit the @c noexcept qualifier and rely on an implicit conversion of
240/// a @c noexcept(true) function to a @c noexcept(false) function.
241///
242template <
243 class Map,
244 class MapBase = inline_container::detail::container_base_type_t<Map>,
245 bool ComparisonIsNoexcept = comparison_is_noexcept_v<typename Map::key_type, typename Map::compare_type>>
246extern constexpr auto const_map_operations_without_at = const_operations<MapBase>{
247 erased_member_function<decltype(&Map::key_comp), &Map::key_comp>,
248 erased_member_function<decltype(&Map::size), &Map::size>,
249 &erased_integral_constant_function<Map, std::size_t, Map::capacity>,
250 &erased_integral_constant_function<Map, std::size_t, Map::max_size>,
251 erased_member_function<
252 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::const_iterator,
253 &Map::find,
254 const_iterator<MapBase>>,
255 erased_member_function<
256 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->bool,
257 &Map::contains>,
258 erased_member_function<
259 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::size_type,
260 &Map::count>,
261 erased_member_function<
262 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::const_iterator,
263 &Map::lower_bound,
264 const_iterator<MapBase>>,
265 erased_member_function<
266 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)->typename Map::const_iterator,
267 &Map::upper_bound,
268 const_iterator<MapBase>>,
269 erased_member_function<
270 auto (Map::*)(typename Map::key_type const&) const noexcept(ComparisonIsNoexcept)
271 ->std::pair<typename Map::const_iterator, typename Map::const_iterator>,
272 &Map::equal_range,
273 std::pair<const_iterator<MapBase>, const_iterator<MapBase>>>,
274 nullptr, // this is &Map::at, which does not exist (and is removed from map_reference by SFINAE)
275 erased_member_function<decltype(&Map::cbegin), &Map::begin, const_iterator<MapBase>>,
276 erased_member_function<decltype(&Map::cend), &Map::end, const_iterator<MapBase>>
277};
278
279/// @brief capacity-erased helper for @c inline_map::erase overloads
280/// @tparam Map The associated @c inline_map type
281/// @tparam MapBase deduced template param used to simplify definition
282///
283/// Helper type that provides functions to call @c inline_map::erase with
284/// iterator arguments.
285///
286template <class Map, class MapBase = inline_container::detail::container_base_type_t<Map>>
287class erase_fn_iterator_argument_adaptor : inline_map_detail::inline_map_passkey_base<MapBase> {
288 /// @brief convert a capacity-erased iterator to an @c inline_map::const_iterator
289 /// @param iter capacity-erased iterator
290 /// @return @c inline_map::const_iterator to the same position in the map
291 ///
292 static auto restored(const_iterator<MapBase> iter) noexcept -> typename Map::const_iterator {
294
295 constexpr auto passkey = typename inline_map_detail::inline_map_passkey_base<MapBase>::inline_map_passkey{};
296
297 return typename Map::const_iterator{
298 passkey,
299 static_cast<Map const*>(iter.get_map(passkey)),
300 static_cast<index_type>(iter.get_index(passkey))
301 };
302 }
303
304 /// @brief obtain the associated @c inline_map
305 /// @param map pointer to a map base
306 /// @return reference to an @c inline_map
307 ///
308 static auto derived(MapBase* map) noexcept -> Map& { return *static_cast<Map*>(map); }
309
310 public:
311 /// @brief erase an element in a map
312 /// @param map pointer to a map base
313 /// @param pos capacity-erased iterator specifying a position in @c map
314 /// @pre @c pos is a dereferencable iterator of @c map
315 /// @return capacity-erased iterator specifying the position after the removed
316 /// element
317 ///
318 static auto one_argument_overload(MapBase* map, const_iterator<MapBase> pos) noexcept -> iterator<MapBase> {
319 return iterator<MapBase>{derived(map).erase(restored(pos))};
320 }
321
322 /// @brief erase elements in a map
323 /// @param map pointer to a map base
324 /// @param first beginning of the range of elements to remove
325 /// @param last end of the range of elements to remove
326 /// @pre <tt> [first, last) </tt> is a valid range in @c map
327 /// @return capacity-erased iterator specifying the position after the removed
328 /// elements
329 ///
330 static auto two_argument_overload(MapBase* map, const_iterator<MapBase> first, const_iterator<MapBase> last) noexcept
331 -> iterator<MapBase> {
332 return iterator<MapBase>{derived(map).erase(restored(first), restored(last))};
333 }
334};
335
336/// @brief function pointers to dispatch to non-const member functions
337/// @tparam Map The associated @c inline_map type
338/// @tparam MapBase deduced template param used to simplify definition
339/// @tparam ComparisonIsNoexcept deduced template param used to simplify definition
340///
341/// Collection of member function pointers for a given instance of @c
342/// inline_map. Member function pointers are transformed to replace the implicit
343/// @c this parameter with a pointer to @c MapBase. Member function pointers
344/// that return an @c inline_map specific iterator type are also transformed to
345/// return a @c map_reference_iterator instead.
346///
347/// @note Older versions of GCC (e.g. GCC8) require the exact @c noexcept
348/// qualifier for the pointer to member function type. More recent versions
349/// may omit the @c noexcept qualifier and rely on an implicit conversion of
350/// a @c noexcept(true) function to a @c noexcept(false) function.
351///
352template <
353 class Map,
354 class MapBase = inline_container::detail::container_base_type_t<Map>,
355 bool ComparisonIsNoexcept = comparison_is_noexcept_v<typename Map::key_type, typename Map::compare_type>>
356extern constexpr auto map_operations_with_at = operations<MapBase>{
357 &const_map_operations_with_at<Map>,
358 erased_member_function<
359 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
360 &Map::find,
361 iterator<MapBase>>,
362 erased_member_function<
363 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
364 &Map::lower_bound,
365 iterator<MapBase>>,
366 erased_member_function<
367 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
368 &Map::upper_bound,
369 iterator<MapBase>>,
370 erased_member_function<
371 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)
372 ->std::pair<typename Map::iterator, typename Map::iterator>,
373 &Map::equal_range,
374 std::pair<iterator<MapBase>, iterator<MapBase>>>,
375 erased_member_function < auto (Map::*)(typename Map::key_type const&) noexcept(false)->typename Map::mapped_type&,
376 &Map::operator[]>,
377 erased_member_function<
378 auto (Map::*)(typename Map::key_type const&) noexcept(false)->typename Map::mapped_type&,
379 &Map::at>,
380 erased_member_function<
381 auto (Map::*)(typename Map::value_type const&) noexcept(false)->std::pair<typename Map::iterator, bool>,
382 &Map::insert,
383 std::pair<iterator<MapBase>, bool>>,
384 erased_member_function<
385 auto (Map::*)(typename Map::key_type const&, typename Map::mapped_type const&) noexcept(false)
386 ->std::pair<typename Map::iterator, bool>,
387 &Map::insert_or_assign,
388 std::pair<iterator<MapBase>, bool>>,
389 erased_member_function<
390 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
391 &Map::erase,
392 iterator<MapBase>>,
393 &erase_fn_iterator_argument_adaptor<Map>::one_argument_overload,
394 &erase_fn_iterator_argument_adaptor<Map>::two_argument_overload,
395 erased_member_function<decltype(&Map::clear), &Map::clear>,
396 erased_member_function<auto (Map::*)() noexcept -> typename Map::iterator, &Map::begin, iterator<MapBase>>,
397 erased_member_function<auto (Map::*)() noexcept -> typename Map::iterator, &Map::end, iterator<MapBase>>
398};
399
400/// @brief function pointers to dispatch to non-const member functions
401/// @tparam Map The associated @c inline_map type
402/// @tparam MapBase deduced template param used to simplify definition
403/// @tparam ComparisonIsNoexcept deduced template param used to simplify definition
404///
405/// Collection of member function pointers for a given instance of @c
406/// inline_map. Member function pointers are transformed to replace the implicit
407/// @c this parameter with a pointer to @c MapBase. Member function pointers
408/// that return an @c inline_map specific iterator type are also transformed to
409/// return a @c map_reference_iterator instead.
410///
411/// @note Older versions of GCC (e.g. GCC8) require the exact @c noexcept
412/// qualifier for the pointer to member function type. More recent versions
413/// may omit the @c noexcept qualifier and rely on an implicit conversion of
414/// a @c noexcept(true) function to a @c noexcept(false) function.
415///
416template <
417 class Map,
418 class MapBase = inline_container::detail::container_base_type_t<Map>,
419 bool ComparisonIsNoexcept = comparison_is_noexcept_v<typename Map::key_type, typename Map::compare_type>>
420extern constexpr auto map_operations_without_at = operations<MapBase>{
421 &const_map_operations_without_at<Map>,
422 erased_member_function<
423 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
424 &Map::find,
425 iterator<MapBase>>,
426 erased_member_function<
427 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
428 &Map::lower_bound,
429 iterator<MapBase>>,
430 erased_member_function<
431 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
432 &Map::upper_bound,
433 iterator<MapBase>>,
434 erased_member_function<
435 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)
436 ->std::pair<typename Map::iterator, typename Map::iterator>,
437 &Map::equal_range,
438 std::pair<iterator<MapBase>, iterator<MapBase>>>,
439 erased_member_function < auto (Map::*)(typename Map::key_type const&) noexcept(false)->typename Map::mapped_type&,
440 &Map::operator[]>,
441 nullptr, // this is &Map::at, which does not exist (and is removed from map_reference by SFINAE)
442 erased_member_function<
443 auto (Map::*)(typename Map::value_type const&) noexcept(false)->std::pair<typename Map::iterator, bool>,
444 &Map::insert,
445 std::pair<iterator<MapBase>, bool>>,
446 erased_member_function<
447 auto (Map::*)(typename Map::key_type const&, typename Map::mapped_type const&) noexcept(false)
448 ->std::pair<typename Map::iterator, bool>,
449 &Map::insert_or_assign,
450 std::pair<iterator<MapBase>, bool>>,
451 erased_member_function<
452 auto (Map::*)(typename Map::key_type const&) noexcept(ComparisonIsNoexcept)->typename Map::iterator,
453 &Map::erase,
454 iterator<MapBase>>,
455 &erase_fn_iterator_argument_adaptor<Map>::one_argument_overload,
456 &erase_fn_iterator_argument_adaptor<Map>::two_argument_overload,
457 erased_member_function<decltype(&Map::clear), &Map::clear>,
458 erased_member_function<auto (Map::*)() noexcept -> typename Map::iterator, &Map::begin, iterator<MapBase>>,
459 erased_member_function<auto (Map::*)() noexcept -> typename Map::iterator, &Map::end, iterator<MapBase>>
460};
461
462/// @brief CRTP helper providing const member functions
463/// @tparam Derived @c const_inline_map_reference or @c inline_map_reference
464///
465template <class Derived>
466class const_inline_map_reference_interface {
467 /// @brief downcast
468 /// @return reference to @c**this as the derived type
469 ///
470 auto derived() const noexcept -> Derived const& { return static_cast<Derived const&>(*this); }
471
472 /// @brief obtain a pointer to the capacity-erased map
473 /// @tparam D type that is always intended to be @c Derived
474 /// @return map base type pointer
475 ///
476 template <class D>
477 auto map() const noexcept -> typename D::map_base_type const* {
478 return derived().map_ptr();
479 }
480
481 /// @brief obtain the capacity-erased operations
482 /// @tparam D type that is always intended to be @c Derived
483 /// @return reference to capacity-erased operations
484 ///
485 template <class D>
486 auto ops() const noexcept -> const_operations<typename D::map_base_type> const& {
487 return *derived().const_ops_ptr();
488 }
489
490 /// @brief determine if comparison is @c noexcept
491 /// @tparam D type that is always intended to be @c Derived
492 ///
493 template <class D>
494 static constexpr bool comparison_is_noexcept{inline_map_reference_detail::comparison_is_noexcept_v<
495 typename D::key_type,
496 typename D::compare_type>};
497
498 protected:
499 /// @brief constructor
500 /// @tparam Actual tag type, intended to always be @c Derived
501 /// @tparam Expected deduced template parameter, defined to improve compiler
502 /// error messages
503 ///
504 /// Construct a 'const_inline_map_reference_interface' CRTP helper type. Intended to be invoked as:
505 /// ~~~{.cpp}
506 /// const_inline_map_reference_interface{this}
507 /// ~~~
508 ///
509 /// This constructor exists to prevent use by a type that does _not_ define
510 /// 'const_inline_map_reference_interface' as a CRTP base class or to detect
511 /// mismatch between the actual derived type and the @c Derived template
512 /// parameter.
513 ///
514 template <class Actual, class Expected = Derived>
515 explicit const_inline_map_reference_interface(Actual*) noexcept {
516 static_assert(
518 "'Derived' type mismatch.\n" //
519 "Please verify that 'Derived' is defined correctly when using 'const_inline_map_reference_interface' as a CRTP "
520 "base."
521 );
522 }
523 /// @brief default destructor
524 ~const_inline_map_reference_interface() = default;
525 /// @brief default copy constructor
526 const_inline_map_reference_interface(const_inline_map_reference_interface const&) = default;
527 /// @brief default move constructor
528 const_inline_map_reference_interface(const_inline_map_reference_interface&&) = default;
529 /// @brief default copy assignment operator
530 auto operator=(const_inline_map_reference_interface const&) -> const_inline_map_reference_interface& = default;
531 /// @brief default move assignment operator
532 auto operator=(const_inline_map_reference_interface&&) -> const_inline_map_reference_interface& = default;
533
534 public:
535 /// @brief Obtain a copy of the comparator
536 /// @return The comparator
537 template <class D = Derived>
538 auto key_comp() const noexcept(std::is_nothrow_copy_constructible<typename D::compare_type>::value)
539 -> decltype(ops<D>().key_comp(map<D>())) {
540 return ops<D>().key_comp(map<D>());
541 }
542
543 /// @brief Get the current number of elements in the map
544 /// @return the size
545 template <class D = Derived>
546 auto size() const noexcept -> decltype(ops<D>().size(map<D>())) {
547 return ops<D>().size(map<D>());
548 }
549
550 /// @brief Get the element capacity of the map
551 /// @return the capacity
552 template <class D = Derived>
553 auto capacity() const noexcept -> decltype(ops<D>().capacity(map<D>())) {
554 return ops<D>().capacity(map<D>());
555 }
556
557 /// @brief Get the max size of the map
558 /// @return the max size
559 template <class D = Derived>
560 auto max_size() const noexcept -> decltype(ops<D>().max_size(map<D>())) {
561 return ops<D>().max_size(map<D>());
562 }
563
564 /// @brief Obtain an iterator referring to the element equivalent to the supplied key, if there is one.
565 /// @param key The key to find
566 /// @return iterator to the equivalent element, or @c end() if the element is not found
567 template <class D = Derived>
568 auto find(typename D::key_type const& key) const noexcept(comparison_is_noexcept<D>)
569 -> decltype(ops<D>().find(map<D>(), key)) {
570 return ops<D>().find(map<D>(), key);
571 }
572
573 /// @brief Check if the set contains a specific key
574 /// @param key The key to search for
575 /// @return true if @c find(key)!=end() .
576 /// @return false if @c find(key)==end() .
577 template <class D = Derived>
578 auto contains(typename D::key_type const& key) const noexcept(comparison_is_noexcept<D>)
579 -> decltype(ops<D>().contains(map<D>(), key)) {
580 return ops<D>().contains(map<D>(), key);
581 }
582
583 /// @brief Return the number of elements in the map equivalent to a specific key.
584 ///
585 /// @param key The key to search for.
586 /// @return std::size_t @c 0 if the element was not in the map, else @c 1 .
587 template <class D = Derived>
588 auto count(typename D::key_type const& key) const noexcept(comparison_is_noexcept<D>)
589 -> decltype(ops<D>().count(map<D>(), key)) {
590 return ops<D>().count(map<D>(), key);
591 }
592
593 /// @brief Find the first element which is _not less than_ a given key.
594 ///
595 /// @param key The key to find the lower bound for.
596 /// @return iterator to the first element which is _not less than_ @c key , or @c end() if there is no
597 /// such element.
598 template <class D = Derived>
599 auto lower_bound(typename D::key_type const& key) const noexcept(comparison_is_noexcept<D>)
600 -> decltype(ops<D>().lower_bound(map<D>(), key)) {
601 return ops<D>().lower_bound(map<D>(), key);
602 }
603
604 /// @brief Find the first element which is _not less than_ a given key.
605 ///
606 /// @param key The key to find the lower bound for.
607 /// @return const_iterator to the first element which is _not less than_ @c key , or @c end() if there is no
608 /// such element.
609 template <class D = Derived>
610 auto upper_bound(typename D::key_type const& key) const noexcept(comparison_is_noexcept<D>)
611 -> decltype(ops<D>().upper_bound(map<D>(), key)) {
612 return ops<D>().upper_bound(map<D>(), key);
613 }
614
615 /// @brief Finds the sequence of elements whose keys compare equivalent to a given key.
616 ///
617 /// @param key The key to search for
618 /// @return std::pair<iterator, iterator> A pair of iterators such that all elements in the range @c [first,second)
619 /// have keys which compare equal to @c key if there was a key equivalent to @c key in the map. Otherwise both
620 /// iterators will be @c end() .
621 template <class D = Derived>
622 auto equal_range(typename D::key_type const& key) const noexcept(comparison_is_noexcept<D>)
623 -> decltype(ops<D>().equal_range(map<D>(), key)) {
624 return ops<D>().equal_range(map<D>(), key);
625 }
626
627 /// @brief Obtain a reference to the mapped value for the specified key or throw.
628 ///
629 /// @param key The key to obtain the value for
630 /// @return Value& A reference to the mapped value
631 /// @throws std::out_of_range if @c find(key)==end() .
632 /// @throws Any exception thrown by the comparisons
633 template <
634 class D = Derived,
635 bool AreExceptionsEnabled = detail::are_exceptions_enabled::value,
637 auto at(typename D::key_type const& key) const noexcept(false) -> decltype(ops<D>().at(map<D>(), key)) {
638 return ops<D>().at(map<D>(), key);
639 }
640
641 /// @brief Obtain an iterator referring to the beginning of the sorted range of elements.
642 /// @return iterator Points to the first element in the sequence, or @c end() if @c empty() .
643 template <class D = Derived>
644 auto begin() const noexcept -> decltype(ops<D>().begin(map<D>())) {
645 return ops<D>().begin(map<D>());
646 }
647
648 /// @brief Obtain an iterator referring to one past the last element in the sorted range of elements.
649 /// @return iterator An iterator pointing to one past the last element in the sequence.
650 template <class D = Derived>
651 auto end() const noexcept -> decltype(ops<D>().end(map<D>())) {
652 return ops<D>().end(map<D>());
653 }
654};
655
656} // namespace inline_map_reference_detail
657
658// parasoft-begin-suppress AUTOSAR-A10_2_1-a "Hiding members of the interface
659// base (e.g. 'begin') does not 'defeat polymorphism by causing an object to
660// behave differently depending on which interface is used to manipulate it.' No
661// functions are virtual and this is no different than selecting a const or
662// non-const member function based on the const-ness of an object."
663
664// parasoft-begin-suppress AUTOSAR-A10_2_1-b "Hiding members of the interface
665// base (e.g. 'begin') does not 'defeat polymorphism by causing an object to
666// behave differently depending on which interface is used to manipulate it.' No
667// functions are virtual and this is no different than selecting a const or
668// non-const member function based on the const-ness of an object."
669
670// parasoft-begin-suppress AUTOSAR-A12_1_5-a "False positive: there is no
671// common class initialization betweeen two constructors where one is deleted"
672
673// parasoft-begin-suppress AUTOSAR-A13_5_1-a "False positive:" rule specifies
674// that a const overload of 'operator[]' is required if a non-const overload of
675// 'operator[]' is defined. This class only defines a const overload."
676
677// parasoft-begin-suppress AUTOSAR-A10_1_1-a-2 "False positive: Only inherits from interface base classes"
678
679/// @brief A reference class to an inline_map object, with size-erased type
680/// @tparam Key The key type for the map
681/// @tparam Value The mapped type for the map
682/// @tparam Compare The comparison function
683/// @pre The comparison must provide a strict ordering over the values of @c Key
684///
685template <class Key, class Value, class Compare>
687 : public inline_map_reference_detail::const_inline_map_reference_interface<
688 inline_map_reference<Key, Value, Compare>>
689 , public ranges::detail::range_interface<inline_map_reference<Key, Value, Compare>> {
690 public:
691 /// @brief alias to the map base class
692 using map_base_type = inline_map_detail::inline_map_base<Key, Value, Compare>;
693
694 /// @brief alias to const operations type
695 using const_ops_type = inline_map_reference_detail::const_operations<map_base_type>;
696
697 /// @brief alias to non-const operations type
698 using ops_type = inline_map_reference_detail::operations<map_base_type>;
699
700 /// @brief key type of the map
701 using key_type = Key;
702 /// @brief mapped type of the map
703 using mapped_type = Value;
704 /// @brief value type of the map
705 using value_type = std::pair<Key const, Value>;
706 /// @brief size type of the map
707 using size_type = typename map_base_type::size_type;
708 /// @brief iterator type of a reference to the map
710 /// @brief const iterator type of the underlying map
712 /// @brief The type of an iterator that provides non- @c const access to the elements
713 /// and iterates in reverse through the elements
715 /// @brief The type of an iterator that provides @c const access to the elements
716 /// and iterates in reverse through the elements
718 /// @brief compare type of the map
719 using compare_type = Compare;
720
721 private:
722 /// @brief alias to the interface class providing const member functions
723 using interface_base = inline_map_reference_detail::const_inline_map_reference_interface<inline_map_reference>;
724
725 /// @brief alias to the range interface class providing range member functions
726 using range_base = ranges::detail::range_interface<inline_map_reference<Key, Value, Compare>>;
727
728 /// @brief pointer to the base class
729 map_base_type* map_ptr_;
730
731 /// @brief pointer to const operations
732 ops_type const* ops_ptr_;
733
734 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: identifier
735 // 'comparison_is_noexcept' in the base type is not hidden, it is private"
736
737 /// @brief determine if comparison is @c noexcept
738 static constexpr bool comparison_is_noexcept{inline_container::detail::compare_wrapper<Compare, Key>::
739 template comparison_is_noexcept<Key>};
740 // parasoft-end-suppress AUTOSAR-A2_10_1-e
741
742 public:
743 /// @brief obtain a pointer to the map base
744 /// @return pointer to the map base
745 ///
746 auto map_ptr() const noexcept -> map_base_type* { return map_ptr_; }
747
748 /// @brief obtain a pointer to the non-const operations
749 /// @return pointer to the non-const operations
750 ///
751 auto ops_ptr() const noexcept -> ops_type const* { return ops_ptr_; }
752
753 /// @brief obtain a pointer to the const operations
754 /// @return pointer to the const operations
755 ///
756 auto const_ops_ptr() const noexcept -> const_ops_type const* { return ops_ptr()->const_ops; }
757
758 /// @brief construct an @c inline_map_reference of a map
759 /// @tparam Capacity capacity of the @c inline_map
760 /// @param map @c inline_map to reference
761 ///
762 template <
763 std::size_t Capacity,
764 bool AreExceptionsEnabled = detail::are_exceptions_enabled::value,
767 : interface_base{this},
768 range_base{this},
769 map_ptr_{&map},
770 ops_ptr_{&inline_map_reference_detail::map_operations_with_at<inline_map<Key, Value, Capacity, Compare>>} {}
771
772 /// @brief construct an @c inline_map_reference of a map
773 /// @tparam Capacity capacity of the @c inline_map
774 /// @param map @c inline_map to reference
775 ///
776 template <
777 std::size_t Capacity,
778 bool AreExceptionsEnabled = detail::are_exceptions_enabled::value,
781 : interface_base{this},
782 range_base{this},
783 map_ptr_{&map},
784 ops_ptr_{&inline_map_reference_detail::map_operations_without_at<inline_map<Key, Value, Capacity, Compare>>} {}
785
786 /// @brief construct an @c inline_map_reference of a map
787 /// @tparam Capacity capacity of the @c inline_map
788 ///
789 /// Deleted overload for rvalue references.
790 ///
791 template <std::size_t Capacity>
793
794 /// @brief obtain an iterator to the first element with a given key
795 /// @param key the key to search for
796 /// @return iterator to the first element equal to @c key, or @c end() if the
797 /// element is not found
798 ///
799 auto find(key_type const& key) const noexcept(comparison_is_noexcept) -> decltype(ops_ptr_->find(map_ptr_, key)) {
800 return ops_ptr_->find(map_ptr_, key);
801 }
802
803 /// @brief find the first element which is _not less than_ a given key
804 /// @param key the key to search for
805 /// @return iterator to the first element which is _not less than_ @c key, or
806 /// @c end() if there is no such element
807 ///
808 auto lower_bound(key_type const& key) const noexcept(comparison_is_noexcept)
809 -> decltype(ops_ptr_->lower_bound(map_ptr_, key)) {
810 return ops_ptr_->lower_bound(map_ptr_, key);
811 }
812
813 /// @brief find the first element which is _greater than_ a given key
814 /// @param key the key to search for
815 /// @return iterator to the first element which is _greater than_ @c key, or
816 /// @c end() if there is no such element
817 ///
818 auto upper_bound(key_type const& key) const noexcept(comparison_is_noexcept)
819 -> decltype(ops_ptr_->upper_bound(map_ptr_, key)) {
820 return ops_ptr_->upper_bound(map_ptr_, key);
821 }
822
823 /// @brief find the sequence of elements whose keys compare equivalent to a given key
824 /// @param key the key to search for
825 /// @return pair of iterators such that all elements in the range <tt> [first, second) </tt>
826 /// have keys which compare equal to @c key if there was a key equivalent to
827 /// @c key in the map. Otherwise both iterators will be @c end().
828 ///
829 auto equal_range(key_type const& key) const noexcept(comparison_is_noexcept)
830 -> decltype(ops_ptr_->equal_range(map_ptr_, key)) {
831 return ops_ptr_->equal_range(map_ptr_, key);
832 }
833
834 /// @brief obtain a reference to the mapped value for the specified key
835 /// @param key the key to search for
836 /// @return reference to the mapped value. If @c key did not exist in the map,
837 /// then a default constructed @c mapped_type is inserted into the map at @c
838 /// key and a reference to it is returned.
839 ///
840 /// @throws anny exception thrown by the comparisons, and exception throw by
841 /// the copy-constructor of @c key_type, or the default-constructor of
842 /// @c mapped_type
843 ///
844 /// @pre <tt> size() < Capacity </tt> if @c contains(key) is @c false
845 ///
846 auto operator[](key_type const& key) const noexcept(false) -> decltype(ops_ptr_->operator_index(map_ptr_, key)) {
847 return ops_ptr_->operator_index(map_ptr_, key);
848 }
849
850 /// @brief obtain a reference to the mapped value for the specified key
851 /// @param key the key to search for
852 /// @return reference to the mapped value
853 /// @throws std::out_of_range if @c contains(key) is @c false
854 /// @throws any exception thrown by the comparisons
855 ///
856 template <
857 bool AreExceptionsEnabled = detail::are_exceptions_enabled::value,
859 auto at(key_type const& key) const noexcept(false) -> decltype(ops_ptr_->at(map_ptr_, key)) {
860 return ops_ptr_->at(map_ptr_, key);
861 }
862
863 /// @brief insert an element in the map
864 /// @param value the value to insert
865 ///
866 /// Copy constructs the provided value into the new element if an appropriate
867 /// element does not already exist.
868 ///
869 /// @return std::pair<iterator, bool> whose first element is the key
870 /// equivalent to @c value.first, and whose second element is a boolean with
871 /// a value of @c true if the element was inserted or @c false if not.
872 ///
873 /// @pre @c contains(value.first) is @c true, or <tt> size() < Capacity </tt>
874 /// of the @c inline_map
875 ///
876 /// @throws any exception thrown by the comparisons, or the copy constructor
877 /// of @c value_type
878 ///
879 auto insert(value_type const& value) const noexcept(false) -> decltype(ops_ptr_->insert(map_ptr_, value)) {
880 return ops_ptr_->insert(map_ptr_, value);
881 }
882
883 /// @brief insert an element in the map or update an existing element
884 /// @param key the key for which to insert or assign an element
885 /// @param mapped the value to associate with @c key
886 ///
887 /// If @c key is contained in the @c inline_map, updates the associated value
888 /// by copy-assigning @c mapped. If @c key is not contained in the @c
889 /// inline_map, constructs a new element in the @c inline_map by copying @c
890 /// key and @c mapped.
891 ///
892 /// @return pair containing an iterator to the element in the map and boolean
893 /// that is @c true if the element was inserted and @c false if not.
894 ///
895 /// @pre @c contains(key) is @c true, or <tt> size() < Capacity </tt> of the
896 /// @c inline_map
897 ///
898 /// @throws any exception thrown by the comparisons, the move constructor of
899 /// @c key_type or the constructor or assignment operator of @c value_type
900 ///
901 auto insert_or_assign(key_type const& key, mapped_type const& mapped) const noexcept(false)
902 -> decltype(ops_ptr_->insert_or_assign(map_ptr_, key, mapped)) {
903 return ops_ptr_->insert_or_assign(map_ptr_, key, mapped);
904 }
905
906 /// @brief remove element with the corresponding key, if there is one
907 /// @param key The key to erase
908 /// @return iterator after the removed element, or @c end if there is no
909 /// element was removed
910 ///
911 auto erase(key_type const& key) const noexcept(comparison_is_noexcept)
912 -> decltype(ops_ptr_->erase_key(map_ptr_, key)) {
913 return ops_ptr_->erase_key(map_ptr_, key);
914 }
915
916 /// @brief remove the element at the specified position
917 /// @param pos iterator referring to the element to remove
918 /// @pre @c pos must be a dereferencable iterator referring to an element in @c map
919 /// @return iterator after the removed element
920 ///
921 auto erase(const_iterator pos) const noexcept -> decltype(ops_ptr_->erase_pos(map_ptr_, pos)) {
922 return ops_ptr_->erase_pos(map_ptr_, pos);
923 }
924
925 /// @brief remove elements in the specified range
926 /// @param first beginning of the range of elements to remove
927 /// @param last end of the range of elements to remove
928 /// @pre <tt> [first, last) </tt> is a valid range in @c map
929 /// @return iterator after the removed element
930 ///
931 auto erase(const_iterator first, const_iterator last) const noexcept
932 -> decltype(ops_ptr_->erase_rng(map_ptr_, first, last)) {
933 return ops_ptr_->erase_rng(map_ptr_, first, last);
934 }
935
936 /// @brief destroy all elements in the assocaited @c inline_map
937 /// @post <tt> size() == 0 </tt>
938 /// @return @c void
939 ///
940 auto clear() const noexcept -> decltype(ops_ptr_->clear(map_ptr_)) { return ops_ptr_->clear(map_ptr_); }
941
942 /// @brief obtain an iterator referring to the beginning of the sorted range of elements
943 /// @return iterator to fhe first element in the sequence, or @c end() if @c empty()
944 ///
945 auto begin() const noexcept -> decltype(ops_ptr_->begin(map_ptr_)) { return ops_ptr_->begin(map_ptr_); }
946
947 /// @brief obtain an iterator referring to one past the last element in the sorted range of elements
948 /// @return iterator one past the last element in the sequence
949 ///
950 auto end() const noexcept -> decltype(ops_ptr_->end(map_ptr_)) { return ops_ptr_->end(map_ptr_); }
951};
952
953// parasoft-end-suppress AUTOSAR-A10_1_1-a-2
954// parasoft-end-suppress AUTOSAR-A10_2_1-a
955// parasoft-end-suppress AUTOSAR-A10_2_1-b
956// parasoft-end-suppress AUTOSAR-A12_1_5-a
957// parasoft-end-suppress AUTOSAR-A13_5_1-a
958
959// parasoft-begin-suppress AUTOSAR-A12_1_5-a "Delegating constructors would not reduce duplication"
960// parasoft-begin-suppress AUTOSAR-A10_1_1-a-2 "False positive: Only inherits from interface base classes"
961
962/// @brief A const reference class to an inline_map object, with size-erased type
963/// @tparam Key The key type for the map
964/// @tparam Value The mapped type for the map
965/// @tparam Compare The comparison function
966/// @pre The comparison must provide a strict ordering over the values of @c Key
967///
968template <class Key, class Value, class Compare>
970 : public inline_map_reference_detail::const_inline_map_reference_interface<
971 const_inline_map_reference<Key, Value, Compare>>
972 , public ranges::detail::range_interface<const_inline_map_reference<Key, Value, Compare>> {
973 public:
974 /// @brief alias to the capacity-erased map base class
975 using map_base_type = inline_map_detail::inline_map_base<Key, Value, Compare>;
976
977 /// @brief alias to const operations type
978 using const_ops_type = inline_map_reference_detail::const_operations<map_base_type>;
979
980 /// @brief key type of the map
981 using key_type = Key;
982 /// @brief mapped type of the map
983 using mapped_type = Value;
984 /// @brief value type of the map
985 using value_type = std::pair<Key const, Value>;
986 /// @brief size type of the map
987 using size_type = typename map_base_type::size_type;
988 /// @brief iterator type of a const reference to the map
990 /// @brief const iterator type of the underlying map
992 /// @brief The type of an iterator that provides non- @c const access to the elements
993 /// and iterates in reverse through the elements
995 /// @brief The type of an iterator that provides @c const access to the elements
996 /// and iterates in reverse through the elements
998 /// @brief compare type of the map
999 using compare_type = Compare;
1000
1001 private:
1002 /// @brief alias to the interface class providing const member functions
1003 using interface_base = inline_map_reference_detail::const_inline_map_reference_interface<const_inline_map_reference>;
1004
1005 /// @brief alias to the range interface class providing range member functions
1006 using range_base = ranges::detail::range_interface<const_inline_map_reference<Key, Value, Compare>>;
1007
1008 /// @brief pointer to the base class
1009 map_base_type const* map_ptr_;
1010
1011 /// @brief pointer to const operations
1012 const_ops_type const* const_ops_ptr_;
1013
1014 public:
1015 /// @brief obtain a pointer to the map base
1016 /// @return pointer to the map base
1017 ///
1018 auto map_ptr() const noexcept -> map_base_type const* { return map_ptr_; }
1019
1020 /// @brief obtain a pointer to the const operations
1021 /// @return pointer to the const operations
1022 ///
1023 auto const_ops_ptr() const noexcept -> const_ops_type const* { return const_ops_ptr_; }
1024
1025 /// @brief construct a @c const_inline_map_reference of a map
1026 /// @tparam Capacity capacity of the @c inline_map
1027 /// @param map @c inline_map to reference
1028 ///
1029 template <
1030 std::size_t Capacity,
1031 bool AreExceptionsEnabled = detail::are_exceptions_enabled::value,
1034 : interface_base{this},
1035 range_base{this},
1036 map_ptr_{&map},
1037 const_ops_ptr_{&inline_map_reference_detail::const_map_operations_with_at<
1038 inline_map<Key, Value, Capacity, Compare>>} {}
1039
1040 /// @brief construct a @c const_inline_map_reference of a map
1041 /// @tparam Capacity capacity of the @c inline_map
1042 /// @param map @c inline_map to reference
1043 ///
1044 template <
1045 std::size_t Capacity,
1046 bool AreExceptionsEnabled = detail::are_exceptions_enabled::value,
1049 : interface_base{this},
1050 range_base{this},
1051 map_ptr_{&map},
1052 const_ops_ptr_{&inline_map_reference_detail::const_map_operations_without_at<
1053 inline_map<Key, Value, Capacity, Compare>>} {}
1054
1055 /// @brief construct a @c const_inline_map_reference of a map
1056 /// @tparam Capacity capacity of the @c inline_map
1057 ///
1058 /// Deleted overload for rvalue references.
1059 ///
1060 template <std::size_t Capacity>
1062
1063 /// @brief construct a @c const_inline_map_reference from an @c inline_map_reference
1064 /// @param other @c inline_map_reference value
1065 ///
1067 : interface_base{this},
1068 range_base{this},
1069 map_ptr_{other.map_ptr()},
1070 const_ops_ptr_{other.const_ops_ptr()} {}
1071};
1072
1073// parasoft-end-suppress AUTOSAR-A10_1_1-a-2
1074// parasoft-end-suppress AUTOSAR-A12_1_5-a
1075
1076namespace ranges {
1077/// @brief Indicate that @c inline_map_reference is a borrowed range
1078/// @tparam Key The key type for the map
1079/// @tparam Value The mapped type for the map
1080/// @tparam Compare The comparison function
1081template <typename Key, typename Value, typename Compare>
1082class enable_borrowed_range<inline_map_reference<Key, Value, Compare>> : public std::true_type {};
1083} // namespace ranges
1084
1085} // namespace base
1086} // namespace arene
1087
1088#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_MAP_REFERENCE_HPP_
auto map_ptr() const noexcept -> map_base_type const *
obtain a pointer to the map base
Definition map_reference.hpp:1018
inline_map_detail::inline_map_base< Key, Value, Compare > map_base_type
alias to the capacity-erased map base class
Definition map_reference.hpp:975
const_inline_map_reference(inline_map< Key, Value, Capacity, Compare > const &map) noexcept
construct a const_inline_map_reference of a map
Definition map_reference.hpp:1033
::arene::base::reverse_iterator< iterator > reverse_iterator
The type of an iterator that provides non- const access to the elements and iterates in reverse throu...
Definition map_reference.hpp:994
inline_map_reference_iterator< map_base_type, true > iterator
iterator type of a const reference to the map
Definition map_reference.hpp:989
std::pair< Key const, Value > value_type
value type of the map
Definition map_reference.hpp:985
::arene::base::reverse_iterator< const_iterator > const_reverse_iterator
The type of an iterator that provides const access to the elements and iterates in reverse through th...
Definition map_reference.hpp:997
const_inline_map_reference(inline_map_reference< Key, Value, Compare > other) noexcept
construct a const_inline_map_reference from an inline_map_reference
Definition map_reference.hpp:1066
inline_map_reference_detail::const_operations< map_base_type > const_ops_type
alias to const operations type
Definition map_reference.hpp:978
Key key_type
key type of the map
Definition map_reference.hpp:981
typename map_base_type::size_type size_type
size type of the map
Definition map_reference.hpp:987
Compare compare_type
compare type of the map
Definition map_reference.hpp:999
auto const_ops_ptr() const noexcept -> const_ops_type const *
obtain a pointer to the const operations
Definition map_reference.hpp:1023
Value mapped_type
mapped type of the map
Definition map_reference.hpp:983
const_inline_map_reference(inline_map< Key, Value, Capacity, Compare > const &&)=delete
construct a const_inline_map_reference of a map
iterator const_iterator
const iterator type of the underlying map
Definition map_reference.hpp:991
iterator type used by inline_map_reference and const_inline_map_reference
Definition map_reference_iterator.hpp:61
A reference class to an inline_map object, with size-erased type.
Definition map_reference.hpp:689
auto operator[](key_type const &key) const noexcept(false) ->
obtain a reference to the mapped value for the specified key
Definition map_reference.hpp:846
auto equal_range(key_type const &key) const noexcept(comparison_is_noexcept) ->
find the sequence of elements whose keys compare equivalent to a given key
Definition map_reference.hpp:829
auto insert(value_type const &value) const noexcept(false) ->
insert an element in the map
Definition map_reference.hpp:879
Key key_type
key type of the map
Definition map_reference.hpp:701
::arene::base::reverse_iterator< iterator > reverse_iterator
The type of an iterator that provides non- const access to the elements and iterates in reverse throu...
Definition map_reference.hpp:714
auto end() const noexcept ->
obtain an iterator referring to one past the last element in the sorted range of elements
Definition map_reference.hpp:950
inline_map_reference_detail::operations< map_base_type > ops_type
alias to non-const operations type
Definition map_reference.hpp:698
Value mapped_type
mapped type of the map
Definition map_reference.hpp:703
auto ops_ptr() const noexcept -> ops_type const *
obtain a pointer to the non-const operations
Definition map_reference.hpp:751
std::pair< Key const, Value > value_type
value type of the map
Definition map_reference.hpp:705
auto erase(key_type const &key) const noexcept(comparison_is_noexcept) ->
remove element with the corresponding key, if there is one
Definition map_reference.hpp:911
auto insert_or_assign(key_type const &key, mapped_type const &mapped) const noexcept(false) ->
insert an element in the map or update an existing element
Definition map_reference.hpp:901
auto clear() const noexcept ->
destroy all elements in the assocaited inline_map
Definition map_reference.hpp:940
auto erase(const_iterator pos) const noexcept ->
remove the element at the specified position
Definition map_reference.hpp:921
inline_map_reference(inline_map< Key, Value, Capacity, Compare > const &&)=delete
construct an inline_map_reference of a map
Compare compare_type
compare type of the map
Definition map_reference.hpp:719
inline_map_reference_iterator< map_base_type, true > const_iterator
const iterator type of the underlying map
Definition map_reference.hpp:711
inline_map_reference(inline_map< Key, Value, Capacity, Compare > &map) noexcept
construct an inline_map_reference of a map
Definition map_reference.hpp:766
auto const_ops_ptr() const noexcept -> const_ops_type const *
obtain a pointer to the const operations
Definition map_reference.hpp:756
auto lower_bound(key_type const &key) const noexcept(comparison_is_noexcept) ->
find the first element which is not less than a given key
Definition map_reference.hpp:808
auto find(key_type const &key) const noexcept(comparison_is_noexcept) ->
obtain an iterator to the first element with a given key
Definition map_reference.hpp:799
inline_map_reference_iterator< map_base_type, false > iterator
iterator type of a reference to the map
Definition map_reference.hpp:709
::arene::base::reverse_iterator< const_iterator > const_reverse_iterator
The type of an iterator that provides const access to the elements and iterates in reverse through th...
Definition map_reference.hpp:717
inline_map_reference_detail::const_operations< map_base_type > const_ops_type
alias to const operations type
Definition map_reference.hpp:695
auto upper_bound(key_type const &key) const noexcept(comparison_is_noexcept) ->
find the first element which is greater than a given key
Definition map_reference.hpp:818
inline_map_detail::inline_map_base< Key, Value, Compare > map_base_type
alias to the map base class
Definition map_reference.hpp:692
auto at(key_type const &key) const noexcept(false) ->
obtain a reference to the mapped value for the specified key
Definition map_reference.hpp:859
auto begin() const noexcept ->
obtain an iterator referring to the beginning of the sorted range of elements
Definition map_reference.hpp:945
auto erase(const_iterator first, const_iterator last) const noexcept ->
remove elements in the specified range
Definition map_reference.hpp:931
auto map_ptr() const noexcept -> map_base_type *
obtain a pointer to the map base
Definition map_reference.hpp:746
typename map_base_type::size_type size_type
size type of the map
Definition map_reference.hpp:707
A container similar to std::map that has a fixed capacity.
Definition map.hpp:153
An opt-in trait to indicate that a range type is a borrowed range.
Definition enable_borrowed_range.hpp:31
A backport of the constexpr std::reverse_iterator from C++17.
Definition reverse_iterator.hpp:188
static constexpr value_type value
Definition integral_constant.hpp:34
Definition external_vector.hpp:803
Definition accumulate.hpp:37
conditional_t<(MaxValue<=smallest_integer_for_detail::max_uint8), std::uint8_t, conditional_t<(MaxValue<=smallest_integer_for_detail::max_uint16), std::uint16_t, conditional_t<(MaxValue<=smallest_integer_for_detail::max_uint32), std::uint32_t, std::uint64_t > > > smallest_unsigned_integer_for
Calculates the smallest unsigned integer type that can be used to hold values up to and including Max...
Definition smallest_integer_for.hpp:38
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
bool_constant< true > true_type
An alias for bool_constant<true>
Definition integral_constant.hpp:76
Provides a backport of the constexpr implementation of std::reverse_iterator .