Assert.cppm 535 B

12345678910111213141516171819202122232425
  1. module;
  2. export module Core.Assert;
  3. import Core.Std;
  4. import Core.Utility;
  5. import Core.Logger;
  6. export namespace Core {
  7. #ifdef NDEBUG
  8. void inline assert(bool) {
  9. }
  10. #else
  11. void inline assert(
  12. bool b,
  13. const std::source_location& l = std::source_location::current()) {
  14. if(!b) {
  15. Core::logError(
  16. FormatLocation("Assert in function #", l),
  17. getShortFileName(l.file_name()), l.line(), l.function_name());
  18. exitWithHandler(1, l);
  19. }
  20. }
  21. #endif
  22. }