xo-unit: + quantity methods .is_dimensionless(), arith conversion
This commit is contained in:
parent
779e7e0569
commit
cb7bd4d1f2
1 changed files with 9 additions and 1 deletions
|
|
@ -37,7 +37,9 @@ namespace xo {
|
|||
constexpr const repr_type & scale() const { return scale_; }
|
||||
constexpr const unit_type & unit() const { return s_unit; }
|
||||
|
||||
// is_dimensionless
|
||||
constexpr bool is_dimensionless() const {
|
||||
return s_unit.is_dimensionless();
|
||||
}
|
||||
|
||||
// unit_qty
|
||||
// zero_qty
|
||||
|
|
@ -152,6 +154,12 @@ namespace xo {
|
|||
return this->template rescale<Q2::s_unit>().template with_repr<typename Q2::repr_type>();
|
||||
}
|
||||
|
||||
constexpr operator Repr() const
|
||||
requires (NaturalUnit.is_dimensionless())
|
||||
{
|
||||
return scale_;
|
||||
}
|
||||
|
||||
public: /* need public members so that a quantity instance can be a non-type template parameter (is a structural type) */
|
||||
static constexpr natural_unit<ratio_int_type> s_unit = NaturalUnit;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue