DiSMEC++
throw_error.h File Reference
#include "spdlog/fmt/fmt.h"

Go to the source code of this file.

Macros

#define THROW_EXCEPTION(exception_type, ...)
 
#define ALWAYS_ASSERT_EQUAL(x, y, msg)
 

Macro Definition Documentation

◆ ALWAYS_ASSERT_EQUAL

#define ALWAYS_ASSERT_EQUAL (   x,
  y,
  msg 
)
Value:
{ \
auto v1=(x); \
auto v2=(y); \
if(v1 != v2) { \
THROW_EXCEPTION(std::invalid_argument, msg, v1, v2); \
}}

This macro adds a check that two values are equal. This check is added both in debug and release mode. If the check fails, a std::invalid_argument exception is raised with the given message. The message should contain two placeholders {} which will be filled with the two values.

Definition at line 24 of file throw_error.h.

◆ THROW_EXCEPTION

#define THROW_EXCEPTION (   exception_type,
  ... 
)
Value:
[&]() __attribute__((cold, noreturn)) { \
throw exception_type( fmt::format(__VA_ARGS__) ); \
}();
void __attribute__((hot)) htd_sum_new(const std

this is a utility macro that wraps the formatting of an error message and throwing of std::runtime_error into an immediately-executed lambda that is marked with the cold attribute. This can help the optimizer.

Definition at line 16 of file throw_error.h.