| 1 |
/* Copyright (C) 2015 Povilas Kanapickas <[email protected]> |
| 2 |
|
| 3 |
This file is part of cppreference-doc |
| 4 |
|
| 5 |
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 6 |
Unported License. To view a copy of this license, visit |
| 7 |
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative |
| 8 |
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this document |
| 11 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 12 |
any later version published by the Free Software Foundation; with no |
| 13 |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CPPREFERENCE_ARRAY_H |
| 17 |
#define CPPREFERENCE_ARRAY_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2011 |
| 20 |
#include <initializer_list> |
| 21 |
|
| 22 |
namespace std { |
| 23 |
|
| 24 |
template<class T, std::size_t N> |
| 25 |
class array { |
| 26 |
public: |
| 27 |
typedef T value_type; |
| 28 |
typedef size_t size_type; // actual type unspecified |
| 29 |
typedef ptrdiff_t difference_type; // actual type not specified |
| 30 |
#if CPPREFERENCE_SIMPLIFY_TYPEDEFS |
| 31 |
typedef T& reference; |
| 32 |
typedef const T& const_reference; |
| 33 |
typedef T* pointer; |
| 34 |
typedef const T* const_pointer; |
| 35 |
#else |
| 36 |
typedef value_type& reference; |
| 37 |
typedef const value_type& const_reference; |
| 38 |
typedef value_type* pointer; |
| 39 |
typedef const value_type* const_pointer; |
| 40 |
#endif |
| 41 |
typedef T* iterator; // actual type is unspecified |
| 42 |
typedef const T* const_iterator; // actual type is unspecified |
| 43 |
typedef std::reverse_iterator<iterator> reverse_iterator; |
| 44 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 45 |
|
| 46 |
// constructor |
| 47 |
array& operator=(const array& other); |
| 48 |
#if CPPREFERENCE_STDVER>= 2011 |
| 49 |
array& operator=(array&& other); |
| 50 |
array& operator=(initializer_list<T> ilist); |
| 51 |
#endif |
| 52 |
|
| 53 |
void assign(size_type count, const value_type& value); |
| 54 |
template <class InputIt> |
| 55 |
void assign(InputIt first, InputIt last); |
| 56 |
#if CPPREFERENCE_STDVER>= 2011 |
| 57 |
void assign(std::initializer_list<T> ilist); |
| 58 |
#endif |
| 59 |
|
| 60 |
allocator_type get_allocator() const; |
| 61 |
|
| 62 |
// element access |
| 63 |
reference at(size_type n); |
| 64 |
const_reference at(size_type n) const; |
| 65 |
reference operator[](size_type n); |
| 66 |
const_reference operator[](size_type n) const; |
| 67 |
|
| 68 |
reference front(); |
| 69 |
const_reference front() const; |
| 70 |
reference back(); |
| 71 |
const_reference back() const; |
| 72 |
|
| 73 |
T* data(); |
| 74 |
const T* data() const; |
| 75 |
|
| 76 |
// iterators |
| 77 |
iterator begin(); |
| 78 |
const_iterator begin() const; |
| 79 |
iterator end(); |
| 80 |
const_iterator end() const; |
| 81 |
|
| 82 |
reverse_iterator rbegin(); |
| 83 |
const_reverse_iterator rbegin() const; |
| 84 |
reverse_iterator rend(); |
| 85 |
const_reverse_iterator rend() const; |
| 86 |
|
| 87 |
const_iterator cbegin() const; |
| 88 |
const_iterator cend() const; |
| 89 |
const_reverse_iterator crbegin() const; |
| 90 |
const_reverse_iterator crend() const; |
| 91 |
|
| 92 |
bool empty() const; |
| 93 |
size_type size() const; |
| 94 |
size_type max_size() const; |
| 95 |
|
| 96 |
void fill(const T& value); |
| 97 |
|
| 98 |
void swap(array& other); |
| 99 |
}; |
| 100 |
|
| 101 |
template<class T, size_t N> |
| 102 |
bool operator==(const array<T, N>& lhs, |
| 103 |
const array<T, N>& rhs); |
| 104 |
|
| 105 |
template<class T, size_t N> |
| 106 |
bool operator!=(const array<T, N>& lhs, |
| 107 |
const array<T, N>& rhs); |
| 108 |
|
| 109 |
template<class T, size_t N> |
| 110 |
bool operator<(const array<T, N>& lhs, |
| 111 |
const array<T, N>& rhs); |
| 112 |
|
| 113 |
template<class T, size_t N> |
| 114 |
bool operator<=(const array<T, N>& lhs, |
| 115 |
const array<T, N>& rhs); |
| 116 |
|
| 117 |
template<class T, size_t N> |
| 118 |
bool operator>(const array<T, N>& lhs, |
| 119 |
const array<T, N>& rhs); |
| 120 |
|
| 121 |
template<class T, size_t N> |
| 122 |
bool operator>=(const array<T, N>& lhs, |
| 123 |
const array<T, N>& rhs); |
| 124 |
|
| 125 |
template<size_t I, class T, size_t N> |
| 126 |
constexpr T& get(array<T, N>& a); |
| 127 |
|
| 128 |
template<size_t I, class T, size_t N> |
| 129 |
constexpr T&& get(array<T, N>&& a); |
| 130 |
|
| 131 |
template<size_t I, class T, size_t N> |
| 132 |
constexpr const T& get(const array<T, N>& a); |
| 133 |
|
| 134 |
template<class T, std::size_t N> |
| 135 |
void swap(array<T, N>& lhs, |
| 136 |
array<T, N>& rhs); |
| 137 |
|
| 138 |
} // namespace std |
| 139 |
|
| 140 |
#endif // CPPREFERENCE_STDVER>= 2011 |
| 141 |
|
| 142 |
#endif // CPPREFERENCE_ARRAY_H |