Mathter
A configurable 3D math library for game developers.
Public Member Functions | List of all members
mathter::Swizzle< T, Indices > Class Template Reference

Enables element swizzling (reordering elements) for vectors. More...

#include <Definitions.hpp>

Public Member Functions

 operator Vector< T, sizeof... (Indices)
 Builds the swizzled vector object. More...
 
 false () const
 
 operator Vector< T, sizeof... (Indices)
 Builds the swizzled vector object. More...
 
 true () const
 
Swizzleoperator= (const Vector< T, sizeof...(Indices), false > &rhs)
 Sets the parent vector's elements from the right-side argument. More...
 
Swizzleoperator= (const Vector< T, sizeof...(Indices), true > &rhs)
 Sets the parent vector's elements from the right-side argument. More...
 
template<class T2 , int... Indices2, typename std::enable_if< sizeof...(Indices)==sizeof...(Indices2), int >::type = 0>
Swizzleoperator= (const Swizzle< T2, Indices2... > &rhs)
 Sets the parent vector's elements from the right-side argument. More...
 
T & operator[] (int idx)
 Returns the nth element of the swizzled vector. Example: v.zxy[2] returns y. More...
 
operator[] (int idx) const
 Returns the nth element of the swizzled vector. Example: v.zxy[2] returns y. More...
 
T & operator() (int idx)
 Returns the nth element of the swizzled vector. Example: v.zxy(2) returns y. More...
 
operator() (int idx) const
 Returns the nth element of the swizzled vector. Example: v.zxy(2) returns y. More...
 
template<bool Packed = false>
const auto ToVector () const
 Builds the swizzled vector object. More...
 

Detailed Description

template<class T, int... Indices>
class mathter::Swizzle< T, Indices >

Enables element swizzling (reordering elements) for vectors.

To access swizzlers, use the xx, xy, xyz and similar elements of vectors. Swizzlers can be used with assignments, concatenation, casting and constructors. To perform arithmetic, cast swizzlers to corresponding vector type.

Member Function Documentation

◆ false()

template<class T, int... Indices>
mathter::Swizzle< T, Indices >::false ( ) const

◆ operator Vector< T, sizeof...() [1/2]

template<class T , int... Indices>
mathter::Swizzle< T, Indices >::operator Vector< T, sizeof... ( Indices  )

Builds the swizzled vector object.

◆ operator Vector< T, sizeof...() [2/2]

template<class T, int... Indices>
mathter::Swizzle< T, Indices >::operator Vector< T, sizeof... ( Indices  )

Builds the swizzled vector object.

◆ operator()() [1/2]

template<class T, int... Indices>
T& mathter::Swizzle< T, Indices >::operator() ( int  idx)
inline

Returns the nth element of the swizzled vector. Example: v.zxy(2) returns y.

◆ operator()() [2/2]

template<class T, int... Indices>
T mathter::Swizzle< T, Indices >::operator() ( int  idx) const
inline

Returns the nth element of the swizzled vector. Example: v.zxy(2) returns y.

◆ operator=() [1/3]

template<class T , int... Indices>
Swizzle< T, Indices... > & mathter::Swizzle< T, Indices >::operator= ( const Vector< T, sizeof...(Indices), false > &  rhs)

Sets the parent vector's elements from the right-side argument.

Example: b = {1,2,3}; a.yxz = b; -> a contains {2,1,3}. You don't have to worry about aliasing (a.xyz = a is totally fine).

◆ operator=() [2/3]

template<class T , int... Indices>
Swizzle< T, Indices... > & mathter::Swizzle< T, Indices >::operator= ( const Vector< T, sizeof...(Indices), true > &  rhs)

Sets the parent vector's elements from the right-side argument.

Example: b = {1,2,3}; a.yxz = b; -> a contains {2,1,3}. You don't have to worry about aliasing (a.xyz = a is totally fine).

◆ operator=() [3/3]

template<class T, int... Indices>
template<class T2 , int... Indices2, typename std::enable_if< sizeof...(Indices)==sizeof...(Indices2), int >::type = 0>
Swizzle& mathter::Swizzle< T, Indices >::operator= ( const Swizzle< T2, Indices2... > &  rhs)
inline

Sets the parent vector's elements from the right-side argument.

Example: b = {1,2,3}; a.yxz = b.xyz; -> a contains {2,1,3}. You don't have to worry about aliasing (a.xyz = a.zyx is totally fine).

◆ operator[]() [1/2]

template<class T, int... Indices>
T& mathter::Swizzle< T, Indices >::operator[] ( int  idx)
inline

Returns the nth element of the swizzled vector. Example: v.zxy[2] returns y.

◆ operator[]() [2/2]

template<class T, int... Indices>
T mathter::Swizzle< T, Indices >::operator[] ( int  idx) const
inline

Returns the nth element of the swizzled vector. Example: v.zxy[2] returns y.

◆ ToVector()

template<class T, int... Indices>
template<bool Packed = false>
const auto mathter::Swizzle< T, Indices >::ToVector ( ) const
inline

Builds the swizzled vector object.

◆ true()

template<class T, int... Indices>
mathter::Swizzle< T, Indices >::true ( ) const

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