General Utility Library for C++17 25.4.1
Classes | Namespaces | Functions
span.h File Reference

Detailed Description

Provides a gul17::span that mimicks C++20's std::span as closely as possible.

Author
Tristan Brindle

Distributed under the Boost Software License, Version 1.0. (See Boost Software License - Version 1.0 or http://www.boost.org/LICENSE_1_0.txt)

For more information, see http://www.boost.org

This is an implementation of C++20's std::span http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4820.pdf

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <stdexcept>
#include <type_traits>
#include "gul17/traits.h"
Include dependency graph for span.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

namespace  gul17
 Namespace gul17 contains all functions and classes of the General Utility Library.
 

Functions

template<typename ElementType , std::size_t Extent>
span< const unsigned char,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> gul17::as_bytes (span< ElementType, Extent > s) noexcept
 Return a constant view to the byte representation of the elements of a given span.
 
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)> gul17::as_writable_bytes (span< ElementType, Extent > s) noexcept
 Return a writable view to the byte representation of the elements of a given span.
 
template<std::size_t N, typename E , std::size_t S>
constexpr auto gul17::get (span< E, S > s) -> decltype(s[N])
 Return a reference to the Nth element of a given span.