General Utility Library for C++14  2.11
Classes | Functions
gul14/span.h

Detailed Description

Backport of std::span from C++20.

Classes

class  gul14::span< ElementType, Extent >
 A view to a contiguous sequence of objects. More...
 

Functions

template<typename ElementType , std::size_t Extent>
span< const unsigned char,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> gul14::as_bytes (span< ElementType, Extent > s) noexcept
 Return a constant view to the byte representation of the elements of a given span. More...
 
template<class ElementType , size_t Extent, typename std::enable_if<!std::is_const< ElementType >::value, int >::type = 0>
span< unsigned char,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> gul14::as_writable_bytes (span< ElementType, Extent > s) noexcept
 Return a writable view to the byte representation of the elements of a given span. More...
 
template<std::size_t N, typename E , std::size_t S>
constexpr auto gul14::get (span< E, S > s) -> decltype(s[N])
 Return a reference to the Nth element of a given span. More...
 

Function Documentation

◆ as_bytes()

template<typename ElementType , std::size_t Extent>
span<const unsigned char, ((Extent == dynamic_extent) ? dynamic_extent : sizeof(ElementType) * Extent)> gul14::as_bytes ( span< ElementType, Extent >  s)
noexcept

Return a constant view to the byte representation of the elements of a given span.

This is a backport from the C++20 standard library, see: https://en.cppreference.com/w/cpp/container/span/as_bytes

Since
GUL version 1.9

References gul14::span< ElementType, Extent >::data(), and gul14::span< ElementType, Extent >::size_bytes().

◆ as_writable_bytes()

template<class ElementType , size_t Extent, typename std::enable_if<!std::is_const< ElementType >::value, int >::type = 0>
span<unsigned char, ((Extent == dynamic_extent) ? dynamic_extent : sizeof(ElementType) * Extent)> gul14::as_writable_bytes ( span< ElementType, Extent >  s)
noexcept

Return a writable view to the byte representation of the elements of a given span.

This is a backport from the C++20 standard library, see: https://en.cppreference.com/w/cpp/container/span/as_bytes

Since
GUL version 1.9

References gul14::span< ElementType, Extent >::data(), and gul14::span< ElementType, Extent >::size_bytes().

◆ get()

template<std::size_t N, typename E , std::size_t S>
constexpr auto gul14::get ( span< E, S >  s) -> decltype(s[N])
constexpr

Return a reference to the Nth element of a given span.

This is a backport from the C++20 standard library, see: https://en.cppreference.com/w/cpp/container/span/get

Since
GUL version 1.9