Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
util
valuetraits
IsPowerOf.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_UTIL_VALUETRAITS_ISPOWEROF_H_
36
#define _BLAZE_UTIL_VALUETRAITS_ISPOWEROF_H_
37
38
39
//*************************************************************************************************
40
// Includes
41
//*************************************************************************************************
42
43
#include <
blaze/util/IntegralConstant.h
>
44
45
46
namespace
blaze {
47
48
//=================================================================================================
49
//
50
// CLASS DEFINITION
51
//
52
//=================================================================================================
53
54
//*************************************************************************************************
77
template
<
size_t
B,
size_t
N >
78
struct
IsPowerOf
79
:
public
BoolConstant
< IsPowerOf<B,N/B>::value >
80
{};
81
//*************************************************************************************************
82
83
84
//*************************************************************************************************
94
template
<
size_t
N >
95
struct
IsPowerOf
<2,N>
96
:
public
BoolConstant
< ( N & (N-1) ) == 0UL >
97
{};
99
//*************************************************************************************************
100
101
102
//*************************************************************************************************
111
template
<>
112
struct
IsPowerOf<2,0>
113
:
public
FalseType
114
{};
116
//*************************************************************************************************
117
118
119
//*************************************************************************************************
129
template
<
size_t
B >
130
struct
IsPowerOf
<B,1>
131
:
public
TrueType
132
{};
134
//*************************************************************************************************
135
136
137
//*************************************************************************************************
147
template
<
size_t
N >
148
struct
IsPowerOf
<1,N>
149
:
public
FalseType
150
{};
152
//*************************************************************************************************
153
154
155
//*************************************************************************************************
165
template
<>
166
struct
IsPowerOf
<1,1>
167
:
public
TrueType
168
{};
170
//*************************************************************************************************
171
172
173
//*************************************************************************************************
183
template
<
size_t
B >
184
struct
IsPowerOf
<B,0>
185
:
public
FalseType
186
{};
188
//*************************************************************************************************
189
190
191
//*************************************************************************************************
201
template
<
size_t
N >
202
struct
IsPowerOf
<0,N>
203
:
public
FalseType
204
{};
206
//*************************************************************************************************
207
208
209
//*************************************************************************************************
219
template
<>
220
struct
IsPowerOf
<0,0>
221
:
public
TrueType
222
{};
224
//*************************************************************************************************
225
226
227
//*************************************************************************************************
240
template
<
size_t
B,
size_t
N >
241
constexpr
bool
IsPowerOf_v
=
IsPowerOf<B,N>::value
;
242
//*************************************************************************************************
243
244
}
// namespace blaze
245
246
#endif
IntegralConstant.h
Header file for the IntegralConstant class template.
blaze::FalseType
BoolConstant< false > FalseType
Type/value traits base class.
Definition
IntegralConstant.h:121
blaze::TrueType
BoolConstant< true > TrueType
Type traits base class.
Definition
IntegralConstant.h:132
blaze::BoolConstant
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition
IntegralConstant.h:110
blaze::IsPowerOf_v
constexpr bool IsPowerOf_v
Auxiliary variable template for the IsPowerOf value trait.
Definition
IsPowerOf.h:241
blaze::IsPowerOf
Compile time check for a power relationship of integral values to a given base.
Definition
IsPowerOf.h:80
Generated by
1.18.0