forked from mpusz/mp-units
feat: = delete
should have a reason
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// IWYU pragma: private, include <mp-units/framework.h>
|
// IWYU pragma: private, include <mp-units/framework.h>
|
||||||
|
#include <mp-units/bits/hacks.h>
|
||||||
#include <mp-units/bits/module_macros.h>
|
#include <mp-units/bits/module_macros.h>
|
||||||
#include <mp-units/bits/sudo_cast.h>
|
#include <mp-units/bits/sudo_cast.h>
|
||||||
#include <mp-units/compat_macros.h>
|
#include <mp-units/compat_macros.h>
|
||||||
@@ -229,7 +230,12 @@ public:
|
|||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
requires(U{} == unit)
|
requires(U{} == unit)
|
||||||
constexpr const rep&& numerical_value_ref_in(U) const&& noexcept = delete;
|
constexpr const rep&& numerical_value_ref_in(U) const&& noexcept
|
||||||
|
#if __cpp_deleted_function
|
||||||
|
= delete("Can't form a reference to a temporary");
|
||||||
|
#else
|
||||||
|
= delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
template<UnitCompatibleWith<unit, quantity_spec> U>
|
template<UnitCompatibleWith<unit, quantity_spec> U>
|
||||||
requires requires(quantity q) { q.in(U{}); }
|
requires requires(quantity q) { q.in(U{}); }
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// IWYU pragma: private, include <mp-units/framework.h>
|
// IWYU pragma: private, include <mp-units/framework.h>
|
||||||
|
#include <mp-units/bits/hacks.h>
|
||||||
#include <mp-units/bits/module_macros.h>
|
#include <mp-units/bits/module_macros.h>
|
||||||
#include <mp-units/framework/compare.h>
|
#include <mp-units/framework/compare.h>
|
||||||
#include <mp-units/framework/customization_points.h>
|
#include <mp-units/framework/customization_points.h>
|
||||||
@@ -241,7 +242,12 @@ public:
|
|||||||
|
|
||||||
template<PointOrigin PO2>
|
template<PointOrigin PO2>
|
||||||
requires(PO2{} == point_origin)
|
requires(PO2{} == point_origin)
|
||||||
constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept = delete;
|
constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept
|
||||||
|
#if __cpp_deleted_function
|
||||||
|
= delete("Can't form a reference to a temporary");
|
||||||
|
#else
|
||||||
|
= delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
template<PointOrigin PO2>
|
template<PointOrigin PO2>
|
||||||
requires requires { quantity_point{} - PO2{}; }
|
requires requires { quantity_point{} - PO2{}; }
|
||||||
|
@@ -240,12 +240,22 @@ template<typename Rep, Reference R>
|
|||||||
template<Reference R, typename Rep>
|
template<Reference R, typename Rep>
|
||||||
requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character>
|
requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character>
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
|
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
|
||||||
constexpr auto operator*(R, Rep&&) = delete;
|
constexpr auto operator*(R, Rep&&)
|
||||||
|
#if __cpp_deleted_function
|
||||||
|
= delete("To create a `quantity` or `quantity_point` use `Rep * R`");
|
||||||
|
#else
|
||||||
|
= delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
template<Reference R, typename Rep>
|
template<Reference R, typename Rep>
|
||||||
requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character>
|
requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character>
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
|
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
|
||||||
constexpr auto operator/(R, Rep&&) = delete;
|
constexpr auto operator/(R, Rep&&)
|
||||||
|
#if __cpp_deleted_function
|
||||||
|
= delete("To create a `quantity` or `quantity_point` use `Rep / R`");
|
||||||
|
#else
|
||||||
|
= delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename Q, Reference R>
|
template<typename Q, Reference R>
|
||||||
requires Quantity<std::remove_cvref_t<Q>>
|
requires Quantity<std::remove_cvref_t<Q>>
|
||||||
|
@@ -449,7 +449,12 @@ template<Magnitude M, Unit U>
|
|||||||
return scaled_unit<M{}, U>{};
|
return scaled_unit<M{}, U>{};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] consteval Unit auto operator*(Unit auto, Magnitude auto) = delete;
|
[[nodiscard]] consteval Unit auto operator*(Unit auto, Magnitude auto)
|
||||||
|
#if __cpp_deleted_function
|
||||||
|
= delete("To scale a unit use `mag * unit` syntax");
|
||||||
|
#else
|
||||||
|
= delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result of multiplication with an inverse unit.
|
* Returns the result of multiplication with an inverse unit.
|
||||||
|
Reference in New Issue
Block a user