|
|
|
|
|
by thradams
849 days ago
|
|
I think gsl::Owner is related with RAII. The difference with cake ownership and RAII , is that with C++ RAII, the destructor is unconditionally called at end of scope.
Then flow analysis is not required in RAII. Cake requires flow analysis because "destructor" is not unconditionally called. When the compiler can see that the owner is not owning a object (because the pointer is null for instance) then the "destructor" is not necessary. To understand the difference. With flow analysis (how it works today) int main()
{
FILE *owner f = fopen("file.txt", "r");
if (f)
fclose(f);
}
Without flow analysis (or with a very simple one, where the destroy must be the last statement) void fclose2(FILE * owner p) {
if (p) fclose(p);
}
int main()
{
FILE *owner f = fopen("file.txt", "r");
if (f){
}
fclose2(f);
}
|
|