2 #define GAUDI_RANGE_H 1 47 template <
class CONTAINER>
51 using Container = Gaudi::cpp17::detected_or_t<CONTAINER, _has_container_t, CONTAINER>;
52 using Iterator =
typename CONTAINER::const_iterator;
124 template <
typename InputIterator>
125 Range_( InputIterator first, InputIterator last ) : m_base( first, last )
131 Range_(
const Base& base ) : m_base( base ) {}
139 Range_( iterator ibegin ) : m_base( ibegin, ibegin ) {}
144 bool empty()
const {
return m_base.second == m_base.first; }
148 iterator
begin()
const {
return m_base.first; }
150 iterator
end()
const {
return m_base.second; }
152 iterator
cbegin()
const {
return m_base.first; }
154 iterator
cend()
const {
return m_base.second; }
156 reverse_iterator
rbegin()
const {
return reverse_iterator(
end() ); }
158 reverse_iterator
rend()
const {
return reverse_iterator(
begin() ); }
168 if ( empty() || index1 == index2 ) {
182 if ( index2 < index1 ) {
186 if ( index1 > (
long)
size() ) {
189 if ( index2 > (
long)
size() ) {
206 inline const_reference
operator[](
const long index )
const {
return ( *
this )( index ); }
212 inline const_reference
at(
const long index )
const 214 if ( index < 0 || index >= (
long)
size() ) {
217 return ( *
this )( index );
223 template <
class C,
class I>
224 bool operator<( const Range_<C, I>& right )
const 229 template <
class ANOTHERCONTAINER>
240 if ( &right ==
this ) {
246 template <
class CNT,
class IT>
252 template <
class ANOTHERCONTAINER>
263 explicit operator bool()
const {
return !empty(); }
268 operator const Base&()
const {
return base(); }
270 inline const Base&
base()
const {
return m_base; }
306 template <
class CONTAINER>
316 #endif // GAUDI_RANGE_H
bool empty() const
empty sequence ?
std::pair< ITERATOR, ITERATOR > Base
std::reverse_iterator< iterator > const_reverse_iterator
Base m_base
the base itself
GAUDI_API void rangeException(const long index, const size_t size)
Helpful function to throw an "out-of-range exception" for class Range_.
iterator cbegin() const
access to begin of the sequence (const version )
typename T::Container _has_container_t
iter_traits::value_type value_type
std::reverse_iterator< iterator > reverse_iterator
helper structure to get container type
std::iterator_traits< iterator > iter_traits
Range_ slice(long index1, long index2) const
get a "slice" of a range, in Python style
helper class to simplify the dealing with ranges in Python
reverse_iterator rbegin() const
access to begin of the reversed sequence (const)
iter_traits::reference reference
bool operator==(const Range_< CNT, IT > &right) const
equality with another range type
const_reference front() const
access for the first element (only for non-empty ranges!)
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
bool operator!() const
empty sequence?
iter_traits::reference const_reference
const_reference operator[](const long index) const
non-checked access to the elements by index (valid only for non-empty sequences)
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Range_(InputIterator first, InputIterator last)
Constructor.
Gaudi::details::container< CONTAINER >::Container Container
type for actual contained iterator
const_reference at(const long index) const
Checked access to the elements by index (valid for all sequences) for out-of-range access...
Range_(const Base &base)
constructor from the pair of iterators
T lexicographical_compare(T...args)
bool operator==(const Range_ &right) const
equality with another range
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
iterator end() const
access to end of the sequence (const version)
typename CONTAINER::const_iterator Iterator
const Base & base() const
conversion operator to the std::pair
iterator cend() const
access to end of the sequence (const version)
bool operator==(const ANOTHERCONTAINER &right) const
compare with another container
bool operator<(const ANOTHERCONTAINER &right) const
compare with another container
Useful class for representation of "sequence" of the objects through the range of valid iterators...
size_t size() const
size of the sequence (number of elements)
reverse_iterator rend() const
access to begin of the reversed sequence (const)
const_reference operator()(const size_t index) const
non-checked access to the elements by index (valid only for non-empty sequences)
AttribStringParser::Iterator begin(const AttribStringParser &parser)
const_reference back() const
access for the back element (only for non-empty ranges!)
Range_(const Container &cont)
constructor from the container
Helper functions to set/get the application return code.
iterator begin() const
access to begin of the sequence (const version )
Gaudi::cpp17::detected_or_t< CONTAINER, _has_container_t, CONTAINER > Container