Made quantity_cast more versatile
- One can now change the unit type without changing the representation type. - One can now change the representation type without changing the unit type. - Had to implement std::common_type<my_value, my_value> to still compile integration tests. (It implicitly converted to another representation before.)
This commit is contained in:
1 parent
952b19c2ed
commit
dc85dd84b9
2 files changed
+15
-1
No files matched your search
@@ -135,11 +135,21 @@ namespace units {
|
||||
return cast::cast(q);
|
||||
}
|
||||
|
||||
template<Unit ToU, Scalar ToRep = double, typename U, typename Rep>
|
||||
template<Unit ToU, Scalar ToRep, typename U, typename Rep>
|
||||
constexpr quantity<ToU, ToRep> quantity_cast(const quantity<U, Rep>& q)
|
||||
{
|
||||
return quantity_cast<quantity<ToU, ToRep>>(q);
|
||||
}
|
||||
template<Unit ToU, typename U, typename Rep>
|
||||
constexpr quantity<ToU, Rep> quantity_cast(const quantity<U, Rep>& q)
|
||||
{
|
||||
return quantity_cast<quantity<ToU, Rep>>(q);
|
||||
}
|
||||
template<Scalar ToRep, typename U, typename Rep>
|
||||
constexpr quantity<U, ToRep> quantity_cast(const quantity<U, Rep>& q)
|
||||
{
|
||||
return quantity_cast<quantity<U, ToRep>>(q);
|
||||
}
|
||||
|
||||
|
||||
// quantity_values
|
||||
|
||||
Reference in new issue
Block a user