Go to the source code of this file.
|
| #define | PHYTH_CONCAT_IMPL(a, b) a##b |
| |
| #define | PHYTH_CONCAT(a, b) PHYTH_CONCAT_IMPL(a, b) |
| |
| #define | PHYTH_DEFINE_UNIT(dim_type, unit_type, suffix, scale_num, scale_den) |
| | Define a unit, literal operator, and registry entry.
|
| |
| #define | PHYTH_DEFINE_UNIT_WITH_NAME(dim_type, unit_type, suffix, scale_num, scale_den, symbol) |
| | Same as DEFINE_UNIT with custom display symbol.
|
| |
| #define | PHYTH_DEFINE_UNIT_WITH_TAG(dim_type, unit_type, suffix, scale_num, scale_den, symbol, tag) |
| | Define a unit with a tag type for type-safe differentiation.
|
| |
◆ Phyth::RadianTag
◆ Phyth::DegreeTag
◆ Phyth::NewtonMeterTag
| struct Phyth::NewtonMeterTag |
◆ Phyth::VoltagePerMeterTag
| struct Phyth::VoltagePerMeterTag |
◆ Phyth::DegreePerSecondTag
| struct Phyth::DegreePerSecondTag |
◆ PHYTH_CONCAT
◆ PHYTH_CONCAT_IMPL
| #define PHYTH_CONCAT_IMPL |
( |
|
a, |
|
|
|
b |
|
) |
| a##b |
◆ PHYTH_DEFINE_UNIT
| #define PHYTH_DEFINE_UNIT |
( |
|
dim_type, |
|
|
|
unit_type, |
|
|
|
suffix, |
|
|
|
scale_num, |
|
|
|
scale_den |
|
) |
| |
Value: using unit_type = Unit<dim_type, std::ratio<scale_num, scale_den>>; \
\
constexpr auto operator""_##suffix(long double x) { \
return Quantity<unit_type>(x); \
} \
\
constexpr auto operator""_##suffix(unsigned long long x) { \
return Quantity<unit_type>(x); \
} \
\
#define PHYTH_CONCAT(a, b)
Static registrar for unit types.
Define a unit, literal operator, and registry entry.
This macro creates:
- A unit type alias (e.g., Meter)
- A literal operator (e.g., 1.0_m)
- A static registrar that registers the unit's name and symbol
- Parameters
-
| dim_type | Dimension type (e.g., Length, Mass) |
| unit_type | Unit type name (e.g., Meter, Kilogram) |
| suffix | Literal suffix (e.g., m, kg) |
| scale_num | Scale numerator relative to base unit |
| scale_den | Scale denominator relative to base unit |
Example: PHYTH_DEFINE_UNIT(Length, Meter, m, 1, 1) // 1.0_m PHYTH_DEFINE_UNIT(Length, Kilometer, km, 1000, 1) // 1.0_km = 1000 m
Definition at line 32 of file Units.hpp.
◆ PHYTH_DEFINE_UNIT_WITH_NAME
| #define PHYTH_DEFINE_UNIT_WITH_NAME |
( |
|
dim_type, |
|
|
|
unit_type, |
|
|
|
suffix, |
|
|
|
scale_num, |
|
|
|
scale_den, |
|
|
|
symbol |
|
) |
| |
Value: using unit_type = Unit<dim_type, std::ratio<scale_num, scale_den>>; \
\
constexpr auto operator""_##suffix(long double x) { \
return Quantity<unit_type>(x); \
} \
\
constexpr auto operator""_##suffix(unsigned long long x) { \
return Quantity<unit_type>(x); \
} \
\
Same as DEFINE_UNIT with custom display symbol.
- Parameters
-
| dim_type | Dimension type |
| unit_type | Unit type name |
| suffix | Literal suffix |
| scale_num | Scale numerator |
| scale_den | Scale denominator |
| symbol | Display symbol (e.g., "m/s", "N/C") |
Example: PHYTH_DEFINE_UNIT_WITH_NAME(Velocity, MeterPerSecond, mps, 1, 1, "m/s")
Definition at line 59 of file Units.hpp.
◆ PHYTH_DEFINE_UNIT_WITH_TAG
| #define PHYTH_DEFINE_UNIT_WITH_TAG |
( |
|
dim_type, |
|
|
|
unit_type, |
|
|
|
suffix, |
|
|
|
scale_num, |
|
|
|
scale_den, |
|
|
|
symbol, |
|
|
|
tag |
|
) |
| |
Value: using unit_type = Unit<dim_type, std::ratio<scale_num, scale_den>, tag>; \
\
constexpr auto operator""_##suffix(long double x) { \
return Quantity<unit_type>(x); \
} \
\
constexpr auto operator""_##suffix(unsigned long long x) { \
return Quantity<unit_type>(x); \
} \
\
Define a unit with a tag type for type-safe differentiation.
This is used when two units have the same dimension and scale but represent different physical concepts. For example, Radian and Degree are both dimensionless with scale 1, but they are distinct types.
- Parameters
-
| dim_type | Dimension type |
| unit_type | Unit type name |
| suffix | Literal suffix |
| scale_num | Scale numerator |
| scale_den | Scale denominator |
| symbol | Display symbol |
| tag | Tag type for type differentiation |
Definition at line 88 of file Units.hpp.