Small code cleanup

This commit is contained in:
Mateusz Pusz
2019-11-16 18:27:31 +01:00
parent 86d4252cca
commit 9c6229302d
4 changed files with 12 additions and 9 deletions

View File

@@ -32,7 +32,7 @@ namespace units {
namespace detail {
template<typename T, typename U = T>
concept basic_arithmetic = // exposition only
concept basic_arithmetic = // exposition only
std::magma<std::ranges::plus, T, U> &&
std::magma<std::ranges::minus, T, U> &&
std::magma<std::ranges::times, T, U> &&

View File

@@ -43,8 +43,8 @@
namespace std {
// concepts
using concepts::common_with;
using concepts::common_reference_with;
using concepts::common_with;
using concepts::constructible_from;
using concepts::convertible_to;
using concepts::default_constructible;

View File

@@ -265,7 +265,7 @@ namespace std {
}
struct times {
template<class T, detail::multiplicable_with <T> U>
template<class T, detail::multiplicable_with<T> U>
constexpr decltype(auto) operator()(T&& t, U&& u) const
{ return std::forward<T>(t) * std::forward<U>(u); }
@@ -290,7 +290,7 @@ namespace std {
}
struct divided_by {
template<class T, detail::divisible_with <T> U>
template<class T, detail::divisible_with<T> U>
constexpr decltype(auto) operator()(T&& t, U&& u) const
{ return std::forward<T>(t) / std::forward<U>(u); }
};
@@ -312,7 +312,7 @@ namespace std {
}
struct modulus {
template<class T, detail::modulo_with <T> U>
template<class T, detail::modulo_with<T> U>
constexpr decltype(auto) operator()(T&& t, U&& u) const
{ return std::forward<T>(t) % std::forward<U>(u); }
};

View File

@@ -205,7 +205,7 @@ namespace units {
template<Scalar Value>
requires detail::safe_convertible<Value, rep>
constexpr explicit quantity(const Value& r): value_{static_cast<rep>(r)}
constexpr explicit quantity(const Value& v): value_{static_cast<rep>(v)}
{
}
@@ -369,7 +369,8 @@ namespace units {
template<typename U1, typename Rep1, typename U2, typename Rep2>
[[nodiscard]] constexpr Quantity AUTO operator-(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
requires same_dim<typename U1::dimension, typename U2::dimension> && detail::basic_arithmetic<Rep1, Rep2>
requires same_dim<typename U1::dimension, typename U2::dimension> &&
detail::basic_arithmetic<Rep1, Rep2>
{
using common_rep = decltype(lhs.count() - rhs.count());
using ret = common_quantity<quantity<U1, Rep1>, quantity<U2, Rep2>, common_rep>;
@@ -394,7 +395,8 @@ namespace units {
template<typename U1, typename Rep1, typename U2, typename Rep2>
[[nodiscard]] constexpr Scalar AUTO operator*(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
requires same_dim<typename U1::dimension, dim_invert<typename U2::dimension>> && detail::basic_arithmetic<Rep1, Rep2>
requires same_dim<typename U1::dimension, dim_invert<typename U2::dimension>> &&
detail::basic_arithmetic<Rep1, Rep2>
{
using common_rep = decltype(lhs.count() * rhs.count());
using ratio = ratio_multiply<typename U1::ratio, typename U2::ratio>;
@@ -439,7 +441,8 @@ namespace units {
template<typename U1, typename Rep1, typename U2, typename Rep2>
[[nodiscard]] constexpr Scalar AUTO operator/(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
requires same_dim<typename U1::dimension, typename U2::dimension> && detail::basic_arithmetic<Rep1, Rep2>
requires same_dim<typename U1::dimension, typename U2::dimension> &&
detail::basic_arithmetic<Rep1, Rep2>
{
Expects(rhs != std::remove_cvref_t<decltype(rhs)>(0));