xo-unit: refactor: basis_unit2 -> basis_unit
This commit is contained in:
parent
99c5fa5e78
commit
ba38f4e03b
4 changed files with 47 additions and 47 deletions
|
|
@ -13,10 +13,10 @@ namespace xo {
|
|||
*
|
||||
* For example "3600 minutes" or "1e-6 grams"
|
||||
**/
|
||||
struct basis_unit2 {
|
||||
struct basis_unit {
|
||||
public:
|
||||
constexpr basis_unit2() = default;
|
||||
constexpr basis_unit2(dim native_dim, const scalefactor_ratio_type & scalefactor)
|
||||
constexpr basis_unit() = default;
|
||||
constexpr basis_unit(dim native_dim, const scalefactor_ratio_type & scalefactor)
|
||||
: native_dim_{native_dim},
|
||||
scalefactor_{scalefactor}
|
||||
{}
|
||||
|
|
@ -29,7 +29,7 @@ namespace xo {
|
|||
scalefactor_);
|
||||
}
|
||||
|
||||
constexpr basis_unit2 & operator=(const basis_unit2 & x) = default;
|
||||
constexpr basis_unit & operator=(const basis_unit & x) = default;
|
||||
|
||||
/** @brief identifies a native unit, e.g. time (in seconds) **/
|
||||
dim native_dim_ = dim::invalid;
|
||||
|
|
@ -38,11 +38,11 @@ namespace xo {
|
|||
};
|
||||
|
||||
namespace bu2 {
|
||||
constexpr basis_unit2 nanogram = basis_unit2(dim::mass, scalefactor_ratio_type(1, 1000000000));
|
||||
constexpr basis_unit2 microgram = basis_unit2(dim::mass, scalefactor_ratio_type(1, 1000000));
|
||||
constexpr basis_unit2 milligram = basis_unit2(dim::mass, scalefactor_ratio_type(1, 1000));
|
||||
constexpr basis_unit2 gram = basis_unit2(dim::mass, scalefactor_ratio_type(1, 1));
|
||||
constexpr basis_unit2 kilogram = basis_unit2(dim::mass, scalefactor_ratio_type(1000, 1));
|
||||
constexpr basis_unit nanogram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1000000000));
|
||||
constexpr basis_unit microgram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1000000));
|
||||
constexpr basis_unit milligram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1000));
|
||||
constexpr basis_unit gram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1));
|
||||
constexpr basis_unit kilogram = basis_unit(dim::mass, scalefactor_ratio_type(1000, 1));
|
||||
}
|
||||
|
||||
namespace units {
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "xo/indentlog/print/tag.hpp"
|
||||
#include "basis_unit2.hpp"
|
||||
#include "basis_unit.hpp"
|
||||
#include "dim_iostream.hpp"
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -58,25 +58,25 @@ namespace xo {
|
|||
* native_bpu<universal::time, ratio<1>, ratio<-1,2>> represents unit of 1/sqrt(t)
|
||||
**/
|
||||
template<typename Int>
|
||||
struct bpu2 : basis_unit2 {
|
||||
struct bpu2 : basis_unit {
|
||||
public:
|
||||
using ratio_int_type = Int;
|
||||
|
||||
public:
|
||||
constexpr bpu2() = default;
|
||||
constexpr bpu2(const basis_unit2 & bu,
|
||||
constexpr bpu2(const basis_unit & bu,
|
||||
const power_ratio_type & power)
|
||||
: basis_unit2{bu},
|
||||
: basis_unit{bu},
|
||||
power_{power}
|
||||
{}
|
||||
constexpr bpu2(dim native_dim,
|
||||
const scalefactor_ratio_type & scalefactor,
|
||||
const power_ratio_type & power)
|
||||
: basis_unit2(native_dim, scalefactor),
|
||||
: basis_unit(native_dim, scalefactor),
|
||||
power_{power}
|
||||
{}
|
||||
|
||||
static constexpr bpu2<Int> unit_power(const basis_unit2 & bu) {
|
||||
static constexpr bpu2<Int> unit_power(const basis_unit & bu) {
|
||||
return bpu2<Int>(bu, power_ratio_type(1,1));
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ namespace xo {
|
|||
};
|
||||
|
||||
template <typename Int>
|
||||
constexpr auto make_unit_power(const basis_unit2 & bu) {
|
||||
constexpr auto make_unit_power(const basis_unit & bu) {
|
||||
return bpu2<Int>::unit_power(bu);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,14 +77,14 @@ namespace xo {
|
|||
template <dim BasisDim, std::int64_t InnerScaleNum, std::int64_t InnerScaleDen>
|
||||
void bu_establish_abbrev_for() {
|
||||
this->bu_establish_abbrev
|
||||
(basis_unit2(BasisDim,
|
||||
(basis_unit(BasisDim,
|
||||
scalefactor_ratio_type(InnerScaleNum, InnerScaleDen)),
|
||||
units::scaled_native_unit2_abbrev_v<BasisDim, InnerScaleNum, InnerScaleDen>);
|
||||
}
|
||||
|
||||
/** @brief establish abbreviation @p abbrev for basis unit @p bu
|
||||
**/
|
||||
void bu_establish_abbrev(const basis_unit2 & bu,
|
||||
void bu_establish_abbrev(const basis_unit & bu,
|
||||
const basis_unit2_abbrev_type & abbrev) {
|
||||
|
||||
auto & bu_abbrev_v = bu_abbrev_vv_[static_cast<std::size_t>(bu.native_dim())];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue