xo-unit: + .is_natural() method in natural_unit, scaled_unit

This commit is contained in:
Roland Conybeare 2024-05-07 13:37:44 -04:00
commit 1a2023a9a2
3 changed files with 8 additions and 1 deletions

View file

@ -70,6 +70,9 @@ namespace xo {
return detail::nu_maker<Int>::make_nu(bpu<Int>(bu, power));
}
/** always true. @see scaled_unit::is_natural **/
constexpr bool is_natural() const { return true; }
constexpr std::size_t n_bpu() const { return n_bpu_; }
constexpr bool is_dimensionless() const { return n_bpu_ == 0; }

View file

@ -32,6 +32,7 @@ namespace xo {
template <
auto NaturalUnit,
typename Repr = double>
requires (NaturalUnit.is_natural())
class quantity {
public:
/** @defgroup quantity-type-traits quantity type traits **/

View file

@ -29,7 +29,10 @@ namespace xo {
1.0 / outer_scale_sq_);
}
/** @brief true iff scaled unit can be faithfully represented by a @ref natural_unit **/
/** @brief true iff scaled unit can be faithfully represented by a @ref natural_unit
*
* @see natural_unit::is_natural
**/
constexpr bool is_natural() const {
return (outer_scale_factor_ == OuterScale(1) && (outer_scale_sq_ == 1.0));
}