79 typedef const T & reference;
80 typedef const T & const_reference;
87 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
88 typedef const_reverse_iterator reverse_iterator;
89 typedef std::size_t size_type;
90 typedef ptrdiff_t difference_type;
97 constexpr
array_ref() : ptr_(nullptr), length_(0) {}
101 constexpr
array_ref(
const T * array,
const size_type length)
102 : ptr_(array), length_(length) {}
108 template<
typename Allocator>
110 : ptr_(v.
data()), length_(v.size()) {}
112 template<
typename traits,
typename Allocator>
113 array_ref(
const std::basic_string<T, traits, Allocator> & s)
114 : ptr_(s.data()), length_(s.size()) {}
116 template<
size_type N>
117 constexpr
array_ref(
const T (&a)[N]) : ptr_(a), length_(N) {}
121 template<
size_type N>
123 : ptr_(a.
data()), length_(N) {}
128 constexpr array_ref
substr(
const size_type pos,
129 const size_type n = size_type(-1))
const {
131 return (pos > size() ?
substr(size(), n)
132 : n > size() - pos ?
substr(pos, size() - pos)
139 constexpr const_iterator begin()
const {
142 constexpr const_iterator end()
const {
143 return ptr_ + length_;
145 constexpr const_iterator cbegin()
const {
148 constexpr const_iterator cend()
const {
151 const_reverse_iterator rbegin()
const {
152 return const_reverse_iterator(end());
154 const_reverse_iterator rend()
const {
155 return const_reverse_iterator(begin());
157 const_reverse_iterator crbegin()
const {
160 const_reverse_iterator crend()
const {
167 constexpr size_type size()
const {
170 constexpr size_type max_size()
const {
171 return (std::numeric_limits<size_type>::max)() /
sizeof(T);
173 constexpr
bool empty()
const {
180 constexpr
const T & operator[](
const size_type i)
const {
183 constexpr
const T & at(
const size_type i)
const {
193 throw std::out_of_range(
"at() argument out of range");
197 constexpr
const T & front()
const {
200 constexpr
const T & back()
const {
201 return ptr_[length_ - 1];
207 constexpr
const T *
data()
const {
227 explicit operator std::vector<T>()
const {
228 return std::vector<T>(begin(), end());
230 std::vector<T> vec()
const {
231 return std::vector<T>(*this);
236 template<
typename traits,
typename Allocator>
237 explicit operator std::basic_string<T, traits, Allocator>()
const {
238 return std::basic_string<T, traits, Allocator>(begin(), end());
240 std::basic_string<T> str()
const {
241 return std::basic_string<T>(*this);
259 assert(length_ >= n);
268 assert(length_ >= n);
299 make_array_ref(
const T * array,
const std::size_t length) {
303 template<
typename T, std::
size_t N>
305 make_array_ref(
const T (&a)[N]) {
311 make_array_ref(
const std::vector<T> & v) {
315 template<
typename T, std::
size_t N>
317 make_array_ref(
const std::array<T, N> & a) {
constexpr array_ref()
Definition: array_ref.hh:97
const T * const_iterator
Definition: array_ref.hh:83
Definition: array_ref.hh:70
constexpr array_ref(const std::array< T, N > &a)
Definition: array_ref.hh:122
const_iterator iterator
Definition: array_ref.hh:86
void clear()
Definition: array_ref.hh:251
void remove_suffix(const size_type n)
Definition: array_ref.hh:267
constexpr array_ref substr(const size_type pos, const size_type n=size_type(-1)) const
Definition: array_ref.hh:128
void remove_prefix(const size_type n)
Definition: array_ref.hh:258
constexpr const T * data() const
Definition: array_ref.hh:207
array_ref(const std::vector< T, Allocator > &v)
Definition: array_ref.hh:109
void pop_back()
Definition: array_ref.hh:273
const T * pointer
Definition: array_ref.hh:78
void pop_front()
Definition: array_ref.hh:278
Definition: control.hh:31