Antkeeper  0.0.1
Public Types | Public Attributes | Static Public Attributes | List of all members
math::vector< T, N > Struct Template Reference

n-dimensional vector. More...

#include <vector.hpp>

Public Types

using element_type = T
 Element type. More...
 

Public Member Functions

Element access
constexpr element_typeoperator[] (std::size_t i) noexcept
 Returns a reference to the element at a given index. More...
 
constexpr const element_typeoperator[] (std::size_t i) const noexcept
 Returns a reference to the element at a given index. More...
 
constexpr element_typefront () noexcept
 Returns a reference to the first element. More...
 
constexpr const element_typefront () const noexcept
 Returns a reference to the first element. More...
 
constexpr element_typeback () noexcept
 Returns a reference to the last element. More...
 
constexpr const element_typeback () const noexcept
 Returns a reference to the last element. More...
 
constexpr element_typedata () noexcept
 Returns a pointer to the element array. More...
 
constexpr const element_typedata () const noexcept
 Returns a pointer to the element array. More...
 
constexpr element_typex () noexcept
 Returns a reference to the first element. More...
 
constexpr const element_typex () const noexcept
 Returns a reference to the first element. More...
 
constexpr element_typey () noexcept
 Returns a reference to the second element. More...
 
constexpr const element_typey () const noexcept
 Returns a reference to the second element. More...
 
constexpr element_typez () noexcept
 Returns a reference to the third element. More...
 
constexpr const element_typez () const noexcept
 Returns a reference to the third element. More...
 
Iterators
constexpr element_typebegin () noexcept
 Returns an iterator to the first element. More...
 
constexpr const element_typebegin () const noexcept
 Returns an iterator to the first element. More...
 
constexpr const element_typecbegin () const noexcept
 Returns an iterator to the first element. More...
 
constexpr element_typeend () noexcept
 Returns an iterator to the element following the last element. More...
 
constexpr const element_typeend () const noexcept
 Returns an iterator to the element following the last element. More...
 
constexpr const element_typecend () const noexcept
 Returns an iterator to the element following the last element. More...
 
constexpr std::reverse_iterator< element_type * > rbegin () noexcept
 Returns a reverse iterator to the first element of the reversed vector. More...
 
constexpr std::reverse_iterator< const element_type * > rbegin () const noexcept
 Returns a reverse iterator to the first element of the reversed vector. More...
 
constexpr std::reverse_iterator< const element_type * > crbegin () const noexcept
 Returns a reverse iterator to the first element of the reversed vector. More...
 
constexpr std::reverse_iterator< element_type * > rend () noexcept
 Returns a reverse iterator to the element following the last element of the reversed vector. More...
 
constexpr std::reverse_iterator< const element_type * > rend () const noexcept
 Returns a reverse iterator to the element following the last element of the reversed vector. More...
 
constexpr std::reverse_iterator< const element_type * > crend () const noexcept
 Returns a reverse iterator to the element following the last element of the reversed vector. More...
 
Capacity
constexpr std::size_t size () const noexcept
 Returns the number of elements in the vector. More...
 

Public Attributes

element_type elements [N]
 Array of elements. More...
 

Static Public Attributes

static constexpr std::size_t element_count = N
 Number of elements. More...
 

Conversion

template<class U >
constexpr operator vector< U, N > () const noexcept
 Type-casts the elements of this vector using static_cast. More...
 
template<std::size_t M>
constexpr operator vector< T, M > () const noexcept
 Size-casts this vector to a vector with a different number of elements. More...
 

Constants

static constexpr vector zero () noexcept
 Returns a zero vector, where every element is equal to zero. More...
 
static constexpr vector one () noexcept
 Returns a vector of ones, where every element is equal to one. More...
 
static constexpr vector infinity () noexcept
 Returns a vector of infinities, where every element is equal to infinity. More...
 

Detailed Description

template<class T, std::size_t N>
struct math::vector< T, N >

n-dimensional vector.

Template Parameters
TElement type.
NNumber of elements.

Definition at line 43 of file vector.hpp.

Member Typedef Documentation

◆ element_type

template<class T , std::size_t N>
using math::vector< T, N >::element_type = T

Element type.

Definition at line 46 of file vector.hpp.

Member Function Documentation

◆ back() [1/2]

template<class T , std::size_t N>
constexpr const element_type& math::vector< T, N >::back ( ) const
inlineconstexprnoexcept

Returns a reference to the last element.

Definition at line 142 of file vector.hpp.

◆ back() [2/2]

template<class T , std::size_t N>
constexpr element_type& math::vector< T, N >::back ( )
inlineconstexprnoexcept

Returns a reference to the last element.

Definition at line 138 of file vector.hpp.

◆ begin() [1/2]

template<class T , std::size_t N>
constexpr const element_type* math::vector< T, N >::begin ( ) const
inlineconstexprnoexcept

Returns an iterator to the first element.

Definition at line 221 of file vector.hpp.

◆ begin() [2/2]

template<class T , std::size_t N>
constexpr element_type* math::vector< T, N >::begin ( )
inlineconstexprnoexcept

Returns an iterator to the first element.

Definition at line 217 of file vector.hpp.

◆ cbegin()

template<class T , std::size_t N>
constexpr const element_type* math::vector< T, N >::cbegin ( ) const
inlineconstexprnoexcept

Returns an iterator to the first element.

Definition at line 225 of file vector.hpp.

◆ cend()

template<class T , std::size_t N>
constexpr const element_type* math::vector< T, N >::cend ( ) const
inlineconstexprnoexcept

Returns an iterator to the element following the last element.

Definition at line 243 of file vector.hpp.

◆ crbegin()

template<class T , std::size_t N>
constexpr std::reverse_iterator<const element_type*> math::vector< T, N >::crbegin ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the first element of the reversed vector.

Definition at line 261 of file vector.hpp.

◆ crend()

template<class T , std::size_t N>
constexpr std::reverse_iterator<const element_type*> math::vector< T, N >::crend ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the element following the last element of the reversed vector.

Definition at line 279 of file vector.hpp.

◆ data() [1/2]

template<class T , std::size_t N>
constexpr const element_type* math::vector< T, N >::data ( ) const
inlineconstexprnoexcept

Returns a pointer to the element array.

Definition at line 156 of file vector.hpp.

◆ data() [2/2]

template<class T , std::size_t N>
constexpr element_type* math::vector< T, N >::data ( )
inlineconstexprnoexcept

Returns a pointer to the element array.

Definition at line 152 of file vector.hpp.

◆ end() [1/2]

template<class T , std::size_t N>
constexpr const element_type* math::vector< T, N >::end ( ) const
inlineconstexprnoexcept

Returns an iterator to the element following the last element.

Definition at line 239 of file vector.hpp.

◆ end() [2/2]

template<class T , std::size_t N>
constexpr element_type* math::vector< T, N >::end ( )
inlineconstexprnoexcept

Returns an iterator to the element following the last element.

Definition at line 235 of file vector.hpp.

◆ front() [1/2]

template<class T , std::size_t N>
constexpr const element_type& math::vector< T, N >::front ( ) const
inlineconstexprnoexcept

Returns a reference to the first element.

Definition at line 128 of file vector.hpp.

◆ front() [2/2]

template<class T , std::size_t N>
constexpr element_type& math::vector< T, N >::front ( )
inlineconstexprnoexcept

Returns a reference to the first element.

Definition at line 124 of file vector.hpp.

◆ infinity()

template<class T , std::size_t N>
static constexpr vector math::vector< T, N >::infinity ( )
inlinestaticconstexprnoexcept

Returns a vector of infinities, where every element is equal to infinity.

Definition at line 342 of file vector.hpp.

◆ one()

template<class T , std::size_t N>
static constexpr vector math::vector< T, N >::one ( )
inlinestaticconstexprnoexcept

Returns a vector of ones, where every element is equal to one.

Definition at line 324 of file vector.hpp.

◆ operator vector< T, M >()

template<class T , std::size_t N>
template<std::size_t M>
constexpr math::vector< T, N >::operator vector< T, M > ( ) const
inlineexplicitconstexprnoexcept

Size-casts this vector to a vector with a different number of elements.

Casting to a greater number of elements causes new elements to be set to zero.

Template Parameters
MTarget number of elements.
Returns
m-dimensional vector.

Definition at line 92 of file vector.hpp.

◆ operator vector< U, N >()

template<class T , std::size_t N>
template<class U >
constexpr math::vector< T, N >::operator vector< U, N > ( ) const
inlineexplicitconstexprnoexcept

Type-casts the elements of this vector using static_cast.

Template Parameters
UTarget element type.
Returns
Vector containing the type-casted elements.

Definition at line 72 of file vector.hpp.

◆ operator[]() [1/2]

template<class T , std::size_t N>
constexpr const element_type& math::vector< T, N >::operator[] ( std::size_t  i) const
inlineconstexprnoexcept

Returns a reference to the element at a given index.

Parameters
iIndex of an element.
Returns
Reference to the element at index i.

Definition at line 114 of file vector.hpp.

◆ operator[]() [2/2]

template<class T , std::size_t N>
constexpr element_type& math::vector< T, N >::operator[] ( std::size_t  i)
inlineconstexprnoexcept

Returns a reference to the element at a given index.

Parameters
iIndex of an element.
Returns
Reference to the element at index i.

Definition at line 110 of file vector.hpp.

◆ rbegin() [1/2]

template<class T , std::size_t N>
constexpr std::reverse_iterator<const element_type*> math::vector< T, N >::rbegin ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the first element of the reversed vector.

Definition at line 257 of file vector.hpp.

◆ rbegin() [2/2]

template<class T , std::size_t N>
constexpr std::reverse_iterator<element_type*> math::vector< T, N >::rbegin ( )
inlineconstexprnoexcept

Returns a reverse iterator to the first element of the reversed vector.

Definition at line 253 of file vector.hpp.

◆ rend() [1/2]

template<class T , std::size_t N>
constexpr std::reverse_iterator<const element_type*> math::vector< T, N >::rend ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the element following the last element of the reversed vector.

Definition at line 275 of file vector.hpp.

◆ rend() [2/2]

template<class T , std::size_t N>
constexpr std::reverse_iterator<element_type*> math::vector< T, N >::rend ( )
inlineconstexprnoexcept

Returns a reverse iterator to the element following the last element of the reversed vector.

Definition at line 271 of file vector.hpp.

◆ size()

template<class T , std::size_t N>
constexpr std::size_t math::vector< T, N >::size ( ) const
inlineconstexprnoexcept

Returns the number of elements in the vector.

Definition at line 293 of file vector.hpp.

◆ x() [1/2]

template<class T , std::size_t N>
constexpr const element_type& math::vector< T, N >::x ( ) const
inlineconstexprnoexcept

Returns a reference to the first element.

Definition at line 169 of file vector.hpp.

◆ x() [2/2]

template<class T , std::size_t N>
constexpr element_type& math::vector< T, N >::x ( )
inlineconstexprnoexcept

Returns a reference to the first element.

Definition at line 164 of file vector.hpp.

◆ y() [1/2]

template<class T , std::size_t N>
constexpr const element_type& math::vector< T, N >::y ( ) const
inlineconstexprnoexcept

Returns a reference to the second element.

Definition at line 185 of file vector.hpp.

◆ y() [2/2]

template<class T , std::size_t N>
constexpr element_type& math::vector< T, N >::y ( )
inlineconstexprnoexcept

Returns a reference to the second element.

Definition at line 180 of file vector.hpp.

◆ z() [1/2]

template<class T , std::size_t N>
constexpr const element_type& math::vector< T, N >::z ( ) const
inlineconstexprnoexcept

Returns a reference to the third element.

Definition at line 201 of file vector.hpp.

◆ z() [2/2]

template<class T , std::size_t N>
constexpr element_type& math::vector< T, N >::z ( )
inlineconstexprnoexcept

Returns a reference to the third element.

Definition at line 196 of file vector.hpp.

◆ zero()

template<class T , std::size_t N>
static constexpr vector math::vector< T, N >::zero ( )
inlinestaticconstexprnoexcept

Returns a zero vector, where every element is equal to zero.

Definition at line 306 of file vector.hpp.

Member Data Documentation

◆ element_count

template<class T , std::size_t N>
constexpr std::size_t math::vector< T, N >::element_count = N
staticconstexpr

Number of elements.

Definition at line 49 of file vector.hpp.

◆ elements

template<class T , std::size_t N>
element_type math::vector< T, N >::elements[N]

Array of elements.

Definition at line 52 of file vector.hpp.


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