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

Default construct rep inside quantity #296

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

chiphogg
Copy link
Contributor

This won't change any actual values when the rep is a fundamental
arithmetic type, but it is more stylistically consistent with the idea
of a "default constructor".

We also update our contract to officially promise that we do this. This
lets us get rid of the scary/threatening language that "we might change
this out from under you!", even though we never had any intention to
actually do so. We retain the encouragement to use au::ZERO, and to
avoid using a default-constructed Quantity for anything other than
future assignment.

Fixes #273.

This won't change any actual values when the rep is a fundamental
arithmetic type, but it is more stylistically consistent with the idea
of a "default constructor".

We also update our contract to officially promise that we do this.  This
lets us get rid of the scary/threatening language that "we might change
this out from under you!", even though we never had any intention to
actually do so.  We retain the encouragement to use `au::ZERO`, and to
avoid using a default-constructed `Quantity` for anything other than
future assignment.

Fixes #273.
Copy link
Contributor

@geoffviola geoffviola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. This feature is a departure from initializing fundamental types in C++. But it seems like the right trade-off in terms of safety and clarity.

@chiphogg chiphogg merged commit 030298c into main Sep 27, 2024
10 checks passed
@chiphogg chiphogg deleted the chiphogg/default-constructor#273 branch September 27, 2024 17:34
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

Successfully merging this pull request may close these issues.

Default constructor and default value
2 participants