PMDK C++ bindings 1.13.0
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
16namespace pmem
17{
18
19namespace detail
20{
21/* smart pointer specialization */
22
23template <typename T>
24struct sp_element {
25 typedef T type;
26};
27
28template <typename T>
29struct sp_element<T[]> {
30 typedef T type;
31};
32
33template <typename T, std::size_t N>
34struct sp_element<T[N]> {
35 typedef T type;
36};
37
38/* sp_dereference is a return type of operator* */
39
40template <typename T>
41struct sp_dereference {
42 typedef T &type;
43};
44
45template <>
46struct sp_dereference<void> {
47 typedef void type;
48};
49
50template <>
51struct sp_dereference<void const> {
52 typedef void type;
53};
54
55template <>
56struct sp_dereference<void volatile> {
57 typedef void type;
58};
59
60template <>
61struct sp_dereference<void const volatile> {
62 typedef void type;
63};
64
65template <typename T>
66struct sp_dereference<T[]> {
67 typedef void type;
68};
69
70template <typename T, std::size_t N>
71struct sp_dereference<T[N]> {
72 typedef void type;
73};
74
75/* sp_member_access is a return type of operator-> */
76
77template <typename T>
78struct sp_member_access {
79 typedef T *type;
80};
81
82template <typename T>
83struct sp_member_access<T[]> {
84 typedef void type;
85};
86
87template <typename T, std::size_t N>
88struct sp_member_access<T[N]> {
89 typedef void type;
90};
91
92/* sp_array_access is a return type of operator[] */
93
94template <typename T>
95struct sp_array_access {
96 typedef T &type;
97};
98
99template <>
100struct sp_array_access<void> {
101 typedef struct does_not_exist {
102 } & type;
103};
104
105template <typename T>
106struct sp_array_access<T[]> {
107 typedef T &type;
108};
109
110template <typename T, std::size_t N>
111struct sp_array_access<T[N]> {
112 typedef T &type;
113};
114
115/* sp_extent is used for operator[] index checking */
116
117template <typename T>
118struct sp_extent {
119 enum _vt { value = 0 };
120};
121
122template <typename T, std::size_t N>
123struct 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 */
Persistent memory namespace.
Definition: allocation_flag.hpp:15