mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 13:14:29 +02:00
refactor: one_of
concept removed and replaced with QSProperty
in quantity_spec
This commit is contained in:
@@ -125,9 +125,6 @@ template<typename T>
|
|||||||
requires std::is_object_v<T>
|
requires std::is_object_v<T>
|
||||||
using value_type_t = detail::value_type_impl<T>::type;
|
using value_type_t = detail::value_type_impl<T>::type;
|
||||||
|
|
||||||
template<typename T, typename... Ts>
|
|
||||||
concept one_of = (false || ... || std::same_as<T, Ts>);
|
|
||||||
|
|
||||||
template<typename T, auto... Vs>
|
template<typename T, auto... Vs>
|
||||||
[[nodiscard]] consteval bool contains()
|
[[nodiscard]] consteval bool contains()
|
||||||
{
|
{
|
||||||
|
@@ -180,6 +180,9 @@ struct quantity_spec_interface : quantity_spec_interface_base {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept QSProperty = (!QuantitySpec<T>);
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
MP_UNITS_EXPORT_BEGIN
|
MP_UNITS_EXPORT_BEGIN
|
||||||
@@ -248,12 +251,10 @@ MP_UNITS_EXPORT_END
|
|||||||
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
||||||
*/
|
*/
|
||||||
#if MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::BaseDimension auto Dim, one_of<quantity_character> auto... Args>
|
template<detail::BaseDimension auto Dim, detail::QSProperty auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
|
||||||
struct quantity_spec<Dim, Args...> : detail::quantity_spec_interface {
|
struct quantity_spec<Dim, Args...> : detail::quantity_spec_interface {
|
||||||
#else
|
#else
|
||||||
template<typename Self, detail::BaseDimension auto Dim, one_of<quantity_character> auto... Args>
|
template<typename Self, detail::BaseDimension auto Dim, detail::QSProperty auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
|
||||||
struct quantity_spec<Self, Dim, Args...> : detail::quantity_spec_interface<Self> {
|
struct quantity_spec<Self, Dim, Args...> : detail::quantity_spec_interface<Self> {
|
||||||
#endif
|
#endif
|
||||||
using _base_type_ = quantity_spec;
|
using _base_type_ = quantity_spec;
|
||||||
@@ -292,12 +293,10 @@ struct quantity_spec<Self, Dim, Args...> : detail::quantity_spec_interface<Self>
|
|||||||
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
||||||
*/
|
*/
|
||||||
#if MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::DerivedQuantitySpec auto Eq, one_of<quantity_character> auto... Args>
|
template<detail::DerivedQuantitySpec auto Eq, detail::QSProperty auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
|
||||||
struct quantity_spec<Eq, Args...> : detail::quantity_spec_interface {
|
struct quantity_spec<Eq, Args...> : detail::quantity_spec_interface {
|
||||||
#else
|
#else
|
||||||
template<typename Self, detail::DerivedQuantitySpec auto Eq, one_of<quantity_character> auto... Args>
|
template<typename Self, detail::DerivedQuantitySpec auto Eq, detail::QSProperty auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
|
||||||
struct quantity_spec<Self, Eq, Args...> : detail::quantity_spec_interface<Self> {
|
struct quantity_spec<Self, Eq, Args...> : detail::quantity_spec_interface<Self> {
|
||||||
#endif
|
#endif
|
||||||
using _base_type_ = quantity_spec;
|
using _base_type_ = quantity_spec;
|
||||||
@@ -346,12 +345,10 @@ struct propagate_equation<Q, true> {
|
|||||||
* or `is_kind` in case the quantity starts a new hierarchy tree of a kind
|
* or `is_kind` in case the quantity starts a new hierarchy tree of a kind
|
||||||
*/
|
*/
|
||||||
#if MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::NamedQuantitySpec auto QS, one_of<quantity_character, struct is_kind> auto... Args>
|
template<detail::NamedQuantitySpec auto QS, detail::QSProperty auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
|
||||||
struct quantity_spec<QS, Args...> : detail::propagate_equation<QS>, detail::quantity_spec_interface {
|
struct quantity_spec<QS, Args...> : detail::propagate_equation<QS>, detail::quantity_spec_interface {
|
||||||
#else
|
#else
|
||||||
template<typename Self, detail::NamedQuantitySpec auto QS, one_of<quantity_character, struct is_kind> auto... Args>
|
template<typename Self, detail::NamedQuantitySpec auto QS, detail::QSProperty auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
|
||||||
struct quantity_spec<Self, QS, Args...> : detail::propagate_equation<QS>, detail::quantity_spec_interface<Self> {
|
struct quantity_spec<Self, QS, Args...> : detail::propagate_equation<QS>, detail::quantity_spec_interface<Self> {
|
||||||
#endif
|
#endif
|
||||||
using _base_type_ = quantity_spec;
|
using _base_type_ = quantity_spec;
|
||||||
@@ -407,14 +404,13 @@ struct quantity_spec<Self, QS, Args...> : detail::propagate_equation<QS>, detail
|
|||||||
*/
|
*/
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#if MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::NamedQuantitySpec auto QS, detail::DerivedQuantitySpec auto Eq,
|
template<detail::NamedQuantitySpec auto QS, detail::DerivedQuantitySpec auto Eq, detail::QSProperty auto... Args>
|
||||||
one_of<quantity_character, struct is_kind> auto... Args>
|
requires(detail::QuantitySpecExplicitlyConvertibleTo<Eq, QS>)
|
||||||
requires(detail::QuantitySpecExplicitlyConvertibleTo<Eq, QS>) && (... && !QuantitySpec<decltype(Args)>)
|
|
||||||
struct quantity_spec<QS, Eq, Args...> : detail::quantity_spec_interface {
|
struct quantity_spec<QS, Eq, Args...> : detail::quantity_spec_interface {
|
||||||
#else
|
#else
|
||||||
template<typename Self, detail::NamedQuantitySpec auto QS, detail::DerivedQuantitySpec auto Eq,
|
template<typename Self, detail::NamedQuantitySpec auto QS, detail::DerivedQuantitySpec auto Eq,
|
||||||
one_of<quantity_character, struct is_kind> auto... Args>
|
detail::QSProperty auto... Args>
|
||||||
requires(detail::QuantitySpecExplicitlyConvertibleTo<Eq, QS>) && (... && !QuantitySpec<decltype(Args)>)
|
requires(detail::QuantitySpecExplicitlyConvertibleTo<Eq, QS>)
|
||||||
struct quantity_spec<Self, QS, Eq, Args...> : detail::quantity_spec_interface<Self> {
|
struct quantity_spec<Self, QS, Eq, Args...> : detail::quantity_spec_interface<Self> {
|
||||||
#endif
|
#endif
|
||||||
using _base_type_ = quantity_spec;
|
using _base_type_ = quantity_spec;
|
||||||
|
Reference in New Issue
Block a user