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 // UNSUPPORTED: c++03, c++11, c++14
11 
12 // template<class T> class weak_ptr
13 
14 // weak_ptr(shared_ptr<T>) -> weak_ptr<T>
15 
16 #include <memory>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 
21 struct A {};
22 
main(int,char **)23 int main(int, char**)
24 {
25   std::shared_ptr<A> s(new A);
26   auto w = std::weak_ptr(s);
27   ASSERT_SAME_TYPE(decltype(w), std::weak_ptr<A>);
28   assert(!w.expired());
29   assert(w.use_count() == 1);
30   assert(w.lock().get() == s.get());
31 
32   return 0;
33 }
34