dsplib
1.1.0
C++ DSP library for MATLAB-like coding
Loading...
Searching...
No Matches
include
dsplib
assert.h
1
#pragma once
2
3
#include <dsplib/defs.h>
4
#include <cassert>
5
6
#ifdef DSPLIB_NO_EXCEPTIONS
7
8
#include <iostream>
9
10
//TODO: add filename to message
11
#define DSPLIB_THROW(MSG) \
12
std::cerr << (std::string("dsplib: ") + MSG) << std::endl; \
13
std::abort();
14
15
#else
16
17
#include <stdexcept>
18
19
#define DSPLIB_THROW(MSG) throw std::runtime_error(std::string("dsplib: ") + MSG);
20
21
#endif
22
23
#define DSPLIB_ASSERT(condition, message) \
24
if (!(condition)) { \
25
DSPLIB_THROW(message); \
26
}
27
28
#ifdef _MSC_VER
29
#define DSPLIB_ASSUME(cond) \
30
assert(cond); \
31
__assume(cond);
32
#elif defined(__clang__)
33
#define DSPLIB_ASSUME(cond) \
34
assert(cond); \
35
__builtin_assume(cond)
36
#elif defined(__GNUC__)
37
#define DSPLIB_ASSUME(cond) \
38
assert(cond); \
39
((cond) ? static_cast<void>(0) : __builtin_unreachable());
40
#else
41
#define DSPLIB_ASSUME(cond) \
42
assert(cond); \
43
static_cast<void>((cond) ? 0 : 0);
44
#endif
Generated by
1.9.8