Loading...
Searching...
No Matches
by::end Class Reference

Deferred execution utility similar to defer keyword in other languages. More...

#include <end.hpp>

Inheritance diagram for by::end:
by::scopeLog

Public Member Functions

 end (std::function< void(void)> l)
 

Detailed Description

Deferred execution utility similar to defer keyword in other languages.

Delays code execution until the end of the current scope. Similar to the defer keyword found in languages like Go or Swift.

In byeolang, end registers code to be executed when exiting the current function. In C++, this is implemented using RAII and is limited to scope boundaries rather than function boundaries.

Usage

Use the provided macros for convenient deferred execution:

void processFile() {
FILE* f = fopen("data.txt", "r");
BY_END(fclose(f)); // Automatically closes file when leaving scope
// Or use block form for multiple statements:
BY_END_BLOCK({
});
// ... do work with file ...
} // fclose(f) executes here automatically
Rich logging support with polymorphic type conversion.
Definition richLog.hpp:34

The documentation for this class was generated from the following file: