feat: add floor/ceil/round for quantity_point#811
Conversation
|
In 2.5.0 this worked like a charm, now I have some troubles, I think they come from 982fc52. The cruxial point is, how can I use Lengthy compiler errors``` In file included from ../../src/core/include/mp-units/math.h:29, from ../../test/runtime/math_test.cpp:34: ../../src/core/include/mp-units/framework/quantity_point.h: In instantiation of ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’: ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../test/runtime/math_test.cpp:406:7: in ‘constexpr’ expansion of ‘mp_units::floor(), si::ice_point(), int>(mp_units::point()>.mp_units::point_ >::operator()(-125))’ ../../src/core/include/mp-units/framework/quantity_point.h:587:49: error: no matching function for call to ‘mp_units::quantity::quantity()’ 587 | return quantity_type{qp - point_origin}; | ^ ../../src/core/include/mp-units/framework/quantity_point.h:587:49: note: there are 12 candidates In file included from ../../test/runtime/almost_equals.h:30, from ../../test/runtime/math_test.cpp:23: ../../src/core/include/mp-units/framework/quantity.h:553:85: note: candidate 1: ‘template requires (QuantityLike) && (QuantityConstructibleFrom, mp_units::quantity::reference, typename mp_units::quantity_like_traits::rep> >) constexpr mp_units::quantity::quantity(const Q&) [with auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); Rep = int]’ 553 | !std::convertible_to, quantity>) quantity(const Q& q) : | ^~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:553:85: note: template argument deduction/substitution failed: ../../src/core/include/mp-units/framework/quantity.h:553:85: note: constraints not satisfied In file included from ../../src/core/include/mp-units/bits/sudo_cast.h:26, from ../../src/core/include/mp-units/framework/quantity.h:28: ../../src/core/include/mp-units/framework/quantity_concepts.h: In substitution of ‘template requires (QuantityLike) && (QuantityConstructibleFrom, mp_units::quantity::reference, typename mp_units::quantity_like_traits::rep> >) constexpr mp_units::quantity::quantity(const Q&) [with Q = mp_units::quantity, mp_units::si::milli_ >(), int>]’: ../../src/core/include/mp-units/framework/quantity_point.h:587:49: required from ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’ 587 | return quantity_type{qp - point_origin}; | ^ ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../src/core/include/mp-units/framework/quantity_concepts.h:86:9: required for the satisfaction of ‘QuantityLike’ [with Q = mp_units::quantity, mp_units::si::milli_ >{}, int>] ../../src/core/include/mp-units/framework/quantity_concepts.h:86:24: note: the expression ‘!(Quantity) [with T = mp_units::quantity, mp_units::si::milli_ >{}, int>]’ evaluated to ‘false’ 86 | concept QuantityLike = !Quantity && detail::QuantityLikeImpl && requires { | ^~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity_point.h: In instantiation of ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’: ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../src/core/include/mp-units/framework/quantity.h:544:5: note: candidate 2: ‘template requires (QuantityConstructibleFrom, mp_units::quantity >) && !equivalent(mp_units::quantity::unit, get_unit(R2)) constexpr mp_units::quantity::quantity(const mp_units::quantity&) [with auto R2 = R2; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); Rep = int]’ 544 | quantity(const quantity& q) : | ^~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:544:5: note: template argument deduction/substitution failed: ../../src/core/include/mp-units/framework/quantity.h:544:5: note: constraints not satisfied ../../src/core/include/mp-units/framework/quantity_point.h: In substitution of ‘template requires (QuantityConstructibleFrom, mp_units::quantity >) && !equivalent(mp_units::quantity::unit, get_unit(R2)) constexpr mp_units::quantity::quantity(const mp_units::quantity&) [with auto R2 = mp_units::common_unit, mp_units::si::milli_ >(); Rep2 = int]’: ../../src/core/include/mp-units/framework/quantity_point.h:587:49: required from ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’ 587 | return quantity_type{qp - point_origin}; | ^ ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../test/runtime/math_test.cpp:406:7: in ‘constexpr’ expansion of ‘mp_units::floor(), si::ice_point(), int>(mp_units::point()>.mp_units::point_ >::operator()(-125))’ ../../src/core/include/mp-units/framework/quantity.h:99:9: required for the satisfaction of ‘ImplicitConversion’ [with QFrom = mp_units::quantity, mp_units::si::milli_ >{}, int>; QTo = mp_units::quantity] ../../src/core/include/mp-units/framework/quantity.h:105:9: required for the satisfaction of ‘QuantityConstructibleFrom, mp_units::quantity >’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int; R2 = mp_units::common_unit, mp_units::si::milli_ >{}; Rep2 = int] ../../src/core/include/mp-units/framework/quantity.h:100:95: note: no operand of the disjunction is satisfied 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:100:41: note: the operand ‘implicitly_scalable’ is unsatisfied because 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:99:9: required for the satisfaction of ‘ImplicitConversion’ [with QFrom = mp_units::quantity, mp_units::si::milli_ >{}, int>; QTo = mp_units::quantity] ../../src/core/include/mp-units/framework/quantity.h:105:9: required for the satisfaction of ‘QuantityConstructibleFrom, mp_units::quantity >’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int; R2 = mp_units::common_unit, mp_units::si::milli_ >{}; Rep2 = int] ../../src/core/include/mp-units/framework/quantity.h:100:41: note: the expression ‘implicitly_scalable [with FromUnit = mp_units::quantity, mp_units::si::milli_ >{}, int>::unit; FromRep = int; ToUnit = mp_units::quantity::unit; ToRep = int]’ evaluated to ‘false’ 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:101:104: note: the operand ‘unsatisfied<"Conversion from \'{}\' as \'{}\' to \'{}\' as \'{}\' is truncating">(mp_units::unit_symbol(FromUnit), type_name(), mp_units::unit_symbol(ToUnit), type_name())’ is unsatisfied because 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../test/runtime/math_test.cpp:406:7: in ‘constexpr’ expansion of ‘mp_units::floor(), si::ice_point(), int>(mp_units::point()>.mp_units::point_ >::operator()(-125))’ ../../src/core/include/mp-units/framework/quantity.h:99:9: required for the satisfaction of ‘ImplicitConversion’ [with QFrom = mp_units::quantity, mp_units::si::milli_ >{}, int>; QTo = mp_units::quantity] ../../src/core/include/mp-units/framework/quantity.h:105:9: required for the satisfaction of ‘QuantityConstructibleFrom, mp_units::quantity >’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int; R2 = mp_units::common_unit, mp_units::si::milli_ >{}; Rep2 = int] ../../src/core/include/mp-units/framework/quantity.h:101:104: note: the expression ‘(unsatisfied<"Conversion from \'{}\' as \'{}\' to \'{}\' as \'{}\' is truncating">)(mp_units::unit_symbol(FromUnit), (type_name)(), mp_units::unit_symbol(ToUnit), (type_name)()) [with FromUnit = mp_units::quantity, mp_units::si::milli_ >{}, int>::unit; FromRep = int; ToUnit = mp_units::quantity::unit; ToRep = int]’ evaluated to ‘false’ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity_point.h: In instantiation of ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’: ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../src/core/include/mp-units/framework/quantity.h:533:5: note: candidate 3: ‘template requires (QuantityConstructibleFrom, mp_units::quantity >) && equivalent(mp_units::quantity::unit, get_unit(R2)) constexpr mp_units::quantity::quantity(const mp_units::quantity&) [with auto R2 = R2; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); Rep = int]’ 533 | quantity(const quantity& q) : | ^~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:533:5: note: template argument deduction/substitution failed: ../../src/core/include/mp-units/framework/quantity.h:533:5: note: constraints not satisfied ../../src/core/include/mp-units/framework/quantity_point.h: In substitution of ‘template requires (QuantityConstructibleFrom, mp_units::quantity >) && equivalent(mp_units::quantity::unit, get_unit(R2)) constexpr mp_units::quantity::quantity(const mp_units::quantity&) [with auto R2 = mp_units::common_unit, mp_units::si::milli_ >(); Rep2 = int]’: ../../src/core/include/mp-units/framework/quantity_point.h:587:49: required from ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’ 587 | return quantity_type{qp - point_origin}; | ^ ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../test/runtime/math_test.cpp:406:7: in ‘constexpr’ expansion of ‘mp_units::floor(), si::ice_point(), int>(mp_units::point()>.mp_units::point_ >::operator()(-125))’ ../../src/core/include/mp-units/framework/quantity.h:99:9: required for the satisfaction of ‘ImplicitConversion’ [with QFrom = mp_units::quantity, mp_units::si::milli_ >{}, int>; QTo = mp_units::quantity] ../../src/core/include/mp-units/framework/quantity.h:105:9: required for the satisfaction of ‘QuantityConstructibleFrom, mp_units::quantity >’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int; R2 = mp_units::common_unit, mp_units::si::milli_ >{}; Rep2 = int] ../../src/core/include/mp-units/framework/quantity.h:100:95: note: no operand of the disjunction is satisfied 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:100:41: note: the operand ‘implicitly_scalable’ is unsatisfied because 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:99:9: required for the satisfaction of ‘ImplicitConversion’ [with QFrom = mp_units::quantity, mp_units::si::milli_ >{}, int>; QTo = mp_units::quantity] ../../src/core/include/mp-units/framework/quantity.h:105:9: required for the satisfaction of ‘QuantityConstructibleFrom, mp_units::quantity >’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int; R2 = mp_units::common_unit, mp_units::si::milli_ >{}; Rep2 = int] ../../src/core/include/mp-units/framework/quantity.h:100:41: note: the expression ‘implicitly_scalable [with FromUnit = mp_units::quantity, mp_units::si::milli_ >{}, int>::unit; FromRep = int; ToUnit = mp_units::quantity::unit; ToRep = int]’ evaluated to ‘false’ 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:101:104: note: the operand ‘unsatisfied<"Conversion from \'{}\' as \'{}\' to \'{}\' as \'{}\' is truncating">(mp_units::unit_symbol(FromUnit), type_name(), mp_units::unit_symbol(ToUnit), type_name())’ is unsatisfied because 100 | (mp_units::implicitly_scalable || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../test/runtime/math_test.cpp:406:7: in ‘constexpr’ expansion of ‘mp_units::floor(), si::ice_point(), int>(mp_units::point()>.mp_units::point_ >::operator()(-125))’ ../../src/core/include/mp-units/framework/quantity.h:99:9: required for the satisfaction of ‘ImplicitConversion’ [with QFrom = mp_units::quantity, mp_units::si::milli_ >{}, int>; QTo = mp_units::quantity] ../../src/core/include/mp-units/framework/quantity.h:105:9: required for the satisfaction of ‘QuantityConstructibleFrom, mp_units::quantity >’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int; R2 = mp_units::common_unit, mp_units::si::milli_ >{}; Rep2 = int] ../../src/core/include/mp-units/framework/quantity.h:101:104: note: the expression ‘(unsatisfied<"Conversion from \'{}\' as \'{}\' to \'{}\' as \'{}\' is truncating">)(mp_units::unit_symbol(FromUnit), (type_name)(), mp_units::unit_symbol(ToUnit), (type_name)()) [with FromUnit = mp_units::quantity, mp_units::si::milli_ >{}, int>::unit; FromRep = int; ToUnit = mp_units::quantity::unit; ToRep = int]’ evaluated to ‘false’ 101 | unsatisfied<"Conversion from '{}' as '{}' to '{}' as '{}' is truncating">( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 102 | unit_symbol(FromUnit), type_name(), unit_symbol(ToUnit), type_name())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity_point.h: In instantiation of ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’: ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../src/core/include/mp-units/framework/quantity.h:520:87: note: candidate 4: ‘template requires (ExplicitFromNumber::reference>) && !(RepConstructibleFrom) constexpr mp_units::quantity::quantity(Value) [with auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); Rep = int]’ (deleted) 520 | !mp_units::implicitly_convertible(quantity_spec, dimensionless)) quantity(Value val) | ^~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:520:87: note: template argument deduction/substitution failed: ../../src/core/include/mp-units/framework/quantity.h:520:87: note: constraints not satisfied ../../src/core/include/mp-units/framework/quantity.h: In substitution of ‘template requires (ExplicitFromNumber::reference>) && !(RepConstructibleFrom) constexpr mp_units::quantity::quantity(Value) [with Value = mp_units::quantity, mp_units::si::milli_ >(), int>]’: ../../src/core/include/mp-units/framework/quantity_point.h:587:49: required from ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’ 587 | return quantity_type{qp - point_origin}; | ^ ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../test/runtime/math_test.cpp:406:7: in ‘constexpr’ expansion of ‘mp_units::floor(), si::ice_point(), int>(mp_units::point()>.mp_units::point_ >::operator()(-125))’ ../../src/core/include/mp-units/framework/quantity.h:118:9: required for the satisfaction of ‘UnitOne’ [with R = mp_units::quantity::reference] ../../src/core/include/mp-units/framework/quantity.h:122:9: required for the satisfaction of ‘ExplicitFromNumber’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int] ../../src/core/include/mp-units/framework/quantity.h:119:30: note: the expression ‘equivalent(get_unit(R), mp_units::one) [with R = mp_units::quantity::reference]’ evaluated to ‘false’ 119 | (equivalent(get_unit(R), one) && detail::get_associated_quantity(get_unit(R)) == dimensionless); | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity_point.h: In instantiation of ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’: ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../src/core/include/mp-units/framework/quantity.h:513:22: note: candidate 5: ‘template requires (ExplicitFromNumber::reference>) && (RepConstructibleFrom) && !(convertible_to) constexpr mp_units::quantity::quantity(Value) [with auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); Rep = int]’ 513 | constexpr explicit quantity(Value val) : numerical_value_is_an_implementation_detail_(std::move(val)) | ^~~~~~~~ ../../src/core/include/mp-units/framework/quantity.h:513:22: note: template argument deduction/substitution failed: ../../src/core/include/mp-units/framework/quantity.h:513:22: note: constraints not satisfied ../../src/core/include/mp-units/framework/quantity.h: In substitution of ‘template requires (ExplicitFromNumber::reference>) && (RepConstructibleFrom) && !(convertible_to) constexpr mp_units::quantity::quantity(Value) [with Value = mp_units::quantity, mp_units::si::milli_ >(), int>]’: ../../src/core/include/mp-units/framework/quantity_point.h:587:49: required from ‘constexpr mp_units::quantity_point::quantity_point(const QP&) [with QP = mp_units::quantity_point; auto [requires mp_units::Reference<, >] R = mp_units::usc::degree_Fahrenheit(); auto [requires mp_units::PointOriginFor<, get_quantity_spec(R)>] PO = mp_units::si::ice_point(); Rep = int]’ 587 | return quantity_type{qp - point_origin}; | ^ ../../src/core/include/mp-units/math.h:371:12: required from here 371 | return res; | ^~~ ../../test/runtime/math_test.cpp:406:7: in ‘constexpr’ expansion of ‘mp_units::floor(), si::ice_point(), int>(mp_units::point()>.mp_units::point_ >::operator()(-125))’ ../../src/core/include/mp-units/framework/quantity.h:118:9: required for the satisfaction of ‘UnitOne’ [with R = mp_units::quantity::reference] ../../src/core/include/mp-units/framework/quantity.h:122:9: required for the satisfaction of ‘ExplicitFromNumber’ [with R = mp_units::usc::degree_Fahrenheit{}; Rep = int] ../../src/core/include/mp-units/framework/quantity.h:119:30: note: the expression ‘equivalent(get_unit(R), mp_units::one) [with R = mp_units::quantity::reference]’ evaluated to ‘false’ 119 | (equivalent(get_unit(R), one) && detail::get_associated_quantity(get_unit(R)) == dimensionless); | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~ ../../src/core/include/mp-units/framework/quantity_point.h: In instantiation of ‘constexpr mp_units::quantity_point |
|
Btw. which clang-format version do you use? I have used 21, 22, and 23 (current HEAD), and there seems to be a bug, as the round declaration goes beyond the 120 column limit. |
I use the one forced in pre-commit. I tried a newer one but it breaks the formatting of some expressions, so I didn't upgrade. |
@HazardyKnusperkeks, I am not sure what problem you might have. Everything seems to work fine: https://godbolt.org/z/GnzW9W5hq. Can you share your use case? |
0ba622a to
eb0abab
Compare
|
Okay, the problem was solved by using Is there any documentation I should touch, apart from the doxygen comments? |
I try not to use
That is a great question. I basically don't have the math functions reference yet, and I don't think a detailed description of each overload is needed in the User's Guide. However, this chapter could mention that the functions also take quantity points. |
|
I meant the return type of I will try to adapt the documentation a bit on monday. |
|
Can't you do the same I did for quantities ( |
📋 Pull Request Description
We have the math functions for
quantity, but we also want them forquantity_point, this PR adds them.Type of Change
work as expected)
🔗 Related Issues
Closes #807
📝 Changes Made
Added the the overloads and tests.
🌟 Additional Context
✅ Checklist
(if this change affects user-facing features)
By submitting this pull request, I confirm that my contribution is made under the terms
of the project's MIT license.