Console Library 8.0.0
A header-only library that makes C++ simple
Loading...
Searching...
No Matches
defer.h File Reference

RAII的作用域宏,在退出作用域时按逆序执行推迟的代码。 More...

#include <type_traits>
#include <utility>

Go to the source code of this file.

Classes

class  console::DeferGuard< F >
 推迟执行的RAII守卫类。 More...

Namespaces

namespace  console
 本库所有组件所在的顶层命名空间。

Macros

#define CONSOLE_CONCAT_IMPL(a, b)
#define CONSOLE_CONCAT(a, b)
#define defer(...)

Functions

template<class F>
DeferGuard< typename std::decay< F >::type > console::make_defer (F &&f)
 工厂函数,创建DeferGuard对象。

Detailed Description

RAII的作用域宏,在退出作用域时按逆序执行推迟的代码。

Author
MrXie1109
Date
2026

Macro Definition Documentation

◆ CONSOLE_CONCAT

#define CONSOLE_CONCAT ( a,
b )
Value:
#define CONSOLE_CONCAT_IMPL(a, b)
Definition defer.h:76

◆ CONSOLE_CONCAT_IMPL

#define CONSOLE_CONCAT_IMPL ( a,
b )
Value:
a##b

◆ defer

#define defer ( ...)
Value:
auto CONSOLE_CONCAT(_dg_, __LINE__) = make_defer([&] { __VA_ARGS__; })
#define CONSOLE_CONCAT(a, b)
Definition defer.h:78
Examples
/media/xie/MrXie1109/Data/console/include/util/defer.h.