Skip to content

Commit

Permalink
🩹 Guard exception definition when disabled
Browse files Browse the repository at this point in the history
When the preprocessor token `NOT_NULL_EXCEPTIONS_DISABLED` is defined,
all exception-related code -- including the exception itself -- should
no longer be emitted. However, a bug in the implementation is
resulting in the _definition_ of the constructor to be present, while
the class declaration is not present -- resulting in compile-errors.

This guards the constructor body definition as well so that this will
not occur.
  • Loading branch information
bitwizeshift committed Dec 19, 2020
1 parent 1ddf1a9 commit c839cb1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/not_null.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ inline namespace bitwizeshift {
} // inline namespace bitwizeshift
} // namespace cpp

#if !defined(NOT_NULL_DISABLE_EXCEPTIONS)

inline
NOT_NULL_NS_IMPL::not_null_contract_violation::not_null_contract_violation()
: logic_error{
Expand All @@ -651,6 +653,8 @@ NOT_NULL_NS_IMPL::not_null_contract_violation::not_null_contract_violation()

}

#endif // !defined(NOT_NULL_DISABLE_EXCEPTIONS)

//=============================================================================
// detail utilities : not_null
//=============================================================================
Expand Down

0 comments on commit c839cb1

Please sign in to comment.