mcpp index

compat.libassert

#include

libassert — the ergonomic assertion library, with expression decomposition and stack traces

#include <libassert/assert.hpp>
mcpp add compat.libassert@2.2.1

用法

來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。

// Behavioral test — compat.libassert decomposes an expression and reports the
// values in it, which is the whole reason to use it over <cassert>.
//
// A passing assertion proves almost nothing, so the test drives the FAILING
// path: it installs a failure handler, provokes a failed assertion, and reads
// what libassert produced. `LIBASSERT_ASSERT` carries `LIBASSERT_NOP_ACTION`,
// so a handler that returns lets execution continue — which is what makes this
// testable in-process rather than through an abort.
//
// It is also the proof that the transitive dependency arrives: the failure
// object hands back a `cpptrace::stacktrace`, and this project declares only
// libassert.
//
// No `import std;` — libassert's headers are textual over the standard library.
#include <libassert/assert.hpp>
#include <libassert/version.hpp>
// libassert's own header only FORWARD-declares cpptrace::stacktrace
// (cpptrace/forward.hpp), so calling .frames on it needs the complete type.
// Including cpptrace's public header here works only because compat.cpptrace's
// include directory reaches this project transitively through libassert — this
// project declares no cpptrace dependency of its own. The include is therefore
// part of the assertion, not incidental.
// …

tests/examples/libassert/tests/assertions.cpp · 專案 tests/examples/libassert

建置

targets
libassert (lib)
language
c++23
C standard
c11
import std
no
include dirs
mcpp_generated, */include

原始檔 (1)

  • */src/*.cpp

產生的檔案

  • mcpp_generated/libassert/platform.hpp
  • mcpp_generated/libassert/version.hpp

版本

版本平台 鏡像sha256
2.2.1 最新 LinuxWindowsmacOS CN GLOBAL a7882ff2922c…