| 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 | // template<class Y> shared_ptr(const shared_ptr<Y>& r); |
| 14 | |
| 15 | #include <memory> |
| 16 | #include <type_traits> |
| 17 | #include <utility> |
| 18 | |
| 19 | #include "test_macros.h" |
| 20 | |
| 21 | struct A { |
| 22 | int x = 42; |
| 23 | }; |
| 24 | |
| 25 | struct ADel : std::default_delete<A> { |
| 26 | typedef A* pointer; |
| 27 | }; |
| 28 | |
| 29 | int main(int, char**) { |
| 30 | static_assert(!(std::is_convertible<A, int>::value), "" ); |
| 31 | |
| 32 | { |
| 33 | std::shared_ptr<A> pA; |
| 34 | std::shared_ptr<int> pi(pA); // expected-error {{no matching constructor for initialization of 'std::shared_ptr<int>'}} |
| 35 | } |
| 36 | { |
| 37 | std::shared_ptr<A> pA; |
| 38 | std::shared_ptr<int> pi(std::move(pA)); // expected-error {{no matching constructor for initialization of 'std::shared_ptr<int>'}} |
| 39 | } |
| 40 | { |
| 41 | std::weak_ptr<A> pA; |
| 42 | std::shared_ptr<int> pi(std::move(pA)); // expected-error {{no matching constructor for initialization of 'std::shared_ptr<int>'}} |
| 43 | } |
| 44 | |
| 45 | #if TEST_STD_VER > 14 |
| 46 | { |
| 47 | std::unique_ptr<int, ADel> ui; |
| 48 | std::shared_ptr<int> pi(std::move(ui)); // expected-error {{no matching constructor for initialization of 'std::shared_ptr<int>'}} |
| 49 | } |
| 50 | #endif |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |