proconlib

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub anqooqie/proconlib

:heavy_check_mark: Assertion macro (tools/assert_that.hpp)

#define assert_that(cond) do {\
  if (!(cond)) {\
    std::cerr << __FILE__ << ':' << __LINE__ << ": " << __func__ << ": Assertion `" << #cond << "' failed." << '\n';\
    std::exit(EXIT_FAILURE);\
  }\
} while (false)

It asserts that cond holds. If cond is false, it outputs the debug information to std::cerr and terminates the program with exit status EXIT_FAILURE.

The macro is always enabled regardless of NDEBUG unlike assert.

Constraints

Time Complexity

License

Author

Verified with

Code

#ifndef TOOLS_ASSERT_THAT_HPP
#define TOOLS_ASSERT_THAT_HPP

#include <iostream>
#include <cstdlib>

#define assert_that_impl(cond, file, line, func) do {\
  if (!cond) {\
    ::std::cerr << file << ':' << line << ": " << func << ": Assertion `" << #cond << "' failed." << '\n';\
    ::std::exit(EXIT_FAILURE);\
  }\
} while (false)
#define assert_that(...) assert_that_impl((__VA_ARGS__), __FILE__, __LINE__, __func__)

#endif
#line 1 "tools/assert_that.hpp"



#include <iostream>
#include <cstdlib>

#define assert_that_impl(cond, file, line, func) do {\
  if (!cond) {\
    ::std::cerr << file << ':' << line << ": " << func << ": Assertion `" << #cond << "' failed." << '\n';\
    ::std::exit(EXIT_FAILURE);\
  }\
} while (false)
#define assert_that(...) assert_that_impl((__VA_ARGS__), __FILE__, __LINE__, __func__)


Back to top page