forked from mpusz/mp-units
[hacks] add MP_UNITS_EXPRESSION
This commit is contained in:
@@ -80,10 +80,12 @@
|
|||||||
#if MP_UNITS_COMP_MSVC
|
#if MP_UNITS_COMP_MSVC
|
||||||
|
|
||||||
#define MP_UNITS_TYPENAME typename
|
#define MP_UNITS_TYPENAME typename
|
||||||
|
#define MP_UNITS_EXPRESSION(x) (x)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define MP_UNITS_TYPENAME
|
#define MP_UNITS_TYPENAME
|
||||||
|
#define MP_UNITS_EXPRESSION(x) x
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -54,14 +54,14 @@ template<PointOrigin PO>
|
|||||||
struct point_origin_interface {
|
struct point_origin_interface {
|
||||||
template<PointOrigin PO, Quantity Q>
|
template<PointOrigin PO, Quantity Q>
|
||||||
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
|
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
|
||||||
[[nodiscard]] friend constexpr quantity_point<Q::reference, (PO{}), typename Q::rep> operator+(PO, Q&& q)
|
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+(PO, Q&& q)
|
||||||
{
|
{
|
||||||
return quantity_point{std::forward<Q>(q), PO{}};
|
return quantity_point{std::forward<Q>(q), PO{}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Quantity Q, PointOrigin PO>
|
template<Quantity Q, PointOrigin PO>
|
||||||
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
|
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
|
||||||
[[nodiscard]] friend constexpr quantity_point<Q::reference, (PO{}), typename Q::rep> operator+(Q&& q, PO po)
|
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+(Q&& q, PO po)
|
||||||
{
|
{
|
||||||
return po + std::forward<Q>(q);
|
return po + std::forward<Q>(q);
|
||||||
}
|
}
|
||||||
@@ -191,13 +191,13 @@ public:
|
|||||||
[[nodiscard]] static constexpr quantity_point min() noexcept
|
[[nodiscard]] static constexpr quantity_point min() noexcept
|
||||||
requires requires { quantity_type::min(); }
|
requires requires { quantity_type::min(); }
|
||||||
{
|
{
|
||||||
return {quantity_type::min(), point_origin};
|
return {quantity_type::min(), PO};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] static constexpr quantity_point max() noexcept
|
[[nodiscard]] static constexpr quantity_point max() noexcept
|
||||||
requires requires { quantity_type::max(); }
|
requires requires { quantity_type::max(); }
|
||||||
{
|
{
|
||||||
return {quantity_type::max(), point_origin};
|
return {quantity_type::max(), PO};
|
||||||
}
|
}
|
||||||
|
|
||||||
// construction, assignment, destruction
|
// construction, assignment, destruction
|
||||||
|
@@ -87,40 +87,40 @@ struct reference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Q2, typename U2>
|
template<typename Q2, typename U2>
|
||||||
[[nodiscard]] friend consteval detail::reference_t<(Q{} * Q2{}), (U{} * U2{})> operator*(reference, reference<Q2, U2>)
|
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} * Q2{}), MP_UNITS_EXPRESSION(U{} * U2{})> operator*(reference, reference<Q2, U2>)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<AssociatedUnit U2>
|
template<AssociatedUnit U2>
|
||||||
[[nodiscard]] friend consteval detail::reference_t<((Q{} * get_quantity_spec(U2{}))), (U{} * U2{})> operator*(reference,
|
[[nodiscard]] friend consteval detail::reference_t<(MP_UNITS_EXPRESSION(Q{} * get_quantity_spec(U2{}))), MP_UNITS_EXPRESSION(U{} * U2{})> operator*(reference,
|
||||||
U2)
|
U2)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<AssociatedUnit U1>
|
template<AssociatedUnit U1>
|
||||||
[[nodiscard]] friend consteval detail::reference_t<(get_quantity_spec(U1{}) * Q{}), (U1{} * U{})> operator*(U1,
|
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) * Q{}), MP_UNITS_EXPRESSION(U1{} * U{})> operator*(U1,
|
||||||
reference)
|
reference)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Q2, typename U2>
|
template<typename Q2, typename U2>
|
||||||
[[nodiscard]] friend consteval detail::reference_t<(Q{} / Q2{}), (U{} / U2{})> operator/(reference, reference<Q2, U2>)
|
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / Q2{}), MP_UNITS_EXPRESSION(U{} / U2{})> operator/(reference, reference<Q2, U2>)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<AssociatedUnit U2>
|
template<AssociatedUnit U2>
|
||||||
[[nodiscard]] friend consteval detail::reference_t<(Q{} / get_quantity_spec(U2{})), (U{} / U2{})> operator/(reference,
|
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / get_quantity_spec(U2{})), MP_UNITS_EXPRESSION(U{} / U2{})> operator/(reference,
|
||||||
U2)
|
U2)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<AssociatedUnit U1>
|
template<AssociatedUnit U1>
|
||||||
[[nodiscard]] friend consteval detail::reference_t<(get_quantity_spec(U1{}) / Q{}), (U1{} / U{})> operator/(U1, reference)
|
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) / Q{}), MP_UNITS_EXPRESSION(U1{} / U{})> operator/(U1, reference)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user