Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
NCollection_LocalArray< theItem, MAX_ARRAY_SIZE > Class Template Reference

Auxiliary class optimizing creation of array buffer (using stack allocation for small arrays). More...

#include <NCollection_LocalArray.hxx>

Data Structures

struct  InlineStorageNonTrivial
 Inline storage for non-trivial types: raw aligned bytes for placement new. More...
 
struct  InlineStorageTrivial
 Inline storage for trivial types: typed array with direct element access. More...
 

Public Member Functions

 NCollection_LocalArray (const size_t theSize)
 
 NCollection_LocalArray () noexcept
 
 ~NCollection_LocalArray ()
 
void Allocate (const size_t theSize)
 
void Reallocate (const size_t theNewSize, bool theToCopy=true)
 Reallocate the array to a new size.
 
size_t Size () const noexcept
 
 operator theItem * () const noexcept
 
 NCollection_LocalArray (NCollection_LocalArray &&theOther) noexcept
 
NCollection_LocalArrayoperator= (NCollection_LocalArray &&theOther) noexcept
 
 NCollection_LocalArray (const NCollection_LocalArray &)=delete
 
NCollection_LocalArrayoperator= (const NCollection_LocalArray &)=delete
 

Protected Types

using InlineStorage
 

Protected Member Functions

void Deallocate ()
 
theItem * inlinePtr () noexcept
 Pointer to inline buffer storage.
 
const theItem * inlinePtr () const noexcept
 
bool isInline () const noexcept
 True if currently using inline (stack) storage.
 

Protected Attributes

InlineStorage myStorage
 Inline buffer.
 
theItem * myPtr
 Points to inline or heap buffer.
 
size_t mySize
 Logical element count.
 

Detailed Description

template<class theItem, int MAX_ARRAY_SIZE = 1024>
class NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >

Auxiliary class optimizing creation of array buffer (using stack allocation for small arrays).

For trivially copyable types the fast memcpy / Standard::Reallocate path is used. For non-trivially-copyable types (Handle, TopLoc_Location, etc.) the class uses placement new, move semantics, and explicit destructors while keeping Standard::Allocate / Standard::Free for heap management.

Non-trivially-copyable types must be default-constructible and nothrow-move-constructible.

Member Typedef Documentation

◆ InlineStorage

template<class theItem , int MAX_ARRAY_SIZE = 1024>
using NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::InlineStorage
protected
Initial value:
std::conditional_t<IS_TRIVIAL, InlineStorageTrivial, InlineStorageNonTrivial>

Constructor & Destructor Documentation

◆ NCollection_LocalArray() [1/4]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::NCollection_LocalArray ( const size_t theSize)
inlineexplicit

◆ NCollection_LocalArray() [2/4]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::NCollection_LocalArray ( )
inlinenoexcept

◆ ~NCollection_LocalArray()

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::~NCollection_LocalArray ( )
inline

◆ NCollection_LocalArray() [3/4]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::NCollection_LocalArray ( NCollection_LocalArray< theItem, MAX_ARRAY_SIZE > && theOther)
inlinenoexcept

◆ NCollection_LocalArray() [4/4]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::NCollection_LocalArray ( const NCollection_LocalArray< theItem, MAX_ARRAY_SIZE > & )
delete

Member Function Documentation

◆ Allocate()

template<class theItem , int MAX_ARRAY_SIZE = 1024>
void NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::Allocate ( const size_t theSize)
inline

◆ Deallocate()

template<class theItem , int MAX_ARRAY_SIZE = 1024>
void NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::Deallocate ( )
inlineprotected

◆ inlinePtr() [1/2]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
const theItem * NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::inlinePtr ( ) const
inlineprotectednoexcept

◆ inlinePtr() [2/2]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
theItem * NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::inlinePtr ( )
inlineprotectednoexcept

Pointer to inline buffer storage.

◆ isInline()

template<class theItem , int MAX_ARRAY_SIZE = 1024>
bool NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::isInline ( ) const
inlineprotectednoexcept

True if currently using inline (stack) storage.

◆ operator theItem *()

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::operator theItem * ( ) const
inlinenoexcept

◆ operator=() [1/2]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray & NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::operator= ( const NCollection_LocalArray< theItem, MAX_ARRAY_SIZE > & )
delete

◆ operator=() [2/2]

template<class theItem , int MAX_ARRAY_SIZE = 1024>
NCollection_LocalArray & NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::operator= ( NCollection_LocalArray< theItem, MAX_ARRAY_SIZE > && theOther)
inlinenoexcept

◆ Reallocate()

template<class theItem , int MAX_ARRAY_SIZE = 1024>
void NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::Reallocate ( const size_t theNewSize,
bool theToCopy = true )
inline

Reallocate the array to a new size.

Parameters
[in]theNewSizenew number of elements
[in]theToCopyif true, existing elements are copied/moved to the new buffer

◆ Size()

template<class theItem , int MAX_ARRAY_SIZE = 1024>
size_t NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::Size ( ) const
inlinenoexcept

Field Documentation

◆ myPtr

template<class theItem , int MAX_ARRAY_SIZE = 1024>
theItem* NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::myPtr
protected

Points to inline or heap buffer.

◆ mySize

template<class theItem , int MAX_ARRAY_SIZE = 1024>
size_t NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::mySize
protected

Logical element count.

◆ myStorage

template<class theItem , int MAX_ARRAY_SIZE = 1024>
InlineStorage NCollection_LocalArray< theItem, MAX_ARRAY_SIZE >::myStorage
protected

Inline buffer.


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