xo-unit: refactor: xo::unit ns -> xo::qty
This commit is contained in:
parent
67e26a426f
commit
cb5cd1d26f
19 changed files with 61 additions and 87 deletions
|
|
@ -10,7 +10,7 @@
|
|||
#include "unit2.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
/** @class quantity
|
||||
* @brief represent a scalar quantity with attached units. enforce dimensional consistency.
|
||||
*
|
||||
|
|
@ -87,7 +87,7 @@ namespace xo {
|
|||
{
|
||||
return Quantity::multiply(x, y);
|
||||
}
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
template <typename Repr = double,
|
||||
typename Int = std::int64_t>
|
||||
inline std::ostream &
|
||||
|
|
@ -23,7 +23,7 @@ namespace xo {
|
|||
|
||||
return os;
|
||||
}
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end Quantity2_iostream.hpp **/
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <vector>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
using basis_unit2_abbrev_type = flatstring<16>;
|
||||
|
||||
using scalefactor_ratio_type = xo::ratio::ratio<std::int64_t>;
|
||||
|
|
@ -365,7 +365,7 @@ namespace xo {
|
|||
constexpr auto scaled_native_unit2_abbrev_v = scaled_native_unit2_abbrev<BasisDim, InnerScaleNum, InnerScaleDen>::value;
|
||||
}
|
||||
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "native_bpu2.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
/** @class basis_unit2_store
|
||||
* @brief Store known basis units for runtime
|
||||
**/
|
||||
|
|
@ -156,7 +156,7 @@ namespace xo {
|
|||
/* bu_abbrev_v[dim] holds known units for native unit dim */
|
||||
std::vector<native_scale_v> bu_abbrev_vv_;
|
||||
};
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end bpu_store.hpp **/
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & os, dim x) {
|
||||
os << dim2str(x);
|
||||
return os;
|
||||
}
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end dim_iostream.hpp **/
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
enum class dim {
|
||||
invalid = -1,
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ namespace xo {
|
|||
template <dim Dim>
|
||||
constexpr auto native_unit_for_v = native_unit_for<Dim>::value;
|
||||
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end dim_util.hpp */
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "xo/flatstring/flatstring.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
using native_unit2_abbrev_type = flatstring<8>;
|
||||
|
||||
/** @class native_unit2
|
||||
|
|
@ -43,7 +43,7 @@ namespace xo {
|
|||
native_unit2(dim::price, native_unit2_abbrev_type::from_chars("px")),
|
||||
};
|
||||
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include "dim_iostream.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
using bpu2_abbrev_type = flatstring<24>;
|
||||
|
||||
using power_ratio_type = xo::ratio::ratio<std::int64_t>;
|
||||
|
|
@ -126,7 +126,7 @@ namespace xo {
|
|||
flatstring_from_exponent<PowerNum, PowerDen>())));
|
||||
};
|
||||
#endif
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
template <typename Int>
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & os, const bpu2<Int> & x) {
|
||||
|
|
@ -22,7 +22,7 @@ namespace xo {
|
|||
|
||||
return os;
|
||||
}
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <cassert>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
/** @class natural_unit
|
||||
* @brief an array representing the cartesian product of distinct basis-power-units
|
||||
*
|
||||
|
|
@ -223,7 +223,7 @@ namespace xo {
|
|||
constexpr auto nanogram = bpu_array_maker<std::int64_t>::make_bpu_array(make_unit_power<std::int64_t>(bu2::nanogram));
|
||||
constexpr auto microgram = bpu_array_maker<std::int64_t>::make_bpu_array(make_unit_power<std::int64_t>(bu2::microgram));
|
||||
}
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end natural_unit.hpp **/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
template <typename Int>
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & os, const natural_unit<Int> & x) {
|
||||
|
|
@ -22,7 +22,7 @@ namespace xo {
|
|||
os << "]>";
|
||||
return os;
|
||||
}
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end natural_unit_iostream.hpp **/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <concepts>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
/** @concept numeric_concept
|
||||
* @brief Concept for values that participate in arithmetic operations (+,-,*,/) and comparisons
|
||||
*
|
||||
|
|
@ -28,7 +28,7 @@ namespace xo {
|
|||
{ x == y };
|
||||
{ x != y };
|
||||
};
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end numeric_concept.hpp */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "bpu_array.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
/** @class quantity
|
||||
* @brief represent a scalar quantity with attached units. enforce dimensional consistency.
|
||||
*
|
||||
|
|
@ -21,7 +21,7 @@ namespace xo {
|
|||
|
||||
private:
|
||||
};
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "numeric_concept.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
template <typename Quantity>
|
||||
concept quantity2_concept = requires(Quantity qty, typename Quantity::repr_type repr)
|
||||
{
|
||||
|
|
@ -19,5 +19,5 @@ namespace xo {
|
|||
//{ Quantity::promote(repr) } -> std::same_as<Quantity>;
|
||||
} && (true //unit_concept<typename Quantity::unit_type>
|
||||
&& numeric_concept<typename Quantity::repr_type>);
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
//#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
/** @class bpu2_array_rescale_result
|
||||
* @brief Represents the product sqrt(outer_scale_sq) * outer_scale_exact * nat_unit
|
||||
**/
|
||||
|
|
@ -120,7 +120,7 @@ namespace xo {
|
|||
rr.outer_scale_exact_ * x_unit.outer_scale_exact_ * y_unit.outer_scale_exact_,
|
||||
rr.outer_scale_sq_ * x_unit.outer_scale_sq_ * y_unit.outer_scale_sq_));
|
||||
}
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end scaled_unit2.hpp **/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
template <typename Int>
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & os, const scaled_unit2<Int> & x) {
|
||||
|
|
@ -21,7 +21,7 @@ namespace xo {
|
|||
|
||||
return os;
|
||||
};
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end scaled_unit_iostream.hpp **/
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "natural_unit.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace unit {
|
||||
namespace qty {
|
||||
/** @class unit2
|
||||
* @brief represent an arbitrary unit along with dimension details
|
||||
*
|
||||
|
|
@ -18,7 +18,7 @@ namespace xo {
|
|||
**/
|
||||
template <typename Int>
|
||||
using unit2 = natural_unit<Int>;
|
||||
} /*namespace unit*/
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end unit2.hpp **/
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace xo {
|
|||
//using xo::unit::bpu2_abbrev_type;
|
||||
//using xo::unit::abbrev::bpu2_abbrev;
|
||||
//using xo::unit::basis_unit2_store;
|
||||
using xo::unit::power_ratio_type;
|
||||
using xo::qty::power_ratio_type;
|
||||
//using xo::unit::abbrev::flatstring_from_exponent;
|
||||
//using xo::unit::bpu2;
|
||||
//using xo::unit::detail::bpu2_rescale;
|
||||
|
|
|
|||
|
|
@ -23,57 +23,31 @@ namespace xo {
|
|||
|
||||
using xo::reflect::Reflect;
|
||||
|
||||
namespace su2 = xo::unit::su2;
|
||||
namespace su2 = xo::qty::su2;
|
||||
|
||||
using xo::unit::Quantity2;
|
||||
using xo::unit::dim;
|
||||
using xo::unit::basis_unit2_abbrev_type;
|
||||
using xo::unit::native_unit2;
|
||||
using xo::unit::native_unit2_v;
|
||||
using xo::unit::scalefactor_ratio_type;
|
||||
using xo::unit::units::scaled_native_unit2_abbrev;
|
||||
using xo::unit::units::scaled_native_unit2_abbrev_v;
|
||||
using xo::unit::basis_unit2;
|
||||
using xo::unit::abbrev::basis_unit2_abbrev;;
|
||||
using xo::unit::bpu2_abbrev_type;
|
||||
using xo::unit::abbrev::bpu2_abbrev;
|
||||
using xo::unit::basis_unit2_store;
|
||||
using xo::unit::power_ratio_type;
|
||||
using xo::unit::abbrev::flatstring_from_exponent;
|
||||
using xo::unit::bpu2;
|
||||
using xo::unit::detail::bpu2_rescale;
|
||||
using xo::unit::detail::bpu2_product;
|
||||
using xo::unit::natural_unit;
|
||||
using xo::unit::bpu_array_maker;
|
||||
using xo::unit::detail::nu_product;
|
||||
using xo::unit::unit_qty;
|
||||
using xo::qty::Quantity2;
|
||||
using xo::qty::dim;
|
||||
using xo::qty::basis_unit2_abbrev_type;
|
||||
using xo::qty::native_unit2;
|
||||
using xo::qty::native_unit2_v;
|
||||
using xo::qty::scalefactor_ratio_type;
|
||||
using xo::qty::units::scaled_native_unit2_abbrev;
|
||||
using xo::qty::units::scaled_native_unit2_abbrev_v;
|
||||
using xo::qty::basis_unit2;
|
||||
using xo::qty::abbrev::basis_unit2_abbrev;;
|
||||
using xo::qty::bpu2_abbrev_type;
|
||||
using xo::qty::abbrev::bpu2_abbrev;
|
||||
using xo::qty::basis_unit2_store;
|
||||
using xo::qty::power_ratio_type;
|
||||
using xo::qty::abbrev::flatstring_from_exponent;
|
||||
using xo::qty::bpu2;
|
||||
using xo::qty::detail::bpu2_rescale;
|
||||
using xo::qty::detail::bpu2_product;
|
||||
using xo::qty::natural_unit;
|
||||
using xo::qty::bpu_array_maker;
|
||||
using xo::qty::detail::nu_product;
|
||||
using xo::qty::unit_qty;
|
||||
|
||||
//using xo::unit::native_unit_abbrev_v;
|
||||
//using xo::unit::units::scaled_native_unit_abbrev_v;
|
||||
//using xo::unit::native_dim_abbrev;
|
||||
//using xo::unit::stringliteral_compare;
|
||||
//using xo::unit::literal_size_v;
|
||||
//using xo::unit::stringliteral_from_digit;
|
||||
//using xo::unit::stringliteral_from_int_v;
|
||||
//using xo::unit::stringliteral;
|
||||
#ifndef __clang__
|
||||
//using xo::unit::stringliteral_concat;
|
||||
//using xo::unit::stringliteral_from_ratio;
|
||||
//using xo::unit::bpu_assemble_abbrev_helper;
|
||||
//using xo::unit::bpu_assemble_abbrev;
|
||||
#endif
|
||||
//using xo::unit::bpu_node;
|
||||
//using xo::unit::wrap_unit;
|
||||
//using xo::unit::unit_abbrev_v;
|
||||
//using xo::unit::dim_abbrev_v;
|
||||
//using xo::unit::di_cartesian_product;
|
||||
//using xo::unit::di_cartesian_product1;
|
||||
//using xo::unit::unit_cartesian_product_t;
|
||||
//using xo::unit::bpu_cartesian_product;
|
||||
//using xo::unit::bpu_cartesian_product_helper;
|
||||
//using xo::unit::unit_invert_t;
|
||||
//using xo::unit::units::gram;
|
||||
//using xo::unit::units::second;
|
||||
using xo::print::ccs;
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -206,7 +180,7 @@ namespace xo {
|
|||
|
||||
log && log(xtag("price", scaled_native_unit2_abbrev_v<dim::price>));
|
||||
|
||||
REQUIRE(xo::unit::units::scaled_native_unit2_abbrev<dim::mass>::value == xo::flatstring("g"));
|
||||
REQUIRE(xo::qty::units::scaled_native_unit2_abbrev<dim::mass>::value == xo::flatstring("g"));
|
||||
|
||||
/* proof that scaled_native_unit2_abbrev::value is constexpr */
|
||||
static_assert(scaled_native_unit2_abbrev_v<dim::mass>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue