Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Example of custom deleter to manage a resource.
//clang 3.8.0 #include <iostream> #include <memory> struct SomeResource { int _i = 10; }; int main() { SomeResource x; auto delFn = [](SomeResource* p) { std::cout << "'Deleter' called on p: " << p->_i; }; x._i = 20; std::unique_ptr<SomeResource, decltype(delFn)> px(&x, delFn); std::cout << "About to exit.\n"; }
run
|
edit
|
history
|
help
0
vf
hello world
std::function ambiguity clang
Thread-safe Interval Average Calculator
Recursive Call Example Sum
001
wasm test for node
Assertion Divide by Zero Example
function pointer
12/2