rstd 0.1.0
Loading...
Searching...
No Matches
macro.hpp
1#pragma once
2
3#if defined(_WIN32)
4# define RSTD_OS_WINDOWS 1
5#endif
6
7#if defined(__linux__)
8# define RSTD_OS_LINUX 1
9#endif
10
11#if defined(__APPLE__)
12# define RSTD_OS_APPLE 1
13#endif
14
15#if defined(__unix__) || defined(__APPLE__)
16# define RSTD_OS_UNIX 1
17#endif
18
19#define USE_TRAIT(Class) \
20 using Self = Class; \
21 template<typename, typename> \
22 friend struct rstd::Impl; \
23 template<typename _USE_TRAIT_T> \
24 requires rstd::Impled<Self, rstd::cmp::PartialEq<_USE_TRAIT_T>> \
25 friend bool operator==(const Self& a, const _USE_TRAIT_T& b) noexcept { \
26 return as<rstd::cmp::PartialEq<_USE_TRAIT_T>>(a).eq(b); \
27 }
28
29#ifdef NDEBUG
30# define debug_assert(...) ((void)0)
31# define debug_assert_eq(...) ((void)0)
32#else
33# define debug_assert(EXP, ...) \
34 if (! (EXP)) rstd::assert_fmt(#EXP __VA_OPT__(, ) __VA_ARGS__)
35# define debug_assert_eq(A, B) \
36 if ((A) != (B)) rstd::assert_fmt("(" #A " == " #B ")")
37#endif
38
39#define assert(EXP, ...) \
40 if (! (EXP)) rstd::assert_fmt(#EXP __VA_OPT__(, ) __VA_ARGS__)
41#define assert_eq(A, B) \
42 if ((A) != (B)) rstd::assert_fmt("(" #A " == " #B ")")