GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::physics::BaseUnit< D, M > Struct Template Reference

Physical base unit type template. More...

#include <GREM/physics/quantities.hpp>

Public Types

using DimensionType = std::remove_cvref_t<decltype(D)>
 Dimension type of the unit.
using MagnitudeType = std::remove_cvref_t<decltype(M)>
 Magintude type of the unit.

Public Member Functions

template<unit OtherUnitT>
requires (OtherUnitT::DIMENSION == D && OtherUnitT::MagnitudeType::VALUE == MagnitudeType::VALUE && OtherUnitT::MagnitudeType::IS_ABSOLUTE && !MagnitudeType::IS_ABSOLUTE)
consteval operator OtherUnitT () const
 Implicitly convert this unit to another unit, where allowed.
consteval auto operator+ () const
 Get the canonical unit resulting from taking the additive identity of a quantity of this unit.
consteval auto operator- () const
 Get the canonical unit resulting from taking the additive inverse of a quantity of this unit.
template<unit OtherUnitT>
consteval auto operator+ (const OtherUnitT &other) const
 Get the canonical unit resulting from adding a quantity of another unit to a quantity of this unit.
template<unit OtherUnitT>
consteval auto operator- (const OtherUnitT &other) const
 Get the canonical unit resulting from subtracting a quantity of another unit from a quantity of this unit.
template<unit OtherUnitT>
consteval auto operator* (const OtherUnitT &other) const
 Get the canonical unit resulting from multiplying a quantity of this unit with a quantity of another unit.
template<unit OtherUnitT>
consteval auto operator/ (const OtherUnitT &other) const
 Get the canonical unit resulting from dividing a quantity of this unit by a quantity of another unit.

Static Public Member Functions

static constexpr auto getSymbolString ()
 Get an ASCII string representation of the unit symbol of this unit, e.g. "kg m^2/s" if D is ANGULAR_MOMENTUM and M is 1.

Static Public Attributes

static constexpr DimensionType DIMENSION = D
 Dimension of the unit.
static constexpr MagnitudeType MAGNITUDE = M
 Magintude of the unit.

Detailed Description

template<Dimension D, Magnitude M>
struct grem::physics::BaseUnit< D, M >

Physical base unit type template.

Template Parameters
Ddimension of the unit.
Mmagnitude of the unit.

Member Typedef Documentation

◆ DimensionType

template<Dimension D, Magnitude M>
using grem::physics::BaseUnit< D, M >::DimensionType = std::remove_cvref_t<decltype(D)>

Dimension type of the unit.

◆ MagnitudeType

template<Dimension D, Magnitude M>
using grem::physics::BaseUnit< D, M >::MagnitudeType = std::remove_cvref_t<decltype(M)>

Magintude type of the unit.

Member Function Documentation

◆ getSymbolString()

template<Dimension D, Magnitude M>
constexpr auto grem::physics::BaseUnit< D, M >::getSymbolString ( )
inlinestaticnodiscardconstexpr

Get an ASCII string representation of the unit symbol of this unit, e.g. "kg m^2/s" if D is ANGULAR_MOMENTUM and M is 1.

Returns
a String or StringView of the unit symbol string.

◆ operator OtherUnitT()

template<Dimension D, Magnitude M>
template<unit OtherUnitT>
requires (OtherUnitT::DIMENSION == D && OtherUnitT::MagnitudeType::VALUE == MagnitudeType::VALUE && OtherUnitT::MagnitudeType::IS_ABSOLUTE && !MagnitudeType::IS_ABSOLUTE)
grem::physics::BaseUnit< D, M >::operator OtherUnitT ( ) const
inlinenodiscardconsteval

Implicitly convert this unit to another unit, where allowed.

Template Parameters
OtherUnitTunit type to convert to.
Returns
the converted unit.

◆ operator+() [1/2]

template<Dimension D, Magnitude M>
auto grem::physics::BaseUnit< D, M >::operator+ ( ) const
inlinenodiscardconsteval

Get the canonical unit resulting from taking the additive identity of a quantity of this unit.

Returns
the resulting unit.

◆ operator-() [1/2]

template<Dimension D, Magnitude M>
auto grem::physics::BaseUnit< D, M >::operator- ( ) const
inlinenodiscardconsteval

Get the canonical unit resulting from taking the additive inverse of a quantity of this unit.

Returns
the resulting unit.

◆ operator+() [2/2]

template<Dimension D, Magnitude M>
template<unit OtherUnitT>
auto grem::physics::BaseUnit< D, M >::operator+ ( const OtherUnitT & other) const
inlinenodiscardconsteval

Get the canonical unit resulting from adding a quantity of another unit to a quantity of this unit.

Parameters
otherthe unit to add to this one.
Returns
the resulting unit.

◆ operator-() [2/2]

template<Dimension D, Magnitude M>
template<unit OtherUnitT>
auto grem::physics::BaseUnit< D, M >::operator- ( const OtherUnitT & other) const
inlinenodiscardconsteval

Get the canonical unit resulting from subtracting a quantity of another unit from a quantity of this unit.

Parameters
otherthe unit to subtract from this one.
Returns
the resulting unit.

◆ operator*()

template<Dimension D, Magnitude M>
template<unit OtherUnitT>
auto grem::physics::BaseUnit< D, M >::operator* ( const OtherUnitT & other) const
inlinenodiscardconsteval

Get the canonical unit resulting from multiplying a quantity of this unit with a quantity of another unit.

Parameters
otherthe unit to multiply this one with.
Returns
the resulting unit.

◆ operator/()

template<Dimension D, Magnitude M>
template<unit OtherUnitT>
auto grem::physics::BaseUnit< D, M >::operator/ ( const OtherUnitT & other) const
inlinenodiscardconsteval

Get the canonical unit resulting from dividing a quantity of this unit by a quantity of another unit.

Parameters
otherthe unit to divide this one by.
Returns
the resulting unit.

Member Data Documentation

◆ DIMENSION

template<Dimension D, Magnitude M>
DimensionType grem::physics::BaseUnit< D, M >::DIMENSION = D
staticconstexpr

Dimension of the unit.

◆ MAGNITUDE

template<Dimension D, Magnitude M>
MagnitudeType grem::physics::BaseUnit< D, M >::MAGNITUDE = M
staticconstexpr

Magintude of the unit.


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