dune-common  2.11
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Dune::StaticIntegralRange< T, to, from > Class Template Reference

static integer range for use in range-based for loops More...

#include <dune/common/rangeutilities.hh>

Public Types

typedef T value_type
 type of integers contained in the range More...
 
typedef Impl::IntegralRangeIterator< T > iterator
 type of iterator More...
 
typedef std::make_unsigned_t< T > size_type
 unsigned integer type corresponding to value_type More...
 

Public Member Functions

constexpr StaticIntegralRange () noexcept=default
 default constructor More...
 
constexpr operator IntegralRange< T > () const noexcept
 cast into dynamic IntegralRange More...
 
constexpr operator integer_sequence () const noexcept
 cast into corresponding std::integer_sequence More...
 
template<class U , U i>
constexpr auto operator[] (const std::integral_constant< U, i > &) const noexcept -> std::integral_constant< value_type, from+static_cast< value_type >(i)>
 access specified element (static version) More...
 
constexpr value_type operator[] (const size_type &i) const noexcept
 access specified element (dynamic version) More...
 

Static Public Member Functions

static constexpr integer_sequence to_integer_sequence () noexcept
 return corresponding std::integer_sequence More...
 
static constexpr iterator begin () noexcept
 obtain a random-access iterator to the first element More...
 
static constexpr iterator end () noexcept
 obtain a random-access iterator past the last element More...
 
static constexpr std::integral_constant< bool, from==to > empty () noexcept
 check whether the range is empty More...
 
static constexpr std::integral_constant< size_type, static_cast< size_type >to) - static_cast< size_type >from) > size () noexcept
 obtain number of elements in the range More...
 
static constexpr bool contains (value_type index) noexcept
 check whether given index is within range [from, to) More...
 

Public Attributes

decltype(shift_integer_sequence< from >(std::make_integer_sequence< T, to-from >())) typedef integer_sequence
 type of corresponding std::integer_sequence More...
 

Detailed Description

template<class T, T to, T from = 0>
class Dune::StaticIntegralRange< T, to, from >

static integer range for use in range-based for loops

This is a compile-time static variant of the IntegralRange. Apart from returning all range information statically, it casts into the corresponding std::integer_sequence.

Note
This range can also be used in Hybrid::forEach, resulting in a static for loop over the contained integers like a std::integer_sequence.
Template Parameters
Ttype of integers contained in the range
tofirst element not contained in the range
fromfirst element contained in the range, defaults to 0

Member Typedef Documentation

◆ iterator

template<class T , T to, T from = 0>
typedef Impl::IntegralRangeIterator<T> Dune::StaticIntegralRange< T, to, from >::iterator

type of iterator

◆ size_type

template<class T , T to, T from = 0>
typedef std::make_unsigned_t<T> Dune::StaticIntegralRange< T, to, from >::size_type

unsigned integer type corresponding to value_type

◆ value_type

template<class T , T to, T from = 0>
typedef T Dune::StaticIntegralRange< T, to, from >::value_type

type of integers contained in the range

Constructor & Destructor Documentation

◆ StaticIntegralRange()

template<class T , T to, T from = 0>
constexpr Dune::StaticIntegralRange< T, to, from >::StaticIntegralRange ( )
defaultnoexcept

default constructor

Member Function Documentation

◆ begin()

template<class T , T to, T from = 0>
static constexpr iterator Dune::StaticIntegralRange< T, to, from >::begin ( )
inlinestaticnoexcept

obtain a random-access iterator to the first element

◆ contains()

template<class T , T to, T from = 0>
static constexpr bool Dune::StaticIntegralRange< T, to, from >::contains ( value_type  index)
inlinestaticnoexcept

check whether given index is within range [from, to)

◆ empty()

template<class T , T to, T from = 0>
static constexpr std::integral_constant<bool, from == to> Dune::StaticIntegralRange< T, to, from >::empty ( )
inlinestaticnoexcept

check whether the range is empty

◆ end()

template<class T , T to, T from = 0>
static constexpr iterator Dune::StaticIntegralRange< T, to, from >::end ( )
inlinestaticnoexcept

obtain a random-access iterator past the last element

◆ operator integer_sequence()

template<class T , T to, T from = 0>
constexpr Dune::StaticIntegralRange< T, to, from >::operator integer_sequence ( ) const
inlinenoexcept

cast into corresponding std::integer_sequence

◆ operator IntegralRange< T >()

template<class T , T to, T from = 0>
constexpr Dune::StaticIntegralRange< T, to, from >::operator IntegralRange< T > ( ) const
inlinenoexcept

cast into dynamic IntegralRange

◆ operator[]() [1/2]

template<class T , T to, T from = 0>
template<class U , U i>
constexpr auto Dune::StaticIntegralRange< T, to, from >::operator[] ( const std::integral_constant< U, i > &  ) const -> std::integral_constant<value_type, from + static_cast<value_type>(i)>
inlinenoexcept

access specified element (static version)

◆ operator[]() [2/2]

template<class T , T to, T from = 0>
constexpr value_type Dune::StaticIntegralRange< T, to, from >::operator[] ( const size_type i) const
inlinenoexcept

access specified element (dynamic version)

◆ size()

template<class T , T to, T from = 0>
static constexpr std::integral_constant<size_type, static_cast<size_type>to) - static_cast<size_type>from) > Dune::StaticIntegralRange< T, to, from >::size ( )
inlinestaticnoexcept

obtain number of elements in the range

◆ to_integer_sequence()

template<class T , T to, T from = 0>
static constexpr integer_sequence Dune::StaticIntegralRange< T, to, from >::to_integer_sequence ( )
inlinestaticnoexcept

return corresponding std::integer_sequence

Member Data Documentation

◆ integer_sequence

template<class T , T to, T from = 0>
decltype(shift_integer_sequence<from>(std::make_integer_sequence<T, to-from>())) typedef Dune::StaticIntegralRange< T, to, from >::integer_sequence

type of corresponding std::integer_sequence


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