Skip to content

Commit

Permalink
Move some code from core.h to format.h where it is used
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Nov 29, 2020
1 parent 9ed0a98 commit 5a49356
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 0 additions & 14 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@
# define FMT_CONSTEXPR_DECL
#endif

#if __cplusplus >= 202002L
# define FMT_CONSTEXPR20 constexpr
#else
# define FMT_CONSTEXPR20 inline
#endif

#ifndef FMT_OVERRIDE
# if FMT_HAS_FEATURE(cxx_override_control) || \
(FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900
Expand Down Expand Up @@ -289,14 +283,6 @@ struct monostate {};

namespace detail {

constexpr bool is_constant_evaluated() FMT_DETECTED_NOEXCEPT {
#ifdef __cpp_lib_is_constant_evaluated
return std::is_constant_evaluated();
#else
return false;
#endif
}

// A helper function to suppress "conditional expression is constant" warnings.
template <typename T> constexpr T const_check(T value) { return value; }

Expand Down
14 changes: 14 additions & 0 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ FMT_END_NAMESPACE
FMT_BEGIN_NAMESPACE
namespace detail {

#if __cplusplus >= 202002L
# define FMT_CONSTEXPR20 constexpr
#else
# define FMT_CONSTEXPR20 inline
#endif

constexpr bool is_constant_evaluated() FMT_DETECTED_NOEXCEPT {
#ifdef __cpp_lib_is_constant_evaluated
return std::is_constant_evaluated();
#else
return false;
#endif
}

// An equivalent of `*reinterpret_cast<Dest*>(&source)` that doesn't have
// undefined behavior (e.g. due to type aliasing).
// Example: uint64_t d = bit_cast<uint64_t>(2.718);
Expand Down

0 comments on commit 5a49356

Please sign in to comment.