Struct array


#include <include/EASTL/array.h>

template <typename T, size_t N = 1>
struct array



Implements a templated array class as per the C++ standard TR1. This class allows you to use a built-in C style array like an STL vector. It does not let you change its size, as it is just like a C built-in array. Our implementation here strives to remove function call nesting, as that makes it hard for us to profile debug builds due to function call overhead. Note that this is intentionally a struct with public data, as per the C++ standard update proposal requirements.

Example usage: array<int, 5> a = { { 0, 1, 2, 3, 4 } }; // Strict compilers such as GCC require the double brackets. a[2] = 4; for(array<int, 5>::iterator i = a.begin(); i < a.end(); ++i) *i = 0;


at overload
back overload
data overload
end overload
fillWe intentionally provide no constructor, destructor, or assignment operator.
front overload
operator[] overload
rbegin overload
rend overload


Lines 57-129 in include/EASTL/array.h.

template <typename T, size_t N = 1>
struct array
    typedef array<T, N>                                   this_type;
    typedef T                                             value_type;
    typedef value_type&                                   reference;
    typedef const value_type&                             const_reference;
    typedef value_type*                                   iterator;
    typedef const value_type*                             const_iterator;
    typedef eastl::reverse_iterator<iterator>             reverse_iterator;
    typedef eastl::reverse_iterator<const_iterator>       const_reverse_iterator;
    typedef eastl_size_t                                  size_type;        // See config.h for the definition of eastl_size_t, which defaults to size_t.
    typedef ptrdiff_t                                     difference_type;
        count = N
    // Note that the member data is intentionally public.
    // This allows for aggregate initialization of the
    // object (e.g. array<int, 5> a = { 0, 3, 2, 4 }; )
    value_type mValue[N ? N : 1];
    // We intentionally provide no constructor, destructor, or assignment operator.
    void fill(const value_type& value);
    // Unlike the swap function for other containers, array::swap takes linear time,
    // may exit via an exception, and does not cause iterators to become associated with the other container.
    void swap(this_type& x) EA_NOEXCEPT_IF(eastl::is_nothrow_swappable<value_type>::value);
    EA_CPP14_CONSTEXPR iterator       begin() EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_iterator begin() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_iterator cbegin() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR iterator       end() EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_iterator end() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_iterator cend() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR reverse_iterator       rbegin() EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_reverse_iterator rbegin() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_reverse_iterator crbegin() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR reverse_iterator       rend() EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_reverse_iterator rend() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const_reverse_iterator crend() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR bool empty() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR size_type size() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR size_type max_size() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR T*       data() EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR const T* data() const EA_NOEXCEPT;
    EA_CPP14_CONSTEXPR reference       operator[](size_type i);
    EA_CPP14_CONSTEXPR const_reference operator[](size_type i) const;
    EA_CPP14_CONSTEXPR const_reference at(size_type i) const;
    EA_CPP14_CONSTEXPR reference       at(size_type i);
    EA_CPP14_CONSTEXPR reference       front();
    EA_CPP14_CONSTEXPR const_reference front() const;
    EA_CPP14_CONSTEXPR reference       back();
    EA_CPP14_CONSTEXPR const_reference back() const;
    bool validate() const;
    int  validate_iterator(const_iterator i) const;
}; // class array

Add Discussion as Guest

Log in