COPP C++ API
C++ interface for COPP trajectory optimization
Loading...
Searching...
No Matches
copp::Span< T > Class Template Reference

Non-owning view of a contiguous one-dimensional array. More...

#include <core.hpp>

Public Types

using element_type = T
using pointer = T *
using reference = T &

Public Member Functions

constexpr Span () noexcept=default
constexpr Span (pointer data, std::size_t size) noexcept
template<std::size_t N>
constexpr Span (element_type(&data)[N]) noexcept
template<typename Container, typename = decltype(std::declval<Container &>().data()), typename = decltype(std::declval<Container &>().size())>
 Span (Container &container) noexcept
template<typename Container, typename = decltype(std::declval<const Container &>().data()), typename = decltype(std::declval<const Container &>().size()), typename U = element_type, typename = typename std::enable_if<std::is_const<U>::value>::type>
 Span (const Container &container) noexcept
constexpr pointer data () const noexcept
constexpr std::size_t size () const noexcept
constexpr bool empty () const noexcept
reference operator[] (std::size_t index) const noexcept

Detailed Description

template<typename T>
class copp::Span< T >

Non-owning view of a contiguous one-dimensional array.

Span<T> is the C++17 compatibility equivalent of std::span<T>. It does not allocate, copy, or own memory. The referenced data must remain alive for the duration of the call that consumes the span.

Typical inputs are std::vector<double>, C arrays, or pointer/length pairs:

std::vector<double> s{0.0, 0.5, 1.0};
auto raw_view = copp::Span<const double>(s.data(), s.size());
Non-owning view of a contiguous one-dimensional array.
Definition core.hpp:139
Template Parameters
TElement type. Use const double for most public inputs.

Definition at line 138 of file core.hpp.

Member Typedef Documentation

◆ element_type

template<typename T>
using copp::Span< T >::element_type = T

Definition at line 141 of file core.hpp.

◆ pointer

template<typename T>
using copp::Span< T >::pointer = T *

Definition at line 142 of file core.hpp.

◆ reference

template<typename T>
using copp::Span< T >::reference = T &

Definition at line 143 of file core.hpp.

Constructor & Destructor Documentation

◆ Span() [1/5]

template<typename T>
copp::Span< T >::Span ( )
constexprdefaultnoexcept

◆ Span() [2/5]

template<typename T>
copp::Span< T >::Span ( pointer data,
std::size_t size )
inlineconstexprnoexcept

Definition at line 147 of file core.hpp.

◆ Span() [3/5]

template<typename T>
template<std::size_t N>
copp::Span< T >::Span ( element_type(&) data[N])
inlineconstexprnoexcept

Definition at line 150 of file core.hpp.

◆ Span() [4/5]

template<typename T>
template<typename Container, typename = decltype(std::declval<Container &>().data()), typename = decltype(std::declval<Container &>().size())>
copp::Span< T >::Span ( Container & container)
inlinenoexcept

Definition at line 156 of file core.hpp.

◆ Span() [5/5]

template<typename T>
template<typename Container, typename = decltype(std::declval<const Container &>().data()), typename = decltype(std::declval<const Container &>().size()), typename U = element_type, typename = typename std::enable_if<std::is_const<U>::value>::type>
copp::Span< T >::Span ( const Container & container)
inlinenoexcept

Definition at line 165 of file core.hpp.

Member Function Documentation

◆ data()

template<typename T>
pointer copp::Span< T >::data ( ) const
inlineconstexprnoexcept

Definition at line 168 of file core.hpp.

◆ size()

template<typename T>
std::size_t copp::Span< T >::size ( ) const
inlineconstexprnoexcept

Definition at line 169 of file core.hpp.

◆ empty()

template<typename T>
bool copp::Span< T >::empty ( ) const
inlineconstexprnoexcept

Definition at line 170 of file core.hpp.

◆ operator[]()

template<typename T>
reference copp::Span< T >::operator[] ( std::size_t index) const
inlinenoexcept

Definition at line 172 of file core.hpp.


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