emlabcpp
modern opinionated embedded C++ library
emlabcpp::view< Iterator, EndIterator > Class Template Reference

Generic class to represent view of some container. More...

#include <view.h>

+ Inheritance diagram for emlabcpp::view< Iterator, EndIterator >:

Public Types

using value_type = typename std::iterator_traits< Iterator >::value_type
 standard public usings for container More...
 
using reverse_iterator = std::reverse_iterator< Iterator >
 
using iterator = Iterator
 
using difference_type = typename std::iterator_traits< Iterator >::difference_type
 
using size_type = std::size_t
 

Public Member Functions

constexpr view ()=default
 
template<range_container_with_iter< iterator > Cont>
constexpr view (Cont &cont)
 constructor from Container, uses begin/end of the container More...
 
template<range_container_with_iter< iterator > Cont>
constexpr view (Cont const &cont)
 constructor from Container, uses begin/end of the container More...
 
template<data_container_with_iter< iterator > Cont>
 requires (!range_container_with_iter< Cont, iterator >) const expr view(Cont &cont)
 
template<data_container_with_iter< iterator > Cont>
 requires (!range_container_with_iter< Cont, iterator >) const expr view(Cont const &cont)
 
constexpr view (Iterator begin, EndIterator end)
 constructor from the iterators that should internally be stored More...
 
template<std::convertible_to< Iterator > OtherIterator, std::convertible_to< EndIterator > OtherEndIterator>
constexpr view (view< OtherIterator, OtherEndIterator > other)
 
constexpr Iterator begin () const
 Start of the dataset iterator. More...
 
constexpr EndIterator end () const
 Past the end iterator. More...
 
constexpr reverse_iterator rbegin () const
 Returns iterator to the last element that goes in reverse. More...
 
constexpr reverse_iterator rend () const
 Returns iterator to the element before first element, that can go in reverse. More...
 
constexpr size_type size () const
 Size of the view over dataset uses std::ranges::distance() to tell the size. More...
 
constexpr bool empty () const
 View is empty if both iterators are equal. More...
 
constexpr value_type const & front () const
 Returns first value of the range. More...
 
constexpr value_type const & back () const
 Returns last value of the range. More...
 
 operator std::span< value_type > ()
 

Detailed Description

template<typename Iterator, typename EndIterator = Iterator>
class emlabcpp::view< Iterator, EndIterator >

Generic class to represent view of some container.

The view stores iterators to the input container and acts as container.

Note: is_view_v<T> can be used to detect if T is view

Member Typedef Documentation

◆ difference_type

template<typename Iterator , typename EndIterator = Iterator>
using emlabcpp::view< Iterator, EndIterator >::difference_type = typename std::iterator_traits< Iterator >::difference_type

◆ iterator

template<typename Iterator , typename EndIterator = Iterator>
using emlabcpp::view< Iterator, EndIterator >::iterator = Iterator

◆ reverse_iterator

template<typename Iterator , typename EndIterator = Iterator>
using emlabcpp::view< Iterator, EndIterator >::reverse_iterator = std::reverse_iterator< Iterator >

◆ size_type

template<typename Iterator , typename EndIterator = Iterator>
using emlabcpp::view< Iterator, EndIterator >::size_type = std::size_t

◆ value_type

template<typename Iterator , typename EndIterator = Iterator>
using emlabcpp::view< Iterator, EndIterator >::value_type = typename std::iterator_traits< Iterator >::value_type

standard public usings for container

Constructor & Destructor Documentation

◆ view() [1/5]

template<typename Iterator , typename EndIterator = Iterator>
constexpr emlabcpp::view< Iterator, EndIterator >::view ( )
constexprdefault

◆ view() [2/5]

template<typename Iterator , typename EndIterator = Iterator>
template<range_container_with_iter< iterator > Cont>
constexpr emlabcpp::view< Iterator, EndIterator >::view ( Cont &  cont)
inlineconstexpr

constructor from Container, uses begin/end of the container

◆ view() [3/5]

template<typename Iterator , typename EndIterator = Iterator>
template<range_container_with_iter< iterator > Cont>
constexpr emlabcpp::view< Iterator, EndIterator >::view ( Cont const &  cont)
inlineconstexpr

constructor from Container, uses begin/end of the container

◆ view() [4/5]

template<typename Iterator , typename EndIterator = Iterator>
constexpr emlabcpp::view< Iterator, EndIterator >::view ( Iterator  begin,
EndIterator  end 
)
inlineconstexpr

constructor from the iterators that should internally be stored

◆ view() [5/5]

template<typename Iterator , typename EndIterator = Iterator>
template<std::convertible_to< Iterator > OtherIterator, std::convertible_to< EndIterator > OtherEndIterator>
constexpr emlabcpp::view< Iterator, EndIterator >::view ( view< OtherIterator, OtherEndIterator >  other)
inlineconstexpr

Member Function Documentation

◆ back()

template<typename Iterator , typename EndIterator = Iterator>
constexpr value_type const& emlabcpp::view< Iterator, EndIterator >::back ( ) const
inlineconstexpr

Returns last value of the range.

◆ begin()

template<typename Iterator , typename EndIterator = Iterator>
constexpr Iterator emlabcpp::view< Iterator, EndIterator >::begin ( ) const
inlineconstexpr

Start of the dataset iterator.

◆ empty()

template<typename Iterator , typename EndIterator = Iterator>
constexpr bool emlabcpp::view< Iterator, EndIterator >::empty ( ) const
inlineconstexpr

View is empty if both iterators are equal.

References emlabcpp::view< Iterator, EndIterator >::begin(), and emlabcpp::view< Iterator, EndIterator >::end().

◆ end()

template<typename Iterator , typename EndIterator = Iterator>
constexpr EndIterator emlabcpp::view< Iterator, EndIterator >::end ( ) const
inlineconstexpr

Past the end iterator.

◆ front()

template<typename Iterator , typename EndIterator = Iterator>
constexpr value_type const& emlabcpp::view< Iterator, EndIterator >::front ( ) const
inlineconstexpr

Returns first value of the range.

◆ operator std::span< value_type >()

template<typename Iterator , typename EndIterator = Iterator>
emlabcpp::view< Iterator, EndIterator >::operator std::span< value_type > ( )
inline

◆ rbegin()

template<typename Iterator , typename EndIterator = Iterator>
constexpr reverse_iterator emlabcpp::view< Iterator, EndIterator >::rbegin ( ) const
inlineconstexpr

Returns iterator to the last element that goes in reverse.

◆ rend()

template<typename Iterator , typename EndIterator = Iterator>
constexpr reverse_iterator emlabcpp::view< Iterator, EndIterator >::rend ( ) const
inlineconstexpr

Returns iterator to the element before first element, that can go in reverse.

◆ requires() [1/2]

template<typename Iterator , typename EndIterator = Iterator>
template<data_container_with_iter< iterator > Cont>
emlabcpp::view< Iterator, EndIterator >::requires ( !range_container_with_iter< Cont, iterator ) const &
inline

◆ requires() [2/2]

template<typename Iterator , typename EndIterator = Iterator>
template<data_container_with_iter< iterator > Cont>
emlabcpp::view< Iterator, EndIterator >::requires ( !range_container_with_iter< Cont, iterator ) const &
inline

◆ size()

template<typename Iterator , typename EndIterator = Iterator>
constexpr size_type emlabcpp::view< Iterator, EndIterator >::size ( ) const
inlineconstexpr

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