codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include "boost/shared_ptr.hpp" #include <iostream> struct b { }; struct d1: b { ~d1() { std::cout << "~d1() called!\n"; } }; struct d2: b { ~d2() { std::cout << "~d2() called!\n"; } }; template <class T> boost::shared_ptr<b> create() { return boost::shared_ptr<T>(new T); } int main() { boost::shared_ptr<b> b1=create<d1>(); boost::shared_ptr<b> b2=create<d2>(); }
Private
[
?
]
Run code
Submit