mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 11:54:27 +02:00
More constraints added for Dimension and Unit concepts
This commit is contained in:
@@ -39,5 +39,10 @@ namespace mp {
|
|||||||
static_cast<To>(f());
|
static_cast<To>(f());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class Derived, class Base>
|
||||||
|
concept bool DerivedFrom =
|
||||||
|
std::is_base_of_v<Base, Derived> &&
|
||||||
|
std::is_convertible_v<const volatile Derived*, const volatile Base*>;
|
||||||
|
|
||||||
} // namespace std_concepts
|
} // namespace std_concepts
|
||||||
} // namespace mp
|
} // namespace mp
|
||||||
|
@@ -101,7 +101,10 @@ namespace units {
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept bool Dimension = detail::is_dimension<typename T::type>;
|
concept bool Dimension =
|
||||||
|
std::is_empty_v<T> &&
|
||||||
|
detail::is_dimension<typename T::type> &&
|
||||||
|
DerivedFrom<T, typename T::type>;
|
||||||
|
|
||||||
|
|
||||||
// dim_invert
|
// dim_invert
|
||||||
|
@@ -47,7 +47,10 @@ namespace units {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept bool Unit = detail::is_unit<typename T::type>;
|
concept bool Unit =
|
||||||
|
std::is_empty_v<T> &&
|
||||||
|
detail::is_unit<typename T::type> &&
|
||||||
|
DerivedFrom<T, typename T::type>;
|
||||||
|
|
||||||
// dimension_traits
|
// dimension_traits
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user