forked from mpusz/mp-units
fix: LA support fixed
This commit is contained in:
@@ -28,6 +28,9 @@ set(projectPrefix UNITS_)
|
||||
option(${projectPrefix}AS_SYSTEM_HEADERS "Exports library as system headers" OFF)
|
||||
message(STATUS "${projectPrefix}AS_SYSTEM_HEADERS: ${${projectPrefix}AS_SYSTEM_HEADERS}")
|
||||
|
||||
option(${projectPrefix}BUILD_LA "Build code depending on the linear algebra library" ON)
|
||||
message(STATUS "${projectPrefix}BUILD_LA: ${${projectPrefix}BUILD_LA}")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(AddUnitsModule)
|
||||
|
||||
@@ -401,8 +401,11 @@ concept castable_number_ = // exposition only
|
||||
|
||||
template<typename T>
|
||||
concept scalable_ = // exposition only
|
||||
castable_number_<T> || (requires { typename T::value_type; } && castable_number_<typename T::value_type> &&
|
||||
scalable_number_<T, std::common_type_t<typename T::value_type, std::intmax_t>>);
|
||||
castable_number_<T> ||
|
||||
(requires { typename T::value_type; } && castable_number_<typename T::value_type> &&
|
||||
scalable_number_<T, std::common_type_t<typename T::value_type, std::intmax_t>>) ||
|
||||
(requires { typename T::element_type; } && castable_number_<typename T::element_type> &&
|
||||
scalable_number_<T, std::common_type_t<typename T::element_type, std::intmax_t>>);
|
||||
|
||||
template<typename T, typename U>
|
||||
concept scalable_with_ = // exposition only
|
||||
@@ -420,6 +423,12 @@ inline constexpr bool is_wrapped_quantity<T> =
|
||||
Quantity<typename T::value_type> || QuantityLike<typename T::value_type> ||
|
||||
is_wrapped_quantity<typename T::value_type>;
|
||||
|
||||
template<typename T>
|
||||
requires requires { typename T::element_type; }
|
||||
inline constexpr bool is_wrapped_quantity<T> =
|
||||
Quantity<typename T::element_type> || QuantityLike<typename T::element_type> ||
|
||||
is_wrapped_quantity<typename T::element_type>;
|
||||
|
||||
template<typename T>
|
||||
requires requires { typename T::quantity_type; }
|
||||
inline constexpr bool is_wrapped_quantity<T> = Quantity<typename T::quantity_type>;
|
||||
@@ -429,8 +438,9 @@ inline constexpr bool is_wrapped_quantity<T> = Quantity<typename T::quantity_typ
|
||||
/**
|
||||
* @brief A concept matching types that wrap quantity objects.
|
||||
*
|
||||
* Satisfied by all wrapper types that satisfy `Quantity<typename T::value_type>`
|
||||
* recursively (i.e. `std::optional<si::length<si::metre>>`).
|
||||
* Satisfied by all wrapper types that satisfy `Quantity<typename T::value_type>` or
|
||||
* `Quantity<typename T::element_type>` recursively
|
||||
* (i.e. `std::optional<si::length<si::metre>>`).
|
||||
*/
|
||||
template<typename T>
|
||||
concept wrapped_quantity_ = // exposition only
|
||||
|
||||
@@ -44,6 +44,10 @@ template<typename T>
|
||||
requires requires { typename T::value_type; }
|
||||
inline constexpr bool treat_as_floating_point<T> = treat_as_floating_point<typename T::value_type>;
|
||||
|
||||
template<typename T>
|
||||
requires requires { typename T::element_type; }
|
||||
inline constexpr bool treat_as_floating_point<T> = treat_as_floating_point<typename T::element_type>;
|
||||
|
||||
/**
|
||||
* @brief A type trait that defines zero, one, min, and max for a representation type
|
||||
*
|
||||
|
||||
@@ -83,6 +83,16 @@ struct cast_traits<From, To> {
|
||||
using rep_type = std::common_type_t<From, To>;
|
||||
};
|
||||
|
||||
template<typename From, typename To>
|
||||
requires(!common_type_with_<std::common_type_t<From, To>, std::intmax_t> &&
|
||||
scalable_number_<std::common_type_t<From, To>, std::intmax_t> &&
|
||||
requires { typename std::common_type_t<From, To>::element_type; } &&
|
||||
common_type_with_<typename std::common_type_t<From, To>::element_type, std::intmax_t>)
|
||||
struct cast_traits<From, To> {
|
||||
using ratio_type = std::common_type_t<typename std::common_type_t<From, To>::element_type, std::intmax_t>;
|
||||
using rep_type = std::common_type_t<From, To>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user