refactor: treat_as_floating_point simplified and extended to use std::chrono::treat_as_floating_point_v

This commit is contained in:
Mateusz Pusz
2024-10-26 19:06:14 +02:00
parent e72f3da6d9
commit 8d24b47948
2 changed files with 10 additions and 5 deletions

View File

@@ -55,6 +55,7 @@
#if MP_UNITS_HOSTED #if MP_UNITS_HOSTED
#include <mp-units/ext/format.h> #include <mp-units/ext/format.h>
#ifndef MP_UNITS_IMPORT_STD #ifndef MP_UNITS_IMPORT_STD
#include <chrono>
#include <cmath> #include <cmath>
#include <locale> #include <locale>
#include <ostream> #include <ostream>

View File

@@ -33,6 +33,9 @@ import std;
#include <concepts> #include <concepts>
#include <limits> #include <limits>
#include <type_traits> #include <type_traits>
#if MP_UNITS_HOSTED
#include <chrono>
#endif
#endif #endif
#endif #endif
@@ -50,11 +53,12 @@ MP_UNITS_EXPORT_BEGIN
* @tparam Rep a representation type for which a type trait is defined * @tparam Rep a representation type for which a type trait is defined
*/ */
template<typename Rep> template<typename Rep>
constexpr bool treat_as_floating_point = std::is_floating_point_v<Rep>; constexpr bool treat_as_floating_point =
#if MP_UNITS_HOSTED
template<typename Rep> std::chrono::treat_as_floating_point_v<value_type_t<Rep>>;
requires requires { typename wrapped_type_t<Rep>; } #else
constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<wrapped_type_t<Rep>>; std::is_floating_point_v<value_type_t<Rep>>;
#endif
/** /**
* @brief Specifies a type to have a scalar character * @brief Specifies a type to have a scalar character