diff --git a/cth/incl/cth/constants.hpp b/cth/incl/cth/constants.hpp index 451a7d3..843df57 100644 --- a/cth/incl/cth/constants.hpp +++ b/cth/incl/cth/constants.hpp @@ -34,14 +34,12 @@ #define CTH_DEBUG_INLINE_IMPL(code) { code } #define CTH_RELEASE_NOEXCEPT noexcept(false) -#define CTH_RELEASE_CONSTEXPR #else #define CTH_DEBUG_IMPL = default; #define CTH_DEBUG_INLINE_IMPL(code) \ {} #define CTH_RELEASE_NOEXCEPT noexcept(true) -#define CTH_RELEASE_CONSTEXPR constexpr #endif #include diff --git a/cth/incl/cth/ptr/not_null.hpp b/cth/incl/cth/ptr/not_null.hpp index 3a1c5e8..50c3eb7 100644 --- a/cth/incl/cth/ptr/not_null.hpp +++ b/cth/incl/cth/ptr/not_null.hpp @@ -40,12 +40,12 @@ class not_null { static constexpr bool NOEXCEPT_CHECK_VAL = COMPILATION_MODE != CompilationMode::DEBUG; static constexpr bool RELEASE_VAL_NOEXCEPT = NOEXCEPT_ASSIGN && NOEXCEPT_MOVE_CTOR; - static CTH_RELEASE_CONSTEXPR void checkVal(T const& obj) noexcept(NOEXCEPT_CHECK_VAL) { + static constexpr void checkVal(T const& obj) noexcept(NOEXCEPT_CHECK_VAL) { CTH_CRITICAL(obj == Null, "obj must not be Null") {} } public: - CTH_RELEASE_CONSTEXPR not_null(T obj) noexcept(NOEXCEPT_MOVE_CTOR && NOEXCEPT_CHECK_VAL) : + constexpr not_null(T obj) noexcept(NOEXCEPT_MOVE_CTOR && NOEXCEPT_CHECK_VAL) : _obj{std::move(obj)} { not_null::checkVal(_obj); } template requires(std::convertible_to && !std::same_as) diff --git a/cth/tests/src/pointers/not_null_test.cpp b/cth/tests/src/pointers/not_null_test.cpp index 2538624..2fd432d 100644 --- a/cth/tests/src/pointers/not_null_test.cpp +++ b/cth/tests/src/pointers/not_null_test.cpp @@ -14,6 +14,14 @@ struct TestStruct { auto const data = std::make_unique(EXAMPLE_NUMBER); // NOLINT(cert-err58-cpp) +CTH_TEST(not_null, constexpr) { + static_assert([] { + not_null const ptr{&EXAMPLE_NUMBER}; + not_null const copy{ptr}; + return *copy; + }() == EXAMPLE_NUMBER); +} + CTH_TEST(not_null, comparison) { int a = EXAMPLE_NUMBER; int b = EXAMPLE_NUMBER;