Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Foundation/Containers/Common.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Containers_Common_h_
5#define _Stroika_Foundation_Containers_Common_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <cstddef>
10#include <cstdint>
11
13
14 /**
15 * \brief For a contiguous container (such as a vector or basic_string) - find the pointer to the start of the container
16 *
17 * For a contiguous container (such as a vector or basic_string) - find the pointer to the start of the container
18 *
19 * Note: this is like std::begin(), except that it returns a pointer, not an iterator, and returns nullptr if the
20 * container is empty.
21 */
22 template <typename CONTAINER>
23 typename CONTAINER::value_type* Start (CONTAINER& c);
24 template <typename CONTAINER>
25 const typename CONTAINER::value_type* Start (const CONTAINER& c);
26
27 /**
28 * \brief For a contiguous container (such as a vector or basic_string) - find the pointer to the end of the container
29 *
30 * For a contiguous container (such as a vector or basic_string) - find the pointer to the end of the container
31 *
32 * Note: this is like std::end(), except that it returns a pointer, not an iterator, and returns nullptr if the
33 * container is empty.
34 */
35 template <typename CONTAINER>
36 typename CONTAINER::value_type* End (CONTAINER& c);
37 template <typename CONTAINER>
38 const typename CONTAINER::value_type* End (const CONTAINER& c);
39
40 /**
41 * \brief Mode flag to say if Adding to a container replaces, or if the first addition wins.
42 *
43 * \see also AddOrExtendOrReplaceMode
44 */
45 enum class AddReplaceMode {
46 /**
47 * Associate argument value iff key argument missing
48 */
50
51 /**
52 * Associate argument with value unconditionally
53 */
55 };
56
57 /**
58 * \brief Mode flag to say if Adding to a container replaces, or if the first addition wins (Logically AddOrExtendOrReplaceMode subclasses AddReplaceMode)
59 *
60 * \see also AddReplaceMode
61 */
63 /**
64 * same value as AddReplaceMode::eAddIfMissing
65 */
67
68 /**
69 * same value as AddReplaceMode::eAddReplaces
70 */
71 eAddReplaces = static_cast<int> (AddReplaceMode::eAddReplaces),
72
73 /**
74 * Used in multisets (where key can be associated with multiple values) - just add extra values.
75 */
77
78 /**
79 * if key already present, throw runtime exception
80 */
82 };
83
84}
85
86/*
87 ********************************************************************************
88 ***************************** Implementation Details ***************************
89 ********************************************************************************
90 */
91#include "Common.inl"
92
93#endif /*_Stroika_Foundation_Containers_Common_h_*/
CONTAINER::value_type * End(CONTAINER &c)
For a contiguous container (such as a vector or basic_string) - find the pointer to the end of the co...
CONTAINER::value_type * Start(CONTAINER &c)
For a contiguous container (such as a vector or basic_string) - find the pointer to the start of the ...
AddOrExtendOrReplaceMode
Mode flag to say if Adding to a container replaces, or if the first addition wins (Logically AddOrExt...
AddReplaceMode
Mode flag to say if Adding to a container replaces, or if the first addition wins.