ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ndarray::ContiguousSpan< T, isConst > Class Template Reference

#include <ContiguousSpan.h>

Public Types

using pointer_type = typename std::conditional< isConst, const T *, T * >::type
 
using reference_type = typename std::conditional< isConst, const T &, T & >::type
 
using iterator_type = pointer_type
 

Public Member Functions

 ContiguousSpan (pointer_type data, size_t len) noexcept
 
template<typename It >
 ContiguousSpan (It first, It last) noexcept
 
 ContiguousSpan (const ContiguousSpan &)=delete
 
 ContiguousSpan (ContiguousSpan &&s) noexcept
 
 operator ContiguousSpan< T, true > ()
 
reference_type operator[] (size_t idx) const noexcept
 
reference_type at (size_t idx) const noexcept
 
ContiguousSpan< T, isConst > offset (size_t offset)
 
template<typename From , bool _ = isConst>
std::enable_if<!_, void >::type assign (const From &f) noexcept
 
template<typename U , bool _ = isConst>
std::enable_if<!_, ContiguousSpan & >::type operator= (std::initializer_list< U > list) noexcept
 
template<typename It , bool _ = isConst>
std::enable_if<!_, void >::type assignFrom (It first, It last) noexcept
 
size_t size () const
 
iterator_type begin () const
 
iterator_type end () const
 
pointer_type data ()
 

Detailed Description

template<typename T, bool isConst = false>
class ndarray::ContiguousSpan< T, isConst >

Definition at line 29 of file ContiguousSpan.h.

Member Typedef Documentation

◆ iterator_type

template<typename T , bool isConst = false>
using ndarray::ContiguousSpan< T, isConst >::iterator_type = pointer_type

Definition at line 34 of file ContiguousSpan.h.

◆ pointer_type

template<typename T , bool isConst = false>
using ndarray::ContiguousSpan< T, isConst >::pointer_type = typename std::conditional<isConst, const T *, T *>::type

Definition at line 32 of file ContiguousSpan.h.

◆ reference_type

template<typename T , bool isConst = false>
using ndarray::ContiguousSpan< T, isConst >::reference_type = typename std::conditional<isConst, const T &, T &>::type

Definition at line 33 of file ContiguousSpan.h.

Constructor & Destructor Documentation

◆ ContiguousSpan() [1/4]

template<typename T , bool isConst = false>
ndarray::ContiguousSpan< T, isConst >::ContiguousSpan ( pointer_type  data,
size_t  len 
)
inlinenoexcept

Definition at line 36 of file ContiguousSpan.h.

36: _data(data), _len(len) {}

◆ ContiguousSpan() [2/4]

template<typename T , bool isConst = false>
template<typename It >
ndarray::ContiguousSpan< T, isConst >::ContiguousSpan ( It  first,
It  last 
)
inlineexplicitnoexcept

Definition at line 39 of file ContiguousSpan.h.

40 : _data(&*first), _len(std::distance(first, last))
41 {
42 }

◆ ContiguousSpan() [3/4]

template<typename T , bool isConst = false>
ndarray::ContiguousSpan< T, isConst >::ContiguousSpan ( const ContiguousSpan< T, isConst > &  )
delete

◆ ContiguousSpan() [4/4]

template<typename T , bool isConst = false>
ndarray::ContiguousSpan< T, isConst >::ContiguousSpan ( ContiguousSpan< T, isConst > &&  s)
inlinenoexcept

Definition at line 46 of file ContiguousSpan.h.

46: _data(s._data), _len(s._len) { s._data = nullptr; }

Member Function Documentation

◆ assign()

template<typename T , bool isConst = false>
template<typename From , bool _ = isConst>
std::enable_if<!_, void >::type ndarray::ContiguousSpan< T, isConst >::assign ( const From &  f)
inlinenoexcept

Definition at line 61 of file ContiguousSpan.h.

62 {
63 assignFrom(std::begin(f), std::end(f));
64 }
std::enable_if<!_, void >::type assignFrom(It first, It last) noexcept

References ndarray::ContiguousSpan< T, isConst >::assignFrom().

◆ assignFrom()

template<typename T , bool isConst = false>
template<typename It , bool _ = isConst>
std::enable_if<!_, void >::type ndarray::ContiguousSpan< T, isConst >::assignFrom ( It  first,
It  last 
)
inlinenoexcept

Definition at line 75 of file ContiguousSpan.h.

76 {
77 std::copy(first, last, begin());
78 }
iterator_type begin() const

References ndarray::ContiguousSpan< T, isConst >::begin().

Referenced by ndarray::ContiguousSpan< T, isConst >::assign(), and ndarray::ContiguousSpan< T, isConst >::operator=().

◆ at()

template<typename T , bool isConst = false>
reference_type ndarray::ContiguousSpan< T, isConst >::at ( size_t  idx) const
inlinenoexcept

Definition at line 52 of file ContiguousSpan.h.

52{ return _data[idx]; }

◆ begin()

template<typename T , bool isConst = false>
iterator_type ndarray::ContiguousSpan< T, isConst >::begin ( ) const
inline

Definition at line 82 of file ContiguousSpan.h.

82{ return iterator_type{_data}; }

Referenced by ndarray::ContiguousSpan< T, isConst >::assignFrom().

◆ data()

template<typename T , bool isConst = false>
pointer_type ndarray::ContiguousSpan< T, isConst >::data ( )
inline

Definition at line 86 of file ContiguousSpan.h.

86{ return _data; }

◆ end()

template<typename T , bool isConst = false>
iterator_type ndarray::ContiguousSpan< T, isConst >::end ( ) const
inline

Definition at line 84 of file ContiguousSpan.h.

84{ return iterator_type{_data + _len}; }

◆ offset()

template<typename T , bool isConst = false>
ContiguousSpan< T, isConst > ndarray::ContiguousSpan< T, isConst >::offset ( size_t  offset)
inline

Definition at line 54 of file ContiguousSpan.h.

55 {
56 assert(offset <= _len);
57 return {_data + offset, _len - offset};
58 }
ContiguousSpan< T, isConst > offset(size_t offset)

References ndarray::ContiguousSpan< T, isConst >::offset().

Referenced by ndarray::ContiguousSpan< T, isConst >::offset().

◆ operator ContiguousSpan< T, true >()

template<typename T , bool isConst = false>
ndarray::ContiguousSpan< T, isConst >::operator ContiguousSpan< T, true > ( )
inline

Definition at line 48 of file ContiguousSpan.h.

48{ return ContiguousSpan<T, true>{_data, _len}; }

◆ operator=()

template<typename T , bool isConst = false>
template<typename U , bool _ = isConst>
std::enable_if<!_, ContiguousSpan & >::type ndarray::ContiguousSpan< T, isConst >::operator= ( std::initializer_list< U >  list)
inlinenoexcept

Definition at line 68 of file ContiguousSpan.h.

69 {
70 assignFrom(std::begin(list), std::end(list));
71 return *this;
72 }

References ndarray::ContiguousSpan< T, isConst >::assignFrom().

◆ operator[]()

template<typename T , bool isConst = false>
reference_type ndarray::ContiguousSpan< T, isConst >::operator[] ( size_t  idx) const
inlinenoexcept

Definition at line 50 of file ContiguousSpan.h.

50{ return _data[idx]; }

◆ size()

template<typename T , bool isConst = false>
size_t ndarray::ContiguousSpan< T, isConst >::size ( ) const
inline

Definition at line 80 of file ContiguousSpan.h.

80{ return _len; }

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