StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe::Iterable< Component > Class Template Reference

Gives a Safe component the iterators of its category. More...

#include <StormByte/safe/iterable.hxx>

Collaboration diagram for StormByte::Safe::Iterable< Component >:

Classes

class  BasicIterator
 Suite cursor. More...

Public Types

using container_type = Component
 Wrapped Safe component.
using value_type = typename container_type::value_type
 Element type.
using size_type = Size
 Element count. Size, not std::size_t.
using difference_type = std::ptrdiff_t
 Cursor distance type.
using iterator = BasicIterator<false>
 Mutable cursor.
using const_iterator = BasicIterator<true>
 Read-only cursor.

Public Member Functions

 Iterable ()=default
 Construct an empty component.
 Iterable (const Iterable &other)=default
 Copy the component.
 Iterable (Iterable &&other) noexcept=default
 Move the component.
 Iterable (container_type container) noexcept
 Take ownership of an existing component.
 ~Iterable ()=default
 Destroy the component through its Safe operations.
Iterable & operator= (const Iterable &other)=default
 Copy-assign the component.
Iterable & operator= (Iterable &&other) noexcept=default
 Move-assign the component.
iterator begin () noexcept
 Return a mutable cursor to the first element.
iterator end () noexcept
 Return the mutable end cursor.
const_iterator begin () const noexcept
 Return a read-only cursor to the first element.
const_iterator end () const noexcept
 Return the read-only end cursor.
const_iterator cbegin () const noexcept
 Return a read-only cursor to the first element.
const_iterator cend () const noexcept
 Return the read-only end cursor.
bool empty () const noexcept
 Test whether the component has no elements.
size_type size () const noexcept
 Return the element count.

Static Public Attributes

static constexpr bool random_access = std::random_access_iterator<InnerIterator>
 Whether the suite selects the index cursor.

Protected Member Functions

container_type & Container () noexcept
 Return the stored component.
const container_type & Container () const noexcept
 Return the stored component.

Protected Attributes

container_type m_container {}
 Stored Safe component. This is the only storage.

Detailed Description

template<Type::SafeComponent Component>
requires requires(Component& component, const Component& readonly) { typename Component::value_type; { component.begin() }; { component.end() }; { readonly.begin() }; { readonly.end() }; { readonly.size() } -> Type::ConvertibleTo<std::size_t>; }
class StormByte::Safe::Iterable< Component >

Gives a Safe component the iterators of its category.

Template Parameters
ComponentSafe component that already stores the elements.

The derived type does not write cursors and does not keep a second container. m_container is the storage. A random-access component gets an index cursor. A bidirectional component gets an ordered cursor. A type that is not a Safe component is rejected. A maybe-safe mark is the consumer's promise that its own allocations stay on Base's heap.

Member Typedef Documentation

◆ const_iterator

template<Type::SafeComponent Component>
using StormByte::Safe::Iterable< Component >::const_iterator = BasicIterator<true>

Read-only cursor.

◆ container_type

template<Type::SafeComponent Component>
using StormByte::Safe::Iterable< Component >::container_type = Component

Wrapped Safe component.

◆ difference_type

template<Type::SafeComponent Component>
using StormByte::Safe::Iterable< Component >::difference_type = std::ptrdiff_t

Cursor distance type.

◆ iterator

template<Type::SafeComponent Component>
using StormByte::Safe::Iterable< Component >::iterator = BasicIterator<false>

Mutable cursor.

◆ size_type

template<Type::SafeComponent Component>
using StormByte::Safe::Iterable< Component >::size_type = Size

Element count. Size, not std::size_t.

◆ value_type

template<Type::SafeComponent Component>
using StormByte::Safe::Iterable< Component >::value_type = typename container_type::value_type

Element type.

Constructor & Destructor Documentation

◆ Iterable() [1/4]

template<Type::SafeComponent Component>
StormByte::Safe::Iterable< Component >::Iterable ( )
default

Construct an empty component.

◆ Iterable() [2/4]

template<Type::SafeComponent Component>
StormByte::Safe::Iterable< Component >::Iterable ( const Iterable< Component > & other)
default

Copy the component.

Parameters
otherSource.

◆ Iterable() [3/4]

template<Type::SafeComponent Component>
StormByte::Safe::Iterable< Component >::Iterable ( Iterable< Component > && other)
defaultnoexcept

Move the component.

other is left empty.

Parameters
otherSource.

◆ Iterable() [4/4]

template<Type::SafeComponent Component>
StormByte::Safe::Iterable< Component >::Iterable ( container_type container)
explicitnoexcept

Take ownership of an existing component.

Parameters
containerComponent to store.

◆ ~Iterable()

template<Type::SafeComponent Component>
StormByte::Safe::Iterable< Component >::~Iterable ( )
default

Destroy the component through its Safe operations.

Member Function Documentation

◆ begin() [1/2]

template<Type::SafeComponent Component>
const_iterator StormByte::Safe::Iterable< Component >::begin ( ) const
noexcept

Return a read-only cursor to the first element.

Returns
Read-only cursor.

◆ begin() [2/2]

template<Type::SafeComponent Component>
iterator StormByte::Safe::Iterable< Component >::begin ( )
noexcept

Return a mutable cursor to the first element.

Returns
Mutable cursor.

◆ cbegin()

template<Type::SafeComponent Component>
const_iterator StormByte::Safe::Iterable< Component >::cbegin ( ) const
noexcept

Return a read-only cursor to the first element.

Returns
Read-only cursor.

◆ cend()

template<Type::SafeComponent Component>
const_iterator StormByte::Safe::Iterable< Component >::cend ( ) const
noexcept

Return the read-only end cursor.

Returns
End cursor.

◆ Container() [1/2]

template<Type::SafeComponent Component>
const container_type & StormByte::Safe::Iterable< Component >::Container ( ) const
protectednoexcept

Return the stored component.

Returns
Read-only component.

◆ Container() [2/2]

template<Type::SafeComponent Component>
container_type & StormByte::Safe::Iterable< Component >::Container ( )
protectednoexcept

Return the stored component.

Returns
Mutable component.

◆ empty()

template<Type::SafeComponent Component>
bool StormByte::Safe::Iterable< Component >::empty ( ) const
noexcept

Test whether the component has no elements.

Returns
Whether the component is empty.

◆ end() [1/2]

template<Type::SafeComponent Component>
const_iterator StormByte::Safe::Iterable< Component >::end ( ) const
noexcept

Return the read-only end cursor.

Returns
End cursor.

◆ end() [2/2]

template<Type::SafeComponent Component>
iterator StormByte::Safe::Iterable< Component >::end ( )
noexcept

Return the mutable end cursor.

Returns
End cursor.

◆ operator=() [1/2]

template<Type::SafeComponent Component>
Iterable & StormByte::Safe::Iterable< Component >::operator= ( const Iterable< Component > & other)
default

Copy-assign the component.

Parameters
otherSource.
Returns
This object.

◆ operator=() [2/2]

template<Type::SafeComponent Component>
Iterable & StormByte::Safe::Iterable< Component >::operator= ( Iterable< Component > && other)
defaultnoexcept

Move-assign the component.

other is left empty.

Parameters
otherSource.
Returns
This object.

◆ size()

template<Type::SafeComponent Component>
size_type StormByte::Safe::Iterable< Component >::size ( ) const
noexcept

Return the element count.

Returns
Element count.

Member Data Documentation

◆ m_container

template<Type::SafeComponent Component>
container_type StormByte::Safe::Iterable< Component >::m_container {}
protected

Stored Safe component. This is the only storage.

◆ random_access

template<Type::SafeComponent Component>
bool StormByte::Safe::Iterable< Component >::random_access = std::random_access_iterator<InnerIterator>
staticconstexpr

Whether the suite selects the index cursor.


The documentation for this class was generated from the following file: