forked from mpusz/mp-units
build: COMP_XXX
renamed to UNITS_COMP_XXX
This commit is contained in:
@@ -74,7 +74,7 @@ enum class downcast_mode {
|
||||
|
||||
template<typename Target, Downcastable T, downcast_mode mode = static_cast<downcast_mode>(UNITS_DOWNCAST_MODE)>
|
||||
struct downcast_dispatch : std::conditional_t<mode == downcast_mode::off, T,
|
||||
#ifdef COMP_MSVC
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
downcast_child<Target, T>> {};
|
||||
#else
|
||||
std::conditional_t<mode == downcast_mode::automatic && has_downcast_guide<T>,
|
||||
|
18
src/include/units/bits/external/hacks.h
vendored
18
src/include/units/bits/external/hacks.h
vendored
@@ -23,15 +23,15 @@
|
||||
#pragma once
|
||||
|
||||
#if __clang__
|
||||
#define COMP_CLANG __clang_major__
|
||||
#define UNITS_COMP_CLANG __clang_major__
|
||||
#elif __GNUC__
|
||||
#define COMP_GCC __GNUC__
|
||||
#define COMP_GCC_MINOR __GNUC_MINOR__
|
||||
#define UNITS_COMP_GCC __GNUC__
|
||||
#define UNITS_COMP_GCC_MINOR __GNUC_MINOR__
|
||||
#elif _MSC_VER
|
||||
#define COMP_MSVC _MSC_VER
|
||||
#define UNITS_COMP_MSVC _MSC_VER
|
||||
#endif
|
||||
|
||||
#if COMP_CLANG
|
||||
#if UNITS_COMP_CLANG
|
||||
|
||||
#include <ciso646>
|
||||
#if _LIBCPP_VERSION
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if COMP_CLANG == 12 && UNITS_LIBCXX
|
||||
#if UNITS_COMP_CLANG == 12 && UNITS_LIBCXX
|
||||
|
||||
#include <concepts/compare.hpp>
|
||||
#include <concepts/concepts.hpp>
|
||||
@@ -55,7 +55,7 @@
|
||||
#include <concepts>
|
||||
#include <compare>
|
||||
|
||||
#if COMP_MSVC || COMP_CLANG
|
||||
#if UNITS_COMP_MSVC || UNITS_COMP_CLANG
|
||||
|
||||
#define TYPENAME typename
|
||||
|
||||
@@ -68,12 +68,12 @@
|
||||
|
||||
namespace std {
|
||||
|
||||
#if COMP_GCC
|
||||
#if UNITS_COMP_GCC
|
||||
|
||||
template<class T>
|
||||
concept default_constructible = constructible_from<T>;
|
||||
|
||||
#elif COMP_CLANG && UNITS_LIBCXX
|
||||
#elif UNITS_COMP_CLANG && UNITS_LIBCXX
|
||||
|
||||
// concepts
|
||||
using concepts::common_with;
|
||||
|
@@ -357,7 +357,7 @@ public:
|
||||
|
||||
[[nodiscard]] friend constexpr auto operator<=>(const quantity& lhs, const quantity& rhs)
|
||||
requires std::three_way_comparable<rep>
|
||||
#if COMP_GCC == 10 && COMP_GCC_MINOR >= 2
|
||||
#if UNITS_COMP_GCC == 10 && UNITS_COMP_GCC_MINOR >= 2
|
||||
= default;
|
||||
#else
|
||||
{
|
||||
|
@@ -1001,7 +1001,7 @@ TEST_CASE("precision specification", "[text][fmt]")
|
||||
CHECK(fmt::format("{:%.0Q %q}", 1.2345_q_m) == "1 m");
|
||||
CHECK(fmt::format("{:%.1Q %q}", 1.2345_q_m) == "1.2 m");
|
||||
CHECK(fmt::format("{:%.2Q %q}", 1.2345_q_m) == "1.23 m");
|
||||
#ifdef COMP_MSVC
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
CHECK(fmt::format("{:%.3Q %q}", 1.2345_q_m) == "1.234 m");
|
||||
#else
|
||||
CHECK(fmt::format("{:%.3Q %q}", 1.2345_q_m) == "1.235 m");
|
||||
@@ -1016,7 +1016,7 @@ TEST_CASE("precision specification", "[text][fmt]")
|
||||
CHECK(fmt::format("{:%.0Q}", 1.2345_q_m) == "1");
|
||||
CHECK(fmt::format("{:%.1Q}", 1.2345_q_m) == "1.2");
|
||||
CHECK(fmt::format("{:%.2Q}", 1.2345_q_m) == "1.23");
|
||||
#ifdef COMP_MSVC
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
CHECK(fmt::format("{:%.3Q}", 1.2345_q_m) == "1.234");
|
||||
#else
|
||||
CHECK(fmt::format("{:%.3Q}", 1.2345_q_m) == "1.235");
|
||||
@@ -1051,7 +1051,7 @@ TEST_CASE("type specification", "[text][fmt]")
|
||||
CHECK(fmt::format("{:%xQ %q}", 42_q_m) == "2a m");
|
||||
CHECK(fmt::format("{:%XQ %q}", 42_q_m) == "2A m");
|
||||
|
||||
#ifdef COMP_MSVC
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
CHECK(fmt::format("{:%aQ %q}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0 m");
|
||||
CHECK(fmt::format("{:%.3aQ %q}", 1.2345678_q_m) == "0x1.3c1p+0 m");
|
||||
CHECK(fmt::format("{:%AQ %q}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0 m");
|
||||
@@ -1085,7 +1085,7 @@ TEST_CASE("type specification", "[text][fmt]")
|
||||
CHECK(fmt::format("{:%xQ}", 42_q_m) == "2a");
|
||||
CHECK(fmt::format("{:%XQ}", 42_q_m) == "2A");
|
||||
|
||||
#ifdef COMP_MSVC
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
CHECK(fmt::format("{:%aQ}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0");
|
||||
CHECK(fmt::format("{:%.3aQ}", 1.2345678_q_m) == "0x1.3c1p+0");
|
||||
CHECK(fmt::format("{:%AQ}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0");
|
||||
|
@@ -73,7 +73,7 @@ TEST_CASE("absolute functions on quantity returns the absolute value", "[math][a
|
||||
REQUIRE(abs(-1_q_m) == 1_q_m);
|
||||
}
|
||||
|
||||
#ifndef COMP_MSVC
|
||||
#ifndef UNITS_COMP_MSVC
|
||||
SECTION ("floating-point representation")
|
||||
{
|
||||
REQUIRE(abs(-1._q_m) == 1_q_m);
|
||||
@@ -88,7 +88,7 @@ TEST_CASE("absolute functions on quantity returns the absolute value", "[math][a
|
||||
REQUIRE(abs(1_q_m) == 1_q_m);
|
||||
}
|
||||
|
||||
#ifndef COMP_MSVC
|
||||
#ifndef UNITS_COMP_MSVC
|
||||
SECTION ("floating-point representation")
|
||||
{
|
||||
REQUIRE(abs(1._q_m) == 1_q_m);
|
||||
|
@@ -144,11 +144,11 @@ static_assert(QuantityValue<min_expl<>>);
|
||||
static_assert(!QuantityValue<min_expl<1>>);
|
||||
static_assert(!QuantityValue<min_expl<2>>);
|
||||
static_assert(!QuantityValue<min_expl<3>>);
|
||||
#if !defined(COMP_GCC) || COMP_GCC > 10 || COMP_GCC_MINOR > 1
|
||||
#if !defined(UNITS_COMP_GCC) || UNITS_COMP_GCC > 10 || UNITS_COMP_GCC_MINOR > 1
|
||||
static_assert(!QuantityValue<min_expl<4>>);
|
||||
#endif
|
||||
static_assert(!QuantityValue<min_expl<5>>);
|
||||
#if !defined(COMP_GCC) || COMP_GCC > 10 || COMP_GCC_MINOR > 1
|
||||
#if !defined(UNITS_COMP_GCC) || UNITS_COMP_GCC > 10 || UNITS_COMP_GCC_MINOR > 1
|
||||
static_assert(!QuantityValue<min_expl<6>>);
|
||||
#endif
|
||||
static_assert(!QuantityValue<min_expl<7>>);
|
||||
|
@@ -176,7 +176,7 @@ static_assert(width<metre, double>::max().common().count() == std::numeric_limit
|
||||
////////////////////////
|
||||
|
||||
// default initialization
|
||||
#if !defined(COMP_MSVC)
|
||||
#if !defined(UNITS_COMP_MSVC)
|
||||
static_assert([] {
|
||||
const auto read_uninitialized_quantity = [] {
|
||||
width<metre> w;
|
||||
@@ -367,7 +367,7 @@ static_assert(!std::is_assignable_v<width<metre, int>, width<millimetre, int>>);
|
||||
// member operators
|
||||
/////////////////////
|
||||
|
||||
#if !defined(COMP_MSVC) || defined(NDEBUG)
|
||||
#if !defined(UNITS_COMP_MSVC) || defined(NDEBUG)
|
||||
static_assert([]() {
|
||||
width<metre, int> w(1 * m);
|
||||
assert(+w.common() == 1 * m);
|
||||
|
@@ -188,7 +188,7 @@ static_assert(abscissa<metre, double>::max().relative().common().count() == std:
|
||||
////////////////////////
|
||||
|
||||
// default initialization
|
||||
#if !defined(COMP_MSVC)
|
||||
#if !defined(UNITS_COMP_MSVC)
|
||||
static_assert([] {
|
||||
const auto read_uninitialized_quantity = [] {
|
||||
abscissa<metre> w;
|
||||
@@ -396,7 +396,7 @@ static_assert(!std::is_assignable_v<abscissa<metre, int>, abscissa<millimetre, i
|
||||
// member operators
|
||||
/////////////////////
|
||||
|
||||
#if !defined(COMP_MSVC) || defined(NDEBUG)
|
||||
#if !defined(UNITS_COMP_MSVC) || defined(NDEBUG)
|
||||
static_assert([]() {
|
||||
const width<metre, int> w(1 * m);
|
||||
[[maybe_unused]] quantity_point_kind x(w);
|
||||
|
@@ -52,7 +52,7 @@ constexpr auto cgs_cm = cgs::unit_constants::cm;
|
||||
static_assert(sizeof(length<metre>) == sizeof(double));
|
||||
static_assert(sizeof(length<metre, short>) == sizeof(short));
|
||||
|
||||
#if COMP_GCC != 10 || COMP_GCC_MINOR > 2
|
||||
#if UNITS_COMP_GCC != 10 || UNITS_COMP_GCC_MINOR > 2
|
||||
template<template<typename, typename, typename> typename Q>
|
||||
concept invalid_types = requires {
|
||||
requires !requires { typename Q<dim_length, second, int>; }; // unit of a different dimension
|
||||
@@ -303,7 +303,7 @@ static_assert((std::uint8_t(255) * m %= quantity(257)).count() == [] { std::uint
|
||||
// TODO: Fix
|
||||
static_assert((std::uint8_t(255) * m %= 257 * m).count() != [] { std::uint8_t ui(255); return ui %= 257; }());
|
||||
|
||||
#ifndef COMP_MSVC // TODO ICE (https://developercommunity2.visualstudio.com/t/ICE-on-a-constexpr-operator-in-mp-unit/1302907)
|
||||
#ifndef UNITS_COMP_MSVC // TODO ICE (https://developercommunity2.visualstudio.com/t/ICE-on-a-constexpr-operator-in-mp-unit/1302907)
|
||||
// next two lines trigger conversions warnings
|
||||
// (warning disabled in CMake for this file)
|
||||
static_assert((22_q_m *= 33.33).count() == 733);
|
||||
|
@@ -97,7 +97,7 @@ constexpr T construct_from_only(Us... us) {
|
||||
return construct_from<T>(us...);
|
||||
}
|
||||
|
||||
#if !defined(COMP_GCC)
|
||||
#if !defined(UNITS_COMP_GCC)
|
||||
template<template<typename...> typename T, typename = std::void_t<>, typename... Us>
|
||||
concept ctad_constructible_from_ = requires(Us... us) { T(us...); };
|
||||
#else
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
#if defined(COMP_MSVC)
|
||||
#if defined(UNITS_COMP_MSVC)
|
||||
#pragma warning( disable : 4459 ) // Disable shadowing warning.
|
||||
#endif
|
||||
|
||||
@@ -82,7 +82,7 @@ static_assert(is_same_v<decltype(120.L * km / 2 / h), decltype(60._q_km_per_h)>)
|
||||
|
||||
static_assert(1. / 4 * m2 == 1._q_m2 / 4);
|
||||
|
||||
#if !defined(COMP_CLANG) // -Wshadow
|
||||
#if !defined(UNITS_COMP_CLANG) // -Wshadow
|
||||
static_assert([] {
|
||||
Speed auto v0 = 10 * m / s;
|
||||
signed s = 2; // hides ^
|
||||
|
@@ -43,7 +43,7 @@ struct dim_time : base_dimension<"time", second> {};
|
||||
|
||||
struct kelvin : named_unit<kelvin, "K", no_prefix> {};
|
||||
|
||||
#if !COMP_MSVC
|
||||
#if !UNITS_COMP_MSVC
|
||||
static_assert([]<Prefix P>(P) { return !requires { typename prefixed_unit<struct kilokelvin, P, kelvin>; }; }(si::kilo{})); // no prefix allowed
|
||||
#endif
|
||||
|
||||
@@ -59,7 +59,7 @@ static_assert(compare<downcast<scaled_unit<ratio(yard::ratio.num, yard::ratio.de
|
||||
static_assert(compare<downcast<scaled_unit<yard::ratio * ratio(1, 3), metre>>, foot>);
|
||||
static_assert(compare<downcast<scaled_unit<kilometre::ratio / hour::ratio, metre_per_second>>, kilometre_per_hour>);
|
||||
|
||||
#if !COMP_MSVC
|
||||
#if !UNITS_COMP_MSVC
|
||||
static_assert([]<ratio R>() { return !requires { typename scaled_unit<R, metre>; }; }.template operator()<ratio(-1, 1)>()); // negative unit ratio
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user