kaycxx-assert
C++ assertion library
Loading...
Searching...
No Matches
kaycxx
assert
assert_not_null.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 Klaus Reimer <k@ailis.de>
2
// SPDX-License-Identifier: MIT
3
4
#pragma once
5
11
#include <string_view>
12
13
#include <
kaycxx/assert/assertion_error.hpp
>
14
#include <kaycxx/assert/detail/source_location.hpp>
15
#include <kaycxx/assert/detail/nullable.hpp>
16
17
namespace
kaycxx::assert
{
18
30
template
<detail::nullable T>
31
void
assert_not_null
(
32
T
const
& actual,
33
std::string_view reason = {},
34
std::optional<std::source_location> location = KAYCXX_ASSERT_DEFAULT_SOURCE
35
) {
36
if
(actual ==
nullptr
) {
37
throw
assertion_error(
"Expected <null> not to be null"
, reason,
"null"
,
"null"
, location);
38
}
39
}
40
41
}
// namespace kaycxx::assert
assertion_error.hpp
Defines the assertion_error type.
kaycxx::assert
Assertion functions and related types.
Definition
assert.hpp:15
kaycxx::assert::assert_not_null
void assert_not_null(T const &actual, std::string_view reason={}, std::optional< std::source_location > location=KAYCXX_ASSERT_DEFAULT_SOURCE)
Asserts that the argument is not null.
Definition
assert_not_null.hpp:31
Generated by
1.9.8