forked from mpusz/mp-units
Doxygen documentation added
This commit is contained in:
@@ -27,6 +27,12 @@
|
|||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A compile-time fixed string
|
||||||
|
*
|
||||||
|
* @tparam CharT Character type to be used by the string
|
||||||
|
* @tparam N The size of the string
|
||||||
|
*/
|
||||||
template<typename CharT, std::size_t N>
|
template<typename CharT, std::size_t N>
|
||||||
struct basic_fixed_string {
|
struct basic_fixed_string {
|
||||||
CharT data_[N + 1] = {};
|
CharT data_[N + 1] = {};
|
||||||
|
@@ -189,6 +189,14 @@ struct dimension_unit_impl<D> {
|
|||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a 'default' unit of the dimension
|
||||||
|
*
|
||||||
|
* Depending on the dimension type it returns a base unit (for base dimensions)
|
||||||
|
* or a coherent unit (in case of derived dimensions).
|
||||||
|
*
|
||||||
|
* @tparam D Dimension type to get the unit from.
|
||||||
|
*/
|
||||||
template<Dimension D>
|
template<Dimension D>
|
||||||
using dimension_unit = detail::dimension_unit_impl<D>::type;
|
using dimension_unit = detail::dimension_unit_impl<D>::type;
|
||||||
|
|
||||||
|
@@ -29,13 +29,15 @@
|
|||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
template<std::intmax_t N, typename D, typename U, typename Rep>
|
/**
|
||||||
requires(N == 0)
|
* @brief Computes the value of a quantity raised to the power `N`
|
||||||
inline Rep pow(const quantity<D, U, Rep>&) noexcept
|
*
|
||||||
{
|
* Both the quantity value and its dimension are the base of the operation.
|
||||||
return 1;
|
*
|
||||||
}
|
* @tparam N Exponent
|
||||||
|
* @param q Quantity being the base of the operation
|
||||||
|
* @return Quantity The result of computation
|
||||||
|
*/
|
||||||
template<std::intmax_t N, typename D, typename U, typename Rep>
|
template<std::intmax_t N, typename D, typename U, typename Rep>
|
||||||
requires(N != 0)
|
requires(N != 0)
|
||||||
inline Quantity AUTO pow(const quantity<D, U, Rep>& q) noexcept
|
inline Quantity AUTO pow(const quantity<D, U, Rep>& q) noexcept
|
||||||
@@ -47,6 +49,26 @@ inline Quantity AUTO pow(const quantity<D, U, Rep>& q) noexcept
|
|||||||
return quantity<dim, unit, Rep>(static_cast<Rep>(std::pow(q.count(), N)));
|
return quantity<dim, unit, Rep>(static_cast<Rep>(std::pow(q.count(), N)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief OVerload that always returns 1 for N == 0
|
||||||
|
*
|
||||||
|
* @return Rep A scalar value of @c 1.
|
||||||
|
*/
|
||||||
|
template<std::intmax_t N, typename D, typename U, typename Rep>
|
||||||
|
requires(N == 0)
|
||||||
|
inline Rep pow(const quantity<D, U, Rep>&) noexcept
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Computes the square root of a quantity
|
||||||
|
*
|
||||||
|
* Both the quantity value and its dimension are the base of the operation.
|
||||||
|
*
|
||||||
|
* @param q Quantity being the base of the operation
|
||||||
|
* @return Quantity The result of computation
|
||||||
|
*/
|
||||||
template<typename D, typename U, typename Rep>
|
template<typename D, typename U, typename Rep>
|
||||||
inline Quantity AUTO sqrt(const quantity<D, U, Rep>& q) noexcept
|
inline Quantity AUTO sqrt(const quantity<D, U, Rep>& q) noexcept
|
||||||
requires requires { std::sqrt(q.count()); }
|
requires requires { std::sqrt(q.count()); }
|
||||||
@@ -57,6 +79,12 @@ inline Quantity AUTO sqrt(const quantity<D, U, Rep>& q) noexcept
|
|||||||
return quantity<dim, unit, Rep>(static_cast<Rep>(std::sqrt(q.count())));
|
return quantity<dim, unit, Rep>(static_cast<Rep>(std::sqrt(q.count())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Computes the absolute value of a quantity
|
||||||
|
*
|
||||||
|
* @param q Quantity being the base of the operation
|
||||||
|
* @return Quantity The absolute value of a provided quantity
|
||||||
|
*/
|
||||||
template<typename D, typename U, typename Rep>
|
template<typename D, typename U, typename Rep>
|
||||||
constexpr Quantity AUTO abs(const quantity<D, U, Rep>& q) noexcept
|
constexpr Quantity AUTO abs(const quantity<D, U, Rep>& q) noexcept
|
||||||
requires requires { std::abs(q.count()); }
|
requires requires { std::abs(q.count()); }
|
||||||
@@ -64,6 +92,14 @@ constexpr Quantity AUTO abs(const quantity<D, U, Rep>& q) noexcept
|
|||||||
return quantity<D, U, Rep>(std::abs(q.count()));
|
return quantity<D, U, Rep>(std::abs(q.count()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the epsilon of the quantity
|
||||||
|
*
|
||||||
|
* The returned value is defined by a <tt>std::numeric_limits<typename Q::rep>::epsilon()</tt>.
|
||||||
|
*
|
||||||
|
* @tparam Q Quantity type being the base of the operation
|
||||||
|
* @return Quantity The epsilon value for quantity's representation type
|
||||||
|
*/
|
||||||
template<Quantity Q>
|
template<Quantity Q>
|
||||||
requires requires { std::numeric_limits<typename Q::rep>::epsilon(); }
|
requires requires { std::numeric_limits<typename Q::rep>::epsilon(); }
|
||||||
constexpr Quantity AUTO epsilon() noexcept
|
constexpr Quantity AUTO epsilon() noexcept
|
||||||
|
@@ -33,6 +33,16 @@
|
|||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Provides compile-time rational arithmetic support.
|
||||||
|
*
|
||||||
|
* This class is really similar to @c std::ratio but gets an additional `Exp`
|
||||||
|
* template parameter.
|
||||||
|
*
|
||||||
|
* @tparam Num Numerator
|
||||||
|
* @tparam Den Denominator (default @c 1)
|
||||||
|
* @tparam Exp Exponent (default @c 0)
|
||||||
|
*/
|
||||||
template<std::intmax_t Num, std::intmax_t Den = 1, std::intmax_t Exp = 0>
|
template<std::intmax_t Num, std::intmax_t Den = 1, std::intmax_t Exp = 0>
|
||||||
requires(Den != 0)
|
requires(Den != 0)
|
||||||
struct ratio {
|
struct ratio {
|
||||||
|
@@ -18,8 +18,20 @@ constexpr void validate_ascii_string([[maybe_unused]] const char (&s)[P + 1]) no
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace detail
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A symbol text representation
|
||||||
|
*
|
||||||
|
* This class template is responsible for definition and handling of a symbol text
|
||||||
|
* representation. In the libary it is used to define symbols of units and prefixes.
|
||||||
|
* Each symbol can have two versions: Unicode and ASCI-only.
|
||||||
|
*
|
||||||
|
* @tparam StandardCharT Character type to be used for a Unicode representation
|
||||||
|
* @tparam N The size of a Unicode symbol
|
||||||
|
* @tparam M The size of the ASCII-only symbol
|
||||||
|
*/
|
||||||
template<typename StandardCharT, std::size_t N, std::size_t M>
|
template<typename StandardCharT, std::size_t N, std::size_t M>
|
||||||
struct basic_symbol_text {
|
struct basic_symbol_text {
|
||||||
basic_fixed_string<StandardCharT, N> standard_;
|
basic_fixed_string<StandardCharT, N> standard_;
|
||||||
|
Reference in New Issue
Block a user