Array< T, N > Class Template Reference

a template class holding a C-array of constant size. More...

#include "Array.hpp"

Public Types

enum  { static_size = N }
typedef T value_type
typedef T * iterator
typedef const T * const_iterator
typedef T & reference
typedef const T & const_reference
typedef std::size_t size_type
typedef std::ptrdiff_t difference_type
typedef std::reverse_iterator
< iterator > 
reverse_iterator
typedef std::reverse_iterator
< const_iterator > 
const_reverse_iterator

Public Member Functions

assignment, swapping
template<typename T2 >
Array< T, N > & operator= (const Array< T2, N > &other)
 assignment with type conversion
template<typename T2 >
Array< T, N > & operator= (const T2(&other)[N])
 assign a C-array with type conversion
void assign (const T &val)
 assign one value to all elements
void swap (Array< T, N > &other)
 swap (linear complexity)
iterator traversal

forward/reverse, const/non-const

iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const
direct element access with range check

zero-based indexing

reference operator[] (size_type i)
const_reference operator[] (size_type i) const
reference at (size_type i)
const_reference at (size_type i) const
first/last element
reference front ()
const_reference front () const
reference back ()
const_reference back () const
direct access to C-array
const T * data () const
T * data ()
T * c_array ()

Public Attributes

elems [N]

Related Functions

(Note that these are not member functions.)

template<class T , std::size_t N>
bool operator== (const Array< T, N > &l, const Array< T, N > &r)
template<class T , std::size_t N>
bool operator< (const Array< T, N > &l, const Array< T, N > &r)
template<class T , std::size_t N>
bool operator!= (const Array< T, N > &l, const Array< T, N > &r)
template<class T , std::size_t N>
bool operator> (const Array< T, N > &l, const Array< T, N > &r)
template<class T , std::size_t N>
bool operator<= (const Array< T, N > &l, const Array< T, N > &r)
template<class T , std::size_t N>
bool operator>= (const Array< T, N > &l, const Array< T, N > &r)
template<class T , std::size_t N>
void swap (Array< T, N > &l, Array< T, N > &r)

size

static size_type size ()
static bool empty ()
static size_type max_size ()

Detailed Description

template<class T, std::size_t N>
class DM::Array< T, N >

a template class holding a C-array of constant size.

Template Parameters
Tthe element type
Nthe constant size, must be >= 1
Author
wk
Date
03.02.2011

Array is an aggregate, meaning that it may be initialized with a static initializer list: opals::Array<double,3> arr = { 1., 2., 3. }; Array fulfills almost all the requirements of an STL reversible container. The complete implementation is exposed, why opals users may instantiate Array<T,N> with arbitrary template arguments. The class closely follows boost::array.

Friends And Related Function Documentation

bool operator!= ( const Array< T, N > &  l,
const Array< T, N > &  r 
)
related
bool operator< ( const Array< T, N > &  l,
const Array< T, N > &  r 
)
related
bool operator<= ( const Array< T, N > &  l,
const Array< T, N > &  r 
)
related
bool operator== ( const Array< T, N > &  l,
const Array< T, N > &  r 
)
related
bool operator> ( const Array< T, N > &  l,
const Array< T, N > &  r 
)
related
bool operator>= ( const Array< T, N > &  l,
const Array< T, N > &  r 
)
related
void swap ( Array< T, N > &  l,
Array< T, N > &  r 
)
related