Sleipnir C++ API
Loading...
Searching...
No Matches
assert.hpp
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#ifdef SLEIPNIR_PYTHON
6#include <format>
7#include <source_location>
8#include <stdexcept>
9
11#define slp_assert(condition) \
12 do { \
13 if (!(condition)) { \
14 auto location = std::source_location::current(); \
15 throw std::invalid_argument(std::format( \
16 "{}:{}: {}: Assertion `{}' failed.", location.file_name(), \
17 location.line(), location.function_name(), #condition)); \
18 } \
19 } while (0)
20#else
21#include <cassert>
22
24#define slp_assert(condition) assert(condition)
25#endif