mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
fix: MP_UNITS_API_NO_CRTP
handling fixed
This commit is contained in:
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <mp-units/bits/hacks.h>
|
#include <mp-units/bits/hacks.h>
|
||||||
|
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
|
|
||||||
#define QUANTITY_SPEC(name, ...) \
|
#define QUANTITY_SPEC(name, ...) \
|
||||||
inline constexpr struct name final : ::mp_units::quantity_spec<__VA_ARGS__> { \
|
inline constexpr struct name final : ::mp_units::quantity_spec<__VA_ARGS__> { \
|
||||||
|
@ -112,11 +112,11 @@ using to_dimension = std::remove_const_t<decltype(Q::dimension)>;
|
|||||||
template<AssociatedUnit U>
|
template<AssociatedUnit U>
|
||||||
[[nodiscard]] consteval auto get_associated_quantity(U);
|
[[nodiscard]] consteval auto get_associated_quantity(U);
|
||||||
|
|
||||||
#ifndef MP_UNITS_API_NO_CRTP
|
#if !MP_UNITS_API_NO_CRTP
|
||||||
template<typename Self>
|
template<typename Self>
|
||||||
#endif
|
#endif
|
||||||
struct quantity_spec_interface {
|
struct quantity_spec_interface {
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<typename Self, UnitOf<Self{}> U>
|
template<typename Self, UnitOf<Self{}> U>
|
||||||
[[nodiscard]] consteval Reference auto operator[](this Self self, U u)
|
[[nodiscard]] consteval Reference auto operator[](this Self self, U u)
|
||||||
{
|
{
|
||||||
@ -171,7 +171,7 @@ MP_UNITS_EXPORT_BEGIN
|
|||||||
* types `speed` and `velocity` are considered not equal to `derived_dimension<length, per<time>>` or
|
* types `speed` and `velocity` are considered not equal to `derived_dimension<length, per<time>>` or
|
||||||
* to each other.
|
* to each other.
|
||||||
*/
|
*/
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<auto...>
|
template<auto...>
|
||||||
#else
|
#else
|
||||||
template<typename, auto...>
|
template<typename, auto...>
|
||||||
@ -216,7 +216,7 @@ MP_UNITS_EXPORT_END
|
|||||||
* @tparam BaseDimension base dimension for which a base quantity is being defined
|
* @tparam BaseDimension base dimension for which a base quantity is being defined
|
||||||
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
||||||
*/
|
*/
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::BaseDimension auto Dim, one_of<quantity_character> auto... Args>
|
template<detail::BaseDimension auto Dim, one_of<quantity_character> auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
requires(... && !QuantitySpec<decltype(Args)>)
|
||||||
struct quantity_spec<Dim, Args...> : detail::quantity_spec_interface {
|
struct quantity_spec<Dim, Args...> : detail::quantity_spec_interface {
|
||||||
@ -260,7 +260,7 @@ struct quantity_spec<Self, Dim, Args...> : detail::quantity_spec_interface<Self>
|
|||||||
* @tparam Eq quantity equation specification of a derived quantity
|
* @tparam Eq quantity equation specification of a derived quantity
|
||||||
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
||||||
*/
|
*/
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::DerivedQuantitySpec auto Eq, one_of<quantity_character> auto... Args>
|
template<detail::DerivedQuantitySpec auto Eq, one_of<quantity_character> auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
requires(... && !QuantitySpec<decltype(Args)>)
|
||||||
struct quantity_spec<Eq, Args...> : detail::quantity_spec_interface {
|
struct quantity_spec<Eq, Args...> : detail::quantity_spec_interface {
|
||||||
@ -314,7 +314,7 @@ struct propagate_equation<Q, true> {
|
|||||||
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
* @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar
|
||||||
* or `is_kind` in case the quantity starts a new hierarchy tree of a kind
|
* or `is_kind` in case the quantity starts a new hierarchy tree of a kind
|
||||||
*/
|
*/
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::NamedQuantitySpec auto QS, one_of<quantity_character, struct is_kind> auto... Args>
|
template<detail::NamedQuantitySpec auto QS, one_of<quantity_character, struct is_kind> auto... Args>
|
||||||
requires(... && !QuantitySpec<decltype(Args)>)
|
requires(... && !QuantitySpec<decltype(Args)>)
|
||||||
struct quantity_spec<QS, Args...> : detail::propagate_equation<QS>, detail::quantity_spec_interface {
|
struct quantity_spec<QS, Args...> : detail::propagate_equation<QS>, detail::quantity_spec_interface {
|
||||||
@ -328,7 +328,7 @@ struct quantity_spec<Self, QS, Args...> : detail::propagate_equation<QS>, detail
|
|||||||
static constexpr Dimension auto dimension = _parent_.dimension;
|
static constexpr Dimension auto dimension = _parent_.dimension;
|
||||||
static constexpr quantity_character character = detail::quantity_character_init<Args...>(QS.character);
|
static constexpr quantity_character character = detail::quantity_character_init<Args...>(QS.character);
|
||||||
|
|
||||||
#ifndef MP_UNITS_API_NO_CRTP
|
#if !MP_UNITS_API_NO_CRTP
|
||||||
template<typename Self_ = Self, UnitOf<Self_{}> U>
|
template<typename Self_ = Self, UnitOf<Self_{}> U>
|
||||||
[[nodiscard]] MP_UNITS_CONSTEVAL Reference auto operator[](U u) const
|
[[nodiscard]] MP_UNITS_CONSTEVAL Reference auto operator[](U u) const
|
||||||
{
|
{
|
||||||
@ -376,7 +376,7 @@ struct quantity_spec<Self, QS, Args...> : detail::propagate_equation<QS>, detail
|
|||||||
* or `is_kind` in case the quantity starts a new hierarchy tree of a kind
|
* or `is_kind` in case the quantity starts a new hierarchy tree of a kind
|
||||||
*/
|
*/
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<detail::NamedQuantitySpec auto QS, detail::DerivedQuantitySpec auto Eq,
|
template<detail::NamedQuantitySpec auto QS, detail::DerivedQuantitySpec auto Eq,
|
||||||
one_of<quantity_character, struct is_kind> auto... Args>
|
one_of<quantity_character, struct is_kind> auto... Args>
|
||||||
requires(!requires { QS._equation_; } || (requires {
|
requires(!requires { QS._equation_; } || (requires {
|
||||||
@ -402,7 +402,7 @@ namespace detail {
|
|||||||
|
|
||||||
template<detail::DerivedQuantitySpecExpr... Expr>
|
template<detail::DerivedQuantitySpecExpr... Expr>
|
||||||
struct derived_quantity_spec_impl :
|
struct derived_quantity_spec_impl :
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
detail::quantity_spec_interface,
|
detail::quantity_spec_interface,
|
||||||
#else
|
#else
|
||||||
detail::quantity_spec_interface<derived_quantity_spec<Expr...>>,
|
detail::quantity_spec_interface<derived_quantity_spec<Expr...>>,
|
||||||
@ -496,7 +496,7 @@ template<QuantitySpec Q>
|
|||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<typename Q>
|
template<typename Q>
|
||||||
requires detail::QuantitySpecWithNoSpecifiers<Q> && (detail::get_kind_tree_root(Q{}) == Q{})
|
requires detail::QuantitySpecWithNoSpecifiers<Q> && (detail::get_kind_tree_root(Q{}) == Q{})
|
||||||
struct kind_of_<Q> final : Q::_base_type_ {
|
struct kind_of_<Q> final : Q::_base_type_ {
|
||||||
@ -1479,7 +1479,7 @@ template<QuantitySpec Q>
|
|||||||
requires requires(Q q) { get_kind_tree_root(q); }
|
requires requires(Q q) { get_kind_tree_root(q); }
|
||||||
using to_kind = decltype(get_kind_tree_root(Q{}));
|
using to_kind = decltype(get_kind_tree_root(Q{}));
|
||||||
|
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<NamedQuantitySpec auto QS, auto... Args>
|
template<NamedQuantitySpec auto QS, auto... Args>
|
||||||
[[nodiscard]] consteval bool defined_as_kind(quantity_spec<QS, Args...>)
|
[[nodiscard]] consteval bool defined_as_kind(quantity_spec<QS, Args...>)
|
||||||
#else
|
#else
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
namespace mp_units {
|
namespace mp_units {
|
||||||
|
|
||||||
MP_UNITS_EXPORT
|
MP_UNITS_EXPORT
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<auto...>
|
template<auto...>
|
||||||
#else
|
#else
|
||||||
template<typename, auto...>
|
template<typename, auto...>
|
||||||
@ -52,7 +52,7 @@ inline constexpr bool is_specialization_of_kind_of<kind_of_<Q>> = true;
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
concept QuantityKindSpec = is_specialization_of_kind_of<T>;
|
concept QuantityKindSpec = is_specialization_of_kind_of<T>;
|
||||||
|
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
template<auto... Args>
|
template<auto... Args>
|
||||||
void to_base_specialization_of_quantity_spec(const volatile quantity_spec<Args...>*);
|
void to_base_specialization_of_quantity_spec(const volatile quantity_spec<Args...>*);
|
||||||
#else
|
#else
|
||||||
|
@ -30,7 +30,7 @@ template<auto V, typename T>
|
|||||||
inline constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>;
|
inline constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>;
|
||||||
|
|
||||||
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
#ifdef MP_UNITS_API_NO_CRTP
|
#if MP_UNITS_API_NO_CRTP
|
||||||
|
|
||||||
#define QUANTITY_SPEC_(name, ...) \
|
#define QUANTITY_SPEC_(name, ...) \
|
||||||
inline constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \
|
inline constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \
|
||||||
|
Reference in New Issue
Block a user