message: [crispy] assert: Adds ability to override assertion error reporting handler.
diff: @@ -32,20 +32,56 @@ namespace crispy
  #undef Ensure
  #endif
  -inline void check(bool _cond, std::string_view _text,
  +/// Function signature for custom assertion failure handlers.
  +using fail_handler_t = std::function<void(std::string_view,
  + std::string_view,
  + std::string_view,
  + int)>;
  +
  +namespace detail
  +{
  + inline fail_handler_t& fail_handler()
  + {
  + static fail_handler_t storage{};
  + return storage;
  + }
  +
  + inline void fail(std::string_view _text,
  std::string_view _message,
  std::string_view _file, int _line)
  {
  - if (_cond)
  - return;
  -
  + if (fail_handler())
  + fail_handler()(_text, _message, _file, _line);
  + else
  + {
  fmt::print("[{}:{}] {} {}\n", _file, _line, _message, _text);
  std::terminate();
  }
  + }
  +
  + inline void check(bool _cond, std::string_view _text,
  + std::string_view _message,
  + std::string_view _file, int _line)
  + {
  + if (!_cond)
  + {
  + fail(_text, _message, _file, _line);
  + }
  + }
  +}
  +
  +/// Sets a custom fail handler to be invoked when Expects() or Ensures() fails.
  +///
  +/// This handler is supposed to report and terminate but may very well
  +/// just ignore either or both.
  +inline void set_fail_handler(fail_handler_t _handler)
  +{
  + detail::fail_handler() = std::move(_handler);
  +}
  #define Expects(cond) \
  do { \
  - ::crispy::check( \
  + ::crispy::detail::check( \
  (cond), #cond, \
  "Precondition failed.", \
  __FILE__, __LINE__ \
  @@ -54,7 +90,7 @@ inline void check(bool _cond, std::string_view _text,
  #define Ensure(cond) \
  do { \
  - ::crispy::check( \
  + ::crispy::detail::check( \
  (cond), #cond, \
  "Postcondition failed.", \
  __FILE__, __LINE__ \
  