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