Go to the documentation of this file.
9 #ifndef EAGINE_WRAPPING_CONTAINER_HPP
10 #define EAGINE_WRAPPING_CONTAINER_HPP
28 using wrapper_type = Wrapper;
32 typename Container::const_iterator,
44 typename Container::size_type count) {
51 : _items{temp._release_items()} {}
62 auto items{temp._release_items()};
79 Transform>() noexcept {
80 return {
cover(_items)};
89 Transform>() noexcept {
90 return {
view(_items)};
95 constexpr
auto empty() const noexcept ->
bool {
96 return _items.empty();
101 constexpr
auto size() const noexcept {
108 return _transf()(_items[range_index<Container>(index)]);
113 return _transf()(_items.at(range_index<Container>(index)));
118 return {_items.begin()};
123 return {_items.end()};
128 if constexpr(std::is_const_v<typename Container::value_type>) {
131 return cover(_items);
141 constexpr
auto _transf() const noexcept -> const Transform& {
147 static constexpr
void _initialize(Container& items) {
154 auto _release_items() noexcept {
155 Container items{std::move(_items)};
163 #endif // EAGINE_WRAPPING_CONTAINER_HPP
constexpr auto at(span_size_t index) const
Access the element at the specified index.
Definition: wrapping_container.hpp:112
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
static constexpr auto span_size(T v) noexcept
Converts argument to span size type.
Definition: types.hpp:59
constexpr auto end() const noexcept -> const_iterator
Returns an iterator past the last element in this container.
Definition: wrapping_container.hpp:122
Common code is placed in this namespace.
Definition: eagine.hpp:21
static constexpr auto cover(T *addr, S size) noexcept -> span_if_mutable< T >
Creates a span starting at the specified pointer and specified length.
Definition: span.hpp:465
constexpr auto empty() const noexcept -> bool
Indicates if this container is empty.
Definition: wrapping_container.hpp:95
static constexpr auto view(T *addr, S size) noexcept -> const_span< T >
Creates a view starting at the specified pointer and specified length.
Definition: span.hpp:458
basic_span< T, T *, S > span
Default alias for basic memory spans with native pointer type.
Definition: span.hpp:415
constexpr auto begin() const noexcept -> const_iterator
Returns an iterator to the first element in this container.
Definition: wrapping_container.hpp:117
static auto fill(basic_span< T, P, S > spn, const V &v) -> basic_span< T, P, S >
Fills a span with copies of the specified value.
Definition: span_algo.hpp:536
constexpr basic_wrapping_container(typename Container::size_type count)
Resizing constructor.
Definition: wrapping_container.hpp:43
constexpr basic_wrapping_container() noexcept
Default constructor.
Definition: wrapping_container.hpp:38
static auto transform(basic_span< T, P, S > spn, Transform function) -> basic_span< T, P, S >
Transforms the elements of a span with a function.
Definition: span_algo.hpp:572
constexpr auto operator[](span_size_t index) const noexcept
Subscript access.
Definition: wrapping_container.hpp:107
constexpr auto raw_items() noexcept
Returns view of the elements as they are stored, without transfomation.
Definition: wrapping_container.hpp:127
constexpr auto size() const noexcept
Returns the number of elements in this container.
Definition: wrapping_container.hpp:101
auto operator=(basic_wrapping_container &&temp) noexcept -> basic_wrapping_container &
Move assignable.
Definition: wrapping_container.hpp:58
basic_wrapping_container(basic_wrapping_container &&temp) noexcept
Move constructible.
Definition: wrapping_container.hpp:50
Template used in implementation of containers with wrapped elements.
Definition: wrapping_container.hpp:26
constexpr auto raw_items() const noexcept
Returns view of the elements as they are stored, without transfomation.
Definition: wrapping_container.hpp:136