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 !=std::dynamic_extent) 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 !=std::dynamic_extent) const expr Span(Vec &vec)
 
template<Vectorlike Vec>
requires (std::is_same_v<std::add_const_t<typename Vec::value_type>, std::add_const_t<T>>)
 explicit (N !=std::dynamic_extent) const expr Span(const Vec &vec)
 
constexpr Span (typename Base::pointer p)
 
subspan

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

constexpr Span< T, std::dynamic_extent > subspan (size_t i, size_t n=std::dynamic_extent) const
 
template<size_t i, size_t n = std::dynamic_extent>
constexpr Span< T, n !=std::dynamic_extent ? n :(N !=std::dynamic_extent ? N - i :std::dynamic_extent)> subspan () const
 E.g.: If span points to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, then the result will point to 2, 3, 4, 5, 6.
 
rsubspan

Similar to Span::subspan but in reverse:

constexpr Span< T, std::dynamic_extent > rsubspan (size_t i, size_t n=std::dynamic_extent) const
 
template<size_t i, size_t n = std::dynamic_extent>
constexpr Span< T, n !=std::dynamic_extent ? n :(N !=std::dynamic_extent ? N - i :std::dynamic_extent)> rsubspan () const
 span.rsubspan(3, 5) removes the last 3 elements and while picking 5 elements onwards from there.
 

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;
    // ...
    }
    This is a thin wrapper for std::span<T, N> with the following additional features:
    Definition span.h:28

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 37 of file span.h.

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

◆ Span() [2/2]

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

Definition at line 45 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 ! = std::dynamic_extent) const &
inline

Definition at line 43 of file span.h.

◆ explicit() [2/3]

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

Definition at line 35 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 ! = std::dynamic_extent) const &
inline

Definition at line 40 of file span.h.

◆ rsubspan() [1/2]

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

span.rsubspan(3, 5) removes the last 3 elements and while picking 5 elements onwards from there.

Definition at line 76 of file span.h.

References mim::Span< T, N >::Span().

◆ rsubspan() [2/2]

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

Definition at line 69 of file span.h.

References mim::Span< T, N >::subspan().

◆ subspan() [1/2]

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

E.g.: If span points to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, then the result will point to 2, 3, 4, 5, 6.

Definition at line 61 of file span.h.

References mim::Span< T, N >::subspan().

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

◆ subspan() [2/2]

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

Definition at line 54 of file span.h.


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