std::array

From Cppreference

Jump to: navigation, search
Defined in header <array>

template<

    class T,
    size_t N

> struct array;
(C++11 feature)

array is a container that encapsulates constant size arrays.

This struct is designed to provide the benefits of a standard container (an array knows its own size, supports assignment, random access iterators, etc.) while still providing the aggregate type semantics of C-style arrays.

Contents

[edit] Member types

Member type Definition
value_type T
size_type size_t
size_type ptrdiff_t
reference value_type&
const_reference const value_type&
pointer T*
const_pointer const T*
iterator Random access iterator
const_iterator Constant random access iterator
reverse_iterator std::reverse_iterator<iterator>
const_reverse_iterator std::reverse_iterator<const_iterator>

[edit] Member functions

Element access
at
access specified element with bounds checking
(public member function)
operator[]
access specified element
(public member function)
front
access the first element
(public member function)
back
access the last element
(public member function)
data
direct access to the underlying array
(public member function)
Iterators
begin
cbegin

returns an iterator to the beginning
(public member function)
end
cend

returns an iterator to the end
(public member function)
rbegin
crbegin

returns a reverse iterator to the beginning
(public member function)
rend
crend

returns a reverse iterator to the end
(public member function)
Capacity
empty
checks whether the container is empty
(public member function)
size
returns the number of elements
(public member function)
max_size
returns the maximum possible number of elements
(public member function)
Operations
fill
fill the container with specified value
(public member function)
swap
swaps the contents
(public member function)

[edit] Non-member functions

get
accesses an element of an array
(function template)
std::swap(std::array)
specializes the std::swap() algorithm
(function template)

[edit] Helper classes

tuple_size
obtains the size of an array
(class template specialization)
tuple_element
obtains the type of the elements of array
(class template specialization)