forked from mpusz/mp-units
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
|
#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>
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user