kaycxx-assert
C++ assertion library
Loading...
Searching...
No Matches
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
14#include <kaycxx/assert/detail/source_location.hpp>
15#include <kaycxx/assert/detail/nullable.hpp>
16
17namespace kaycxx::assert {
18
30template <detail::nullable T>
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
Defines the assertion_error type.
Assertion functions and related types.
Definition assert.hpp:15
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