From fbe384a4761ebce8679a9994aec392e554669caa Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 4 Oct 2024 14:55:59 +0200 Subject: [PATCH] feat: TagType concept added --- src/core/include/mp-units/ext/type_traits.h | 7 +++++++ src/core/include/mp-units/framework/dimension_concepts.h | 2 +- .../include/mp-units/framework/quantity_point_concepts.h | 2 +- .../include/mp-units/framework/quantity_spec_concepts.h | 3 +-- src/core/include/mp-units/framework/unit_concepts.h | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/include/mp-units/ext/type_traits.h b/src/core/include/mp-units/ext/type_traits.h index 74a14139..965444f5 100644 --- a/src/core/include/mp-units/ext/type_traits.h +++ b/src/core/include/mp-units/ext/type_traits.h @@ -207,4 +207,11 @@ template typename T, typename T1, typename T2, typename... Ts> return get(); } +namespace detail { + +template +concept TagType = std::is_empty_v && std::is_final_v; + +} + } // namespace mp_units diff --git a/src/core/include/mp-units/framework/dimension_concepts.h b/src/core/include/mp-units/framework/dimension_concepts.h index ee2d7d9c..60539ee5 100644 --- a/src/core/include/mp-units/framework/dimension_concepts.h +++ b/src/core/include/mp-units/framework/dimension_concepts.h @@ -42,7 +42,7 @@ struct dimension_interface; * Satisfied by all dimension types in the library. */ MP_UNITS_EXPORT template -concept Dimension = std::derived_from && std::is_empty_v && std::is_final_v; +concept Dimension = detail::TagType && std::derived_from; MP_UNITS_EXPORT template struct base_dimension; diff --git a/src/core/include/mp-units/framework/quantity_point_concepts.h b/src/core/include/mp-units/framework/quantity_point_concepts.h index 4537428f..3e40b7df 100644 --- a/src/core/include/mp-units/framework/quantity_point_concepts.h +++ b/src/core/include/mp-units/framework/quantity_point_concepts.h @@ -65,7 +65,7 @@ struct point_origin_interface; * Satisfied by either quantity points or by all types derived from `absolute_point_origin` class template. */ MP_UNITS_EXPORT template -concept PointOrigin = std::derived_from && std::is_empty_v && std::is_final_v; +concept PointOrigin = detail::TagType && std::derived_from; /** * @brief A concept matching all quantity point origins for a specified quantity type in the library diff --git a/src/core/include/mp-units/framework/quantity_spec_concepts.h b/src/core/include/mp-units/framework/quantity_spec_concepts.h index 8464954b..90792dd9 100644 --- a/src/core/include/mp-units/framework/quantity_spec_concepts.h +++ b/src/core/include/mp-units/framework/quantity_spec_concepts.h @@ -37,8 +37,7 @@ struct quantity_spec_interface_base; } MP_UNITS_EXPORT template -concept QuantitySpec = - std::derived_from && std::is_empty_v && std::is_final_v; +concept QuantitySpec = detail::TagType && std::derived_from; MP_UNITS_EXPORT #if MP_UNITS_API_NO_CRTP diff --git a/src/core/include/mp-units/framework/unit_concepts.h b/src/core/include/mp-units/framework/unit_concepts.h index c0859345..b7379f4b 100644 --- a/src/core/include/mp-units/framework/unit_concepts.h +++ b/src/core/include/mp-units/framework/unit_concepts.h @@ -43,7 +43,7 @@ struct unit_interface; * Satisfied by all unit types provided by the library. */ MP_UNITS_EXPORT template -concept Unit = std::derived_from && std::is_empty_v && std::is_final_v; +concept Unit = detail::TagType && std::derived_from; template requires(M != magnitude<>{} && M != mag<1>)