LLFIO v2.00
Loading...
Searching...
No Matches
llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T > Struct Template Reference

Public Types

using value_type = T
 Value type.
using pointer = value_type *
 Pointer type.
using const_pointer = typename std::pointer_traits<pointer>::template rebind<const value_type>
 Const pointer type.
using difference_type = typename std::pointer_traits<pointer>::difference_type
 Difference type.
using size_type = typename std::make_unsigned<difference_type>::type
 Size type.
using reference = value_type &
 Reference type.
using const_reference = const value_type &
 Const reference type.
using iterator = pointer
 Iterator type.
using const_iterator = const_pointer
 Const iterator type.
using reverse_iterator = std::reverse_iterator<iterator>
 Reverse iterator type.
using const_reverse_iterator = std::reverse_iterator<const_iterator>
 Const reverse iterator type.

Public Member Functions

constexpr trivial_vector_impl ()
 Default constructor.
 trivial_vector_impl (size_type count, const value_type &v)
 Filling constructor of value_type.
template<class InputIt>
 trivial_vector_impl (InputIt first, InputIt last)
 Range constructor.
 trivial_vector_impl (const trivial_vector_impl &)=delete
 Copy constructor disabled, use range constructor if you really want this.
trivial_vector_impl & operator= (const trivial_vector_impl &)=delete
 Copy assigned disabled, use range constructor if you really want this.
 trivial_vector_impl (trivial_vector_impl &&o) noexcept
 Move constructor.
trivial_vector_impl & operator= (trivial_vector_impl &&o) noexcept
 Move assignment.
 trivial_vector_impl (std::initializer_list< value_type > il)
 Initialiser list constructor.
void assign (size_type count, const value_type &v)
 Assigns.
template<class InputIt>
void assign (InputIt first, InputIt last)
 Assigns.
void assign (std::initializer_list< value_type > il)
 Assigns.
reference at (size_type i)
 Item index, bounds checked.
const_reference at (size_type i) const
 Item index, bounds checked.
reference operator[] (size_type i)
 Item index, unchecked.
const_reference operator[] (size_type i) const
 Item index, unchecked.
reference front ()
 First element.
const_reference front () const
 First element.
reference back ()
 Last element.
const_reference back () const
 Last element.
pointer data () noexcept
 Underlying array.
const_pointer data () const noexcept
 Underlying array.
iterator begin () noexcept
 Iterator to first item.
const_iterator begin () const noexcept
 Iterator to first item.
const_iterator cbegin () const noexcept
 Iterator to first item.
iterator end () noexcept
 Iterator to after last item.
const_iterator end () const noexcept
 Iterator to after last item.
const_iterator cend () const noexcept
 Iterator to after last item.
reverse_iterator rbegin () noexcept
 Iterator to last item.
const_reverse_iterator rbegin () const noexcept
 Iterator to last item.
const_reverse_iterator crbegin () const noexcept
 Iterator to last item.
reverse_iterator rend () noexcept
 Iterator to before first item.
const_reverse_iterator rend () const noexcept
 Iterator to before first item.
const_reverse_iterator crend () const noexcept
 Iterator to before first item.
bool empty () const noexcept
 If empty.
size_type size () const noexcept
 Items in container.
size_type max_size () const noexcept
 Maximum items in container.
void reserve (size_type n)
 Increase capacity.
size_type capacity () const noexcept
 Items can be stored until storage expanded.
void shrink_to_fit ()
 Removes unused capacity.
void clear () noexcept
 Clears container.
iterator insert (const_iterator pos, const value_type &v)
 Inserts item.
iterator insert (const_iterator pos, value_type &&v)
 Inserts item.
iterator insert (const_iterator pos, size_type count, const value_type &v)
 Inserts items.
template<class InputIt>
iterator insert (const_iterator pos, InputIt first, InputIt last)
 Inserts items.
iterator insert (const_iterator pos, std::initializer_list< value_type > il)
 Inserts items.
template<class... Args>
iterator emplace (const_iterator pos, Args &&... args)
 Emplace item.
iterator erase (const_iterator pos)
 Erases item.
iterator erase (const_iterator first, const_iterator last)
 Erases items.
void push_back (const value_type &v)
 Appends item.
void push_back (value_type &&v)
 Appends item.
template<class... Args>
reference emplace_back (Args &&... args)
 Appends item.
void pop_back ()
 Removes last element.
void resize (size_type count, const value_type &v)
 Resizes container.
void swap (trivial_vector_impl &o) noexcept
 Swaps.

Constructor & Destructor Documentation

◆ trivial_vector_impl() [1/4]

template<bool has_default_construction, class T>
llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::trivial_vector_impl ( )
inlineconstexpr

Default constructor.

201{} // NOLINT

◆ trivial_vector_impl() [2/4]

template<bool has_default_construction, class T>
llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::trivial_vector_impl ( size_type count,
const value_type & v )
inline

Filling constructor of value_type.

203{ insert(begin(), count, v); }
iterator begin() noexcept
Iterator to first item.
Definition trivial_vector.hpp:282
iterator insert(const_iterator pos, const value_type &v)
Inserts item.
Definition trivial_vector.hpp:382

◆ trivial_vector_impl() [3/4]

template<bool has_default_construction, class T>
template<class InputIt>
llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::trivial_vector_impl ( InputIt first,
InputIt last )
inline

Range constructor.

205{ insert(begin(), first, last); }

◆ trivial_vector_impl() [4/4]

template<bool has_default_construction, class T>
llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::trivial_vector_impl ( trivial_vector_impl< has_default_construction, T > && o)
inlinenoexcept

Move constructor.

211 : _sh(std::move(o._sh)), _mh(std::move(o._mh)), _begin(o._begin), _end(o._end), _capacity(o._capacity)
212 {
213 _mh.set_section(&_sh);
214 o._begin = o._end = o._capacity = nullptr;
215 }

◆ ~trivial_vector_impl()

template<bool has_default_construction, class T>
llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::~trivial_vector_impl ( )
inline
229{ clear(); }
void clear() noexcept
Clears container.
Definition trivial_vector.hpp:375

Member Function Documentation

◆ assign() [1/3]

template<bool has_default_construction, class T>
template<class InputIt>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::assign ( InputIt first,
InputIt last )
inline

Assigns.

239 {
240 clear();
241 insert(begin(), first, last);
242 }

◆ assign() [2/3]

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::assign ( size_type count,
const value_type & v )
inline

Assigns.

233 {
234 clear();
235 insert(begin(), count, v);
236 }

◆ assign() [3/3]

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::assign ( std::initializer_list< value_type > il)
inline

Assigns.

244{ assign(il.begin(), il.end()); }
iterator end() noexcept
Iterator to after last item.
Definition trivial_vector.hpp:288
void assign(size_type count, const value_type &v)
Assigns.
Definition trivial_vector.hpp:232

◆ at() [1/2]

template<bool has_default_construction, class T>
reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::at ( size_type i)
inline

Item index, bounds checked.

248 {
249 if(i >= size())
250 {
251 LLFIO_EXCEPTION_THROW(std::out_of_range("bounds exceeded")); // NOLINT
252 }
253 return _begin[i];
254 }
size_type size() const noexcept
Items in container.
Definition trivial_vector.hpp:309

◆ at() [2/2]

template<bool has_default_construction, class T>
const_reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::at ( size_type i) const
inline

Item index, bounds checked.

257 {
258 if(i >= size())
259 {
260 LLFIO_EXCEPTION_THROW(std::out_of_range("bounds exceeded")); // NOLINT
261 }
262 return _begin[i];
263 }

◆ back() [1/2]

template<bool has_default_construction, class T>
reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::back ( )
inline

Last element.

273{ return _end[-1]; }

◆ back() [2/2]

template<bool has_default_construction, class T>
const_reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::back ( ) const
inline

Last element.

275{ return _end[-1]; }

◆ begin() [1/2]

template<bool has_default_construction, class T>
const_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::begin ( ) const
inlinenoexcept

Iterator to first item.

284{ return const_iterator(_begin); }
const_pointer const_iterator
Const iterator type.
Definition trivial_vector.hpp:178

◆ begin() [2/2]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::begin ( )
inlinenoexcept

Iterator to first item.

282{ return iterator(_begin); }
pointer iterator
Iterator type.
Definition trivial_vector.hpp:176

◆ capacity()

template<bool has_default_construction, class T>
size_type llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::capacity ( ) const
inlinenoexcept

Items can be stored until storage expanded.

349{ return _capacity - _begin; }

◆ cbegin()

template<bool has_default_construction, class T>
const_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::cbegin ( ) const
inlinenoexcept

Iterator to first item.

286{ return const_iterator(_begin); }

◆ cend()

template<bool has_default_construction, class T>
const_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::cend ( ) const
inlinenoexcept

Iterator to after last item.

292{ return const_iterator(_end); }

◆ clear()

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::clear ( )
inlinenoexcept

Clears container.

376 {
377 // Trivially copyable means trivial destructor
378 _end = _begin;
379 }

◆ crbegin()

template<bool has_default_construction, class T>
const_reverse_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::crbegin ( ) const
inlinenoexcept

Iterator to last item.

298{ return const_reverse_iterator(end()); }
std::reverse_iterator< const_iterator > const_reverse_iterator
Const reverse iterator type.
Definition trivial_vector.hpp:182

◆ crend()

template<bool has_default_construction, class T>
const_reverse_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::crend ( ) const
inlinenoexcept

Iterator to before first item.

304{ return const_reverse_iterator(begin()); }

◆ data() [1/2]

template<bool has_default_construction, class T>
const_pointer llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::data ( ) const
inlinenoexcept

Underlying array.

279{ return _begin; }

◆ data() [2/2]

template<bool has_default_construction, class T>
pointer llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::data ( )
inlinenoexcept

Underlying array.

277{ return _begin; }

◆ emplace()

template<bool has_default_construction, class T>
template<class... Args>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::emplace ( const_iterator pos,
Args &&... args )
inline

Emplace item.

443 {
444 // reserve() may remap, which invalidates pos, so remember where it was
445 const auto offset = pos - _begin;
446 if(capacity() == size())
447 {
448 reserve(_scale_capacity(capacity()));
449 }
450 value_type *p = _begin + offset;
451 // Trivially copyable, so memmove
452 memmove(p + 1, p, (_end - p) * sizeof(value_type));
453 // BUT complex constructors may throw!
455 {
457 }
459 {
460 memmove(p, p + 1, (_end - p) * sizeof(value_type));
462 }
463 ++_end;
464 return iterator(p);
465 }
size_type capacity() const noexcept
Items can be stored until storage expanded.
Definition trivial_vector.hpp:349
void reserve(size_type n)
Increase capacity.
Definition trivial_vector.hpp:313
T value_type
Value type.
Definition trivial_vector.hpp:162

◆ emplace_back()

template<bool has_default_construction, class T>
template<class... Args>
reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::emplace_back ( Args &&... args)
inline

Appends item.

499 {
500 if(_end == _capacity)
501 {
502 reserve(_scale_capacity(capacity()));
503 }
504 new(_end) value_type(std::forward<Args>(args)...);
505 ++_end;
506 return *(_end - 1);
507 }

◆ empty()

template<bool has_default_construction, class T>
bool llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::empty ( ) const
inlinenoexcept

If empty.

307{ return _end == _begin; }

◆ end() [1/2]

template<bool has_default_construction, class T>
const_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::end ( ) const
inlinenoexcept

Iterator to after last item.

290{ return const_iterator(_end); }

◆ end() [2/2]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::end ( )
inlinenoexcept

Iterator to after last item.

288{ return iterator(_end); }

◆ erase() [1/2]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::erase ( const_iterator first,
const_iterator last )
inline

Erases items.

479 {
480 value_type *f = const_cast<value_type *>(first), *l = const_cast<value_type *>(last);
481 // Trivially copyable
482 memmove(f, l, (_end - l) * sizeof(value_type));
483 _end -= l - f;
484 return iterator(f);
485 }

◆ erase() [2/2]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::erase ( const_iterator pos)
inline

Erases item.

469 {
470 // The iterator types are raw pointers, so there is no _v member to use
471 value_type *p = const_cast<value_type *>(pos);
472 // Trivially copyable
473 memmove(p, p + 1, ((_end - 1) - p) * sizeof(value_type));
474 --_end;
475 return iterator(p);
476 }

◆ front() [1/2]

template<bool has_default_construction, class T>
reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::front ( )
inline

First element.

269{ return _begin[0]; }

◆ front() [2/2]

template<bool has_default_construction, class T>
const_reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::front ( ) const
inline

First element.

271{ return _begin[0]; }

◆ insert() [1/5]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::insert ( const_iterator pos,
const value_type & v )
inline

Inserts item.

382{ return emplace(pos, v); }
iterator emplace(const_iterator pos, Args &&... args)
Emplace item.
Definition trivial_vector.hpp:442

◆ insert() [2/5]

template<bool has_default_construction, class T>
template<class InputIt>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::insert ( const_iterator pos,
InputIt first,
InputIt last )
inline

Inserts items.

414 {
416 const auto offset = pos - _begin;
417 {
419 // Grow until the current capacity can hold everything. This test was
420 // inverted: it grew while there was already enough room, so an insert
421 // larger than the spare capacity reserved the capacity it already had
422 // and then memmoved past the end of the mapping.
423 while(size() + count > cap)
424 {
425 cap = _scale_capacity(cap);
426 }
427 reserve(cap);
428 }
429 value_type *p = _begin + offset;
430 // Trivially copyable, so memmove and we know copy construction can't fail
431 memmove(p + count, p, (_end - p) * sizeof(value_type));
432 for(size_type n = 0; n < count; n++)
433 {
434 new(p + n) value_type(*first++);
435 }
436 _end += count;
437 return iterator(p);
438 }
typename std::make_unsigned< difference_type >::type size_type
Size type.
Definition trivial_vector.hpp:170

◆ insert() [3/5]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::insert ( const_iterator pos,
size_type count,
const value_type & v )
inline

Inserts items.

387 {
388 // reserve() may remap, which invalidates pos, so remember where it was
389 const auto offset = pos - _begin;
390 {
392 // Grow until the current capacity can hold everything. This test was
393 // inverted: it grew while there was already enough room, so an insert
394 // larger than the spare capacity reserved the capacity it already had
395 // and then memmoved past the end of the mapping.
396 while(size() + count > cap)
397 {
398 cap = _scale_capacity(cap);
399 }
400 reserve(cap);
401 }
402 value_type *p = _begin + offset;
403 // Trivially copyable, so memmove and we know copy construction can't fail
404 memmove(p + count, p, (_end - p) * sizeof(value_type));
405 for(size_type n = 0; n < count; n++)
406 {
407 new(p + n) value_type(v);
408 }
409 _end += count;
410 return iterator(p);
411 }

◆ insert() [4/5]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::insert ( const_iterator pos,
std::initializer_list< value_type > il )
inline

Inserts items.

440{ return insert(pos, il.begin(), il.end()); }

◆ insert() [5/5]

template<bool has_default_construction, class T>
iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::insert ( const_iterator pos,
value_type && v )
inline

Inserts item.

384{ return emplace(pos, std::move(v)); }

◆ max_size()

template<bool has_default_construction, class T>
size_type llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::max_size ( ) const
inlinenoexcept

Maximum items in container.

311{ return static_cast<map_handle::size_type>(-1) / sizeof(T); }

◆ operator=()

template<bool has_default_construction, class T>
trivial_vector_impl & llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::operator= ( trivial_vector_impl< has_default_construction, T > && o)
inlinenoexcept

Move assignment.

218 {
219 if(this == &o)
220 {
221 return *this;
222 }
223 this->~trivial_vector_impl();
224 new(this) trivial_vector_impl(std::move(o));
225 return *this;
226 }
constexpr trivial_vector_impl()
Default constructor.
Definition trivial_vector.hpp:201

◆ operator[]() [1/2]

template<bool has_default_construction, class T>
reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::operator[] ( size_type i)
inline

Item index, unchecked.

265{ return _begin[i]; }

◆ operator[]() [2/2]

template<bool has_default_construction, class T>
const_reference llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::operator[] ( size_type i) const
inline

Item index, unchecked.

267{ return _begin[i]; }

◆ pop_back()

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::pop_back ( )
inline

Removes last element.

510 {
511 if(!empty())
512 {
513 --_end;
514 }
515 }
bool empty() const noexcept
If empty.
Definition trivial_vector.hpp:307

◆ push_back() [1/2]

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::push_back ( const value_type & v)
inline

Appends item.

488 {
489 if(_end == _capacity)
490 {
491 reserve(_scale_capacity(capacity()));
492 }
493 new(_end++) value_type(v);
494 }

◆ push_back() [2/2]

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::push_back ( value_type && v)
inline

Appends item.

496{ push_back(v); }
void push_back(const value_type &v)
Appends item.
Definition trivial_vector.hpp:487

◆ rbegin() [1/2]

template<bool has_default_construction, class T>
const_reverse_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::rbegin ( ) const
inlinenoexcept

Iterator to last item.

296{ return const_reverse_iterator(end()); }

◆ rbegin() [2/2]

template<bool has_default_construction, class T>
reverse_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::rbegin ( )
inlinenoexcept

Iterator to last item.

294{ return reverse_iterator(end()); }
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator type.
Definition trivial_vector.hpp:180

◆ rend() [1/2]

template<bool has_default_construction, class T>
const_reverse_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::rend ( ) const
inlinenoexcept

Iterator to before first item.

302{ return const_reverse_iterator(begin()); }

◆ rend() [2/2]

template<bool has_default_construction, class T>
reverse_iterator llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::rend ( )
inlinenoexcept

Iterator to before first item.

300{ return reverse_iterator(begin()); }

◆ reserve()

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::reserve ( size_type n)
inline

Increase capacity.

314 {
315 if(n > max_size())
316 {
317 LLFIO_EXCEPTION_THROW(std::length_error("Max size exceeded")); // NOLINT
318 }
320 size_type bytes = n * sizeof(value_type);
322 if(!_sh.is_valid())
323 {
324 _sh = section_handle::section(bytes).value();
325 _mh = map_handle::map(_sh, bytes).value();
326 }
327 else if(n > capacity())
328 {
329 // We can always grow a section even with maps open on it
330 _sh.truncate(bytes).value();
331 // Attempt to resize the map in place
332 if(!_mh.truncate(bytes, true))
333 {
334 // std::cerr << "truncate fail" << std::endl;
335 // If can't resize, close the map and reopen it into a new address
336 _mh.close().value();
337 _mh = map_handle::map(_sh, bytes).value();
338 }
339 }
340 else
341 {
342 return;
343 }
344 _begin = reinterpret_cast<pointer>(_mh.address());
345 _capacity = reinterpret_cast<pointer>(_mh.address() + bytes);
346 _end = _begin + current_size;
347 }
static result< map_handle > map(size_type bytes, bool zeroed=false, section_handle::flag _flag=section_handle::flag::readwrite) noexcept
Definition map_handle.hpp:634
static result< section_handle > section(file_handle &backing, extent_type maximum_size, flag _flag) noexcept
Create a memory section backed by a file.
T round_up_to_page_size(T i, size_t pagesize) noexcept
Round a value to its next highest page size multiple.
Definition utils.hpp:67
value_type * pointer
Pointer type.
Definition trivial_vector.hpp:164
size_type max_size() const noexcept
Maximum items in container.
Definition trivial_vector.hpp:311

◆ resize()

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::resize ( size_type count,
const value_type & v )
inline

Resizes container.

519 {
520 if(count < size())
521 {
522 // Trivially copyable means trivial destructor
523 _end = _begin + count;
524 return;
525 }
526 if(count > capacity())
527 {
528 reserve(count);
529 }
530 // TODO(ned): Kinda assuming the compiler will do the right thing below, should really check that
531 while(count - size() >= 16)
532 {
533 new(_end++) value_type(v);
534 new(_end++) value_type(v);
535 new(_end++) value_type(v);
536 new(_end++) value_type(v);
537 new(_end++) value_type(v);
538 new(_end++) value_type(v);
539 new(_end++) value_type(v);
540 new(_end++) value_type(v);
541 new(_end++) value_type(v);
542 new(_end++) value_type(v);
543 new(_end++) value_type(v);
544 new(_end++) value_type(v);
545 new(_end++) value_type(v);
546 new(_end++) value_type(v);
547 new(_end++) value_type(v);
548 new(_end++) value_type(v);
549 }
550 while(count > size())
551 {
552 new(_end++) value_type(v);
553 }
554 }

◆ shrink_to_fit()

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::shrink_to_fit ( )
inline

Removes unused capacity.

352 {
355 bytes = utils::round_up_to_page_size(bytes, _mh.page_size());
356 if(bytes / sizeof(value_type) == capacity())
357 {
358 return;
359 }
360 if(bytes == 0)
361 {
362 _mh.close().value();
363 _sh.close().value();
364 _begin = _end = _capacity = nullptr;
365 return;
366 }
367 _mh.close().value();
368 _sh.truncate(bytes).value();
369 _mh = map_handle::map(_sh, bytes).value();
370 _begin = reinterpret_cast<pointer>(_mh.address());
371 _capacity = reinterpret_cast<pointer>(_mh.address() + bytes);
372 _end = _begin + current_size;
373 }

◆ size()

template<bool has_default_construction, class T>
size_type llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::size ( ) const
inlinenoexcept

Items in container.

309{ return _end - _begin; }

◆ swap()

template<bool has_default_construction, class T>
void llfio_v2_xxx::algorithm::impl::trivial_vector_impl< has_default_construction, T >::swap ( trivial_vector_impl< has_default_construction, T > & o)
inlinenoexcept

Swaps.

557 {
558 using namespace std;
559 swap(_sh, o._sh);
560 swap(_mh, o._mh);
561 swap(_begin, o._begin);
562 swap(_end, o._end);
563 swap(_capacity, o._capacity);
564 }
void swap(trivial_vector_impl &o) noexcept
Swaps.
Definition trivial_vector.hpp:556

The documentation for this struct was generated from the following file: