Loading...
Searching...
No Matches
end.hpp
Go to the documentation of this file.
1
2
#pragma once
3
4
#include "
indep/common.hpp
"
5
#include "
indep/macro.hpp
"
6
7
namespace
by {
8
35
class
_nout
end
{
36
BY(ME(
end
))
37
38
public
:
39
end
(std::function<
void
(
void
)>
l
);
40
~end
();
41
42
private
:
43
std::function<void(
void
)> _lambda;
44
};
45
46
// e.g.
47
// BY_END_BLOCK({
48
// ....doSomething()
49
// });
50
// or,
51
// BY_END(doSomething());
52
#define BY_END_BLOCK_2(__class, blockStmt) auto BY_CONCAT(__defer__, __COUNTER__) = __class(blockStmt)
53
#define BY_END_BLOCK_1(blockStmt) BY_END_BLOCK_2(end, [&]() blockStmt)
54
#define BY_END_BLOCK(...) BY_OVERLOAD(BY_END_BLOCK, __VA_ARGS__)
55
56
#define BY_END_2(__class, stmt) auto BY_CONCAT(__defer__, __COUNTER__) = __class(stmt)
57
#define BY_END_1(stmt) BY_END_2(end, ([&]() { stmt; }))
58
#define BY_END(...) BY_OVERLOAD(BY_END, __VA_ARGS__)
59
}
by::end
Deferred execution utility similar to defer keyword in other languages.
Definition
end.hpp:35
common.hpp
macro.hpp
by::noWrap
Rich logging support with polymorphic type conversion.
Definition
richLog.hpp:34