Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement aliased quantity types? #502

Open
mpusz opened this issue Oct 15, 2023 · 1 comment
Open

How to implement aliased quantity types? #502

mpusz opened this issue Oct 15, 2023 · 1 comment
Labels
design Design-related discussion question Further information is requested

Comments

@mpusz
Copy link
Owner

mpusz commented Oct 15, 2023

height, depth, altitude are aliases to the same quantity types. Right now, the library implements them as:

inline constexpr struct height : quantity_spec<length> {} height;
inline constexpr auto depth = height;
inline constexpr auto altitude = height;

which means that the user will always see isq::height in the quantity type even when another aliased name was used in the code.

The feature associated with it is the fact that:

static_assert(isq::height / isq::depth == dimensionless);
@mpusz
Copy link
Owner Author

mpusz commented Oct 15, 2023

We could implement those as:

inline constexpr struct height : quantity_spec<length> {} height;
inline constexpr struct depth : decltype(height) {} height;
inline constexpr struct altitude : decltype(height) {} height;

which would preserve the types in a quantity type.

But the below will not result in dimensionless anymore:

static_assert(isq::height / isq::depth != dimensionless);

which may be a good thing?

Ideas? Comments?

@mpusz mpusz added question Further information is requested design Design-related discussion labels Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design-related discussion question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant