CCF
Loading...
Searching...
No Matches
ccf_assert.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
5#include "ccf/ds/logger.h"
6
7#define CCF_ASSERT_FMT_FAIL(...) \
8 CCF_ASSERT(false, fmt::format(__VA_ARGS__).c_str())
9
10#define CCF_ASSERT_FMT(expr, ...) \
11 CCF_ASSERT(expr, fmt::format(__VA_ARGS__).c_str())
12
13#ifndef NDEBUG
14# define CCF_ASSERT(expr, msg) \
15 do \
16 { \
17 if ((expr) == 0) \
18 { \
19 CCF_LOG_FMT(FAIL, "assert") \
20 ("Assertion failed: {} {}", #expr, (msg)); \
21 throw std::logic_error(msg); \
22 } \
23 } while (0)
24#else
25# define CCF_ASSERT(expr, msg) ((void)0)
26#endif /* NDEBUG */