PlayRho  2.0.0
An interactive physics engine & library.
Vector.hpp File Reference

Definition of the Vector class template and closely related code. More...

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <iostream>
#include <tuple>
#include <type_traits>
#include <playrho/InvalidArgument.hpp>
#include <playrho/Real.hpp>
#include <playrho/Templates.hpp>
Include dependency graph for Vector.hpp:
This graph shows which files directly or indirectly include this file:

Classes

struct  playrho::detail::IsVector< T >
 Trait class for checking if type is a Vector type. More...
 
struct  playrho::detail::IsVector< Vector< T, N > >
 Trait class specialization for checking if type is a Vector type.. More...
 
class  std::tuple_element< I, playrho::Vector< T, N > >
 Tuple element type info for playrho::Vector More...
 
class  std::tuple_size< playrho::Vector< T, N > >
 Tuple size info for playrho::Vector More...
 
struct  playrho::Vector< T, N >
 Vector. More...
 

Namespaces

 playrho
 
 playrho::detail
 

Functions

template<typename T , std::size_t N>
constexpr auto playrho::abs (const Vector< T, N > &v) noexcept -> decltype(abs(T{}), Vector< T, N >{})
 Absolute value function for vectors.
 
template<std::size_t I, std::size_t N, typename T >
constexpr auto playrho::get (const Vector< T, N > &v) noexcept
 Gets the specified element of the given collection.
 
template<std::size_t I, std::size_t N, typename T >
constexpr auto & playrho::get (Vector< T, N > &v) noexcept
 Gets the specified element of the given collection.
 
template<typename T , std::size_t N>
constexpr auto playrho::GetX (const Vector< T, N > &value) -> decltype(get< 0 >(value))
 Gets the "X" element of the given value - i.e. the first element.
 
template<typename T , std::size_t N>
constexpr auto playrho::GetX (Vector< T, N > &value) -> decltype(get< 0 >(value))
 Gets the "X" element of the given value - i.e. the first element.
 
template<typename T , std::size_t N>
constexpr auto playrho::GetY (const Vector< T, N > &value) -> decltype(get< 1 >(value))
 Gets the "Y" element of the given value - i.e. the second element.
 
template<typename T , std::size_t N>
constexpr auto playrho::GetY (Vector< T, N > &value) -> decltype(get< 1 >(value))
 Gets the "Y" element of the given value - i.e. the second element.
 
template<typename T , std::size_t N>
constexpr auto playrho::GetZ (const Vector< T, N > &value) -> decltype(get< 2 >(value))
 Gets the "Z" element of the given value - i.e. the third element.
 
template<typename T , std::size_t N>
constexpr auto playrho::GetZ (Vector< T, N > &value) -> decltype(get< 2 >(value))
 Gets the "Z" element of the given value - i.e. the third element.
 
template<typename T , std::size_t N>
constexpr bool playrho::operator!= (const Vector< T, N > &lhs, const Vector< T, N > &rhs) noexcept
 Inequality operator.
 
template<std::size_t N, typename T1 , typename T2 , typename OT = decltype(T1{} * T2{})>
constexpr std::enable_if_t< IsMultipliableV< T1, T2 > &&!IsVectorV< T1 >, Vector< OT, N > > playrho::operator* (const T1 &s, const Vector< T2, N > &a) noexcept
 Multiplication operator for non-vector times vector. More...
 
template<typename T1 , typename T2 , std::size_t A, std::size_t B, typename OT = decltype(T1{} * T2{})>
constexpr std::enable_if_t< IsMultipliableV< T1, T2 > &&!IsVectorV< T1 >, Vector< OT, B > > playrho::operator* (const Vector< T1, A > &lhs, const Vector< Vector< T2, B >, A > &rhs) noexcept
 Multiplies an A-element vector by a A-by-B vector of vectors. More...
 
template<std::size_t N, typename T1 , typename T2 , typename OT = decltype(T1{} * T2{})>
constexpr std::enable_if_t< IsMultipliableV< T1, T2 > &&!IsVectorV< T2 >, Vector< OT, N > > playrho::operator* (const Vector< T1, N > &a, const T2 &s) noexcept
 Multiplication operator for vector times non-vector. More...
 
template<typename T1 , typename T2 , std::size_t A, std::size_t B, typename OT = decltype(T1{} * T2{})>
constexpr std::enable_if_t< IsMultipliableV< T1, T2 > &&!IsVectorV< T2 >, Vector< OT, B > > playrho::operator* (const Vector< Vector< T1, A >, B > &lhs, const Vector< T2, A > &rhs) noexcept
 Multiplies a B-by-A vector of vectors by an A-element vector. More...
 
template<typename T1 , typename T2 , std::size_t A, std::size_t B, std::size_t C, typename OT = decltype(T1{} * T2{})>
constexpr std::enable_if_t< IsMultipliableV< T1, T2 >, Vector< Vector< OT, C >, A > > playrho::operator* (const Vector< Vector< T1, B >, A > &lhs, const Vector< Vector< T2, C >, B > &rhs) noexcept
 Calculates the matrix product of the two given vector of vectors (matrices). More...
 
template<typename T1 , typename T2 , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T1, decltype(T1{} *T2{})>, Vector< T1, N > & > playrho::operator*= (Vector< T1, N > &lhs, const T2 rhs) noexcept
 Multiplication assignment operator.
 
template<typename T , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T, decltype(T{}+T{})>, Vector< T, N > > playrho::operator+ (Vector< T, N > lhs, const Vector< T, N > rhs) noexcept
 Adds two vectors component-wise.
 
template<typename T , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T, decltype(+T{})>, Vector< T, N > > playrho::operator+ (Vector< T, N > v) noexcept
 Unary plus operator.
 
template<typename T , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T, decltype(T{}+T{})>, Vector< T, N > & > playrho::operator+= (Vector< T, N > &lhs, const Vector< T, N > rhs) noexcept
 Increments the left hand side value by the right hand side value.
 
template<typename T , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T, decltype(T{} - T{})>, Vector< T, N > > playrho::operator- (Vector< T, N > lhs, const Vector< T, N > rhs) noexcept
 Subtracts two vectors component-wise.
 
template<typename T , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T, decltype(-T{})>, Vector< T, N > > playrho::operator- (Vector< T, N > v) noexcept
 Unary negation operator.
 
template<typename T , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T, decltype(T{} - T{})>, Vector< T, N > & > playrho::operator-= (Vector< T, N > &lhs, const Vector< T, N > rhs) noexcept
 Decrements the left hand side value by the right hand side value.
 
template<std::size_t N, typename T1 , typename T2 , typename OT = decltype(T1{} / T2{})>
constexpr std::enable_if_t< IsDivisableV< T1, T2 > &&!IsVectorV< T2 >, Vector< OT, N > > playrho::operator/ (const Vector< T1, N > &a, const T2 &s) noexcept
 Division operator.
 
template<typename T1 , typename T2 , std::size_t N>
constexpr std::enable_if_t< std::is_same_v< T1, decltype(T1{}/T2{})>, Vector< T1, N > & > playrho::operator/= (Vector< T1, N > &lhs, const T2 rhs) noexcept
 Division assignment operator.
 
template<std::size_t N0, class T0 , std::size_t N1, class T1 >
constexpr bool playrho::operator< (const Vector< T0, N0 > &lhs, const Vector< T1, N1 > &rhs) noexcept
 Less than operator. More...
 
template<typename T , std::size_t N>
::std::ostream & playrho::operator<< (::std::ostream &os, const Vector< T, N > &value)
 Output stream operator.
 
template<typename T , std::size_t N>
constexpr bool playrho::operator== (const Vector< T, N > &lhs, const Vector< T, N > &rhs) noexcept
 Equality operator.
 

Variables

template<class T >
constexpr bool playrho::IsVectorV = detail::IsVector<T>::value
 Determines whether the given type is a Vector type.
 

Detailed Description

Definition of the Vector class template and closely related code.