General Utility Library for C++14  2.7
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
gul14::span< ElementType, Extent > Class Template Reference

Detailed Description

template<typename ElementType, std::size_t Extent>
class gul14::span< ElementType, Extent >

A view to a contiguous sequence of objects.

This is a backport of std::span from C++20.

Since
GUL version 1.9

#include <span.h>

Public Types

using element_type = ElementType
 See std::span.
 
using value_type = typename std::remove_cv< ElementType >::type
 See std::span.
 
using index_type = std::size_t
 See std::span.
 
using difference_type = std::ptrdiff_t
 See std::span.
 
using pointer = element_type *
 See std::span.
 
using const_pointer = const element_type *
 See std::span.
 
using reference = element_type &
 See std::span.
 
using iterator = pointer
 See std::span.
 
using const_iterator = const_pointer
 See std::span.
 
using reverse_iterator = std::reverse_iterator< iterator >
 See std::span.
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 See std::span.
 
template<std::size_t Offset, std::size_t Count = dynamic_extent>
using subspan_return_t = span< ElementType, Count !=dynamic_extent ? Count :(Extent !=dynamic_extent ? Extent - Offset :dynamic_extent)>
 See std::span.
 

Public Member Functions

template<std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||E<=0), int >::type = 0>
constexpr span () noexcept
 See std::span.
 
constexpr span (pointer ptr, index_type count)
 See std::span.
 
constexpr span (pointer first_elem, pointer last_elem)
 See std::span.
 
template<std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==E) &&detail::is_container_element_type_compatible< element_type(&)[N], ElementType >::value, int >::type = 0>
constexpr span (element_type(&arr)[N]) noexcept
 See std::span.
 
template<std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==E) &&detail::is_container_element_type_compatible< std::array< value_type, N > &, ElementType >::value, int >::type = 0>
 span (std::array< value_type, N > &arr) noexcept
 See std::span.
 
template<std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==E) &&detail::is_container_element_type_compatible< const std::array< value_type, N > &, ElementType >::value, int >::type = 0>
 span (const std::array< value_type, N > &arr) noexcept
 See std::span.
 
template<typename Container , std::size_t E = Extent, typename std::enable_if< E==dynamic_extent &&detail::is_container< Container >::value &&detail::is_container_element_type_compatible< Container &, ElementType >::value, int >::type = 0>
constexpr span (Container &cont)
 See std::span.
 
template<typename Container , std::size_t E = Extent, typename std::enable_if< E==dynamic_extent &&detail::is_container< Container >::value &&detail::is_container_element_type_compatible< const Container &, ElementType >::value, int >::type = 0>
constexpr span (const Container &cont)
 See std::span.
 
constexpr span (const span &other) noexcept=default
 See std::span.
 
template<typename OtherElementType , std::size_t OtherExtent, typename std::enable_if<(Extent==OtherExtent||Extent==dynamic_extent) &&std::is_convertible< OtherElementType(*)[], ElementType(*)[]>::value, int >::type = 0>
constexpr span (const span< OtherElementType, OtherExtent > &other) noexcept
 See std::span.
 
 ~span () noexcept=default
 See std::span.
 
GUL_SPAN_CONSTEXPR_ASSIGN spanoperator= (const span &other) noexcept=default
 See std::span.
 
template<std::size_t Count>
constexpr span< element_type, Count > first () const
 See std::span.
 
template<std::size_t Count>
constexpr span< element_type, Count > last () const
 See std::span.
 
template<std::size_t Offset, std::size_t Count = dynamic_extent>
constexpr subspan_return_t< Offset, Count > subspan () const
 See std::span.
 
constexpr span< element_type, dynamic_extent > first (index_type count) const
 See std::span.
 
constexpr span< element_type, dynamic_extent > last (index_type count) const
 See std::span.
 
constexpr span< element_type, dynamic_extent > subspan (index_type offset, index_type count=dynamic_extent) const
 See std::span.
 
constexpr index_type size () const noexcept
 See std::span.
 
constexpr index_type size_bytes () const noexcept
 See std::span.
 
constexpr bool empty () const noexcept
 See std::span.
 
constexpr reference operator[] (index_type idx) const
 See std::span.
 
constexpr reference front () const
 See std::span.
 
constexpr reference back () const
 See std::span.
 
constexpr pointer data () const noexcept
 See std::span.
 
constexpr iterator begin () const noexcept
 See std::span.
 
constexpr iterator end () const noexcept
 See std::span.
 
constexpr const_iterator cbegin () const noexcept
 See std::span.
 
constexpr const_iterator cend () const noexcept
 See std::span.
 
reverse_iterator rbegin () const noexcept
 See std::span.
 
reverse_iterator rend () const noexcept
 See std::span.
 
const_reverse_iterator crbegin () const noexcept
 See std::span.
 
const_reverse_iterator crend () const noexcept
 See std::span.
 

Static Public Attributes

static constexpr index_type extent = Extent
 See std::span.
 

Friends

constexpr friend iterator begin (span s) noexcept
 See std::span.
 
constexpr friend iterator end (span s) noexcept
 See std::span.
 

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