From 329439e3d1ac46c8b69ad03d34ecd509f40c3fa3 Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sat, 1 Feb 2025 19:42:25 -0600 Subject: [PATCH] Constexpr fix --- include/cpptrace/basic.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/cpptrace/basic.hpp b/include/cpptrace/basic.hpp index b32b0c7..e2d2f58 100644 --- a/include/cpptrace/basic.hpp +++ b/include/cpptrace/basic.hpp @@ -31,6 +31,12 @@ # endif #endif +#if __cplusplus >= 201703L + #define CONSTEXPR_SINCE_CPP17 constexpr +#else + #define CONSTEXPR_SINCE_CPP17 +#endif + #ifdef _MSC_VER #define CPPTRACE_FORCE_NO_INLINE __declspec(noinline) #else @@ -105,7 +111,7 @@ namespace cpptrace { constexpr bool has_value() const noexcept { return raw_value != null_value(); } - constexpr T& value() noexcept { + CONSTEXPR_SINCE_CPP17 T& value() noexcept { return raw_value; } constexpr const T& value() const noexcept { @@ -114,10 +120,10 @@ namespace cpptrace { constexpr T value_or(T alternative) const noexcept { return has_value() ? raw_value : alternative; } - constexpr void swap(nullable& other) noexcept { + CONSTEXPR_SINCE_CPP17 void swap(nullable& other) noexcept { std::swap(raw_value, other.raw_value); } - constexpr void reset() noexcept { + CONSTEXPR_SINCE_CPP17 void reset() noexcept { raw_value = (std::numeric_limits::max)(); } constexpr bool operator==(const nullable& other) const noexcept {