Skip to content

Commit

Permalink
Constexpr fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Feb 2, 2025
1 parent 85be7c3 commit 9871ecb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions include/cpptrace/basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
# endif
#endif

#if __cplusplus >= 201703L
#define CONSTEXPR_SINCE_CPP17 constexpr
#endif

#ifdef _MSC_VER
#define CPPTRACE_FORCE_NO_INLINE __declspec(noinline)
#else
Expand Down Expand Up @@ -105,7 +109,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 {
Expand All @@ -114,10 +118,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<T>::max)();
}
constexpr bool operator==(const nullable& other) const noexcept {
Expand Down

0 comments on commit 9871ecb

Please sign in to comment.