Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
Classes | Namespaces | Functions | Variables
Quantity.hpp File Reference
#include "Dimension.hpp"
#include "Unit.hpp"
#include "Phyth/System/UnitsRegistry.hpp"
#include "Phyth/System/Config.hpp"
#include <sstream>
#include <type_traits>
Include dependency graph for Quantity.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Phyth::Quantity< UnitT >
 Physical quantity with a value and a compile-time unit. More...
 
struct  Phyth::is_quantity< typename >
 Trait: check if a type is a Quantity instantiation. More...
 
struct  Phyth::is_quantity< Quantity< UnitT > >
 
struct  common_type_impl< U1, U2, std::enable_if_t< Phyth::is_unit_v< U1 > &&Phyth::is_unit_v< U2 > > >
 
struct  common_type_impl< U1, U2, void >
 
struct  std::common_type< Phyth::Quantity< U1 >, Phyth::Quantity< U2 > >
 

Namespaces

namespace  Phyth
 

Functions

template<typename U1 , typename U2 >
constexpr bool Phyth::operator== (Quantity< U1 > a, Quantity< U2 > b)
 Equality comparison between two quantities.
 
template<typename U1 , typename U2 >
constexpr bool Phyth::operator!= (Quantity< U1 > a, Quantity< U2 > b)
 Inequality comparison between two quantities.
 
template<typename U1 , typename U2 >
constexpr bool Phyth::operator< (Quantity< U1 > a, Quantity< U2 > b)
 Less-than comparison between two quantities.
 
template<typename U1 , typename U2 >
constexpr bool Phyth::operator> (Quantity< U1 > a, Quantity< U2 > b)
 Greater-than comparison between two quantities.
 
template<typename U1 , typename U2 >
constexpr bool Phyth::operator<= (Quantity< U1 > a, Quantity< U2 > b)
 Less-than-or-equal comparison between two quantities.
 
template<typename U1 , typename U2 >
constexpr bool Phyth::operator>= (Quantity< U1 > a, Quantity< U2 > b)
 Greater-than-or-equal comparison between two quantities.
 
template<typename UnitT >
constexpr bool Phyth::operator== (Quantity< UnitT > a, double scalar)
 Equality comparison: dimensionless quantity == scalar.
 
template<typename UnitT >
constexpr bool Phyth::operator== (double scalar, Quantity< UnitT > a)
 Equality comparison: scalar == dimensionless quantity.
 
template<typename UnitT >
constexpr bool Phyth::operator!= (Quantity< UnitT > a, double scalar)
 Inequality comparison: dimensionless quantity != scalar.
 
template<typename UnitT >
constexpr bool Phyth::operator!= (double scalar, Quantity< UnitT > a)
 Inequality comparison: scalar != dimensionless quantity.
 
template<typename UnitT >
constexpr bool Phyth::operator< (Quantity< UnitT > a, double scalar)
 Less-than comparison: dimensionless quantity < scalar.
 
template<typename UnitT >
constexpr bool Phyth::operator< (double scalar, Quantity< UnitT > a)
 Less-than comparison: scalar < dimensionless quantity.
 
template<typename UnitT >
constexpr bool Phyth::operator> (Quantity< UnitT > a, double scalar)
 Greater-than comparison: dimensionless quantity > scalar.
 
template<typename UnitT >
constexpr bool Phyth::operator> (double scalar, Quantity< UnitT > a)
 Greater-than comparison: scalar > dimensionless quantity.
 
template<typename UnitT >
constexpr bool Phyth::operator<= (Quantity< UnitT > a, double scalar)
 Less-than-or-equal comparison: dimensionless quantity <= scalar.
 
template<typename UnitT >
constexpr bool Phyth::operator<= (double scalar, Quantity< UnitT > a)
 Less-than-or-equal comparison: scalar <= dimensionless quantity.
 
template<typename UnitT >
constexpr bool Phyth::operator>= (Quantity< UnitT > a, double scalar)
 Greater-than-or-equal comparison: dimensionless quantity >= scalar.
 
template<typename UnitT >
constexpr bool Phyth::operator>= (double scalar, Quantity< UnitT > a)
 Greater-than-or-equal comparison: scalar >= dimensionless quantity.
 
template<typename U1 , typename U2 >
constexpr auto Phyth::operator+ (Quantity< U1 > a, Quantity< U2 > b)
 Add two quantities of the same dimension.
 
template<typename U1 , typename U2 >
constexpr auto Phyth::operator- (Quantity< U1 > a, Quantity< U2 > b)
 Subtract two quantities of the same dimension.
 
template<typename U1 , typename U2 >
constexpr auto Phyth::operator* (Quantity< U1 > a, Quantity< U2 > b)
 Multiply two quantities.
 
template<typename U1 , typename U2 >
constexpr auto Phyth::operator/ (Quantity< U1 > a, Quantity< U2 > b)
 Divide one quantity by another.
 
template<typename UnitT >
constexpr auto Phyth::operator+ (Quantity< UnitT > a, double scalar)
 Add a dimensionless quantity and a scalar.
 
template<typename UnitT >
constexpr auto Phyth::operator+ (double scalar, Quantity< UnitT > a)
 Add a scalar and a dimensionless quantity (commutative)
 
template<typename UnitT >
constexpr auto Phyth::operator- (Quantity< UnitT > a, double scalar)
 Subtract a scalar from a dimensionless quantity.
 
template<typename UnitT >
constexpr auto Phyth::operator- (double scalar, Quantity< UnitT > a)
 Subtract a dimensionless quantity from a scalar.
 
template<typename UnitT >
constexpr auto Phyth::operator* (Quantity< UnitT > a, double scalar)
 Multiply a quantity by a scalar.
 
template<typename UnitT >
constexpr auto Phyth::operator* (double scalar, Quantity< UnitT > a)
 Multiply a scalar by a quantity (commutative)
 
template<typename UnitT >
constexpr auto Phyth::operator/ (Quantity< UnitT > a, double scalar)
 Divide a quantity by a scalar.
 
template<typename UnitT >
constexpr auto Phyth::operator/ (double scalar, Quantity< UnitT > a)
 Divide a scalar by a quantity, producing an inverse unit.
 
template<typename UnitT >
constexpr auto Phyth::operator- (Quantity< UnitT > a)
 Unary negation.
 
template<typename UnitT >
constexpr auto Phyth::operator+ (Quantity< UnitT > a)
 Unary plus.
 
template<typename UnitT >
std::string Phyth::UnitSymbol ()
 Get the symbol string for a unit type (e.g., "m", "kg", "N")
 
template<typename UnitT >
std::string Phyth::UnitName ()
 Get the full name string for a unit type (e.g., "meter", "kilogram")
 
std::string Phyth::FormatValue (const double value)
 Format a raw numeric value for string output.
 
template<typename UnitT >
std::string Phyth::QuantityToString (const Quantity< UnitT > &q)
 Convert a Quantity to a human-readable string.
 
template<typename UnitT >
std::ostream & Phyth::operator<< (std::ostream &os, const Quantity< UnitT > &q)
 Stream insertion operator for Quantity.
 

Variables

template<typename T >
constexpr bool Phyth::is_quantity_v = is_quantity<T>::value
 Convenience variable template for is_quantity.
 

Class Documentation

◆ common_type_impl< U1, U2, std::enable_if_t< Phyth::is_unit_v< U1 > &&Phyth::is_unit_v< U2 > > >

struct common_type_impl< U1, U2, std::enable_if_t< Phyth::is_unit_v< U1 > &&Phyth::is_unit_v< U2 > > >
template<typename U1, typename U2>
struct common_type_impl< U1, U2, std::enable_if_t< Phyth::is_unit_v< U1 > &&Phyth::is_unit_v< U2 > > >

Definition at line 786 of file Quantity.hpp.

Class Members
typedef Quantity< U1 > type

◆ common_type_impl< U1, U2, void >

struct common_type_impl< U1, U2, void >
template<typename U1, typename U2>
struct common_type_impl< U1, U2, void >

Definition at line 791 of file Quantity.hpp.