|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
调试断点和断言工具 更多...
宏定义 | |
| #define | NEFORCE_CONSTEXPR_ASSERT(COND) |
| 编译时常量断言 | |
函数 | |
| NEFORCE_NORETURN void | unreachable () noexcept |
| 标记不可达代码路径 | |
| constexpr bool | is_constant_evaluated () noexcept |
| 检查当前上下文是否在常量求值中 | |
| bool | is_debugger_present () |
| 检测当前进程是否正在被调试器附加 | |
| void | debug_assert (bool condition, const char *message=nullptr) |
| 调试断言 | |
| void | breakpoint () noexcept |
| 触发调试断点 | |
| void | breakpoint_if_debugging () |
| 如果正在调试则触发断点 | |
调试断点和断言工具
| #define NEFORCE_CONSTEXPR_ASSERT | ( | COND | ) |
编译时常量断言
在常量求值上下文中进行断言,如果条件为false则触发不可达代码。 仅在C++20及以上版本有效。
在文件 breakpoint.hpp 第 47 行定义.
被这些函数引用 atomic_cmpexch_strong(), atomic_cmpexch_strong_any(), atomic_cmpexch_weak(), atomic_cmpexch_weak_any(), atomic_ref_base< Float, false, true >::atomic_ref_base(), atomic_ref_base< T, false, false >::atomic_ref_base(), atomic_ref_base< T, true, false >::atomic_ref_base(), atomic_semaphore< 1 >::atomic_semaphore(), memory_view< byte_t >::back(), atomic_flag::clear(), atomic_flag::clear(), atomic< T >::compare_exchange_strong(), atomic< T >::compare_exchange_strong(), atomic_base< T * >::compare_exchange_strong(), atomic_base< T * >::compare_exchange_strong(), atomic< T >::compare_exchange_weak(), atomic< T >::compare_exchange_weak(), atomic_base< T * >::compare_exchange_weak(), atomic_base< T * >::compare_exchange_weak(), memory_view< byte_t >::first(), memory_view< byte_t >::front(), memory_view< byte_t >::last(), latch::latch(), atomic_base< char >::load(), atomic_base< char >::load(), atomic_base< T * >::load(), atomic_base< T * >::load(), generator< T >::iterator::operator*(), memory_view< byte_t >::operator[](), atomic_base< char >::store(), atomic_base< char >::store(), atomic_base< T * >::store(), atomic_base< T * >::store() , 以及 memory_view< byte_t >::view().
|
inlinenoexcept |
|
inline |
如果正在调试则触发断点
首先检查是否有调试器附加,如果有则触发断点。 适用于条件性断点,避免在非调试环境中意外中断。
在文件 breakpoint.hpp 第 137 行定义.
引用了 breakpoint() , 以及 is_debugger_present().
| void debug_assert | ( | bool | condition, |
| const char * | message = nullptr ) |
调试断言
| condition | 条件表达式 |
| message | 断言失败时的消息 |
当条件为false时,输出断言失败信息并触发调试断点(如果正在调试)。 仅在调试构建中有效,发布构建中此函数为空操作。
|
inlinenodiscardconstexprnoexcept |
检查当前上下文是否在常量求值中
用于区分编译时和运行时
在文件 breakpoint.hpp 第 83 行定义.
被这些函数引用 allocate() , 以及 deallocate().
| bool is_debugger_present | ( | ) |
|
inlinenoexcept |
标记不可达代码路径
该函数用于向编译器指示当前代码路径永远不会被执行。当编译器遇到此调用时, 可以进行激进的优化,假设此后的代码永远不会运行。如果实际执行到了此函数, 将导致未定义行为(通常是程序崩溃或产生不可预测的结果)。
在文件 breakpoint.hpp 第 68 行定义.
被这些函数引用 standard_allocator< U >::allocate(), any_cast(), meta_any::convert(), meta_any::get(), meta_any::get(), toml_datetime::get_string_value(), make_shared(), color::parse() , 以及 toml_datetime::toml_datetime().