-
I have been playing around with mp-units in my project in which I tend to write custom quantity specifications for strongly typed quantities, as in inline constexpr struct horizontal_length final : quantity_spec<isq::length> {} horizontal_length; However, I might need Now // Note that following naming does not follow the convention from mp-units,
// in which identifiers of the custom quantity_spec and corresponding object are the same.
//
// This is due to the elaborated-type-specifier can not be class template (as far as I know),
// so it can not be used, which prevents the type and the object sharing a identifier.
// `_type` suffix is added to the type identifier, as a workaround.
template <QuantitySpec auto WrappedQS>
struct horizontal_quantity_type final : quantity_spec<WrappedQS> {};
template <QuantitySpec auto WrappedQS>
inline constexpr horizontal_quantity_type<WrappedQS> horizontal_quantity;
inline constexpr QuantitySpecOf<isq::length> auto horizontal_length = horizontal_quantity<isq::length>; Now to questions: A) As I'm not 100% confident with the library abstractions, I fear that this technique might be a some sort of anti-pattern and there is nicer way to do this in mp-units. Is this there a another way? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
It's not OK, it's necessary. See #475. |
Beta Was this translation helpful? Give feedback.
-
There are many ways to do it, and you definitely proposed an interesting approach to this subject. As @JohelEGP mentioned, we still have #475 to solve. This issue requires something similar as a solution. However, we initially wanted to solve it the other way around. By this, I mean that we will end up with something like |
Beta Was this translation helpful? Give feedback.
There are many ways to do it, and you definitely proposed an interesting approach to this subject.
As @JohelEGP mentioned, we still have #475 to solve. This issue requires something similar as a solution. However, we initially wanted to solve it the other way around. By this, I mean that we will end up with something like
my_length<horizontal>
rather thanhorizontal<my_length>
. We will have to decide one way or the other when we do more analysis on this in the future (it is planned for the 2.4.0 release).