diff --git a/src/core/include/units/customization_points.h b/src/core/include/units/customization_points.h index 889e8176..5570ee37 100644 --- a/src/core/include/units/customization_points.h +++ b/src/core/include/units/customization_points.h @@ -23,6 +23,7 @@ #pragma once #include +#include #include #include @@ -40,9 +41,46 @@ namespace units { template inline constexpr bool treat_as_floating_point = std::is_floating_point_v; -template - requires requires { typename T::value_type; } -inline constexpr bool treat_as_floating_point = treat_as_floating_point; +template + requires requires { typename Rep::value_type; } +inline constexpr bool treat_as_floating_point = treat_as_floating_point; + +/** + * @brief Specifies a type to have a scalar character + * + * A scalar is a physical quantity that has magnitude but no direction. + */ +template +inline constexpr bool is_scalar = std::is_floating_point_v || (std::is_integral_v && !is_same_v); + +/** + * @brief Specifies a type to have a vector character + * + * Vectors are physical quantities that possess both magnitude and direction + * and whose operations obey the axioms of a vector space. + * + * In specific cases a scalar can represent a vector with the default direction. + * If that is the intent, a user should provide a partial specialization: + * + * @code{.cpp} + * template + * requires units::is_scalar + * inline constexpr bool units::is_vector = true; + * @endcode + */ +template +inline constexpr bool is_vector = false; + +/** + * @brief Specifies a type to have a tensor character + * + * Tensors can be used to describe more general physical quantities. + * + * A vector is a tensor of the first order and a scalar is a tensor of order zero. + * Similarly to `is_vector` a partial specialization is needed in such cases. + */ +template +inline constexpr bool is_tensor = false; /** * @brief A type trait that defines zero, one, min, and max for a representation type