@@ -153,8 +153,7 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
153
153
// number of words per block
154
154
static constexpr std::size_t BLOCK_WORDS = (Bits * BLOCK_ELEMENTS) / WORD_BITS;
155
155
156
- // C++14 does not allow operator[] to be constexpr, this is fixed in C++17.
157
- static /* constexpr */ std::array<WordT, BLOCK_ELEMENTS> initialize_lower_mask ()
156
+ static constexpr std::array<WordT, BLOCK_ELEMENTS> initialize_lower_mask ()
158
157
{
159
158
std::array<WordT, BLOCK_ELEMENTS> lower_mask;
160
159
@@ -170,7 +169,7 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
170
169
return lower_mask;
171
170
}
172
171
173
- static /* constexpr */ std::array<WordT, BLOCK_ELEMENTS> initialize_upper_mask ()
172
+ static constexpr std::array<WordT, BLOCK_ELEMENTS> initialize_upper_mask ()
174
173
{
175
174
std::array<WordT, BLOCK_ELEMENTS> upper_mask;
176
175
@@ -194,7 +193,7 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
194
193
return upper_mask;
195
194
}
196
195
197
- static /* constexpr */ std::array<std::uint8_t , BLOCK_ELEMENTS> initialize_lower_offset ()
196
+ static constexpr std::array<std::uint8_t , BLOCK_ELEMENTS> initialize_lower_offset ()
198
197
{
199
198
std::array<std::uint8_t , WORD_BITS> lower_offset;
200
199
@@ -209,7 +208,7 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
209
208
return lower_offset;
210
209
}
211
210
212
- static /* constexpr */ std::array<std::uint8_t , BLOCK_ELEMENTS> initialize_upper_offset ()
211
+ static constexpr std::array<std::uint8_t , BLOCK_ELEMENTS> initialize_upper_offset ()
213
212
{
214
213
std::array<std::uint8_t , BLOCK_ELEMENTS> upper_offset;
215
214
@@ -232,7 +231,7 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
232
231
return upper_offset;
233
232
}
234
233
235
- static /* constexpr */ std::array<std::uint8_t , BLOCK_ELEMENTS> initialize_word_offset ()
234
+ static constexpr std::array<std::uint8_t , BLOCK_ELEMENTS> initialize_word_offset ()
236
235
{
237
236
std::array<std::uint8_t , BLOCK_ELEMENTS> word_offset;
238
237
@@ -246,28 +245,15 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
246
245
return word_offset;
247
246
}
248
247
249
- // For now we need to call these on object creation
250
- void initialize ()
251
- {
252
- lower_mask = initialize_lower_mask ();
253
- upper_mask = initialize_upper_mask ();
254
- lower_offset = initialize_lower_offset ();
255
- upper_offset = initialize_upper_offset ();
256
- word_offset = initialize_word_offset ();
257
- }
258
-
259
248
// mask for the lower/upper word of a record
260
- // TODO: With C++17 these could be constexpr
261
- /* static constexpr */ std::array<WordT, BLOCK_ELEMENTS>
262
- lower_mask /* = initialize_lower_mask()*/ ;
263
- /* static constexpr */ std::array<WordT, BLOCK_ELEMENTS>
264
- upper_mask /* = initialize_upper_mask()*/ ;
265
- /* static constexpr */ std::array<std::uint8_t , BLOCK_ELEMENTS>
266
- lower_offset /* = initialize_lower_offset()*/ ;
267
- /* static constexpr */ std::array<std::uint8_t , BLOCK_ELEMENTS>
268
- upper_offset /* = initialize_upper_offset()*/ ;
249
+ static constexpr std::array<WordT, BLOCK_ELEMENTS> lower_mask = initialize_lower_mask();
250
+ static constexpr std::array<WordT, BLOCK_ELEMENTS> upper_mask = initialize_upper_mask();
251
+ static constexpr std::array<std::uint8_t , BLOCK_ELEMENTS> lower_offset =
252
+ initialize_lower_offset ();
253
+ static constexpr std::array<std::uint8_t , BLOCK_ELEMENTS> upper_offset =
254
+ initialize_upper_offset ();
269
255
// in which word of the block is the element
270
- /* static constexpr */ std::array<std::uint8_t , BLOCK_ELEMENTS> word_offset =
256
+ static constexpr std::array<std::uint8_t , BLOCK_ELEMENTS> word_offset =
271
257
initialize_word_offset ();
272
258
273
259
struct InternalIndex
@@ -378,35 +364,28 @@ template <typename T, std::size_t Bits, storage::Ownership Ownership> class Pack
378
364
379
365
PackedVector (std::initializer_list<T> list)
380
366
{
381
- initialize ();
382
367
reserve (list.size ());
383
368
for (const auto value : list)
384
369
push_back (value);
385
370
}
386
371
387
- PackedVector () { initialize (); };
372
+ PackedVector (){ };
388
373
PackedVector (const PackedVector &) = default ;
389
374
PackedVector (PackedVector &&) = default ;
390
375
PackedVector &operator =(const PackedVector &) = default ;
391
376
PackedVector &operator =(PackedVector &&) = default ;
392
377
393
- PackedVector (std::size_t size)
394
- {
395
- initialize ();
396
- resize (size);
397
- }
378
+ PackedVector (std::size_t size) { resize (size); }
398
379
399
380
PackedVector (std::size_t size, T initial_value)
400
381
{
401
- initialize ();
402
382
resize (size);
403
383
fill (initial_value);
404
384
}
405
385
406
386
PackedVector (util::ViewOrVector<WordT, Ownership> vec_, std::size_t num_elements)
407
387
: vec(std::move(vec_)), num_elements(num_elements)
408
388
{
409
- initialize ();
410
389
}
411
390
412
391
// forces the efficient read-only lookup
0 commit comments