Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
shared_ptr deleter
//g++ 4.9.3 #include <iostream> #include <memory> struct Connection { std::shared_ptr<int> ts; }; Connection* generateConnection(int* tss) { Connection* c = new Connection; struct Del { void operator()(int* ptr) const { std::cout << "Deleting ptr" << std::endl; if(ptr) delete [] ptr; } }; c->ts.reset(tss, Del()); return c; } int main() { std::unique_ptr<Connection> con(generateConnection(new int[4]{1,2,3})); }
run
|
edit
|
history
|
help
0
The Menu
CutRod(BottomUp)
Camel case
Assigment operator (easy)
My billing system
synowie abrahama
stream1
operator++
Good1
GenericPacker