MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
Public Types | Public Member Functions | List of all members
mip::Vector< T, N > Struct Template Reference

Vector is a wrapper around an array of some type T, usually float or double. More...

#include <common.hpp>

Public Types

typedef T Array[N]
 

Public Member Functions

 Vector ()
 Default constructor, no initialization. More...
 
template<typename U >
 Vector (U value)
 
template<typename U >
 Vector (const U(&ptr)[N])
 
template<typename U , size_t M>
 Vector (const U(&ptr)[M])
 
template<typename U >
 Vector (const U *ptr, size_t n)
 
template<typename U , typename V , typename... Rest>
 Vector (U u, V v, Rest... rest)
 
 Vector (const Vector &)=default
 Copy constructor. More...
 
Vectoroperator= (const Vector &)=default
 Assignment operator. More...
 
template<typename U >
Vectoroperator= (const Vector< U, N > &other)
 Assignment operator from different type (e.g. float to double). More...
 
 operator T* ()
 
 operator const T * () const
 
Arraydata ()
 Explicitly convert to a C-style array. More...
 
const Arraydata () const
 
template<typename U >
void fill (U value)
 Fill all elements with a given value. More...
 
template<typename U >
void copyFrom (const U *ptr, size_t n)
 
size_t size () const
 Get the size of the array. More...
 

Detailed Description

template<typename T, size_t N>
struct mip::Vector< T, N >

Vector is a wrapper around an array of some type T, usually float or double.

Implicit conversion to/from C-style pointers is provided to allow simple integration with code using plain arrays.

Member Typedef Documentation

◆ Array

template<typename T , size_t N>
typedef T mip::Vector< T, N >::Array[N]

Constructor & Destructor Documentation

◆ Vector() [1/7]

template<typename T , size_t N>
mip::Vector< T, N >::Vector ( )
inline

Default constructor, no initialization.

◆ Vector() [2/7]

template<typename T , size_t N>
template<typename U >
mip::Vector< T, N >::Vector ( value)
inline

Set all elements to this value (typically 0).

Parameters
value

◆ Vector() [3/7]

template<typename T , size_t N>
template<typename U >
mip::Vector< T, N >::Vector ( const U(&)  ptr[N])
inline

Construct from a C array of known size.

Parameters
ptr

◆ Vector() [4/7]

template<typename T , size_t N>
template<typename U , size_t M>
mip::Vector< T, N >::Vector ( const U(&)  ptr[M])
inlineexplicit

Construct from a C array of different size (smaller or larger vector).

Parameters
ptr

◆ Vector() [5/7]

template<typename T , size_t N>
template<typename U >
mip::Vector< T, N >::Vector ( const U *  ptr,
size_t  n 
)
inlineexplicit

Construct from a pointer and size.

Parameters
ptrPointer to data to copy. Can be NULL if n==0.
nNumber of elements to copy. Clamped to N.

◆ Vector() [6/7]

template<typename T , size_t N>
template<typename U , typename V , typename... Rest>
mip::Vector< T, N >::Vector ( u,
v,
Rest...  rest 
)
inline

Construct from individual elements or a braced init list.

Parameters
uThe first value (typically X).
vThe value value (typically Y).
restAdditional optional values (typically none, Z, or Z and W).

◆ Vector() [7/7]

template<typename T , size_t N>
mip::Vector< T, N >::Vector ( const Vector< T, N > &  )
default

Copy constructor.

Member Function Documentation

◆ copyFrom()

template<typename T , size_t N>
template<typename U >
void mip::Vector< T, N >::copyFrom ( const U *  ptr,
size_t  n 
)
inline

Copy data from a pointer and size to this vector.

Parameters
ptrPointer to data. Can be NULL if n==0.
nNumber of elements in ptr. Clamped to N.

◆ data() [1/2]

template<typename T , size_t N>
Array& mip::Vector< T, N >::data ( )
inline

Explicitly convert to a C-style array.

◆ data() [2/2]

template<typename T , size_t N>
const Array& mip::Vector< T, N >::data ( ) const
inline

◆ fill()

template<typename T , size_t N>
template<typename U >
void mip::Vector< T, N >::fill ( value)
inline

Fill all elements with a given value.

◆ operator const T *()

template<typename T , size_t N>
mip::Vector< T, N >::operator const T * ( ) const
inline

◆ operator T*()

template<typename T , size_t N>
mip::Vector< T, N >::operator T* ( )
inline

◆ operator=() [1/2]

template<typename T , size_t N>
Vector& mip::Vector< T, N >::operator= ( const Vector< T, N > &  )
default

Assignment operator.

◆ operator=() [2/2]

template<typename T , size_t N>
template<typename U >
Vector& mip::Vector< T, N >::operator= ( const Vector< U, N > &  other)
inline

Assignment operator from different type (e.g. float to double).

◆ size()

template<typename T , size_t N>
size_t mip::Vector< T, N >::size ( ) const
inline

Get the size of the array.


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