PMDK C++ bindings  1.10.1
This is the C++ bindings documentation for PMDK's libpmemobj.
specialization.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2015-2018, Intel Corporation */
3 
11 #ifndef LIBPMEMOBJ_CPP_SPECIALIZATION_HPP
12 #define LIBPMEMOBJ_CPP_SPECIALIZATION_HPP
13 
14 #include <memory>
15 
16 namespace pmem
17 {
18 
19 namespace detail
20 {
21 /* smart pointer specialization */
22 
23 template <typename T>
24 struct sp_element {
25  typedef T type;
26 };
27 
28 template <typename T>
29 struct sp_element<T[]> {
30  typedef T type;
31 };
32 
33 template <typename T, std::size_t N>
34 struct sp_element<T[N]> {
35  typedef T type;
36 };
37 
38 /* sp_dereference is a return type of operator* */
39 
40 template <typename T>
41 struct sp_dereference {
42  typedef T &type;
43 };
44 
45 template <>
46 struct sp_dereference<void> {
47  typedef void type;
48 };
49 
50 template <>
51 struct sp_dereference<void const> {
52  typedef void type;
53 };
54 
55 template <>
56 struct sp_dereference<void volatile> {
57  typedef void type;
58 };
59 
60 template <>
61 struct sp_dereference<void const volatile> {
62  typedef void type;
63 };
64 
65 template <typename T>
66 struct sp_dereference<T[]> {
67  typedef void type;
68 };
69 
70 template <typename T, std::size_t N>
71 struct sp_dereference<T[N]> {
72  typedef void type;
73 };
74 
75 /* sp_member_access is a return type of operator-> */
76 
77 template <typename T>
78 struct sp_member_access {
79  typedef T *type;
80 };
81 
82 template <typename T>
83 struct sp_member_access<T[]> {
84  typedef void type;
85 };
86 
87 template <typename T, std::size_t N>
88 struct sp_member_access<T[N]> {
89  typedef void type;
90 };
91 
92 /* sp_array_access is a return type of operator[] */
93 
94 template <typename T>
95 struct sp_array_access {
96  typedef T &type;
97 };
98 
99 template <>
100 struct sp_array_access<void> {
101  typedef struct does_not_exist {
102  } & type;
103 };
104 
105 template <typename T>
106 struct sp_array_access<T[]> {
107  typedef T &type;
108 };
109 
110 template <typename T, std::size_t N>
111 struct sp_array_access<T[N]> {
112  typedef T &type;
113 };
114 
115 /* sp_extent is used for operator[] index checking */
116 
117 template <typename T>
118 struct sp_extent {
119  enum _vt { value = 0 };
120 };
121 
122 template <typename T, std::size_t N>
123 struct sp_extent<T[N]> {
124  enum _vt { value = N };
125 };
126 
127 } /* namespace detail */
128 
129 } /* namespace pmem */
130 
131 #endif /* LIBPMEMOBJ_CPP_SPECIALIZATION_HPP */
pmem
Persistent memory namespace.
Definition: allocation_flag.hpp:15