Blaze 3.9
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
44
45
46namespace blaze {
47
48//=================================================================================================
49//
50// CLASS DEFINITION
51//
52//=================================================================================================
53
54//*************************************************************************************************
77template< size_t B, size_t N >
79 : public BoolConstant< IsPowerOf<B,N/B>::value >
80{};
81//*************************************************************************************************
82
83
84//*************************************************************************************************
94template< size_t N >
95struct IsPowerOf<2,N>
96 : public BoolConstant< ( N & (N-1) ) == 0UL >
97{};
99//*************************************************************************************************
100
101
102//*************************************************************************************************
111template<>
112struct IsPowerOf<2,0>
113 : public FalseType
114{};
116//*************************************************************************************************
117
118
119//*************************************************************************************************
129template< size_t B >
130struct IsPowerOf<B,1>
131 : public TrueType
132{};
134//*************************************************************************************************
135
136
137//*************************************************************************************************
147template< size_t N >
148struct IsPowerOf<1,N>
149 : public FalseType
150{};
152//*************************************************************************************************
153
154
155//*************************************************************************************************
165template<>
166struct IsPowerOf<1,1>
167 : public TrueType
168{};
170//*************************************************************************************************
171
172
173//*************************************************************************************************
183template< size_t B >
184struct IsPowerOf<B,0>
185 : public FalseType
186{};
188//*************************************************************************************************
189
190
191//*************************************************************************************************
201template< size_t N >
202struct IsPowerOf<0,N>
203 : public FalseType
204{};
206//*************************************************************************************************
207
208
209//*************************************************************************************************
219template<>
220struct IsPowerOf<0,0>
221 : public TrueType
222{};
224//*************************************************************************************************
225
226
227//*************************************************************************************************
240template< size_t B, size_t N >
242//*************************************************************************************************
243
244} // namespace blaze
245
246#endif
Header file for the IntegralConstant class template.
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
BoolConstant< false > FalseType
Type/value traits base class.
Definition: IntegralConstant.h:121
constexpr bool IsPowerOf_v
Auxiliary variable template for the IsPowerOf value trait.
Definition: IsPowerOf.h:241
Generic wrapper for a compile time constant integral value.
Definition: IntegralConstant.h:74
Compile time check for a power relationship of integral values to a given base.
Definition: IsPowerOf.h:80