Merge pull request #15 from jansende/patch-1

Made quantity_cast more versatile
This commit is contained in:
Mateusz Pusz
2019-09-30 08:55:39 +02:00
committed by GitHub
2 changed files with 15 additions and 1 deletions

View File

@@ -135,11 +135,21 @@ namespace units {
return cast::cast(q); 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) constexpr quantity<ToU, ToRep> quantity_cast(const quantity<U, Rep>& q)
{ {
return quantity_cast<quantity<ToU, ToRep>>(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 // quantity_values

View File

@@ -62,6 +62,10 @@ namespace units {
namespace std { namespace std {
template<typename T, typename U>
struct common_type<my_value<T>, my_value<U>> : common_type<T, U> {
};
template<typename T, typename U> template<typename T, typename U>
struct common_type<my_value<T>, U> : common_type<T, U> { struct common_type<my_value<T>, U> : common_type<T, U> {
}; };