More constraints added for Dimension and Unit concepts

This commit is contained in:
Mateusz Pusz
2018-11-15 05:27:16 +01:00
parent e866985668
commit db64a3e6a1
3 changed files with 13 additions and 2 deletions

View File

@@ -39,5 +39,10 @@ namespace mp {
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 mp

View File

@@ -101,7 +101,10 @@ namespace units {
} // namespace detail
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

View File

@@ -47,7 +47,10 @@ namespace units {
}
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