libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal::Vector< T > Class Template Reference
Inheritance diagram for gimbal::Vector< T >:
GblArrayList gimbal::VectorViewBase< Vector< T >, T > gimbal::tags::VectorBase gimbal::ReadWriteContiguousIndexable< CRTP, Index, Value > gimbal::RandomAccessIterable< CRTP, Index, Value > gimbal::ReadWriteIndexable< CRTP, Index, Value, true > gimbal::FlexibleVector< ExtraStackSize, T >

Public Types

using VectorType = Vector< T >
 
using VectorViewBaseType = VectorViewBase< Vector< T >, T >
 
using ViewType = VectorViewBaseType
 
using MoveValues = std::tuple< void *, Size, Size >
 
using iterator = typename VectorViewBaseType::iterator
 
using const_iterator = typename VectorViewBaseType::const_iterator
 
using difference_type = typename VectorViewBaseType::difference_type
 
- Public Types inherited from gimbal::VectorViewBase< Vector< T >, T >
using VectorViewBaseType = VectorViewBase< Vector< T >, T >
 
using DerivedType = Vector< T >
 
using IterableType = RandomAccessIterable< Vector< T >, Size, T >
 
using IndexableType = ReadWriteContiguousIndexable< Vector< T >, Size, T >
 
using value_type = T
 
using allocator_type = Context *
 
using size_type = Size
 
using difference_type = std::ptrdiff_t
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = T *
 
using const_pointer = const T *
 
using iterator = typename IterableType::iterator
 
using const_iterator = typename IterableType::const_iterator
 
using reverse_iterator = typename IterableType::reverse_iterator
 
using reverse_const_iterator = typename IterableType::reverse_const_iterator
 
- Public Types inherited from gimbal::RandomAccessIterable< CRTP, Index, Value >
using iterator = RandomAccessIterator< CRTP, Index, Value, false >
 
using reverse_iterator = RandomAccessIterator< CRTP, Index, Value, true >
 
using const_iterator = RandomAccessIterator< std::add_const_t< CRTP >, Index, Value, false >
 
using reverse_const_iterator = RandomAccessIterator< std::add_const_t< CRTP >, Index, Value, true >
 

Public Member Functions

const GblArrayListgetVector_ (void) const
 
GblArrayListgetVector_ (void)
 
 Vector (std::nullptr_t, Size allocSize=sizeof(VectorType))
 
 Vector (Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (const T *pInitialData, Size elementCount, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType), Size elementSize=sizeof(T))
 
 Vector (Size count, const T &value=T(), Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (std::initializer_list< T > c, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (type_compatible_container_readable< T > auto &&c, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (const type_compatible_iterator_readable< T > auto &first, const type_compatible_iterator_readable< T > auto &last, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (const VectorType &other, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (VectorView< T > other, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (VectorType &&rhs, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (GblArrayList &&rhs, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
auto take (void)
 
void give (MoveValues moveValues)
 
void reserve (Size count)
 
void resize (Size newSize)
 
void shrink_to_fit (void)
 
void pushBack (T value)
 
void push_back (T value)
 
template<typename... Args>
T & emplace_back (Args &&... args)
 
void pushFront (T value)
 
void push_front (T value)
 
iterator insert (const_iterator position, const T *pValue, Size count)
 
iterator insert (const_iterator position, const T &val)
 
iterator insert (const_iterator position, gimbal::Size size, const T &val)
 
iterator insert (const_iterator position, const type_compatible_iterator_readable< T > auto &first, const type_compatible_iterator_readable< T > auto &last)
 
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
iterator insert (const_iterator position, const It &first, const It &last)
 
iterator insert (const_iterator position, const type_compatible_container_readable< T > auto &c)
 
iterator insert (const_iterator position, const type_compatible_contiguous_container_readable< T > auto &c)
 
template<typename... Args>
iterator emplace (const_iterator position, Args &&... args)
 
void popBack (void)
 
void pop_back (void)
 
iterator erase (const_iterator pos)
 
iterator erase (const_iterator first, const_iterator last)
 
void clear (void)
 
void assign (const T *pData, Size elementCount)
 
void assign (gimbal::Size size, const T &value)
 
void assign (const type_compatible_contiguous_container_readable< T > auto &c)
 
void assign (const type_compatible_container_readable< T > auto &c)
 
void assign (const type_compatible_iterator_readable< T > auto &first, const type_compatible_iterator_readable< T > auto &last)
 
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
void assign (const It &first, const It &last)
 
const VectorTypeoperator= (VectorView< T > rhs)
 
const VectorTypeoperator= (const VectorType &rhs)
 
const VectorTypeoperator= (VectorType &&rhs)
 
const VectorTypeoperator= (GblArrayList &&rhs)
 
const VectorTypeoperator= (const type_compatible_container< T > auto &&c)
 
const VectorTypeoperator+= (const type_compatible_container_readable< T > auto &view)
 
const VectorTypeoperator+= (const type_compatible_iterator_readable< T > auto &it)
 
const VectorTypeoperator+= (const T &value)
 
const VectorTypeoperator+= (VectorView< T > view)
 
- Public Member Functions inherited from gimbal::VectorViewBase< Vector< T >, T >
 operator const GblArrayList * () const
 
const_reference getElement_ (size_type index) const
 
reference getElement_ (size_type index)
 
void setElement_ (size_type index, value_type value)
 
size_t getElementCount_ (void) const
 
bool isEmpty (void) const
 
bool isStack (void) const
 
bool isHeap (void) const
 
std::vector< value_type > toStdVector (void) const
 
Size getStackBytes (void) const
 
ContextgetContext (void) const
 
allocator_type get_allocator (void) const
 
Size getSize (void) const
 
Size getSizeBytes (void) const
 
Size size_bytes (void) const
 
Size getCapacity (void) const
 
Size capacity (void) const
 
Size getElementSize (void) const
 
size_type element_size (void) const
 
size_type max_size (void) const
 
const void * getData (void) const
 
constexpr pointer data (void)
 
constexpr const_pointer data (void) const
 
T & front (void) const
 
T & back (void) const
 
- Public Member Functions inherited from gimbal::ReadWriteContiguousIndexable< CRTP, Index, Value >
void checkBounds (Index index) const
 
Index size (void) const
 
Index length (void) const
 
Index empty (void) const
 
Value at (Index index) const
 
IndexableProxy at (Index index)
 
Value front (Index index) const
 
IndexableProxy front (void)
 
Value back (void) const
 
IndexableProxy back (void)
 
- Public Member Functions inherited from gimbal::ReadWriteIndexable< CRTP, Index, Value, true >
Value operator[] (Index key) const
 
- Public Member Functions inherited from gimbal::RandomAccessIterable< CRTP, Index, Value >
iterator begin (void)
 
auto begin (void) const
 
auto rbegin (void)
 
auto rbegin (void) const
 
iterator end (void)
 
auto end (void) const
 
auto rend (void)
 
auto rend (void) const
 
const_iterator cbegin (void) const
 
auto crbegin (void) const
 
const_iterator cend (void) const
 
auto crend (void) const
 

Static Public Member Functions

static MoveValues take (GblArrayList *pVec)
 

Protected Member Functions

void destruct_ (Size startPos, Size count=1)
 
- Protected Member Functions inherited from gimbal::VectorViewBase< Vector< T >, T >
decltype(auto) vec_ (void) const
 
decltype(auto) vec_ (void)
 
void * at_ (Size index) const
 

Additional Inherited Members

- Data Fields inherited from GblArrayList
struct { 
 
   GblContext *   pCtx 
 
   uint8_t *   pData 
 
   size_t   size 
 
   size_t   capacity 
 
   uint16_t   elementSize 
 
   uint16_t   zeroTerminated: 1 
 
   uint16_t   stackCapacity: 15 
 
private_ 
 

Detailed Description

template<typename T>
class gimbal::Vector< T >

Definition at line 274 of file gimbal_vector.hpp.

Member Typedef Documentation

◆ VectorType

template<typename T >
using gimbal::Vector< T >::VectorType = Vector<T>

Definition at line 289 of file gimbal_vector.hpp.

◆ VectorViewBaseType

template<typename T >
using gimbal::Vector< T >::VectorViewBaseType = VectorViewBase<Vector<T>, T>

Definition at line 290 of file gimbal_vector.hpp.

◆ ViewType

template<typename T >
using gimbal::Vector< T >::ViewType = VectorViewBaseType

Definition at line 291 of file gimbal_vector.hpp.

◆ MoveValues

template<typename T >
using gimbal::Vector< T >::MoveValues = std::tuple<void*, Size, Size>

Definition at line 292 of file gimbal_vector.hpp.

◆ iterator

template<typename T >
using gimbal::Vector< T >::iterator = typename VectorViewBaseType::iterator

Definition at line 293 of file gimbal_vector.hpp.

◆ const_iterator

template<typename T >
using gimbal::Vector< T >::const_iterator = typename VectorViewBaseType::const_iterator

Definition at line 294 of file gimbal_vector.hpp.

◆ difference_type

template<typename T >
using gimbal::Vector< T >::difference_type = typename VectorViewBaseType::difference_type

Definition at line 295 of file gimbal_vector.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/11]

template<typename T >
gimbal::Vector< T >::Vector ( std::nullptr_t  ,
Size  allocSize = sizeof(VectorType) 
)
inlineexplicit

Definition at line 308 of file gimbal_vector.hpp.

308 :
309 Vector(nullptr, 0, nullptr, allocSize) {}

◆ Vector() [2/11]

template<typename T >
gimbal::Vector< T >::Vector ( Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inlineexplicit

Definition at line 312 of file gimbal_vector.hpp.

312 :
313 Vector(nullptr, 0, pCtx, allocSize) {}

◆ Vector() [3/11]

template<typename T >
gimbal::Vector< T >::Vector ( const T *  pInitialData,
Size  elementCount,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType),
Size  elementSize = sizeof(T) 
)
inlineexplicit

Definition at line 316 of file gimbal_vector.hpp.

316 {
317 Exception::checkThrow(GblArrayList_construct(this, elementSize, elementCount, pInitialData, allocSize, pCtx));
318 }

◆ Vector() [4/11]

template<typename T >
gimbal::Vector< T >::Vector ( Size  count,
const T &  value = T(),
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inlineexplicit

Definition at line 321 of file gimbal_vector.hpp.

321 {
322 T* pTempArray = static_cast<T*>(GBL_ALLOCA(count * sizeof(T)));
323 std::fill(pTempArray, pTempArray+count, value);
324 Exception::checkThrow(GblArrayList_construct(this, sizeof(T), count, pTempArray, allocSize, pCtx));
325 }

◆ Vector() [5/11]

template<typename T >
gimbal::Vector< T >::Vector ( std::initializer_list< T >  c,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inline

Definition at line 328 of file gimbal_vector.hpp.

328 :
329 Vector(pCtx, allocSize)
330 {
331 insert(this->begin(), c.begin(), c.end());
332 }

◆ Vector() [6/11]

template<typename T >
gimbal::Vector< T >::Vector ( type_compatible_container_readable< T > auto &&  c,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inlineexplicit

Definition at line 336 of file gimbal_vector.hpp.

336 :
337 Vector(pCtx, allocSize)
338 {
339 *this = std::forward<decltype(c)>(c);
340 }

◆ Vector() [7/11]

template<typename T >
gimbal::Vector< T >::Vector ( const type_compatible_iterator_readable< T > auto &  first,
const type_compatible_iterator_readable< T > auto &  last,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inlineexplicit

Definition at line 343 of file gimbal_vector.hpp.

343 :
344 Vector(pCtx, allocSize)
345 {
346 insert(this->end(), first, last);
347 }

◆ Vector() [8/11]

template<typename T >
gimbal::Vector< T >::Vector ( const VectorType other,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inline

Definition at line 352 of file gimbal_vector.hpp.

352 :
353 Vector(VectorView(other), pCtx, allocSize) {}

◆ Vector() [9/11]

template<typename T >
gimbal::Vector< T >::Vector ( VectorView< T >  other,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inline

Definition at line 356 of file gimbal_vector.hpp.

356 :
357 Vector(other.data(), other.size(), pCtx, allocSize) {}

◆ Vector() [10/11]

template<typename T >
gimbal::Vector< T >::Vector ( VectorType &&  rhs,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inline

Definition at line 363 of file gimbal_vector.hpp.

363 :
364 Vector(static_cast<GblArrayList&&>(rhs), pCtx, allocSize) {}
Contiguous, array-based abstract list container with C++-style STL API.

◆ Vector() [11/11]

template<typename T >
gimbal::Vector< T >::Vector ( GblArrayList &&  rhs,
Context pCtx = nullptr,
Size  allocSize = sizeof(VectorType) 
)
inline

Definition at line 367 of file gimbal_vector.hpp.

367 :
368 Vector(pCtx, allocSize)
369 {
370 *this = std::move(rhs);
371 }

◆ ~Vector()

template<typename T >
gimbal::Vector< T >::~Vector ( void  )
inline

Definition at line 389 of file gimbal_vector.hpp.

389 {
390 destruct_(0, size());
391 Exception::checkThrow(GblArrayList_destruct(this));
392 }

Member Function Documentation

◆ destruct_()

template<typename T >
void gimbal::Vector< T >::destruct_ ( Size  startPos,
Size  count = 1 
)
inlineprotected

Definition at line 280 of file gimbal_vector.hpp.

280 {
281 if constexpr(std::is_destructible_v<T>) {
282 for(Size i = startPos; i < count; ++i) {
283 this->data()[i].~T();
284 }
285 }
286 }

◆ getVector_() [1/2]

template<typename T >
const GblArrayList * gimbal::Vector< T >::getVector_ ( void  ) const
inline

Definition at line 297 of file gimbal_vector.hpp.

297 {
298 return static_cast<const GblArrayList*>(this);
299 }

◆ getVector_() [2/2]

template<typename T >
GblArrayList * gimbal::Vector< T >::getVector_ ( void  )
inline

Definition at line 301 of file gimbal_vector.hpp.

301 {
302 return static_cast<GblArrayList*>(this);
303 }

◆ take() [1/2]

template<typename T >
static MoveValues gimbal::Vector< T >::take ( GblArrayList pVec)
inlinestatic

Definition at line 373 of file gimbal_vector.hpp.

373 {
374 auto moveValues = MoveValues(nullptr, 0, 0);
375 auto& [pData, size, capacity] = moveValues;
376 Exception::checkThrow(GblArrayList_release(pVec, &pData, &size, &capacity));
377 return moveValues;
378 }

◆ take() [2/2]

template<typename T >
auto gimbal::Vector< T >::take ( void  )
inline

Definition at line 380 of file gimbal_vector.hpp.

380 {
381 return take(this);
382 }

◆ give()

template<typename T >
void gimbal::Vector< T >::give ( MoveValues  moveValues)
inline

Definition at line 384 of file gimbal_vector.hpp.

384 {
385 auto& [pData, size, capacity] = moveValues;
386 Exception::checkThrow(GblArrayList_acquire(this, pData, size, capacity));
387 }

◆ reserve()

template<typename T >
void gimbal::Vector< T >::reserve ( Size  count)
inline

Definition at line 397 of file gimbal_vector.hpp.

397 {
398 Exception::checkThrow(GblArrayList_reserve(this, count));
399 }

◆ resize()

template<typename T >
void gimbal::Vector< T >::resize ( Size  newSize)
inline

Definition at line 401 of file gimbal_vector.hpp.

401 {
402 if(newSize < size()) {
403 destruct_(newSize, size() - newSize);
404 }
405 Exception::checkThrow(GblArrayList_resize(this, newSize));
406 }

◆ shrink_to_fit()

template<typename T >
void gimbal::Vector< T >::shrink_to_fit ( void  )
inline

Definition at line 408 of file gimbal_vector.hpp.

408 {
409 Exception::checkThrow(GblArrayList_shrinkToFit(this));
410 }

◆ pushBack()

template<typename T >
void gimbal::Vector< T >::pushBack ( value)
inline

Definition at line 412 of file gimbal_vector.hpp.

412 {
413 Exception::checkThrow(GblArrayList_pushBack(this, &value));
414 }

◆ push_back()

template<typename T >
void gimbal::Vector< T >::push_back ( value)
inline

Definition at line 416 of file gimbal_vector.hpp.

416 {
417 pushBack(std::move(value));
418 }

◆ emplace_back()

template<typename T >
template<typename... Args>
T & gimbal::Vector< T >::emplace_back ( Args &&...  args)
inline

Definition at line 421 of file gimbal_vector.hpp.

421 {
422 resize(size()+1);
423 void* pData = this->at_(size()-1);
424 T* pObj = new (pData) T(std::forward<Args>(args)...);
425 return *pObj;
426 }

◆ pushFront()

template<typename T >
void gimbal::Vector< T >::pushFront ( value)
inline

Definition at line 428 of file gimbal_vector.hpp.

428 {
429 Exception::checkThrow(GblArrayList_pushFront(this, &value));
430 }

◆ push_front()

template<typename T >
void gimbal::Vector< T >::push_front ( value)
inline

Definition at line 432 of file gimbal_vector.hpp.

432 {
433 pushFront(std::move(value));
434 }

◆ insert() [1/7]

template<typename T >
iterator gimbal::Vector< T >::insert ( const_iterator  position,
const T *  pValue,
Size  count 
)
inline

Definition at line 436 of file gimbal_vector.hpp.

436 {
437 const auto index = std::distance(this->cbegin(), position);
438 Exception::checkThrow([&]() {
439 GblArrayList_insert(this, index, count, pValue);
440 });
441 return iterator(*this, index);
442 }

◆ insert() [2/7]

template<typename T >
iterator gimbal::Vector< T >::insert ( const_iterator  position,
const T &  val 
)
inline

Definition at line 444 of file gimbal_vector.hpp.

444 {
445 return insert(std::move(position), &val, 1);
446 }

◆ insert() [3/7]

template<typename T >
iterator gimbal::Vector< T >::insert ( const_iterator  position,
gimbal::Size  size,
const T &  val 
)
inline

Definition at line 448 of file gimbal_vector.hpp.

448 {
449 T* pTempArray = static_cast<T*>(GBL_ALLOCA(size * sizeof(T)));
450 std::fill(pTempArray, pTempArray+size, val);
451 return insert(std::move(position), pTempArray, size);
452 }

◆ insert() [4/7]

template<typename T >
iterator gimbal::Vector< T >::insert ( const_iterator  position,
const type_compatible_iterator_readable< T > auto &  first,
const type_compatible_iterator_readable< T > auto &  last 
)
inline

Definition at line 454 of file gimbal_vector.hpp.

454 {
455 const auto size = std::distance(first, last);
456 T* pTempArray = static_cast<T*>(GBL_ALLOCA(size * sizeof(T)));
457 std::copy(first, last, pTempArray);
458 return insert(std::move(position), pTempArray, size);
459 }

◆ insert() [5/7]

template<typename T >
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
iterator gimbal::Vector< T >::insert ( const_iterator  position,
const It &  first,
const It &  last 
)
inline

Definition at line 463 of file gimbal_vector.hpp.

463 {
464 return insert(std::move(position), &first[0], std::distance(first, last));
465 }

◆ insert() [6/7]

template<typename T >
iterator gimbal::Vector< T >::insert ( const_iterator  position,
const type_compatible_container_readable< T > auto &  c 
)
inline

Definition at line 467 of file gimbal_vector.hpp.

467 {
468 return insert(std::move(position), std::cbegin(c), std::cend(c));
469 }

◆ insert() [7/7]

template<typename T >
iterator gimbal::Vector< T >::insert ( const_iterator  position,
const type_compatible_contiguous_container_readable< T > auto &  c 
)
inline

Definition at line 471 of file gimbal_vector.hpp.

471 {
472 return insert(std::move(position), c.data(), std::size(c));
473 }

◆ emplace()

template<typename T >
template<typename... Args>
iterator gimbal::Vector< T >::emplace ( const_iterator  position,
Args &&...  args 
)
inline

Definition at line 476 of file gimbal_vector.hpp.

476 {
477 const auto index = std::distance(this->cbegin(), position);
478 void* pData = nullptr;
479 Exception::checkThrow([&]() {
480 pData = GblArrayList_insert(this, index, 1, nullptr);
481 });
482 T* pObj = new (pData) T(std::forward<Args>(args)...);
483 return iterator(*this, index);
484 }

◆ popBack()

template<typename T >
void gimbal::Vector< T >::popBack ( void  )
inline

Definition at line 486 of file gimbal_vector.hpp.

486 {// throw if bullshit
487 destruct_(this->getSize()-1, 1);
488 erase(this->end()-1);
489 }

◆ pop_back()

template<typename T >
void gimbal::Vector< T >::pop_back ( void  )
inline

Definition at line 491 of file gimbal_vector.hpp.

491 {
492 popBack();
493 }

◆ erase() [1/2]

template<typename T >
iterator gimbal::Vector< T >::erase ( const_iterator  pos)
inline

Definition at line 495 of file gimbal_vector.hpp.

495 {
496 return erase(pos, pos+1);
497 }

◆ erase() [2/2]

template<typename T >
iterator gimbal::Vector< T >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Definition at line 499 of file gimbal_vector.hpp.

499 {
500 const auto index = std::distance<const_iterator>(this->begin(), first);
501 const auto count = std::distance(first, last);
502 destruct_(index, count);
503 Exception::checkThrow(GblArrayList_erase(this, index, count));
504 return iterator(*this, index+count);
505 }

◆ clear()

template<typename T >
void gimbal::Vector< T >::clear ( void  )
inline

Definition at line 507 of file gimbal_vector.hpp.

507 {
508 destruct_(0, this->getSize());
509 Exception::checkThrow(GblArrayList_clear(this));
510 }

◆ assign() [1/6]

template<typename T >
void gimbal::Vector< T >::assign ( const T *  pData,
Size  elementCount 
)
inline

Definition at line 512 of file gimbal_vector.hpp.

512 {
513 Exception::checkThrow(GblArrayList_assign(this, pData, elementCount));
514 }

◆ assign() [2/6]

template<typename T >
void gimbal::Vector< T >::assign ( gimbal::Size  size,
const T &  value 
)
inline

Definition at line 516 of file gimbal_vector.hpp.

516 {
517 T* pTempArray = static_cast<T*>(GBL_ALLOCA(size * sizeof(T)));
518 std::fill(pTempArray, pTempArray+size, value);
519 assign(pTempArray, size);
520 }

◆ assign() [3/6]

template<typename T >
void gimbal::Vector< T >::assign ( const type_compatible_contiguous_container_readable< T > auto &  c)
inline

Definition at line 522 of file gimbal_vector.hpp.

522 {
523 assign(c.data(), std::size(c));
524 }

◆ assign() [4/6]

template<typename T >
void gimbal::Vector< T >::assign ( const type_compatible_container_readable< T > auto &  c)
inline

Definition at line 526 of file gimbal_vector.hpp.

526 {
527 T* pTempArray = static_cast<T*>(GBL_ALLOCA(std::size(c) * sizeof(T)));
528 std::copy(begin(c), end(c), pTempArray);
529 Exception::checkThrow(GblArrayList_assign(this, pTempArray, std::size(c)));
530 }

◆ assign() [5/6]

template<typename T >
void gimbal::Vector< T >::assign ( const type_compatible_iterator_readable< T > auto &  first,
const type_compatible_iterator_readable< T > auto &  last 
)
inline

Definition at line 532 of file gimbal_vector.hpp.

532 {
533 const auto size = std::distance(first, last);
534 T* pTempArray = static_cast<T*>(GBL_ALLOCA(size * sizeof(T)));
535 std::copy(first, last, pTempArray);
536 assign(pTempArray, size);
537 }

◆ assign() [6/6]

template<typename T >
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
void gimbal::Vector< T >::assign ( const It &  first,
const It &  last 
)
inline

Definition at line 541 of file gimbal_vector.hpp.

541 {
542
543 const T* pData = &first[0];
544 const auto dist = std::distance(first, last);
545
546 assign(pData, dist);
547 }

◆ operator=() [1/5]

template<typename T >
const VectorType & gimbal::Vector< T >::operator= ( VectorView< T >  rhs)
inline

Definition at line 549 of file gimbal_vector.hpp.

549 {
550 Exception::checkThrow(GblArrayList_assign(this, rhs.data(), rhs.size()));
551 return *this;
552 }

◆ operator=() [2/5]

template<typename T >
const VectorType & gimbal::Vector< T >::operator= ( const VectorType rhs)
inline

Definition at line 554 of file gimbal_vector.hpp.

554 {
555 return *this = VectorView<T>(rhs);
556 }

◆ operator=() [3/5]

template<typename T >
const VectorType & gimbal::Vector< T >::operator= ( VectorType &&  rhs)
inline

Definition at line 558 of file gimbal_vector.hpp.

558 {
559 return *this = static_cast<GblArrayList&&>(rhs);
560 }

◆ operator=() [4/5]

template<typename T >
const VectorType & gimbal::Vector< T >::operator= ( GblArrayList &&  rhs)
inline

Definition at line 562 of file gimbal_vector.hpp.

562 {
563 VectorView<T> rhsView(rhs); //C++ wrapper "viewing" C object
564
565 if(this->getContext() == rhsView.getContext() && rhsView.isHeap()) {
566 give(take(&rhs));
567 } else {
568 *this = rhsView; //do regular-ass copy assignment for generic view
569 }
570 return *this;
571 }

◆ operator=() [5/5]

template<typename T >
const VectorType & gimbal::Vector< T >::operator= ( const type_compatible_container< T > auto &&  c)
inline

Definition at line 573 of file gimbal_vector.hpp.

573 {
574 // check for supported move semantics!
575#ifdef GBL_PMR_VECTOR
576 if constexpr(std::same_as<decltype(c), gimbal::pmr::vector<T>&&>) {
577 if(this->get_allocator() == c.get_allocator()) {
578 assign(c);
579 }
580 } else {
581#endif
582 assign(c);
583#ifdef GBL_PMR_VECTOR
584 }
585#endif
586 return *this;
587 }

◆ operator+=() [1/4]

template<typename T >
const VectorType & gimbal::Vector< T >::operator+= ( const type_compatible_container_readable< T > auto &  view)
inline

Definition at line 589 of file gimbal_vector.hpp.

589 {
590 insert(this->end(), view);
591 return *this;
592 }

◆ operator+=() [2/4]

template<typename T >
const VectorType & gimbal::Vector< T >::operator+= ( const type_compatible_iterator_readable< T > auto &  it)
inline

Definition at line 594 of file gimbal_vector.hpp.

594 {
595 insert(this->end(), it);
596 return *this;
597 }

◆ operator+=() [3/4]

template<typename T >
const VectorType & gimbal::Vector< T >::operator+= ( const T &  value)
inline

Definition at line 599 of file gimbal_vector.hpp.

599 {
600 insert(this->end(), 1, value);
601 return *this;
602 }

◆ operator+=() [4/4]

template<typename T >
const VectorType & gimbal::Vector< T >::operator+= ( VectorView< T >  view)
inline

Definition at line 604 of file gimbal_vector.hpp.

604 {
605 insert(this->end(), view.data(), view.size());
606 return *this;
607 }

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