Debian Codegraph @

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp

raw
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 //===----------------------------------------------------------------------===//
8
9 // <memory>
10
11 // shared_ptr
12
13 // bool unique() const; // deprecated in C++17, removed in C++20
14
15 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE
16
17 #include <memory>
18 #include <cassert>
19
20 #include "test_macros.h"
21
22 int main(int, char**)
23 {
24 const std::shared_ptr<int> p(new int(32));
25 assert(p.unique());
26 {
27 std::shared_ptr<int> p2 = p;
28 assert(!p.unique());
29 }
30 assert(p.unique());
31
32 return 0;
33 }