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
#include <mp-units/ext/format.h>
#ifndef MP_UNITS_IMPORT_STD
#include <chrono>
#include <cmath>
#include <locale>
#include <ostream>

View File

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