4 ms·
My favorite is "template<auto>". An universal smart pointer: template <typename T,auto f> struct smart { T* pointer=nullptr; ~smart(){f(poin
by vmorgulis 10y ago
My favorite is "template<auto>". An universal smart pointer:
template <typename T,auto f> struct smart
{
T* pointer=nullptr;
~smart(){f(pointer);}
};
smart<char,free> buffer={malloc(...)};
smart<FILE*,fclose> file={fopen(...)};
...
Something to keep in the "potential subset".
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0127r1.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p012...