libstdc++-v3/testsuite/20_util/shared_ptr/cons/lwg3548.cc
raw| 1 | // { dg-do compile { target c++11 } } |
| 2 | // { dg-require-effective-target hosted } |
| 3 | |
| 4 | #include <memory> |
| 5 | |
| 6 | // LWG 3548 |
| 7 | // shared_ptr construction from unique_ptr should move (not copy) the deleter |
| 8 | |
| 9 | struct D |
| 10 | { |
| 11 | D() { } |
| 12 | D(D&&) { } |
| 13 | void operator()(int* p) const { delete p; } |
| 14 | }; |
| 15 | |
| 16 | std::unique_ptr<int, D> u; |
| 17 | std::shared_ptr<int> s1(std::move(u)); |