osrm-backend/src/util/assert.cpp
Daniel Patterson 50d9632ed7
Upgrade formatting to clang-format 10 (#5895)
* Update formatting tools to clang-format-10

* Reformat using clang-format-10.0.09
2020-11-26 07:21:39 -08:00

36 lines
1003 B
C++

#include <boost/assert.hpp>
#include <exception>
#include <iostream>
#include <thread>
namespace
{
// We hard-abort on assertion violations.
[[noreturn]] void assertion_failed_msg_helper(
char const *expr, char const *msg, char const *function, char const *file, long line)
{
const auto tid = std::this_thread::get_id();
std::cerr << "[assert][" << tid << "] " << file << ":" << line << "\nin: " << function << ": "
<< expr << "\n"
<< msg;
std::terminate();
}
} // namespace
// Boost.Assert only declares the following two functions and let's us define them here.
namespace boost
{
void assertion_failed(char const *expr, char const *function, char const *file, long line)
{
::assertion_failed_msg_helper(expr, "", function, file, line);
}
void assertion_failed_msg(
char const *expr, char const *msg, char const *function, char const *file, long line)
{
::assertion_failed_msg_helper(expr, msg, function, file, line);
}
} // namespace boost