Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Sequence_stdvector.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Containers_Concrete_Sequence_stdvector_h_
5#define _Stroika_Foundation_Containers_Concrete_Sequence_stdvector_h_
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
10#include "Stroika/Foundation/Containers/Sequence.h"
11
12/**
13 * \file
14 *
15 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
16 *
17 * TODO:
18 * @todo Be sure can move-semantics into and out of Sequence_stdvector() - with vector<T> -
19 * so can go back and forth between reps efficiently. This COULD use used to avoid
20 * any performance overhead with Stroika Sequences.
21 */
22
24
25 /**
26 * \brief Sequence_stdvector<T> is an std::vector-based concrete implementation of the Sequence<T> container pattern.
27 *
28 * \note Performance notes
29 *
30 * A good default implementation, except that empirically, this appears slower than Sequence_Array<>.
31 *
32 * o push_back should perform well (typically constant time, but occasionally O(N))
33 * o it is FAST to array index a Sequence_stdvector.
34 *
35 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
36 *
37 */
38 template <typename T>
39 class Sequence_stdvector : public Private::StdVectorBasedContainer<Sequence_stdvector<T>, Sequence<T>> {
40 private:
42
43 public:
44 using value_type = typename inherited::value_type;
45
46 public:
47 /**
48 * \see docs on Sequence<> constructor
49 * (plus a move constructor for vector<T>)
50 */
52 Sequence_stdvector (Sequence_stdvector&&) noexcept = default;
53 Sequence_stdvector (const Sequence_stdvector&) noexcept = default;
54 Sequence_stdvector (std::vector<T>&& src);
55 Sequence_stdvector (const initializer_list<value_type>& src);
56 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
57 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, Sequence_stdvector<T>>)
58 explicit Sequence_stdvector (ITERABLE_OF_ADDABLE&& src)
59#if qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
61 {
63 this->reserve (src.size ());
64 }
65 this->AppendAll (forward<ITERABLE_OF_ADDABLE> (src));
66 AssertRepValidType_ ();
67 }
68#endif
69 ;
70 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
71 Sequence_stdvector (ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end);
72
73 public:
74 /**
75 */
76 nonvirtual Sequence_stdvector& operator= (Sequence_stdvector&&) noexcept = default;
77 nonvirtual Sequence_stdvector& operator= (const Sequence_stdvector&) = default;
78
79 private:
80 class Rep_;
81
82 private:
83 nonvirtual void AssertRepValidType_ () const;
84
85 private:
86 friend inherited;
87 };
88
89}
90
91/*
92 ********************************************************************************
93 ******************************* Implementation Details *************************
94 ********************************************************************************
95 */
96#include "Sequence_stdvector.inl"
97
98#endif /*_Stroika_Foundation_Containers_Concrete_Sequence_stdvector_h_ */
Sequence_stdvector<T> is an std::vector-based concrete implementation of the Sequence<T> container pa...
StdVectorBasedContainer is a Stroika implementation detail, but its public methods are fair game and ...
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
typename inherited::value_type value_type
Definition Sequence.h:198
nonvirtual void AppendAll(ITERABLE_OF_ADDABLE &&s)
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.
Concept checks if the given type T has a const size() method which can be called to return a size_t.
Definition Concepts.h:361