ape  0.5.0
Audio Programming Environment
Public Types | Public Member Functions | List of all members
ape::uarray< T > Struct Template Reference

An unowned array wrapper - a mutable "view" of something else, that cannot be resized. Construction parameters are referenced directly, and no copies of data are ever taken / made. This also means you should take care to ensure referred-to data outlives any uarray. Following that, uarrays should probably only ever exist on the stack. More...

#include <misc.h>

Public Types

typedef T value_type
 Alias for T More...
 

Public Member Functions

 uarray (std::vector< T > &source)
 Construct from a mutable vector. More...
 
 uarray (const std::vector< typename std::remove_const_t< T >> &source)
 Construct a read-only uarray from a const-qualified vector. More...
 
 uarray (T *buffer, std::size_t length)
 Construct from a possibly cv-qualified source More...
 
 uarray (T *begin, T *end)
 Construct from a possibly cv-qualified iterator pair More...
 
T & operator[] (std::size_t index)
 Access a potential read-only element at index More...
 
const T & operator[] (std::size_t index) const
 Access a read-only element at index More...
 
T * begin () noexcept
 Returns an iterator to the beginning of the array pointed to More...
 
const T * begin () const noexcept
 Returns a const iterator to the beginning of the array pointed to More...
 
T * end () noexcept
 Returns an iterator pointing to 1 element past the end of the array pointed to More...
 
const T * end () const noexcept
 Returns a const iterator pointing to 1 element past the end of the array pointed to More...
 
T * data () noexcept
 Retrieve a raw pointer to the array pointed to More...
 
const T * data () const noexcept
 Retrieve a const raw pointer to the array pointed to More...
 
std::size_t size () const noexcept
 Returns the size of the array pointed to by this uarray More...
 
uarray< T > slice (std::size_t offset, std::size_t newLength=-1) noexcept
 Returns a new, constant uarray formed from a slice of the original. More...
 
template<typename Other >
std::enable_if< std::is_standard_layout< Other >::value &&!std::is_const< T >::value, uarray< Other > >::type reinterpret () noexcept
 
template<typename Other >
std::enable_if< std::is_standard_layout< Other >::value &&std::is_const< T >::value, uarray< const Other > >::type reinterpret () const noexcept
 
uarray< const T > slice (std::size_t offset, std::size_t newLength=-1) const noexcept
 Returns a new, constant uarray formed from a slice of the original. More...
 
 operator uarray< const T > () const noexcept
 Implicit conversion operator to a const / read-only version of this uarray More...
 

Detailed Description

template<typename T>
struct ape::uarray< T >

An unowned array wrapper - a mutable "view" of something else, that cannot be resized. Construction parameters are referenced directly, and no copies of data are ever taken / made. This also means you should take care to ensure referred-to data outlives any uarray. Following that, uarrays should probably only ever exist on the stack.

Template Parameters
TThe source content type. Append const to the type for perfectly enforced read-only access to the contents.

Member Typedef Documentation

◆ value_type

template<typename T>
typedef T ape::uarray< T >::value_type

Alias for T

Constructor & Destructor Documentation

◆ uarray() [1/4]

template<typename T>
ape::uarray< T >::uarray ( std::vector< T > &  source)
inline

Construct from a mutable vector.

◆ uarray() [2/4]

template<typename T>
ape::uarray< T >::uarray ( const std::vector< typename std::remove_const_t< T >> &  source)
inline

Construct a read-only uarray from a const-qualified vector.

◆ uarray() [3/4]

template<typename T>
ape::uarray< T >::uarray ( T *  buffer,
std::size_t  length 
)
inline

Construct from a possibly cv-qualified source

◆ uarray() [4/4]

template<typename T>
ape::uarray< T >::uarray ( T *  begin,
T *  end 
)
inline

Construct from a possibly cv-qualified iterator pair

Member Function Documentation

◆ begin() [1/2]

template<typename T>
const T* ape::uarray< T >::begin ( ) const
inlinenoexcept

Returns a const iterator to the beginning of the array pointed to

◆ begin() [2/2]

template<typename T>
T* ape::uarray< T >::begin ( )
inlinenoexcept

Returns an iterator to the beginning of the array pointed to

◆ data() [1/2]

template<typename T>
const T* ape::uarray< T >::data ( ) const
inlinenoexcept

Retrieve a const raw pointer to the array pointed to

◆ data() [2/2]

template<typename T>
T* ape::uarray< T >::data ( )
inlinenoexcept

Retrieve a raw pointer to the array pointed to

◆ end() [1/2]

template<typename T>
const T* ape::uarray< T >::end ( ) const
inlinenoexcept

Returns a const iterator pointing to 1 element past the end of the array pointed to

◆ end() [2/2]

template<typename T>
T* ape::uarray< T >::end ( )
inlinenoexcept

Returns an iterator pointing to 1 element past the end of the array pointed to

◆ operator uarray< const T >()

template<typename T>
ape::uarray< T >::operator uarray< const T > ( ) const
inlinenoexcept

Implicit conversion operator to a const / read-only version of this uarray

◆ operator[]() [1/2]

template<typename T>
T& ape::uarray< T >::operator[] ( std::size_t  index)
inline

Access a potential read-only element at index

◆ operator[]() [2/2]

template<typename T>
const T& ape::uarray< T >::operator[] ( std::size_t  index) const
inline

Access a read-only element at index

◆ reinterpret() [1/2]

template<typename T>
template<typename Other >
std::enable_if<std::is_standard_layout<Other>::value && std::is_const<T>::value, uarray<const Other> >::type ape::uarray< T >::reinterpret ( ) const
inlinenoexcept

◆ reinterpret() [2/2]

template<typename T>
template<typename Other >
std::enable_if<std::is_standard_layout<Other>::value && !std::is_const<T>::value, uarray<Other> >::type ape::uarray< T >::reinterpret ( )
inlinenoexcept

◆ size()

template<typename T>
std::size_t ape::uarray< T >::size ( ) const
inlinenoexcept

Returns the size of the array pointed to by this uarray

◆ slice() [1/2]

template<typename T>
uarray<const T> ape::uarray< T >::slice ( std::size_t  offset,
std::size_t  newLength = -1 
) const
inlinenoexcept

Returns a new, constant uarray formed from a slice of the original.

Parameters
offsetHow much to skip from the start
newLengthThe length of the slice, starting from offset . The default value adopts the current length, and substract the offset (ie. the remaining).

◆ slice() [2/2]

template<typename T>
uarray<T> ape::uarray< T >::slice ( std::size_t  offset,
std::size_t  newLength = -1 
)
inlinenoexcept

Returns a new, constant uarray formed from a slice of the original.

Parameters
offsetHow much to skip from the start
newLengthThe length of the slice, starting from offset . The default value adopts the current length, and substract the offset (ie. the remaining).

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