1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi"). 18 begin, declval, distance, end, make_reverse_iterator, move,
next,
prev,
19 queue, reverse_iterator, stack
22 template<
class Collection >
29 template<
class Collection >
36 template<
class Iterator >
43 auto first() const -> Iterator {
return m_first; }
44 auto beyond() const -> Iterator {
return m_beyond; }
45 auto&
front()
const {
return *m_first; }
49 auto begin() const -> Iterator {
return m_first; }
50 auto end() const -> Iterator {
return m_beyond; }
51 auto empty() const ->
Truth {
return (m_first == m_beyond); }
58 template<
class Collection >
65 template<
class Item >
68 template<
class Iterator >
71 {
return distance( range.begin(), range.end() ); }
73 template<
class Iterator >
74 inline auto span_of(
const Iterator first,
const Iterator beyond )
78 template<
class Container >
80 ->
Span_<decltype( begin( c ) )>
81 {
return span_of( begin( c ), end( c ) ); }
83 template<
class Item,
class Container >
84 auto all_of(
const queue<Item, Container>& q )
87 struct Accessible: queue<Item, Container>
89 static auto container_of(
const queue<Item, Container>& q )
91 {
return q.*&Accessible::c; }
94 return all_of( Accessible::container_of( q ) );
97 template<
class Item,
class Container >
98 auto all_of(
const stack<Item, Container>& st )
101 struct Accessible: stack<Item, Container>
103 static auto container_of(
const stack<Item, Container>& st )
105 {
return st.*&Accessible::c; }
108 return all_of( Accessible::container_of( st ) );
111 template<
class Container >
113 ->
Span_<decltype( begin( c ) )>
115 const auto all =
all_of( c );
116 return span_of(
next( all.first() ), all.beyond() );
119 template<
class Container >
121 ->
Span_<decltype( begin( c ) )>
123 const auto all =
all_of( c );
124 return span_of(
next( all.first(), n ), all.beyond() );
127 template<
class Container >
129 ->
Span_<decltype( begin( c ) )>
131 const auto all =
all_of( c );
132 return span_of( all.first(),
prev( all.beyond() ) );
143 template<
class Container >
145 ->
Span_<decltype( begin( c ) )>
147 const auto all =
all_of( c );
148 return span_of( all.first(),
prev( all.beyond(), n ) );
151 template<
class Container >
153 ->
Span_<reverse_iterator<decltype( begin( c ) )>>
155 const auto all =
all_of( c );
157 make_reverse_iterator( all.beyond() ),
158 make_reverse_iterator( all.first() )
auto first() const -> Iterator
constexpr auto n_items_of(const Collection &c) noexcept -> Size
auto prev(P_< const char > p) -> P_< const char >
A drop-in replacement for bool without implicit conversion from/to types other than bool.
auto all_but_first_n_of(Container &&c, const Size n) -> Span_< decltype(begin(c))>
auto all_of(Container &&c) -> Span_< decltype(begin(c))>
auto begin() const -> Iterator
auto all_but_first_of(Container &&c) -> Span_< decltype(begin(c))>
auto all_but_last_n_of(Container &&c, const Size n) -> Span_< decltype(begin(c))>
auto it_begin_of(Collection &&c)
auto it_end_of(Collection &&c)
auto end() const -> Iterator
Span_(const Iterator first, const Iterator beyond)
Truth is a drop-in replacement for bool without implicit conversion from/to types other than bool.
auto text_span_of_literal(const Raw_array_of_< n, const Char > &string_literal) -> Span_< P_< const Char >>
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
auto span_of(const Iterator first, const Iterator beyond) -> Span_< Iterator >
auto is_empty() const -> Truth
auto next(P_< const char > p) -> P_< const char >
Signed_< size_t > Size
A Signed_ equivalent of size_t.
auto beyond() const -> Iterator
Item[n] Raw_array_of_
Creates a raw array type of a specified size.
void reversed(const Range_< Integer > &)=delete
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...
auto empty() const -> Truth
Signed Size and Index, plus unsigned equivalents Unsigned_size and Unsigned_index.
auto all_but_last_of(Container &&c) -> Span_< decltype(begin(c))>