// { dg-options "-std=gnu++0x -Wno-deprecated" } // Copyright (C) 2010 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . // 20.9.11.2 Template class shared_ptr [util.smartptr.shared] #include #include struct A { }; std::unique_ptr create_unique_ptr() { return std::unique_ptr(new A()); } std::auto_ptr create_auto_ptr() { return std::auto_ptr(new A()); } void process(std::shared_ptr a) { bool test __attribute__((unused)) = true; VERIFY( a.get() != 0 ); VERIFY( a.use_count() == 1 ); } // 20.9.11.2.1 shared_ptr creation [util.smartptr.shared.const] // Implicit conversion of auto_ptr to shared_ptr is allowed void test01() { process(create_auto_ptr()); } void test02() { std::auto_ptr a = create_auto_ptr(); process(std::move(a)); } // Implicit conversion of unique_ptr to shared_ptr is allowed void test03() { process(create_unique_ptr()); } void test04() { std::unique_ptr a = create_unique_ptr(); process(std::move(a)); } int main() { test01(); test02(); test03(); test04(); return 0; }