Merge branch 'master' of github.com:mpusz/units

This commit is contained in:
Mateusz Pusz committed 2023-06-19 14:02:39 +02:00
commit dde5bcab7e
6 files changed
+30 -26

No files matched your search

+2 -2
View File
@@ -350,8 +350,8 @@ private:
f.specs.unit.separator = mp_units::unit_symbol_separator::space;
else {
if (f.specs.unit.encoding == mp_units::text_encoding::ascii)
throw UNITS_STD_FMT::format_error("dot unit separator allowed only for Unicode encoding");
f.specs.unit.separator = mp_units::unit_symbol_separator::dot;
throw UNITS_STD_FMT::format_error("half_high_dot unit separator allowed only for Unicode encoding");
f.specs.unit.separator = mp_units::unit_symbol_separator::half_high_dot;
}
}
@@ -66,11 +66,12 @@ concept CastableNumber = CommonTypeWith<T, std::intmax_t> && ScalableNumber<std:
// TODO Fix it according to sudo_cast implementation
template<typename T>
concept Scalable = CastableNumber<T> ||
(requires { typename T::value_type; } && CastableNumber<typename T::value_type> &&
ScalableNumber<T, std::common_type_t<typename T::value_type, std::intmax_t>>) ||
(requires { typename T::element_type; } && CastableNumber<typename T::element_type> &&
ScalableNumber<T, std::common_type_t<typename T::element_type, std::intmax_t>>);
concept Scalable =
CastableNumber<T> ||
(requires { typename T::value_type; } && CastableNumber<typename T::value_type> &&
ScalableNumber<T, std::common_type_t<typename T::value_type, std::intmax_t>>) ||
(requires { typename T::element_type; } && CastableNumber<std::remove_reference_t<typename T::element_type>> &&
ScalableNumber<T, std::common_type_t<std::remove_reference_t<typename T::element_type>, std::intmax_t>>);
} // namespace detail
@@ -42,12 +42,14 @@ template<typename Rep>
inline constexpr bool treat_as_floating_point = std::is_floating_point_v<Rep>;
template<typename Rep>
requires requires { typename Rep::value_type; }
inline constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<typename Rep::value_type>;
template<typename Rep>
requires requires { typename Rep::element_type; }
inline constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<typename Rep::element_type>;
requires requires { typename Rep::value_type; } || requires { typename Rep::element_type; }
inline constexpr bool treat_as_floating_point<Rep> = requires {
typename Rep::value_type;
requires treat_as_floating_point<typename Rep::value_type>;
} || requires {
typename Rep::element_type;
requires treat_as_floating_point<std::remove_reference_t<typename Rep::element_type>>;
};
/**
* @brief Specifies a type to have a scalar character
+5 -4
View File
@@ -648,8 +648,8 @@ enum class unit_symbol_solidus {
};
enum class unit_symbol_separator {
space, // kg m²/s²
dot, // kg⋅m²/s² (valid only for unicode encoding)
space, // kg m²/s²
half_high_dot, // kg⋅m²/s² (valid only for unicode encoding)
default_separator = space
};
@@ -681,9 +681,10 @@ constexpr Out copy(const basic_symbol_text<UnicodeCharT, N, M>& txt, text_encodi
template<typename CharT, std::output_iterator<CharT> Out>
constexpr Out print_separator(Out out, unit_symbol_formatting fmt)
{
if (fmt.separator == unit_symbol_separator::dot) {
if (fmt.separator == unit_symbol_separator::half_high_dot) {
if (fmt.encoding != text_encoding::unicode)
throw std::invalid_argument("'unit_symbol_separator::dot' can be only used with 'text_encoding::unicode'");
throw std::invalid_argument(
"'unit_symbol_separator::half_high_dot' can be only used with 'text_encoding::unicode'");
copy(std::string_view("⋅"), out);
} else {
*out++ = ' ';