39 template <
typename Iterator,
typename EndIterator = Iterator >
50 using difference_type =
typename std::iterator_traits< Iterator >::difference_type;
53 constexpr
view() =
default;
56 template < range_container_with_iter< iterator > Cont >
57 constexpr
view( Cont& cont )
58 : begin_( std::
begin( cont ) )
59 , end_( std::
end( cont ) )
64 template < range_container_with_iter< iterator > Cont >
65 constexpr
view( Cont
const& cont )
66 : begin_( std::
begin( cont ) )
67 , end_( std::
end( cont ) )
71 template < data_container_with_iter< iterator > Cont >
72 requires( !range_container_with_iter< Cont, iterator > )
73 constexpr
view( Cont& cont )
74 : begin_( std::
data( cont ) )
75 , end_( begin_ + std::
size( cont ) )
79 template < data_container_with_iter< iterator > Cont >
80 requires( !range_container_with_iter< Cont, iterator > )
81 constexpr
view( Cont
const& cont )
82 : begin_( std::
data( cont ) )
83 , end_( begin_ + std::
size( cont ) )
89 : begin_( std::move(
begin ) )
90 , end_( std::move(
end ) )
95 std::convertible_to< Iterator > OtherIterator,
96 std::convertible_to< EndIterator > OtherEndIterator >
98 : begin_( other.
begin() )
104 [[nodiscard]] constexpr Iterator
begin()
const
110 [[nodiscard]] constexpr EndIterator
end()
const
116 [[nodiscard]] constexpr decltype(
auto ) operator[](
size_type const i )
const
141 [[nodiscard]] constexpr
bool empty()
const
155 return *std::prev( end_ );
158 operator std::span< value_type >()
164 template <
typename IteratorLh,
typename IteratorRh >
170 IteratorLh lhiter = lh.
begin();
171 IteratorRh rhiter = rh.
begin();
173 for ( ; lhiter != lh.
end(); ++lhiter, ++rhiter )
174 if ( *lhiter != *rhiter )
179 template <
typename IteratorLh,
typename IteratorRh >
182 return !( lh == rh );
186 template < range_container Container >
190 template <
typename Iter >
197 template <
typename Iter >
201 begin,
static_cast< typename std::iterator_traits< Iter >::difference_type
>( n ) );
205 template < data_container Container >
214 template < range_container Container >
217 std::size_t
const step = std::size( cont ) * ( 1.f - r ) / 2.f;
218 return { std::begin( cont ) + step, std::end( cont ) - step };
228 template <
typename Iterator,
typename EndIterator >
241 #ifdef EMLABCPP_USE_OSTREAM
243 template <
typename Iterator,
typename EndIterator >
244 std::ostream&
operator<<( std::ostream& os, view< Iterator, EndIterator >
const& iter )
248 [&os](
auto const& item ) {
Generic class to represent view of some container.
Definition: view.h:41
std::size_t size_type
Definition: view.h:51
requires(!range_container_with_iter< Cont, iterator >) const expr view(Cont const &cont)
Definition: view.h:80
constexpr EndIterator end() const
Past the end iterator.
Definition: view.h:110
constexpr Iterator begin() const
Start of the dataset iterator.
Definition: view.h:104
constexpr value_type const & back() const
Returns last value of the range.
Definition: view.h:153
requires(!range_container_with_iter< Cont, iterator >) const expr view(Cont &cont)
Definition: view.h:72
constexpr view(Cont const &cont)
constructor from Container, uses begin/end of the container
Definition: view.h:65
constexpr value_type const & front() const
Returns first value of the range.
Definition: view.h:147
Iterator iterator
Definition: view.h:49
constexpr view(view< OtherIterator, OtherEndIterator > other)
Definition: view.h:97
std::reverse_iterator< Iterator > reverse_iterator
Definition: view.h:48
constexpr view(Cont &cont)
constructor from Container, uses begin/end of the container
Definition: view.h:57
typename std::iterator_traits< Iterator >::difference_type difference_type
Definition: view.h:50
constexpr reverse_iterator rend() const
Returns iterator to the element before first element, that can go in reverse.
Definition: view.h:129
constexpr view(Iterator begin, EndIterator end)
constructor from the iterators that should internally be stored
Definition: view.h:88
constexpr reverse_iterator rbegin() const
Returns iterator to the last element that goes in reverse.
Definition: view.h:122
typename std::iterator_traits< Iterator >::value_type value_type
standard public usings for container
Definition: view.h:47
constexpr bool empty() const
View is empty if both iterators are equal.
Definition: view.h:141
constexpr size_type size() const
Size of the view over dataset uses std::ranges::distance() to tell the size.
Definition: view.h:135
hdr_state next(hdr_state cs) noexcept
Definition: page.h:43
std::variant< int64_t, float, bool, string_buffer > value_type
Definition: base.h:51
MIT License.
Definition: impl.h:31
length distance
Definition: physical_quantity.h:129
std::size_t size_type
Definition: static_storage.h:105
constexpr pointer data() noexcept
Returns pointer to first item of the storage.
Definition: static_storage.h:108
constexpr auto reversed(referenceable_container auto &container) -> view< decltype(std::rbegin(container)) >
Returns view to the Container in reverse order.
Definition: view.h:223
constexpr view< iterator_of_t< Container > > trim_view(Container &cont, float const r)
Creates the view over over Container, where we ignore first r*size/2 items and last r*size/2 items.
Definition: view.h:215
view(Container &cont) -> view< iterator_of_t< Container > >
The container deduction guide uses iterator_of_t.
constexpr view< Iter > view_n(Iter begin, std::size_t const n)
Creates view over 'n' items of dataset starting at 'begin' This does not check validity of the range!
Definition: view.h:198
T value_type
Definition: static_storage.h:100
constexpr auto data_view(Container &cont)
Definition: view.h:206
concept ostreamable
Definition: concepts.h:164
concept container
Definition: concepts.h:93
concept referenceable_container
Definition: concepts.h:96
constexpr bool operator!=(pose const &x, pose const &y)
negation of operator== between poses
Definition: pose.h:99
std::ostream & operator<<(std::ostream &os, string_buffer< N > const &sb)
Definition: string_buffer.h:112
void string_serialize_view(auto &&w, view< Iterator, EndIterator > const &output)
Definition: view.h:229
constexpr bool operator==(pose const &x, pose const &y)
compares poses on their position and orientation
Definition: pose.h:93