refactor: QuantityValue concept renamed to Representation
This commit is contained in:
1 parent
67b2ad5d05
commit
88e642ec74
97 files changed
+197
-197
No files matched your search
@@ -337,7 +337,7 @@ concept QuantityLike = detail::is_quantity_like<T>;
|
||||
template<typename T>
|
||||
concept QuantityPointLike = detail::is_quantity_point_like<T>;
|
||||
|
||||
// QuantityValue
|
||||
// Representation
|
||||
|
||||
template<typename T, typename U>
|
||||
concept common_type_with_ = // exposition only
|
||||
@@ -397,7 +397,7 @@ concept wrapped_quantity_ = // exposition only
|
||||
* Satisfied by types that satisfy `(!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept QuantityValue =
|
||||
concept Representation =
|
||||
(!Quantity<T>) &&
|
||||
(!QuantityLike<T>) &&
|
||||
(!wrapped_quantity_<T>) &&
|
||||
@@ -413,7 +413,7 @@ template<typename T>
|
||||
typename quantity_like_traits<T>::rep;
|
||||
requires Dimension<typename quantity_like_traits<T>::dimension>;
|
||||
requires Unit<typename quantity_like_traits<T>::unit>;
|
||||
requires QuantityValue<typename quantity_like_traits<T>::rep>;
|
||||
requires Representation<typename quantity_like_traits<T>::rep>;
|
||||
{ quantity_like_traits<T>::number(q) } -> std::convertible_to<typename quantity_like_traits<T>::rep>;
|
||||
}
|
||||
inline constexpr bool is_quantity_like<T> = true;
|
||||
@@ -425,7 +425,7 @@ template<typename T>
|
||||
typename quantity_point_like_traits<T>::rep;
|
||||
requires Dimension<typename quantity_point_like_traits<T>::dimension>;
|
||||
requires Unit<typename quantity_point_like_traits<T>::unit>;
|
||||
requires QuantityValue<typename quantity_point_like_traits<T>::rep>;
|
||||
requires Representation<typename quantity_point_like_traits<T>::rep>;
|
||||
{ quantity_point_like_traits<T>::relative(q) } -> QuantityLike;
|
||||
}
|
||||
inline constexpr bool is_quantity_point_like<T> = true;
|
||||
|
||||
@@ -28,16 +28,16 @@
|
||||
|
||||
namespace units {
|
||||
|
||||
template<Dimension D, UnitOf<D> U, QuantityValue Rep>
|
||||
template<Dimension D, UnitOf<D> U, Representation Rep>
|
||||
class quantity;
|
||||
|
||||
template<Dimension D, UnitOf<D> U, QuantityValue Rep>
|
||||
template<Dimension D, UnitOf<D> U, Representation Rep>
|
||||
class quantity_point;
|
||||
|
||||
template<Kind K, UnitOf<typename K::dimension> U, QuantityValue Rep>
|
||||
template<Kind K, UnitOf<typename K::dimension> U, Representation Rep>
|
||||
class quantity_kind;
|
||||
|
||||
template<PointKind PK, UnitOf<typename PK::dimension> U, QuantityValue Rep>
|
||||
template<PointKind PK, UnitOf<typename PK::dimension> U, Representation Rep>
|
||||
class quantity_point_kind;
|
||||
|
||||
namespace detail {
|
||||
@@ -73,7 +73,7 @@ struct common_quantity_impl<quantity<D1, U1, Rep1>, quantity<D2, U2, Rep2>, Rep>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<Quantity Q1, QuantityEquivalentTo<Q1> Q2, QuantityValue Rep = std::common_type_t<typename Q1::rep, typename Q2::rep>>
|
||||
template<Quantity Q1, QuantityEquivalentTo<Q1> Q2, Representation Rep = std::common_type_t<typename Q1::rep, typename Q2::rep>>
|
||||
using common_quantity = TYPENAME detail::common_quantity_impl<Q1, Q2, Rep>::type;
|
||||
|
||||
template<QuantityPoint QP1, QuantityPointEquivalentTo<QP1> QP2>
|
||||
|
||||
@@ -35,7 +35,7 @@ struct dim_angle : base_dimension<"A", U> {};
|
||||
template<typename T>
|
||||
concept Angle = QuantityOfT<T, dim_angle>;
|
||||
|
||||
template<UnitOf<dim_angle<>> U, QuantityValue Rep = double>
|
||||
template<UnitOf<dim_angle<>> U, Representation Rep = double>
|
||||
using angle = quantity<dim_angle<>, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
@@ -40,7 +40,7 @@ struct dim_one : derived_dimension<dim_one, one> {};
|
||||
template<typename T>
|
||||
concept Dimensionless = QuantityOf<T, dim_one>;
|
||||
|
||||
template<UnitOf<dim_one> U, QuantityValue Rep = double>
|
||||
template<UnitOf<dim_one> U, Representation Rep = double>
|
||||
using dimensionless = quantity<dim_one, U, Rep>;
|
||||
|
||||
} // namespace units
|
||||
@@ -73,11 +73,11 @@ concept safe_castable_to_ = // exposition only
|
||||
template<typename Func, typename T, typename U>
|
||||
concept quantity_value_for_ =
|
||||
std::regular_invocable<Func, T, U> &&
|
||||
QuantityValue<std::invoke_result_t<Func, T, U>>;
|
||||
Representation<std::invoke_result_t<Func, T, U>>;
|
||||
|
||||
template<typename T, typename Func, typename U, typename V>
|
||||
concept invoke_result_convertible_to_ =
|
||||
QuantityValue<T> &&
|
||||
Representation<T> &&
|
||||
quantity_value_for_<Func, U, V> &&
|
||||
safe_convertible_to_<T, std::invoke_result_t<Func, U, V>>;
|
||||
|
||||
@@ -104,7 +104,7 @@ using quantity_like_type = quantity<typename quantity_like_traits<Q>::dimension,
|
||||
* @tparam U a measurement unit of the quantity
|
||||
* @tparam Rep a type to be used to represent values of a quantity
|
||||
*/
|
||||
template<Dimension D, UnitOf<D> U, QuantityValue Rep = double>
|
||||
template<Dimension D, UnitOf<D> U, Representation Rep = double>
|
||||
class quantity {
|
||||
Rep number_;
|
||||
public:
|
||||
@@ -381,8 +381,8 @@ public:
|
||||
};
|
||||
|
||||
// CTAD
|
||||
template<QuantityValue V>
|
||||
explicit(false) quantity(V) -> quantity<dim_one, one, V>;
|
||||
template<Representation Rep>
|
||||
explicit(false) quantity(Rep) -> quantity<dim_one, one, Rep>;
|
||||
|
||||
template<QuantityLike Q>
|
||||
explicit quantity(Q) -> quantity<typename quantity_like_traits<Q>::dimension, typename quantity_like_traits<Q>::unit, typename quantity_like_traits<Q>::rep>;
|
||||
|
||||
@@ -36,16 +36,16 @@
|
||||
|
||||
namespace units {
|
||||
|
||||
template<Dimension D, UnitOf<D> U, QuantityValue Rep>
|
||||
template<Dimension D, UnitOf<D> U, Representation Rep>
|
||||
class quantity;
|
||||
|
||||
template<Dimension D, UnitOf<D> U, QuantityValue Rep>
|
||||
template<Dimension D, UnitOf<D> U, Representation Rep>
|
||||
class quantity_point;
|
||||
|
||||
template<Kind K, UnitOf<typename K::dimension> U, QuantityValue Rep>
|
||||
template<Kind K, UnitOf<typename K::dimension> U, Representation Rep>
|
||||
class quantity_kind;
|
||||
|
||||
template<PointKind PK, UnitOf<typename PK::dimension> U, QuantityValue Rep>
|
||||
template<PointKind PK, UnitOf<typename PK::dimension> U, Representation Rep>
|
||||
class quantity_point_kind;
|
||||
|
||||
namespace detail {
|
||||
@@ -211,7 +211,7 @@ template<Dimension ToD, Unit ToU, typename D, typename U, typename Rep>
|
||||
*
|
||||
* @tparam ToRep a representation type to use for a target quantity
|
||||
*/
|
||||
template<QuantityValue ToRep, typename D, typename U, scalable_with_<ToRep> Rep>
|
||||
template<Representation ToRep, typename D, typename U, scalable_with_<ToRep> Rep>
|
||||
requires std::constructible_from<ToRep, std::common_type_t<ToRep, Rep>>
|
||||
[[nodiscard]] constexpr auto quantity_cast(const quantity<D, U, Rep>& q)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ concept QuantityKindRelatedTo = QuantityKind<QK1> && QuantityKind<QK2> &&
|
||||
* @tparam U the measurement unit of the quantity kind
|
||||
* @tparam Rep the type to be used to represent values of the quantity kind
|
||||
*/
|
||||
template<Kind K, UnitOf<typename K::dimension> U, QuantityValue Rep = double>
|
||||
template<Kind K, UnitOf<typename K::dimension> U, Representation Rep = double>
|
||||
class quantity_kind {
|
||||
public:
|
||||
using kind_type = K;
|
||||
@@ -239,21 +239,21 @@ public:
|
||||
|
||||
// Hidden Friends
|
||||
// Below friend functions are to be found via argument-dependent lookup only
|
||||
template<QuantityValue Value>
|
||||
template<Representation Value>
|
||||
[[nodiscard]] friend constexpr QuantityKind auto operator*(const quantity_kind& qk, const Value& v)
|
||||
requires requires(quantity_type q) { { q * v } -> Quantity; }
|
||||
{
|
||||
return detail::make_quantity_kind<quantity_kind>(qk.common() * v);
|
||||
}
|
||||
|
||||
template<QuantityValue Value>
|
||||
template<Representation Value>
|
||||
[[nodiscard]] friend constexpr QuantityKind auto operator*(const Value& v, const quantity_kind& qk)
|
||||
requires requires(quantity_type q) { { v * q } -> Quantity; }
|
||||
{
|
||||
return detail::make_quantity_kind<quantity_kind>(v * qk.common());
|
||||
}
|
||||
|
||||
template<QuantityValue Value>
|
||||
template<Representation Value>
|
||||
[[nodiscard]] friend constexpr QuantityKind auto operator/(const quantity_kind& qk, const Value& v)
|
||||
requires requires(quantity_type q) { { q / v } -> Quantity; }
|
||||
{
|
||||
@@ -261,7 +261,7 @@ public:
|
||||
return detail::make_quantity_kind<quantity_kind>(qk.common() / v);
|
||||
}
|
||||
|
||||
template<QuantityValue Value>
|
||||
template<Representation Value>
|
||||
[[nodiscard]] friend constexpr QuantityKind auto operator/(const Value& v, const quantity_kind& qk)
|
||||
requires requires(quantity_type q) { { v / q } -> Quantity; }
|
||||
{
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
return detail::downcasted_kind<quantity_kind>(v / qk.common());
|
||||
}
|
||||
|
||||
template<QuantityValue Value>
|
||||
template<Representation Value>
|
||||
[[nodiscard]] friend constexpr QuantityKind auto operator%(const quantity_kind& qk, const Value& v)
|
||||
requires requires(quantity_type q) { q % v; }
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace units {
|
||||
* @tparam U a measurement unit of the quantity point
|
||||
* @tparam Rep a type to be used to represent values of a quantity point
|
||||
*/
|
||||
template<Dimension D, UnitOf<D> U, QuantityValue Rep = double>
|
||||
template<Dimension D, UnitOf<D> U, Representation Rep = double>
|
||||
class quantity_point {
|
||||
public:
|
||||
using quantity_type = quantity<D, U, Rep>;
|
||||
@@ -180,8 +180,8 @@ public:
|
||||
|
||||
};
|
||||
|
||||
template<QuantityValue V>
|
||||
explicit(false) quantity_point(V) -> quantity_point<dim_one, one, V>;
|
||||
template<Representation Rep>
|
||||
explicit(false) quantity_point(Rep) -> quantity_point<dim_one, one, Rep>;
|
||||
|
||||
template<QuantityLike Q>
|
||||
quantity_point(Q) -> quantity_point<typename quantity_like_traits<Q>::dimension,
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace units {
|
||||
* @tparam U the measurement unit of the quantity point kind
|
||||
* @tparam Rep the type to be used to represent values of the quantity point kind
|
||||
*/
|
||||
template<PointKind PK, UnitOf<typename PK::dimension> U, QuantityValue Rep = double>
|
||||
template<PointKind PK, UnitOf<typename PK::dimension> U, Representation Rep = double>
|
||||
class quantity_point_kind {
|
||||
public:
|
||||
using point_kind_type = PK;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace units {
|
||||
|
||||
template<Dimension D, UnitOf<D> U, QuantityValue Rep>
|
||||
template<Dimension D, UnitOf<D> U, Representation Rep>
|
||||
class quantity;
|
||||
|
||||
template<Dimension D, UnitOf<D> U>
|
||||
@@ -102,7 +102,7 @@ struct reference {
|
||||
template<Reference R2>
|
||||
[[nodiscard]] friend constexpr reference_divide<reference, R2> operator/(reference, R2) { return {}; }
|
||||
|
||||
template<QuantityValue Rep>
|
||||
template<Representation Rep>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator*(const Rep& lhs, reference)
|
||||
{
|
||||
return quantity<D, U, Rep>(lhs);
|
||||
|
||||
Reference in new issue
Block a user