PMDK C++ bindings 1.2.0
This is the C++ bindings documentation for PMDK's libpmemobj.
specialization.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2015-2017, Intel Corporation
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * * Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
40#ifndef PMEMOBJ_SPECIALIZATION_HPP
41#define PMEMOBJ_SPECIALIZATION_HPP
42
43#include <memory>
44
45namespace pmem
46{
47
48namespace detail
49{
50/* smart pointer specialization */
51
52template <typename T>
53struct sp_element {
54 typedef T type;
55};
56
57template <typename T>
58struct sp_element<T[]> {
59 typedef T type;
60};
61
62template <typename T, std::size_t N>
63struct sp_element<T[N]> {
64 typedef T type;
65};
66
67/* sp_dereference is a return type of operator* */
68
69template <typename T>
70struct sp_dereference {
71 typedef T &type;
72};
73
74template <>
75struct sp_dereference<void> {
76 typedef void type;
77};
78
79template <>
80struct sp_dereference<void const> {
81 typedef void type;
82};
83
84template <>
85struct sp_dereference<void volatile> {
86 typedef void type;
87};
88
89template <>
90struct sp_dereference<void const volatile> {
91 typedef void type;
92};
93
94template <typename T>
95struct sp_dereference<T[]> {
96 typedef void type;
97};
98
99template <typename T, std::size_t N>
100struct sp_dereference<T[N]> {
101 typedef void type;
102};
103
104/* sp_member_access is a return type of operator-> */
105
106template <typename T>
107struct sp_member_access {
108 typedef T *type;
109};
110
111template <typename T>
112struct sp_member_access<T[]> {
113 typedef void type;
114};
115
116template <typename T, std::size_t N>
117struct sp_member_access<T[N]> {
118 typedef void type;
119};
120
121/* sp_array_access is a return type of operator[] */
122
123template <typename T>
124struct sp_array_access {
125 typedef T &type;
126};
127
128template <>
129struct sp_array_access<void> {
130 typedef struct does_not_exist {
131 } & type;
132};
133
134template <typename T>
135struct sp_array_access<T[]> {
136 typedef T &type;
137};
138
139template <typename T, std::size_t N>
140struct sp_array_access<T[N]> {
141 typedef T &type;
142};
143
144/* sp_extent is used for operator[] index checking */
145
146template <typename T>
147struct sp_extent {
148 enum _vt { value = 0 };
149};
150
151template <typename T, std::size_t N>
152struct sp_extent<T[N]> {
153 enum _vt { value = N };
154};
155
156} /* namespace detail */
157
158} /* namespace pmem */
159
160#endif /* PMEMOBJ_SPECIALIZATION_HPP */