Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
math
expressions
RepeatExprData.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_MATH_EXPRESSIONS_REPEATEXPRDATA_H_
36
#define _BLAZE_MATH_EXPRESSIONS_REPEATEXPRDATA_H_
37
38
39
//*************************************************************************************************
40
// Includes
41
//*************************************************************************************************
42
43
#include <
blaze/util/StaticAssert.h
>
44
#include <
blaze/util/Types.h
>
45
46
47
namespace
blaze {
48
49
//=================================================================================================
50
//
51
// FORWARD DECLARATIONS
52
//
53
//=================================================================================================
54
55
//*************************************************************************************************
63
template
<
size_t
Dim
// Number of dimensions
64
,
size_t
... CRAs >
// Compile time repeater arguments
65
class
RepeatExprData
;
66
//*************************************************************************************************
67
68
69
70
71
//=================================================================================================
72
//
73
// BASE TEMPLATE FOR MANY COMPILE TIME REPEATER ARGUMENTS
74
//
75
//=================================================================================================
76
77
//*************************************************************************************************
85
template
<
size_t
Dim
// Number of dimensions
86
,
size_t
... Rs >
// Compile time repetitions
87
class
RepeatExprData
88
{
89
public
:
90
//**Constructors********************************************************************************
93
constexpr
RepeatExprData
() noexcept;
94
95
RepeatExprData
( const
RepeatExprData
& ) = default;
97
//**********************************************************************************************
98
99
//**Destructor**********************************************************************************
102
~
RepeatExprData
() = default;
104
//**********************************************************************************************
105
106
//**Assignment operators************************************************************************
109
RepeatExprData
& operator=( const
RepeatExprData
& ) = delete;
111
//**********************************************************************************************
112
113
//**Utility functions***************************************************************************
116
template<
size_t
I >
117
static constexpr
size_t
repetitions() noexcept;
119
//**********************************************************************************************
120
121
private:
122
//**Compile time checks*************************************************************************
123
BLAZE_STATIC_ASSERT
( Dim == sizeof...( Rs ) );
124
//**********************************************************************************************
125
};
127
//*************************************************************************************************
128
129
130
//*************************************************************************************************
134
template<
size_t
Dim
// Number of dimensions
135
,
size_t
... Rs >
// Compile time repetitions
136
constexpr
RepeatExprData
<Dim,Rs...>::
RepeatExprData
() noexcept
137
{}
139
//*************************************************************************************************
140
141
142
//*************************************************************************************************
148
template
<
size_t
Dim
// Number of dimensions
149
,
size_t
... Rs >
// Compile time repetitions
150
template
<
size_t
I >
// Dimension index
151
constexpr
size_t
RepeatExprData<Dim,Rs...>::repetitions
() noexcept
152
{
153
BLAZE_STATIC_ASSERT
( I < Dim );
154
constexpr
size_t
reps[] = { Rs... };
155
return
reps[I];
156
}
157
159
//*************************************************************************************************
160
161
162
163
164
//=================================================================================================
165
//
166
// CLASS TEMPLATE SPECIALIZATION FOR ZERO COMPILE TIME REPEATER ARGUMENTS
167
//
168
//=================================================================================================
169
170
//*************************************************************************************************
179
template
<
size_t
Dim >
// Number of dimensions
180
class
RepeatExprData<Dim>
181
{
182
public
:
183
//**Constructors********************************************************************************
186
template
<
typename
... Reps >
187
inline
RepeatExprData( Reps... reps )
noexcept
;
188
189
RepeatExprData(
const
RepeatExprData& ) =
default
;
191
//**********************************************************************************************
192
193
//**Destructor**********************************************************************************
196
~RepeatExprData() =
default
;
198
//**********************************************************************************************
199
200
//**Assignment operators************************************************************************
203
RepeatExprData& operator=(
const
RepeatExprData& ) =
delete
;
205
//**********************************************************************************************
206
207
//**Utility functions***************************************************************************
210
template
<
size_t
I >
211
inline
size_t
repetitions() const noexcept;
213
//**********************************************************************************************
214
215
private:
216
//**Member variables****************************************************************************
219
const
size_t
repetitions_[Dim];
221
//**********************************************************************************************
222
};
224
//*************************************************************************************************
225
226
227
//*************************************************************************************************
233
template<
size_t
Dim >
// Number of dimensions
234
template< typename... Reps >
// Runtime repetitions
235
inline RepeatExprData<Dim>::RepeatExprData( Reps... reps ) noexcept
236
: repetitions_{ reps... }
// The number of repetitions of the repeater expression
237
{
238
BLAZE_STATIC_ASSERT
(
sizeof
...( Reps ) == Dim );
239
}
241
//*************************************************************************************************
242
243
244
//*************************************************************************************************
250
template
<
size_t
Dim >
// Number of dimensions
251
template
<
size_t
I >
// Dimension index
252
inline
size_t
RepeatExprData<Dim>::repetitions() const noexcept
253
{
254
BLAZE_STATIC_ASSERT
( I < 3UL );
255
return
repetitions_[I];
256
}
258
//*************************************************************************************************
259
260
}
// namespace blaze
261
262
#endif
StaticAssert.h
Compile time assertion.
blaze::RepeatExprData
Auxiliary class template for the data members of repeater expression classes.
Definition
RepeatExprData.h:65
BLAZE_STATIC_ASSERT
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition
StaticAssert.h:112
Types.h
Header file for basic type definitions.
Generated by
1.18.0