applegame:
Wound @ De, TTF_CloseFont, scope(exit) - TTF_Quit. , scope(exit) TTF_Quit, De, TTF_CloseFont. ?
, scope(exit), . TTF_Quit . , TTF_Quit .
, :
AFTER the scope(exit) statements
AFTER exit from the function scope
scope(exit) .
Wound @ . . . , RAII , .
scope(exit) delete(ptr) . - , , ?
Wound @ , ! , . RAII , ? ?
. . return, ( unique_ptr , ), , . .
Wound @ , ! ++ . , . !
. D . scope(exit) GC. !
Wound @ ? . RAII - . .
? . scope(exit) - . .
Wound @ D - , .
. - scope(exit) - .
Wound @ goto , . scope(exit) - , - , GC. .
, scope(...) . GC GC. scope(...)?
Wound @ - , .
scope(...). http- http-:
auto handleHTTPRequest(...) {
activeRequests.atomicIncrement();
scope(exit) activeRequests.atomicDecrement();
scope(success) successRequests.atomicIncrement();
...
if(...) return result1;
...
if(...) throw Error1;
...
if(...) return result2;
...
if(...) throw Error2;
...
}
, ?
Wound @ - try/catch/finally, finally. , , finally GC JAVA/C#. .
D, try/catch/finally Java, finally - try/catch/finally, try/catch.
, . - , . , C# try-catch-finally. , finally try-catch, try-finally catch.
Wound @ std::fstream - RAII FILE* . 10 , 10 , , , , , , ... .. , , .
, . RAII .
Wound @ , scope(exit), , RAII . .

, RAII . RAII, scope(exit), , , :)
// , RAII-
void useFile(F fn)(string name, F fn) {
auto file = open(name);
scope(exit) close(file);
fn(file);
}
void onClick(data) {
//
useFile("hello.txt", (file) {
...
write(file, data);
...
data1 = read(file);
...
});
}
https://forum.sources.ru/index.php?showtopic=362619&view=findpost&p=3834547