[RISCV] Improve Errors for X1/X5/X1X5 Reg Classes (#126184)
[llvm-project.git] / libcxx / test / std / depr / depr.auto.ptr / auto.ptr / auto.ptr.members / reset.pass.cpp
blob1b5a09525b75192b4ee240a972672a56ae4afcb1
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <memory>
11 // template <class X> class auto_ptr;
13 // void reset(X* p=0) throw();
15 // REQUIRES: c++03 || c++11 || c++14
16 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
18 #include <memory>
19 #include <cassert>
21 #include "test_macros.h"
22 #include "../A.h"
24 void
25 test()
28 A* p = new A(1);
29 std::auto_ptr<A> ap(p);
30 ap.reset();
31 assert(ap.get() == 0);
32 assert(A::count == 0);
34 assert(A::count == 0);
36 A* p = new A(1);
37 std::auto_ptr<A> ap(p);
38 ap.reset(p);
39 assert(ap.get() == p);
40 assert(A::count == 1);
42 assert(A::count == 0);
44 A* p = new A(1);
45 std::auto_ptr<A> ap(p);
46 A* p2 = new A(2);
47 ap.reset(p2);
48 assert(ap.get() == p2);
49 assert(A::count == 1);
51 assert(A::count == 0);
54 int main(int, char**)
56 test();
58 return 0;