forked from mpusz/mp-units
refactor: FMT macros moved to compat_macros.h
This commit is contained in:
@@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <mp-units/bits/external/hacks.h> // IWYU pragma: keep
|
|
||||||
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
|
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
|
||||||
#include <mp-units/bits/external/algorithm.h>
|
#include <mp-units/bits/external/algorithm.h>
|
||||||
|
#include <mp-units/compat_macros.h> // IWYU pragma: keep
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
// IWYU pragma: begin_exports
|
||||||
#include <compare>
|
#include <compare>
|
||||||
|
43
src/core/include/mp-units/bits/external/hacks.h
vendored
43
src/core/include/mp-units/bits/external/hacks.h
vendored
@@ -108,46 +108,3 @@
|
|||||||
#define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X) X
|
#define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X) X
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MP_UNITS_USE_FMTLIB
|
|
||||||
|
|
||||||
MP_UNITS_DIAGNOSTIC_PUSH
|
|
||||||
MP_UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
|
||||||
MP_UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
|
||||||
#include <fmt/format.h>
|
|
||||||
MP_UNITS_DIAGNOSTIC_POP
|
|
||||||
|
|
||||||
#define MP_UNITS_STD_FMT fmt
|
|
||||||
#define MP_UNITS_FMT_LOCALE(loc) (loc).template get<std::locale>()
|
|
||||||
#define MP_UNITS_FMT_TO_ARG_ID(arg) (arg)
|
|
||||||
#define MP_UNITS_FMT_FROM_ARG_ID(arg) (arg)
|
|
||||||
|
|
||||||
// This re-uses code from fmt;
|
|
||||||
#if FMT_EXCEPTIONS
|
|
||||||
#if FMT_MSC_VERSION || defined(__NVCC__)
|
|
||||||
#define MP_UNITS_THROW(x) ::fmt::detail::do_throw(x)
|
|
||||||
#else
|
|
||||||
#define MP_UNITS_THROW(x) throw x
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define MP_UNITS_THROW(x) \
|
|
||||||
do { \
|
|
||||||
FMT_ASSERT(false, (x).what()); \
|
|
||||||
} while (false)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#if !defined __cpp_lib_format && !defined MP_UNITS_COMP_CLANG
|
|
||||||
#error "std::formatting facility not supported"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <format>
|
|
||||||
|
|
||||||
#define MP_UNITS_STD_FMT std
|
|
||||||
#define MP_UNITS_FMT_LOCALE(loc) loc
|
|
||||||
#define MP_UNITS_FMT_TO_ARG_ID(arg) static_cast<std::size_t>(arg)
|
|
||||||
#define MP_UNITS_FMT_FROM_ARG_ID(arg) static_cast<int>(arg)
|
|
||||||
#define MP_UNITS_THROW(arg) throw arg
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -37,3 +37,46 @@
|
|||||||
} name
|
} name
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MP_UNITS_USE_FMTLIB
|
||||||
|
|
||||||
|
MP_UNITS_DIAGNOSTIC_PUSH
|
||||||
|
MP_UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
||||||
|
MP_UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
||||||
|
#include <fmt/format.h>
|
||||||
|
MP_UNITS_DIAGNOSTIC_POP
|
||||||
|
|
||||||
|
#define MP_UNITS_STD_FMT fmt
|
||||||
|
#define MP_UNITS_FMT_LOCALE(loc) (loc).template get<std::locale>()
|
||||||
|
#define MP_UNITS_FMT_TO_ARG_ID(arg) (arg)
|
||||||
|
#define MP_UNITS_FMT_FROM_ARG_ID(arg) (arg)
|
||||||
|
|
||||||
|
// This re-uses code from fmt;
|
||||||
|
#if FMT_EXCEPTIONS
|
||||||
|
#if FMT_MSC_VERSION || defined(__NVCC__)
|
||||||
|
#define MP_UNITS_THROW(x) ::fmt::detail::do_throw(x)
|
||||||
|
#else
|
||||||
|
#define MP_UNITS_THROW(x) throw x
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define MP_UNITS_THROW(x) \
|
||||||
|
do { \
|
||||||
|
FMT_ASSERT(false, (x).what()); \
|
||||||
|
} while (false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if !defined __cpp_lib_format && !defined MP_UNITS_COMP_CLANG
|
||||||
|
#error "std::formatting facility not supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
#define MP_UNITS_STD_FMT std
|
||||||
|
#define MP_UNITS_FMT_LOCALE(loc) loc
|
||||||
|
#define MP_UNITS_FMT_TO_ARG_ID(arg) static_cast<std::size_t>(arg)
|
||||||
|
#define MP_UNITS_FMT_FROM_ARG_ID(arg) static_cast<int>(arg)
|
||||||
|
#define MP_UNITS_THROW(arg) throw arg
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Reference in New Issue
Block a user