Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ScopeExit.h21 linesDownload Raw Back to c_util
1#pragma once
2
3template <typename T>
4
5class ScopeExit
6{
7public:
8    ScopeExit(T t) : t(t) {}
9    ~ScopeExit() { t(); }
10    T t;
11};
12
13template <typename T>
14ScopeExit<T> MoveScopeExit(T t) {
15    return ScopeExit<T>(t);
16};
17
18#define NV_ANONYMOUS_VARIABLE_DIRECT(name, line) name##line
19#define NV_ANONYMOUS_VARIABLE_INDIRECT(name, line) NV_ANONYMOUS_VARIABLE_DIRECT(name, line)
20
21#define SCOPE_EXIT(func) const auto NV_ANONYMOUS_VARIABLE_INDIRECT(EXIT, __LINE__) = MoveScopeExit([=](){func;})
codekingpro/portable-devtools · Team Ai