Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
util
smallarray
SmallArrayData.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_UTIL_SMALLARRAY_SMALLARRAYDATA_H_
36
#define _BLAZE_UTIL_SMALLARRAY_SMALLARRAYDATA_H_
37
38
39
//*************************************************************************************************
40
// Includes
41
//*************************************************************************************************
42
43
#include <
blaze/util/Types.h
>
44
#include <
blaze/util/typetraits/AlignmentOf.h
>
45
46
47
namespace
blaze {
48
49
//=================================================================================================
50
//
51
// CLASS DEFINITION
52
//
53
//=================================================================================================
54
55
//*************************************************************************************************
63
template
<
typename
T
// Data type of the elements
64
,
size_t
N >
// Number of preallocated elements
65
struct
SmallArrayData
66
{
67
public
:
68
//**Constructors********************************************************************************
71
constexpr
SmallArrayData() noexcept;
73
//**********************************************************************************************
74
75
//**Data access functions***********************************************************************
78
constexpr T* array() noexcept;
79
constexpr const T* array() const noexcept;
81
//**********************************************************************************************
82
83
private:
84
//**Member variables****************************************************************************
87
alignas( AlignmentOf_v<T> ) byte_t v_[N*sizeof(T)];
89
//**********************************************************************************************
90
};
92
//*************************************************************************************************
93
94
95
//*************************************************************************************************
101
template< typename T
// Data type of the elements
102
,
size_t
N >
// Number of preallocated elements
103
constexpr SmallArrayData<T,N>::SmallArrayData() noexcept
104
// v_ is intentionally not initialized
105
{}
107
//*************************************************************************************************
108
109
110
//*************************************************************************************************
116
template
<
typename
T
// Data type of the elements
117
,
size_t
N >
// Number of preallocated elements
118
constexpr
T* SmallArrayData<T,N>::array() noexcept
119
{
120
return
reinterpret_cast<
T*
>
( v_ );
121
}
123
//*************************************************************************************************
124
125
126
//*************************************************************************************************
132
template
<
typename
T
// Data type of the elements
133
,
size_t
N >
// Number of preallocated elements
134
constexpr
const
T* SmallArrayData<T,N>::array() const noexcept
135
{
136
return
reinterpret_cast<
const
T*
>
( v_ );
137
}
139
//*************************************************************************************************
140
141
142
143
144
//=================================================================================================
145
//
146
// CLASS TEMPLATE SPECIALIZATION FOR N = 0
147
//
148
//=================================================================================================
149
150
//*************************************************************************************************
157
template
<
typename
T >
// Data type of the elements
158
struct
SmallArrayData<T,0UL>
159
{
160
public
:
161
//**Data access functions***********************************************************************
164
constexpr
T* array() noexcept;
165
constexpr const T* array() const noexcept;
167
//**********************************************************************************************
168
};
170
//*************************************************************************************************
171
172
173
//*************************************************************************************************
179
template< typename T >
// Data type of the elements
180
constexpr T* SmallArrayData<T,0UL>::array() noexcept
181
{
182
return
nullptr
;
183
}
185
//*************************************************************************************************
186
187
188
//*************************************************************************************************
194
template
<
typename
T >
// Data type of the elements
195
constexpr
const
T* SmallArrayData<T,0UL>::array() const noexcept
196
{
197
return
nullptr
;
198
}
200
//*************************************************************************************************
201
202
}
// namespace blaze
203
204
#endif
AlignmentOf.h
Header file for the AlignmentOf type trait.
Types.h
Header file for basic type definitions.
Generated by
1.18.0