1 // { dg-options "-std=gnu++14" }
4 // Copyright (C) 2015-2016 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a moved_to of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <experimental/memory>
23 using std::experimental::observer_ptr
;
25 struct nontrivial
{nontrivial() {}};
28 struct derived
: base
{};
30 static_assert(!std::is_trivially_constructible
<
31 observer_ptr
<nontrivial
>>::value
, "");
32 static_assert(std::is_trivially_copyable
<
33 observer_ptr
<nontrivial
>>::value
, "");
34 static_assert(std::is_trivially_destructible
<
35 observer_ptr
<nontrivial
>>::value
, "");
37 static_assert(std::is_constructible
<
38 observer_ptr
<nontrivial
>, nontrivial
*>::value
,
40 static_assert(std::is_constructible
<observer_ptr
<base
>, base
*>::value
, "");
41 static_assert(std::is_constructible
<observer_ptr
<base
>, derived
*>::value
, "");
42 static_assert(!std::is_constructible
<observer_ptr
<base
>, other
*>::value
, "");
43 static_assert(std::is_constructible
<
44 observer_ptr
<base
>, observer_ptr
<base
>>::value
, "");
45 static_assert(std::is_constructible
<
46 observer_ptr
<base
>, observer_ptr
<derived
>>::value
, "");
47 static_assert(!std::is_constructible
<
48 observer_ptr
<base
>, observer_ptr
<other
>>::value
, "");
50 static_assert(!std::is_assignable
<
51 observer_ptr
<nontrivial
>, nontrivial
*>::value
,
53 static_assert(std::is_assignable
<
54 observer_ptr
<nontrivial
>, observer_ptr
<nontrivial
>>::value
,
56 static_assert(std::is_assignable
<observer_ptr
<base
>,
57 observer_ptr
<base
>>::value
, "");
58 static_assert(std::is_assignable
<observer_ptr
<base
>,
59 observer_ptr
<derived
>>::value
, "");
60 static_assert(!std::is_assignable
<
61 observer_ptr
<base
>, observer_ptr
<other
>>::value
, "");
62 static_assert(std::is_assignable
<observer_ptr
<const int>,
63 observer_ptr
<int>>::value
, "");
64 static_assert(!std::is_assignable
<observer_ptr
<int>,
65 observer_ptr
<const int>>::value
, "");