mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 05:04:27 +02:00
is_instantiation
renamed to is_instantiation_of
This commit is contained in:
14
src/include/units/bits/external/type_traits.h
vendored
14
src/include/units/bits/external/type_traits.h
vendored
@@ -46,25 +46,25 @@ struct conditional_impl<true> {
|
|||||||
template<bool B, typename T, typename F>
|
template<bool B, typename T, typename F>
|
||||||
using conditional = detail::conditional_impl<B>::template type<T, F>;
|
using conditional = detail::conditional_impl<B>::template type<T, F>;
|
||||||
|
|
||||||
// is_instantiation
|
// is_instantiation_of
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<typename T, template<typename...> typename Type>
|
template<typename T, template<typename...> typename Type>
|
||||||
inline constexpr bool is_instantiation_impl = false;
|
inline constexpr bool is_instantiation_of_impl = false;
|
||||||
|
|
||||||
template<typename... Params, template<typename...> typename Type>
|
template<typename... Params, template<typename...> typename Type>
|
||||||
inline constexpr bool is_instantiation_impl<Type<Params...>, Type> = true;
|
inline constexpr bool is_instantiation_of_impl<Type<Params...>, Type> = true;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<typename T, template<typename...> typename Type>
|
template<typename T, template<typename...> typename Type>
|
||||||
inline constexpr bool is_instantiation = detail::is_instantiation_impl<T, Type>;
|
inline constexpr bool is_instantiation_of = detail::is_instantiation_of_impl<T, Type>;
|
||||||
|
|
||||||
// is_derived_from_instantiation
|
// is_derived_from_instantiation_of
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<template<typename...> typename Type>
|
template<template<typename...> typename Type>
|
||||||
struct is_derived_from_instantiation_impl {
|
struct is_derived_from_instantiation_of_impl {
|
||||||
template<typename... Params>
|
template<typename... Params>
|
||||||
static constexpr std::true_type check_base(const Type<Params...>&);
|
static constexpr std::true_type check_base(const Type<Params...>&);
|
||||||
static constexpr std::false_type check_base(...);
|
static constexpr std::false_type check_base(...);
|
||||||
@@ -73,6 +73,6 @@ struct is_derived_from_instantiation_impl {
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<typename T, template<typename...> typename Type>
|
template<typename T, template<typename...> typename Type>
|
||||||
inline constexpr bool is_derived_from_instantiation = decltype(detail::is_derived_from_instantiation_impl<Type>::check_base(std::declval<T>()))::value;
|
inline constexpr bool is_derived_from_instantiation_of = decltype(detail::is_derived_from_instantiation_of_impl<Type>::check_base(std::declval<T>()))::value;
|
||||||
|
|
||||||
} // namespace units
|
} // namespace units
|
||||||
|
@@ -30,10 +30,10 @@
|
|||||||
namespace units::physical {
|
namespace units::physical {
|
||||||
|
|
||||||
template<typename Dim, template<typename...> typename DimTemplate>
|
template<typename Dim, template<typename...> typename DimTemplate>
|
||||||
concept DimensionOf = Dimension<Dim> && is_derived_from_instantiation<Dim, DimTemplate>;
|
concept DimensionOf = Dimension<Dim> && is_derived_from_instantiation_of<Dim, DimTemplate>;
|
||||||
|
|
||||||
template<typename Q, template<typename...> typename DimTemplate>
|
template<typename Q, template<typename...> typename DimTemplate>
|
||||||
concept QuantityOf = Quantity<Q> && is_derived_from_instantiation<typename Q::dimension, DimTemplate>;
|
concept QuantityOf = Quantity<Q> && is_derived_from_instantiation_of<typename Q::dimension, DimTemplate>;
|
||||||
|
|
||||||
// ------------------------ base dimensions -----------------------------
|
// ------------------------ base dimensions -----------------------------
|
||||||
|
|
||||||
|
@@ -403,10 +403,10 @@ template<Scalar ToRep, typename D, typename U, typename Rep>
|
|||||||
*/
|
*/
|
||||||
template<typename CastSpec, typename D, typename U, typename Rep>
|
template<typename CastSpec, typename D, typename U, typename Rep>
|
||||||
[[nodiscard]] constexpr auto quantity_point_cast(const quantity_point<D, U, Rep>& qp)
|
[[nodiscard]] constexpr auto quantity_point_cast(const quantity_point<D, U, Rep>& qp)
|
||||||
requires is_instantiation<CastSpec, quantity_point> ||
|
requires is_instantiation_of<CastSpec, quantity_point> ||
|
||||||
requires(quantity<D, U, Rep> q) { quantity_cast<CastSpec>(q); }
|
requires(quantity<D, U, Rep> q) { quantity_cast<CastSpec>(q); }
|
||||||
{
|
{
|
||||||
if constexpr (is_instantiation<CastSpec, quantity_point>)
|
if constexpr (is_instantiation_of<CastSpec, quantity_point>)
|
||||||
return quantity_point(quantity_cast<typename CastSpec::quantity_type>(qp.relative()));
|
return quantity_point(quantity_cast<typename CastSpec::quantity_type>(qp.relative()));
|
||||||
else
|
else
|
||||||
return quantity_point(quantity_cast<CastSpec>(qp.relative()));
|
return quantity_point(quantity_cast<CastSpec>(qp.relative()));
|
||||||
|
Reference in New Issue
Block a user