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

feat: improve types readability by eliminating extraneous () for a value of a type for prefixes #550

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

mpusz
Copy link
Owner

@mpusz mpusz commented Feb 5, 2024

This PR improves types readability.

-error: could not convert 'speed' from 'quantity<derived_unit<si::kilo_<si::metre()>, per<non_si::hour>>()>'
+error: could not convert 'speed' from 'quantity<derived_unit<si::kilo_<si::metre>, per<non_si::hour>>()>'
       to 'quantity<si::metre()>'
   50 |   std::println("TTG: {:{%N:.6} %U}",
      |                time_to_goal(speed, distance_m));
      |                                      ^~~~~
      |                                      |
-     |                                      quantity<derived_unit<si::kilo_<si::metre()>, per<non_si::hour>>()>
+     |                                      quantity<derived_unit<si::kilo_<si::metre>, per<non_si::hour>>()>
Compiler returned: 1
error: no matching function for call to 'time_to_goal'
   22 | const quantity ttg = time_to_goal(half_marathon_distance, pace);
      |                      ^~~~~~~~~~~~
-note: candidate template ignored: constraints not satisfied [with distance:auto = quantity<kilo_<metre{{}}>{}, double>,
-                                                                  speed:auto = quantity<derived_unit<second, per<kilo_<metre{{}}>>>{}, double>]
+note: candidate template ignored: constraints not satisfied [with distance:auto = quantity<kilo_<metre>{}, double>,
+                                                                  speed:auto = quantity<derived_unit<second, per<kilo_<metre>>>{}, double>]
   12 | QuantityOf<isq::time> auto time_to_goal(QuantityOf<isq::length> auto distance,
      |                            ^
-note: because 'QuantityOf<quantity<derived_unit<si::second, per<si::kilo_<si::metre{{}}>>>{{{}}}>, isq::speed>' evaluated to false
+note: because 'QuantityOf<quantity<derived_unit<si::second, per<si::kilo_<si::metre>>>{{{}}}>, isq::speed>' evaluated to false
   13 |                                         QuantityOf<isq::speed> auto speed)
      |                                         ^
-note: because 'QuantitySpecOf<std::remove_const_t<decltype(get_quantity_spec(derived_unit<second, per<kilo_<metre{{}}>>>{}))>, struct speed{{{}}}>' evaluated to false
+note: because 'QuantitySpecOf<std::remove_const_t<decltype(get_quantity_spec(derived_unit<second, per<kilo_<metre>>>{}))>, struct speed{{{}}}>' evaluated to false
   77 |                    QuantitySpecOf<std::remove_const_t<decltype(get_quantity_spec(T{}))>, V>);
      |                    ^
note: because 'implicitly_convertible(kind_of_<derived_quantity_spec<isq::time, per<isq::length>>{{}, {{}}}>{}, struct speed{{{}}})' evaluated to false
  147 |   QuantitySpec<T> && QuantitySpec<std::remove_const_t<decltype(QS)>> && implicitly_convertible(T{}, QS) &&
      |                                                                         ^
1 error generated.
Compiler returned: 1

Is it worth it?

Copy link
Collaborator

@chiphogg chiphogg left a comment

Choose a reason for hiding this comment

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

A nice bit of polish, tidying up error messages without complicating things for end users. Thanks!

@mpusz mpusz merged commit 26a7b35 into master Feb 13, 2024
91 checks passed
@mpusz mpusz deleted the typed_prefixes branch February 13, 2024 19:45
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.

2 participants