4#ifndef _Stroika_Foundation_Containers_DataStructures_STLContainerWrapper_h_
5#define _Stroika_Foundation_Containers_DataStructures_STLContainerWrapper_h_
7#include "Stroika/Foundation/StroikaPreComp.h"
9#include "Stroika/Foundation/Common/Common.h"
10#include "Stroika/Foundation/Common/Concepts.h"
12#include "Stroika/Foundation/Containers/Common.h"
34 using has_erase_t =
decltype (declval<T&> ().erase (begin (declval<T&> ()), end (declval<T&> ())));
36 constexpr inline bool has_erase_v = Common::is_detected_v<has_erase_t, T>;
45 template <
typename STL_CONTAINER_OF_T>
48 using inherited = STL_CONTAINER_OF_T;
51 using value_type =
typename STL_CONTAINER_OF_T::value_type;
52 using iterator =
typename STL_CONTAINER_OF_T::iterator;
53 using const_iterator =
typename STL_CONTAINER_OF_T::const_iterator;
65 template <
typename... EXTRA_ARGS>
103 template <invocable<typename STL_CONTAINER_OF_T::const_iterator, typename STL_CONTAINER_OF_T::const_iterator> POINT_TO_SAME_THING>
105 requires (convertible_to<invoke_result_t<POINT_TO_SAME_THING, typename STL_CONTAINER_OF_T::const_iterator, typename STL_CONTAINER_OF_T::const_iterator>,
bool>)
109 nonvirtual
bool contains (Common::ArgByValueType<value_type> item) const;
116 template <invocable<typename STL_CONTAINER_OF_T::value_type> FUNCTION>
117 nonvirtual
void Apply (FUNCTION&& doToElement) const;
125 template <predicate<typename STL_CONTAINER_OF_T::value_type> FUNCTION>
126 nonvirtual iterator
Find (FUNCTION&& firstThat);
127 template <predicate<typename STL_CONTAINER_OF_T::value_type> FUNCTION>
128 nonvirtual const_iterator
Find (FUNCTION&& firstThat) const;
131 template <predicate<typename STL_CONTAINER_OF_T::value_type> PREDICATE>
132 nonvirtual
bool FindIf (PREDICATE&& pred) const;
135 nonvirtual
void Invariant () const noexcept;
138 nonvirtual iterator remove_constness (const_iterator it);
155 template <typename STL_CONTAINER_OF_T>
159 using iterator_category = forward_iterator_tag;
160 using value_type = STLContainerWrapper::value_type;
161 using difference_type = ptrdiff_t;
162 using pointer =
const value_type*;
163 using reference =
const value_type&;
185 explicit operator
bool () const;
188 nonvirtual
bool AtEnd () const noexcept;
195 nonvirtual const value_type& operator* () const;
198 nonvirtual const value_type* operator->() const;
222 const_iterator _fStdIterator{};
229 static_assert (forward_iterator<typename STLContainerWrapper<vector<int>>::ForwardIterator>);
230 static_assert (regular<typename STLContainerWrapper<vector<int>>::ForwardIterator>);
242 template <
typename STL_CONTAINER_OF_T>
248 using iterator_category = bidirectional_iterator_tag;
249 using value_type =
typename inherited::value_type;
250 using difference_type =
typename inherited::difference_type;
251 using pointer =
typename inherited::pointer;
252 using reference =
typename inherited::reference;
255 using inherited::inherited;
265 nonvirtual
bool AtStart ()
const noexcept;
276 static_assert (bidirectional_iterator<typename STLContainerWrapper<vector<int>>::BidirectionalIterator>);
277 static_assert (regular<typename STLContainerWrapper<vector<int>>::BidirectionalIterator>);
289 template <
typename STL_CONTAINER_OF_T>
295 using iterator_category = random_access_iterator_tag;
296 using value_type =
typename inherited::value_type;
297 using difference_type = ptrdiff_t;
298 using pointer =
typename inherited::pointer;
299 using reference =
typename inherited::reference;
323 nonvirtual
const value_type& operator[] (difference_type i)
const;
342 if (lhs._fData ==
nullptr) {
343 if (rhs._fData ==
nullptr) {
346 return static_cast<difference_type
> (rhs._fData->size ()) -
static_cast<difference_type
> (rhs.CurrentIndex ());
348 else if (rhs._fData ==
nullptr) {
349 return static_cast<difference_type
> (lhs.CurrentIndex ()) -
static_cast<difference_type
> (lhs._fData->size ());
352 return static_cast<difference_type
> (lhs._fStdIterator - rhs._fStdIterator);
358 static_assert (random_access_iterator<typename STLContainerWrapper<vector<int>>::RandomAccessIterator>);
359 static_assert (regular<typename STLContainerWrapper<vector<int>>::RandomAccessIterator>);
361 static_assert (ranges::input_range<STLContainerWrapper<vector<int>>>);
370#include "STLContainerWrapper.inl"
like ForwardIterator, but adding the ability to reverse direction.
constexpr ForwardIterator() noexcept=default
like BidirectionalIterator, but adding random access (operator+=, operator[], etc).
const_iterator UnderlyingIteratorRep
nonvirtual void Apply(FUNCTION &&doToElement) const
nonvirtual iterator Find(FUNCTION &&firstThat)
NOT a real mutex - just a debugging infrastructure support tool so in debug builds can be assured thr...
constexpr void AssertDataMatches(const DoublyLinkedList *data) const
nonvirtual ForwardIterator & operator++() noexcept
nonvirtual size_t CurrentIndex(const DoublyLinkedList *data) const
Collection< T > operator+(const Iterable< T > &lhs, const Collection< T > &rhs)
Set< T > operator-(const Set< T > &lhs, const Iterable< T > &rhs)