Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::details::VecBase< T, N > Struct Template Reference

CRTP base class for vectors. More...

#include <VecBase.hpp>

Inheritance diagram for rtp::details::VecBase< T, N >:
Collaboration diagram for rtp::details::VecBase< T, N >:

Public Types

using RealT = std::conditional_t< std::is_integral_v< T >, double, T >
 

Public Member Functions

template<typename Self >
constexpr auto squaredDistance (this const Self &self, const std::remove_cvref_t< Self > &other) noexcept -> T
 
template<typename Self >
constexpr auto distance (this const Self &self, const std::remove_cvref_t< Self > &other) noexcept -> RealT
 
template<typename Self >
constexpr auto squaredLength (this const Self &self) noexcept -> T
 
template<typename Self >
constexpr auto length (this const Self &self) noexcept -> RealT
 
template<typename Self >
requires std::floating_point<T>
constexpr auto normalize (this Self &self) noexcept -> Self &
 
template<typename Self >
requires std::floating_point<T>
constexpr auto normalized (this const Self &self) noexcept -> std::remove_cvref_t< Self >
 
template<typename Self >
constexpr auto dot (this const Self &self, const std::remove_cvref_t< Self > &other) noexcept -> T
 
template<typename Self >
requires std::floating_point<T>
constexpr auto project (this const Self &self, const std::remove_cvref_t< Self > &other) noexcept -> std::remove_cvref_t< Self >
 
template<typename Self >
constexpr auto & operator+= (this Self &self, const std::remove_cvref_t< Self > &other) noexcept
 
template<typename Self >
constexpr auto & operator-= (this Self &self, const std::remove_cvref_t< Self > &other) noexcept
 
template<typename Self >
constexpr auto & operator*= (this Self &self, const std::remove_cvref_t< Self > &other) noexcept
 
template<typename Self >
constexpr auto & operator/= (this Self &self, const std::remove_cvref_t< Self > &other) noexcept
 
template<typename Self >
constexpr auto & operator+= (this Self &self, T scalar) noexcept
 
template<typename Self >
constexpr auto & operator-= (this Self &self, T scalar) noexcept
 
template<typename Self >
constexpr auto & operator*= (this Self &self, T scalar) noexcept
 
template<typename Self >
constexpr auto & operator/= (this Self &self, T scalar) noexcept
 

Friends

template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator+ (ConcreteVec lhs, const ConcreteVec &rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- (ConcreteVec lhs, const ConcreteVec &rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator* (ConcreteVec lhs, const ConcreteVec &rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator/ (ConcreteVec lhs, const ConcreteVec &rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator+ (ConcreteVec lhs, T scalar) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- (ConcreteVec lhs, T scalar) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator* (ConcreteVec lhs, T scalar) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator/ (ConcreteVec lhs, T scalar) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator+ (T scalar, ConcreteVec rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator* (T scalar, ConcreteVec rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- (T scalar, ConcreteVec rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator/ (T scalar, const ConcreteVec &rhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- (ConcreteVec lhs) noexcept -> ConcreteVec
 
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
std::ostream & operator<< (std::ostream &os, const ConcreteVec &v)
 

Detailed Description

template<Numeric T, std::size_t N>
struct rtp::details::VecBase< T, N >

CRTP base class for vectors.

Template Parameters
TNumeric type of the vector components
NDimension of the vector

Provides common functionality for vectors of various dimensions using the Curiously Recurring Template Pattern (CRTP). Enables code reuse and static polymorphism for vector operations.

Definition at line 60 of file VecBase.hpp.

Member Typedef Documentation

◆ RealT

template<Numeric T, std::size_t N>
using rtp::details::VecBase< T, N >::RealT = std::conditional_t<std::is_integral_v<T>, double, T>

Definition at line 61 of file VecBase.hpp.

Member Function Documentation

◆ distance()

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto rtp::details::VecBase< T, N >::distance ( this const Self &  self,
const std::remove_cvref_t< Self > &  other 
) -> RealT
constexprnoexcept

◆ dot()

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto rtp::details::VecBase< T, N >::dot ( this const Self &  self,
const std::remove_cvref_t< Self > &  other 
) -> T
constexprnoexcept

◆ length()

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto rtp::details::VecBase< T, N >::length ( this const Self &  self) -> RealT
constexprnoexcept

◆ normalize()

template<Numeric T, std::size_t N>
template<typename Self >
requires std::floating_point<T>
constexpr auto rtp::details::VecBase< T, N >::normalize ( this Self &  self) -> Self &
constexprnoexcept

◆ normalized()

template<Numeric T, std::size_t N>
template<typename Self >
requires std::floating_point<T>
constexpr auto rtp::details::VecBase< T, N >::normalized ( this const Self &  self) -> std::remove_cvref_t< Self >
constexprnoexcept

◆ operator*=() [1/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator*= ( this Self &  self,
const std::remove_cvref_t< Self > &  other 
)
constexprnoexcept

◆ operator*=() [2/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator*= ( this Self &  self,
scalar 
)
constexprnoexcept

◆ operator+=() [1/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator+= ( this Self &  self,
const std::remove_cvref_t< Self > &  other 
)
constexprnoexcept

◆ operator+=() [2/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator+= ( this Self &  self,
scalar 
)
constexprnoexcept

◆ operator-=() [1/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator-= ( this Self &  self,
const std::remove_cvref_t< Self > &  other 
)
constexprnoexcept

◆ operator-=() [2/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator-= ( this Self &  self,
scalar 
)
constexprnoexcept

◆ operator/=() [1/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator/= ( this Self &  self,
const std::remove_cvref_t< Self > &  other 
)
constexprnoexcept

◆ operator/=() [2/2]

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto & rtp::details::VecBase< T, N >::operator/= ( this Self &  self,
scalar 
)
constexprnoexcept

◆ project()

template<Numeric T, std::size_t N>
template<typename Self >
requires std::floating_point<T>
constexpr auto rtp::details::VecBase< T, N >::project ( this const Self &  self,
const std::remove_cvref_t< Self > &  other 
) -> std::remove_cvref_t< Self >
constexprnoexcept

◆ squaredDistance()

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto rtp::details::VecBase< T, N >::squaredDistance ( this const Self &  self,
const std::remove_cvref_t< Self > &  other 
) -> T
constexprnoexcept

◆ squaredLength()

template<Numeric T, std::size_t N>
template<typename Self >
constexpr auto rtp::details::VecBase< T, N >::squaredLength ( this const Self &  self) -> T
constexprnoexcept

Friends And Related Symbol Documentation

◆ operator* [1/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator* ( ConcreteVec  lhs,
const ConcreteVec &  rhs 
) -> ConcreteVec
friend

Definition at line 171 of file VecBase.hpp.

◆ operator* [2/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator* ( ConcreteVec  lhs,
scalar 
) -> ConcreteVec
friend

Definition at line 217 of file VecBase.hpp.

◆ operator* [3/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator* ( scalar,
ConcreteVec  rhs 
) -> ConcreteVec
friend

Definition at line 251 of file VecBase.hpp.

◆ operator+ [1/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator+ ( ConcreteVec  lhs,
const ConcreteVec &  rhs 
) -> ConcreteVec
friend

Definition at line 149 of file VecBase.hpp.

◆ operator+ [2/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator+ ( ConcreteVec  lhs,
scalar 
) -> ConcreteVec
friend

Definition at line 197 of file VecBase.hpp.

◆ operator+ [3/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator+ ( scalar,
ConcreteVec  rhs 
) -> ConcreteVec
friend

Definition at line 241 of file VecBase.hpp.

◆ operator- [1/4]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- ( ConcreteVec  lhs) -> ConcreteVec
friend

Definition at line 289 of file VecBase.hpp.

◆ operator- [2/4]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- ( ConcreteVec  lhs,
const ConcreteVec &  rhs 
) -> ConcreteVec
friend

Definition at line 160 of file VecBase.hpp.

◆ operator- [3/4]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- ( ConcreteVec  lhs,
scalar 
) -> ConcreteVec
friend

Definition at line 207 of file VecBase.hpp.

◆ operator- [4/4]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator- ( scalar,
ConcreteVec  rhs 
) -> ConcreteVec
friend

Definition at line 261 of file VecBase.hpp.

◆ operator/ [1/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator/ ( ConcreteVec  lhs,
const ConcreteVec &  rhs 
) -> ConcreteVec
friend

Definition at line 182 of file VecBase.hpp.

◆ operator/ [2/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator/ ( ConcreteVec  lhs,
scalar 
) -> ConcreteVec
friend

Definition at line 227 of file VecBase.hpp.

◆ operator/ [3/3]

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
constexpr auto operator/ ( scalar,
const ConcreteVec &  rhs 
) -> ConcreteVec
friend

Definition at line 272 of file VecBase.hpp.

◆ operator<<

template<Numeric T, std::size_t N>
template<typename ConcreteVec >
requires std::derived_from<ConcreteVec, VecBase>
std::ostream & operator<< ( std::ostream &  os,
const ConcreteVec &  v 
)
friend

Definition at line 303 of file VecBase.hpp.


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