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

Structural types #411

Closed
mpusz opened this issue Dec 22, 2022 · 3 comments
Closed

Structural types #411

mpusz opened this issue Dec 22, 2022 · 3 comments

Comments

@mpusz
Copy link
Owner

mpusz commented Dec 22, 2022

Structural types are the types that can be used as NTTPs. quantity and quantity_point do not satisfy a current definition of a structural type as it requires a class to have public data members. This means that we cannot put them in template parameters which could be really handy in some cases.

Should we make a data member public (at least until the C++ language will not extend the definition to allow private members as well)?

@JohelEGP
Copy link
Collaborator

Why not? There's already the number accessor, which essentially makes it public.

@mpusz
Copy link
Owner Author

mpusz commented Dec 22, 2022

A use case where I would like to use it right away is a quantity_point definition:

template<Reference auto R, OriginOffset auto OO = 0, RepresentationOf<R.quantity_spec.character> Rep = double>
class quantity_point;
constexpr auto room_reference_temperature = quantity_point{21 * isq::Celsius_temperature[deg_C]};
constexpr auto temperature_controller_delta = 3 * isq::Celsius_temperature[deg_C];

constexpr quantity_point<isq::Celsius_temperature[deg_C], room_reference_temperature> room_default{0};
constexpr quantity_point<isq::Celsius_temperature[deg_C], room_reference_temperature> room_low = room_default - temperature_controller_delta;
constexpr quantity_point<isq::Celsius_temperature[deg_C], room_reference_temperature> room_high = room_default + temperature_controller_delta;

BTW, I hate ISO 80000 for specifying separate quantities for thermodynamic_temperature and Celsius_temperature...

@mpusz
Copy link
Owner Author

mpusz commented Dec 22, 2022

Why not? There's already the number accessor, which essentially makes it public.

You are right! And actually, you highlighted a new issue #412.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants