]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / utilities / smartptr / unique.ptr / unique.ptr.class / pointer_type.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <memory>
11
12 // unique_ptr
13
14 // Test unique_ptr::pointer type
15
16 #include <memory>
17 #include <type_traits>
18
19 #include "test_macros.h"
20
21 struct Deleter {
22   struct pointer {};
23 };
24
25 struct D2 {
26 private:
27   typedef void pointer;
28 };
29
30 struct D3 {
31   static long pointer;
32 };
33
34 template <bool IsArray>
35 void test_basic() {
36   typedef typename std::conditional<IsArray, int[], int>::type VT;
37   {
38     typedef std::unique_ptr<VT> P;
39     static_assert((std::is_same<typename P::pointer, int*>::value), "");
40   }
41   {
42     typedef std::unique_ptr<VT, Deleter> P;
43     static_assert((std::is_same<typename P::pointer, Deleter::pointer>::value),
44                   "");
45   }
46 #if TEST_STD_VER >= 11
47   {
48     typedef std::unique_ptr<VT, D2> P;
49     static_assert(std::is_same<typename P::pointer, int*>::value, "");
50   }
51   {
52     typedef std::unique_ptr<VT, D3> P;
53     static_assert(std::is_same<typename P::pointer, int*>::value, "");
54   }
55 #endif
56 }
57
58 int main() {
59   test_basic</*IsArray*/ false>();
60   test_basic<true>();
61 }