API Guides > ConceptRT 3.x
SafeArray< ElementType, Size > Class Template Reference

Array ensures safe usage. More...

Detailed Description

template<class ElementType, Int32 Size>
class ConceptRT::SafeArray< ElementType, Size >

Array ensures safe usage.

The bounds of the given index is systematically checked in order to avoid memory corruption in any use case.

Template Parameters
ElementTypeArray items type. Items must be instanciable whitout parameters. (scalar type or class with constructor without parameters or with default values.)
SizeArray size

If the element type has no constructor (simple scalar value) items are not initialized. Use SmartType like SmartBool in this case.

Examples:
ErrorsManagement/main.cpp.
+ Inheritance diagram for SafeArray< ElementType, Size >:

Public Member Methods

ElementType & operator[] (Int32 index)
 Array indexer operator. More...
 
const ElementType & operator[] (Int32 index) const
 Array indexer operator. More...
 
Int32 GetSize () const
 Gets the array size. More...
 
- Public Member Methods inherited from BaseSafeArray< ElementType >
bool IndexValid (Int32 index) const
 Query if index is valid. More...
 
void Exchange (Int32 index1, Int32 index2)
 Exchanges two items More...
 

Methods Documentation

Int32 GetSize ( ) const
inlinevirtual

Gets the array size.

Returns
The size.

Implements BaseSafeArray< ElementType >.

ElementType & operator[] ( Int32  index)
virtual

Array indexer operator.

Parameters
indexZero-based index of the item.
Returns
The indexed item.
RT Exceptions:
RT_ERROR_OUT_OF_BOUND_INDEX

Implements BaseSafeArray< ElementType >.

const ElementType & operator[] ( Int32  index) const
virtual

Array indexer operator.

Parameters
indexZero-based index of the item.
Returns
The indexed item.
RT Exceptions:
RT_ERROR_OUT_OF_BOUND_INDEX

Implements BaseSafeArray< ElementType >.