LibQuicR
defer.h File Reference
#include <utility>

Go to the source code of this file.

Classes

class  quicr::ScopeGuard< F >
 Non-copyable RAII guard that invokes a callable at scope exit. More...
 

Namespaces

 quicr
 

Macros

#define QUICR_DEFER_CONCAT(a, b)   QUICR_DEFER_CONCAT_INNER(a, b)
 Expands and concatenates two preprocessing tokens. More...
 
#define QUICR_DEFER_CONCAT_INNER(a, b)   a##b
 Concatenates two preprocessing tokens after outer expansion. More...
 
#define QUICR_DEFER_PUSH
 No-op on compilers that do not require deferred-action diagnostic suppression. More...
 
#define QUICR_DEFER_POP
 No-op on compilers that do not require deferred-action diagnostic suppression. More...
 
#define defer(n)
 Runs statements when the current scope exits. More...
 

Macro Definition Documentation

◆ defer

#define defer (   n)
Value:
quicr::ScopeGuard QUICR_DEFER_CONCAT(defer_, __LINE__)([&]() { \
QUICR_DEFER_PUSH n; \
QUICR_DEFER_POP \
})
Non-copyable RAII guard that invokes a callable at scope exit.
Definition: defer.h:49
#define QUICR_DEFER_CONCAT(a, b)
Expands and concatenates two preprocessing tokens.
Definition: defer.h:9

Runs statements when the current scope exits.

Parameters
nStatements captured by reference and executed exactly once by a generated scope guard.
Warning
Every referenced object must outlive the generated guard. An exception escaping n during stack unwinding terminates the process because the guard destructor is noexcept.

◆ QUICR_DEFER_CONCAT

#define QUICR_DEFER_CONCAT (   a,
  b 
)    QUICR_DEFER_CONCAT_INNER(a, b)

Expands and concatenates two preprocessing tokens.

◆ QUICR_DEFER_CONCAT_INNER

#define QUICR_DEFER_CONCAT_INNER (   a,
  b 
)    a##b

Concatenates two preprocessing tokens after outer expansion.

◆ QUICR_DEFER_POP

#define QUICR_DEFER_POP

No-op on compilers that do not require deferred-action diagnostic suppression.

◆ QUICR_DEFER_PUSH

#define QUICR_DEFER_PUSH

No-op on compilers that do not require deferred-action diagnostic suppression.