Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
thorin::Span< T, N > Class Template Reference

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

#include <thorin/util/span.h>

Inheritance diagram for thorin::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 thorin::Span.

constexpr Span< T, std::dynamic_extent > subspan (size_t i, size_t n=std::dynamic_extent) const
 
constexpr Span< T, std::dynamic_extent > rsubspan (size_t i, size_t n=std::dynamic_extent) const
 
rsubspan

Similar to Span::subspan but in reverse: span.rsubspan(3, 5) removes the last 3 elements and while picking 5 elements onwards from there.

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.

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
 
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
 

Detailed Description

template<class T, size_t N = std::dynamic_extent>
class thorin::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;
    // ...
    }
    std::span< T, N > Base
    Definition span.h:30

Definition at line 28 of file span.h.

Member Typedef Documentation

◆ Base

template<class T , size_t N = std::dynamic_extent>
using thorin::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>
constexpr thorin::Span< T, N >::Span ( std::span< T, N span)
inlineconstexprnoexcept

Definition at line 37 of file span.h.

◆ Span() [2/2]

template<class T , size_t N = std::dynamic_extent>
constexpr thorin::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>>)
thorin::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>
thorin::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>)
thorin::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>
constexpr Span< T, n !=std::dynamic_extent ? n :(N !=std::dynamic_extent ? N - i :std::dynamic_extent)> thorin::Span< T, N >::rsubspan ( ) const
inlineconstexpr

Definition at line 75 of file span.h.

◆ rsubspan() [2/2]

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

Definition at line 57 of file span.h.

References thorin::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>
constexpr Span< T, n !=std::dynamic_extent ? n :(N !=std::dynamic_extent ? N - i :std::dynamic_extent)> thorin::Span< T, N >::subspan ( ) const
inlineconstexpr

Definition at line 69 of file span.h.

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

◆ subspan() [2/2]

template<class T , size_t N = std::dynamic_extent>
constexpr Span< T, std::dynamic_extent > thorin::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: