MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::Span< T, N > Class Template Reference

This is a thin wrapper for std::span<T, N> with the following additional features: More...

#include <mim/util/span.h>

Inheritance diagram for mim::Span< T, N >:
[legend]

Public Types

using Base = std::span<T, N>
 

Public Member Functions

Constructors
 explicit (N !=D) const expr Span(std
 
constexpr Span (std::span< T, N > span) noexcept
 
template<Vectorlike Vec>
requires (std::is_same_v<typename Vec::value_type, T>)
 explicit (N !=D) const expr Span(Vec &vec) noexcept(noexcept(vec.data()) &&noexcept(vec.size()))
 
template<Vectorlike Vec>
requires (std::is_same_v<std::add_const_t<typename Vec::value_type>, std::add_const_t<T>>)
 explicit (N !=D) const expr Span(const Vec &vec) noexcept(noexcept(vec.data()) &&noexcept(vec.size()))
 
constexpr Span (typename Base::pointer p) noexcept
 
subspan

Wrappers for std::span::subspan that return a mim::Span.

Example: If span points to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, then

  • span.subspan<2, 5>() and span.subspan(2, 5) will point to 2, 3, 4, 5, 6.
  • span.subspan<2>() and span.subspan(2) will point to 2, 3, 4, 5, 6, 7, 8, 9.
constexpr Span< T, Dsubspan (size_t i, size_t n=D) const noexcept
 
template<size_t i, size_t n = D>
constexpr Span< T, n !=D ? n :(N !=D ? N - i :D)> subspan () const noexcept
 
rsubspan

Similar to Span::subspan but in reverse:

constexpr Span< T, Drsubspan (size_t i, size_t n=D) const noexcept
 
template<size_t i, size_t n = D>
constexpr Span< T, n !=D ? n :(N !=D ? N - i :D)> rsubspan () const noexcept
 span.rsubspan(3, 5) removes the last 3 elements and picks 5 elements starting before those.
 

Static Public Attributes

static constexpr auto D = std::dynamic_extent
 

Detailed Description

template<class T, size_t N = std::dynamic_extent>
class mim::Span< T, N >

This is a thin wrapper for std::span<T, N> with the following additional features:

  • Constructor with std::initializer_list (C++26 will get this ...)
  • Constructor for any compatible Vectorlike argument
  • rsubspan (reverse subspan)
  • structured binding, if N != std::dynamic_extent:
    void f(Span<int, 3> span) {
    auto& [a, b, c] = span;
    b = 23;
    // ...
    }
    constexpr Span(std::span< T, N > span) noexcept
    Definition span.h:38

Definition at line 28 of file span.h.

Member Typedef Documentation

◆ Base

template<class T, size_t N = std::dynamic_extent>
using mim::Span< T, N >::Base = std::span<T, N>

Definition at line 30 of file span.h.

Constructor & Destructor Documentation

◆ Span() [1/2]

template<class T, size_t N = std::dynamic_extent>
mim::Span< T, N >::Span ( std::span< T, N > span)
inlineconstexprnoexcept

Definition at line 38 of file span.h.

Referenced by mim::Span< const T, N >::rsubspan().

◆ Span() [2/2]

template<class T, size_t N = std::dynamic_extent>
mim::Span< T, N >::Span ( typename Base::pointer p)
inlineexplicitconstexprnoexcept

Definition at line 46 of file span.h.

Member Function Documentation

◆ explicit() [1/3]

template<class T, size_t N = std::dynamic_extent>
template<Vectorlike Vec>
requires (std::is_same_v<std::add_const_t<typename Vec::value_type>, std::add_const_t<T>>)
mim::Span< T, N >::explicit ( N ! = D) const &
inlinenoexcept

Definition at line 44 of file span.h.

◆ explicit() [2/3]

template<class T, size_t N = std::dynamic_extent>
mim::Span< T, N >::explicit ( N ! = D) const
inline

Definition at line 36 of file span.h.

◆ explicit() [3/3]

template<class T, size_t N = std::dynamic_extent>
template<Vectorlike Vec>
requires (std::is_same_v<typename Vec::value_type, T>)
mim::Span< T, N >::explicit ( N ! = D) const &
inlinenoexcept

Definition at line 41 of file span.h.

◆ rsubspan() [1/2]

template<class T, size_t N = std::dynamic_extent>
template<size_t i, size_t n = D>
Span< T, n !=D ? n :(N !=D ? N - i :D)> mim::Span< T, N >::rsubspan ( ) const
inlinenodiscardconstexprnoexcept

span.rsubspan(3, 5) removes the last 3 elements and picks 5 elements starting before those.

Definition at line 75 of file span.h.

◆ rsubspan() [2/2]

template<class T, size_t N = std::dynamic_extent>
Span< T, D > mim::Span< T, N >::rsubspan ( size_t i,
size_t n = D ) const
inlinenodiscardconstexprnoexcept

Definition at line 69 of file span.h.

◆ subspan() [1/2]

template<class T, size_t N = std::dynamic_extent>
template<size_t i, size_t n = D>
Span< T, n !=D ? n :(N !=D ? N - i :D)> mim::Span< T, N >::subspan ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 61 of file span.h.

Referenced by mim::Span< const T, N >::rsubspan(), and mim::Span< const T, N >::subspan().

◆ subspan() [2/2]

template<class T, size_t N = std::dynamic_extent>
Span< T, D > mim::Span< T, N >::subspan ( size_t i,
size_t n = D ) const
inlinenodiscardconstexprnoexcept

Definition at line 58 of file span.h.

Member Data Documentation

◆ D

template<class T, size_t N = std::dynamic_extent>
auto mim::Span< T, N >::D = std::dynamic_extent
staticconstexpr

Definition at line 31 of file span.h.


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