fix: address comments from @mpusz

This commit is contained in:
Johel Ernesto Guerrero Peña
2021-02-23 13:23:02 -04:00
committed by Mateusz Pusz
parent 94eb477f02
commit 533595d669
5 changed files with 15 additions and 15 deletions

View File

@@ -51,6 +51,7 @@ struct basic_fixed_string {
for (std::size_t i = 0; i < N; ++i) data_[i] = txt[i];
}
[[nodiscard]] constexpr bool empty() const noexcept { return N == 0; }
[[nodiscard]] constexpr std::size_t size() const noexcept { return N; }
[[nodiscard]] constexpr const CharT* data() const noexcept { return data_; }
[[nodiscard]] constexpr const CharT* c_str() const noexcept { return data(); }

View File

@@ -83,10 +83,9 @@ struct one_rep {
[[nodiscard]] friend constexpr Rep operator/(one_rep, const Rep&) = delete;
template<typename Rep>
requires requires { quantity_values<Rep>::one(); requires !Quantity<Rep> && // TODO: Replace with `QuantityValue`
!QuantityLike<Rep> && // when Clang catches up.
!wrapped_quantity_<Rep>; }
[[nodiscard]] constexpr operator Rep() const noexcept
requires requires { quantity_values<Rep>::one(); } &&
(!Quantity<Rep> && !QuantityLike<Rep> && !wrapped_quantity_<Rep>) // TODO: Replace with `QuantityValue`
[[nodiscard]] constexpr operator Rep() const noexcept // when Clang catches up.
{
return quantity_values<Rep>::one();
}

View File

@@ -269,30 +269,30 @@ public:
// Below friend functions are to be found via argument-dependent lookup only
template<typename Value>
[[nodiscard]] friend constexpr Quantity auto operator+(const quantity& lhs, const Value& rhs)
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
requires invoke_result_convertible_to_<rep, std::plus<>, rep, Value>; }
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
requires invoke_result_convertible_to_<rep, std::plus<>, rep, Value>; } // when Clang catches up.
{
return units::quantity(lhs.count() + rhs);
}
template<typename Value>
[[nodiscard]] friend constexpr Quantity auto operator+(const Value& lhs, const quantity& rhs)
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
requires invoke_result_convertible_to_<rep, std::plus<>, Value, rep>; }
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
requires invoke_result_convertible_to_<rep, std::plus<>, Value, rep>; } // when Clang catches up.
{
return units::quantity(lhs + rhs.count());
}
template<typename Value>
[[nodiscard]] friend constexpr Quantity auto operator-(const quantity& lhs, const Value& rhs)
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
requires invoke_result_convertible_to_<rep, std::minus<>, rep, Value>; }
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
requires invoke_result_convertible_to_<rep, std::minus<>, rep, Value>; } // when Clang catches up.
{
return units::quantity(lhs.count() - rhs);
}
template<typename Value>
[[nodiscard]] friend constexpr Quantity auto operator-(const Value& lhs, const quantity& rhs)
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
requires invoke_result_convertible_to_<rep, std::minus<>, Value, rep>; }
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
requires invoke_result_convertible_to_<rep, std::minus<>, Value, rep>; } // when Clang catches up.
{
return units::quantity(lhs - rhs.count());
}

View File

@@ -290,7 +290,7 @@ template<typename CastSpec, typename K, typename U, typename Rep>
requires requires { requires is_specialization_of<CastSpec, quantity_kind>;
requires requires { quantity_cast<typename CastSpec::quantity_type>(qk.common()); }; } ||
requires { requires Kind<CastSpec>; requires UnitOf<U, typename CastSpec::dimension>; } ||
requires { quantity_cast<CastSpec>(qk.common()); }
requires { quantity_cast<CastSpec>(qk.common()); } // TODO: Simplify when Clang catches up.
{
if constexpr (is_specialization_of<CastSpec, quantity_kind>)
return CastSpec(quantity_cast<typename CastSpec::quantity_type>(qk.common()));
@@ -349,7 +349,7 @@ template<typename CastSpec, typename PK, typename U, typename Rep>
requires requires { requires is_specialization_of<CastSpec, quantity_point_kind>;
requires requires { quantity_kind_cast<typename CastSpec::quantity_kind_type>(qpk.relative()); }; } ||
requires { requires PointKind<CastSpec> && UnitOf<U, typename CastSpec::dimension>; } ||
requires { quantity_kind_cast<CastSpec>(qpk.relative()); }
requires { quantity_kind_cast<CastSpec>(qpk.relative()); } // TODO: Simplify when Clang catches up.
{
if constexpr (is_specialization_of<CastSpec, quantity_point_kind>)
return CastSpec(quantity_kind_cast<typename CastSpec::quantity_kind_type>(qpk.relative()));

View File

@@ -36,7 +36,7 @@ void to_stream(std::basic_ostream<CharT, Traits>& os, const quantity<D, U, Rep>&
{
os << q.count();
constexpr auto symbol = detail::unit_text<D, U>();
if constexpr (bool(symbol.standard().size())) {
if constexpr (!symbol.standard().empty()) {
os << " " << symbol.standard();
}
}