mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
refactor: treat_as_floating_point
simplified and extended to use std::chrono::treat_as_floating_point_v
This commit is contained in:
@@ -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>
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user