Yes, it is possible, but ... I don't see a compelling reason to do so. The delete_array function has a very specific purpose, and adding that would beg the questions of "Why add that, and not other inline functions which also have very specific purposes? Why not also add inline functions to close ports, close files, etc...?"
Also, what if somebody wanted to use delete_array (or any similar function), and not want to use ScopeGuard. Why should that person be forced to include ScopeGuard.h to get a simple inline function which is not directly related to ScopeGuard?
I don't recommend adding it.
Sincerely,
Rich
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Would it be possible to add a funtion to the scopeguard header, as proposed here by Andrei:
<<http://leafe.com/archives/showMsg/106096>>
inline delete_array( void* p )
{
delete [] p;
}
This would allow one to do:
char *c = new char[110];
Loki::ScopeGuard = Loki::MakeGuard(delete_array, c);
Regards,
Dieter Rosch
Hi Dieter,
Yes, it is possible, but ... I don't see a compelling reason to do so. The delete_array function has a very specific purpose, and adding that would beg the questions of "Why add that, and not other inline functions which also have very specific purposes? Why not also add inline functions to close ports, close files, etc...?"
Also, what if somebody wanted to use delete_array (or any similar function), and not want to use ScopeGuard. Why should that person be forced to include ScopeGuard.h to get a simple inline function which is not directly related to ScopeGuard?
I don't recommend adding it.
Sincerely,
Rich
For new features please open a new request in the tracker
https://sourceforge.net/tracker/?atid=396647&group_id=29557&func=browse
Otherwise it could get lost in the depth of the forum.
Peter
For new features please open a new request in the tracker
https://sourceforge.net/tracker/?atid=396647&group_id=29557&func=browse
Otherwise it could get lost in the depth of the forum.
Peter
https://sourceforge.net/tracker/index.php?func=detail&aid=1746122&group_id=29557&atid=396647