* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
+2016-08-23 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
+ * include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
+ (crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
+ * include/bits/stl_iterator.h (reverse_iterator, move_iterator)
+ (__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
+ Likewise.
+ * include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
+ _GLIBCXX14_CONSTEXPR.
+ (distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
+ * include/std/array (array::begin, array::end, array::rbegin)
+ (array::rend, array::cbegin, array:cend, array::crbegin)
+ (array::crend, array::operator[], array::at, array::front)
+ (array::back, array::data): Likewise.
+ * testsuite/24_iterators/headers/iterator/range_access.cc: Replace
+ with separate tests for C++11, C++14, and C++17.
+ * testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
+ * testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
+ * testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
+
2016-08-22 Tim Shen <timshen@google.com>
Split _M_dfs() into smaller functions.
# endif
#endif
+#ifndef _GLIBCXX17_CONSTEXPR
+# if __cplusplus > 201402L
+# define _GLIBCXX17_CONSTEXPR constexpr
+# else
+# define _GLIBCXX17_CONSTEXPR
+# endif
+#endif
+
// Macro for noexcept, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_NOEXCEPT
# if __cplusplus >= 201103L
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
begin(_Container& __cont) -> decltype(__cont.begin())
{ return __cont.begin(); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
begin(const _Container& __cont) -> decltype(__cont.begin())
{ return __cont.begin(); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
end(_Container& __cont) -> decltype(__cont.end())
{ return __cont.end(); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
end(const _Container& __cont) -> decltype(__cont.end())
{ return __cont.end(); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
rbegin(_Container& __cont) -> decltype(__cont.rbegin())
{ return __cont.rbegin(); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
rbegin(const _Container& __cont) -> decltype(__cont.rbegin())
{ return __cont.rbegin(); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
rend(_Container& __cont) -> decltype(__cont.rend())
{ return __cont.rend(); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
rend(const _Container& __cont) -> decltype(__cont.rend())
{ return __cont.rend(); }
* @param __arr Array.
*/
template<typename _Tp, size_t _Nm>
- inline reverse_iterator<_Tp*>
+ inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*>
rbegin(_Tp (&__arr)[_Nm])
{ return reverse_iterator<_Tp*>(__arr + _Nm); }
* @param __arr Array.
*/
template<typename _Tp, size_t _Nm>
- inline reverse_iterator<_Tp*>
+ inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*>
rend(_Tp (&__arr)[_Nm])
{ return reverse_iterator<_Tp*>(__arr); }
* @param __il initializer_list.
*/
template<typename _Tp>
- inline reverse_iterator<const _Tp*>
+ inline _GLIBCXX17_CONSTEXPR reverse_iterator<const _Tp*>
rbegin(initializer_list<_Tp> __il)
{ return reverse_iterator<const _Tp*>(__il.end()); }
* @param __il initializer_list.
*/
template<typename _Tp>
- inline reverse_iterator<const _Tp*>
+ inline _GLIBCXX17_CONSTEXPR reverse_iterator<const _Tp*>
rend(initializer_list<_Tp> __il)
{ return reverse_iterator<const _Tp*>(__il.begin()); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
crbegin(const _Container& __cont) -> decltype(std::rbegin(__cont))
{ return std::rbegin(__cont); }
* @param __cont Container.
*/
template<typename _Container>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
crend(const _Container& __cont) -> decltype(std::rend(__cont))
{ return std::rend(__cont); }
#include <bits/move.h>
#include <bits/ptr_traits.h>
+#if __cplusplus > 201402L
+# define __cpp_lib_array_constexpr 201603
+#endif
+
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 235 No specification of default ctor for reverse_iterator
+ _GLIBCXX17_CONSTEXPR
reverse_iterator() : current() { }
/**
* This %iterator will move in the opposite direction that @p x does.
*/
- explicit
+ explicit _GLIBCXX17_CONSTEXPR
reverse_iterator(iterator_type __x) : current(__x) { }
/**
* The copy constructor is normal.
*/
+ _GLIBCXX17_CONSTEXPR
reverse_iterator(const reverse_iterator& __x)
: current(__x.current) { }
* underlying %iterator can be converted to the type of @c current.
*/
template<typename _Iter>
+ _GLIBCXX17_CONSTEXPR
reverse_iterator(const reverse_iterator<_Iter>& __x)
: current(__x.base()) { }
/**
* @return @c current, the %iterator used for underlying work.
*/
- iterator_type
+ _GLIBCXX17_CONSTEXPR iterator_type
base() const
{ return current; }
* @c *x remains valid after @c x has been modified or
* destroyed. This is a bug: http://gcc.gnu.org/PR51823
*/
- reference
+ _GLIBCXX17_CONSTEXPR reference
operator*() const
{
_Iterator __tmp = current;
*
* This requires that @c --current is dereferenceable.
*/
- pointer
+ _GLIBCXX17_CONSTEXPR pointer
operator->() const
{ return &(operator*()); }
*
* Decrements the underlying iterator.
*/
- reverse_iterator&
+ _GLIBCXX17_CONSTEXPR reverse_iterator&
operator++()
{
--current;
*
* Decrements the underlying iterator.
*/
- reverse_iterator
+ _GLIBCXX17_CONSTEXPR reverse_iterator
operator++(int)
{
reverse_iterator __tmp = *this;
*
* Increments the underlying iterator.
*/
- reverse_iterator&
+ _GLIBCXX17_CONSTEXPR reverse_iterator&
operator--()
{
++current;
*
* Increments the underlying iterator.
*/
- reverse_iterator
+ _GLIBCXX17_CONSTEXPR reverse_iterator
operator--(int)
{
reverse_iterator __tmp = *this;
*
* The underlying iterator must be a Random Access Iterator.
*/
- reverse_iterator
+ _GLIBCXX17_CONSTEXPR reverse_iterator
operator+(difference_type __n) const
{ return reverse_iterator(current - __n); }
* Moves the underlying iterator backwards @a __n steps.
* The underlying iterator must be a Random Access Iterator.
*/
- reverse_iterator&
+ _GLIBCXX17_CONSTEXPR reverse_iterator&
operator+=(difference_type __n)
{
current -= __n;
*
* The underlying iterator must be a Random Access Iterator.
*/
- reverse_iterator
+ _GLIBCXX17_CONSTEXPR reverse_iterator
operator-(difference_type __n) const
{ return reverse_iterator(current + __n); }
* Moves the underlying iterator forwards @a __n steps.
* The underlying iterator must be a Random Access Iterator.
*/
- reverse_iterator&
+ _GLIBCXX17_CONSTEXPR reverse_iterator&
operator-=(difference_type __n)
{
current += __n;
*
* The underlying iterator must be a Random Access Iterator.
*/
- reference
+ _GLIBCXX17_CONSTEXPR reference
operator[](difference_type __n) const
{ return *(*this + __n); }
};
*
*/
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator==(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y)
{ return __x.base() == __y.base(); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y)
{ return __y.base() < __x.base(); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator!=(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y)
{ return !(__x == __y); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y)
{ return __y < __x; }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<=(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y)
{ return !(__y < __x); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>=(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y)
{ return !(__x < __y); }
template<typename _Iterator>
- inline typename reverse_iterator<_Iterator>::difference_type
+ inline _GLIBCXX17_CONSTEXPR
+ typename reverse_iterator<_Iterator>::difference_type
operator-(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y)
{ return __y.base() - __x.base(); }
template<typename _Iterator>
- inline reverse_iterator<_Iterator>
+ inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
operator+(typename reverse_iterator<_Iterator>::difference_type __n,
const reverse_iterator<_Iterator>& __x)
{ return reverse_iterator<_Iterator>(__x.base() - __n); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 280. Comparison of reverse_iterator to const reverse_iterator.
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator==(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
{ return __x.base() == __y.base(); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
{ return __y.base() < __x.base(); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator!=(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
{ return !(__x == __y); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
{ return __y < __x; }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<=(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
{ return !(__y < __x); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>=(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
{ return !(__x < __y); }
template<typename _IteratorL, typename _IteratorR>
#if __cplusplus >= 201103L
// DR 685.
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
operator-(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
-> decltype(__y.base() - __x.base())
#if __cplusplus >= 201103L
// Same as C++14 make_reverse_iterator but used in C++03 mode too.
template<typename _Iterator>
- inline reverse_iterator<_Iterator>
+ inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
__make_reverse_iterator(_Iterator __i)
{ return reverse_iterator<_Iterator>(__i); }
// DR 2285. make_reverse_iterator
/// Generator function for reverse_iterator.
template<typename _Iterator>
- inline reverse_iterator<_Iterator>
+ inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
make_reverse_iterator(_Iterator __i)
{ return reverse_iterator<_Iterator>(__i); }
# endif
typename remove_reference<__base_ref>::type&&,
__base_ref>::type reference;
+ _GLIBCXX17_CONSTEXPR
move_iterator()
: _M_current() { }
- explicit
+ explicit _GLIBCXX17_CONSTEXPR
move_iterator(iterator_type __i)
: _M_current(__i) { }
template<typename _Iter>
+ _GLIBCXX17_CONSTEXPR
move_iterator(const move_iterator<_Iter>& __i)
: _M_current(__i.base()) { }
- iterator_type
+ _GLIBCXX17_CONSTEXPR iterator_type
base() const
{ return _M_current; }
- reference
+ _GLIBCXX17_CONSTEXPR reference
operator*() const
{ return static_cast<reference>(*_M_current); }
- pointer
+ _GLIBCXX17_CONSTEXPR pointer
operator->() const
{ return _M_current; }
- move_iterator&
+ _GLIBCXX17_CONSTEXPR move_iterator&
operator++()
{
++_M_current;
return *this;
}
- move_iterator
+ _GLIBCXX17_CONSTEXPR move_iterator
operator++(int)
{
move_iterator __tmp = *this;
return __tmp;
}
- move_iterator&
+ _GLIBCXX17_CONSTEXPR move_iterator&
operator--()
{
--_M_current;
return *this;
}
- move_iterator
+ _GLIBCXX17_CONSTEXPR move_iterator
operator--(int)
{
move_iterator __tmp = *this;
return __tmp;
}
- move_iterator
+ _GLIBCXX17_CONSTEXPR move_iterator
operator+(difference_type __n) const
{ return move_iterator(_M_current + __n); }
- move_iterator&
+ _GLIBCXX17_CONSTEXPR move_iterator&
operator+=(difference_type __n)
{
_M_current += __n;
return *this;
}
- move_iterator
+ _GLIBCXX17_CONSTEXPR move_iterator
operator-(difference_type __n) const
{ return move_iterator(_M_current - __n); }
- move_iterator&
+ _GLIBCXX17_CONSTEXPR move_iterator&
operator-=(difference_type __n)
{
_M_current -= __n;
return *this;
}
- reference
+ _GLIBCXX17_CONSTEXPR reference
operator[](difference_type __n) const
{ return std::move(_M_current[__n]); }
};
// why there are always 2 versions for most of the move_iterator
// operators.
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator==(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
{ return __x.base() == __y.base(); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator==(const move_iterator<_Iterator>& __x,
const move_iterator<_Iterator>& __y)
{ return __x.base() == __y.base(); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator!=(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
{ return !(__x == __y); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator!=(const move_iterator<_Iterator>& __x,
const move_iterator<_Iterator>& __y)
{ return !(__x == __y); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
{ return __x.base() < __y.base(); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<(const move_iterator<_Iterator>& __x,
const move_iterator<_Iterator>& __y)
{ return __x.base() < __y.base(); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<=(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
{ return !(__y < __x); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator<=(const move_iterator<_Iterator>& __x,
const move_iterator<_Iterator>& __y)
{ return !(__y < __x); }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
{ return __y < __x; }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>(const move_iterator<_Iterator>& __x,
const move_iterator<_Iterator>& __y)
{ return __y < __x; }
template<typename _IteratorL, typename _IteratorR>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>=(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
{ return !(__x < __y); }
template<typename _Iterator>
- inline bool
+ inline _GLIBCXX17_CONSTEXPR bool
operator>=(const move_iterator<_Iterator>& __x,
const move_iterator<_Iterator>& __y)
{ return !(__x < __y); }
// DR 685.
template<typename _IteratorL, typename _IteratorR>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
operator-(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
-> decltype(__x.base() - __y.base())
{ return __x.base() - __y.base(); }
template<typename _Iterator>
- inline auto
+ inline _GLIBCXX17_CONSTEXPR auto
operator-(const move_iterator<_Iterator>& __x,
const move_iterator<_Iterator>& __y)
-> decltype(__x.base() - __y.base())
{ return __x.base() - __y.base(); }
template<typename _Iterator>
- inline move_iterator<_Iterator>
+ inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
operator+(typename move_iterator<_Iterator>::difference_type __n,
const move_iterator<_Iterator>& __x)
{ return __x + __n; }
template<typename _Iterator>
- inline move_iterator<_Iterator>
+ inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
make_move_iterator(_Iterator __i)
{ return move_iterator<_Iterator>(__i); }
= typename conditional<__move_if_noexcept_cond
<typename iterator_traits<_Iterator>::value_type>::value,
_Iterator, move_iterator<_Iterator>>::type>
- inline _ReturnType
+ inline _GLIBCXX17_CONSTEXPR _ReturnType
__make_move_if_noexcept_iterator(_Iterator __i)
{ return _ReturnType(__i); }
template<typename _Tp, typename _ReturnType
= typename conditional<__move_if_noexcept_cond<_Tp>::value,
const _Tp*, move_iterator<_Tp*>>::type>
- inline _ReturnType
+ inline _GLIBCXX17_CONSTEXPR _ReturnType
__make_move_if_noexcept_iterator(_Tp* __i)
{ return _ReturnType(__i); }
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIterator>
- inline typename iterator_traits<_InputIterator>::difference_type
+ inline _GLIBCXX14_CONSTEXPR
+ typename iterator_traits<_InputIterator>::difference_type
__distance(_InputIterator __first, _InputIterator __last,
input_iterator_tag)
{
}
template<typename _RandomAccessIterator>
- inline typename iterator_traits<_RandomAccessIterator>::difference_type
+ inline _GLIBCXX14_CONSTEXPR
+ typename iterator_traits<_RandomAccessIterator>::difference_type
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
random_access_iterator_tag)
{
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator>
- inline typename iterator_traits<_InputIterator>::difference_type
+ inline _GLIBCXX17_CONSTEXPR
+ typename iterator_traits<_InputIterator>::difference_type
distance(_InputIterator __first, _InputIterator __last)
{
// concept requirements -- taken care of in __distance
}
template<typename _InputIterator, typename _Distance>
- inline void
+ inline _GLIBCXX14_CONSTEXPR void
__advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
{
// concept requirements
}
template<typename _BidirectionalIterator, typename _Distance>
- inline void
+ inline _GLIBCXX14_CONSTEXPR void
__advance(_BidirectionalIterator& __i, _Distance __n,
bidirectional_iterator_tag)
{
}
template<typename _RandomAccessIterator, typename _Distance>
- inline void
+ inline _GLIBCXX14_CONSTEXPR void
__advance(_RandomAccessIterator& __i, _Distance __n,
random_access_iterator_tag)
{
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator, typename _Distance>
- inline void
+ inline _GLIBCXX17_CONSTEXPR void
advance(_InputIterator& __i, _Distance __n)
{
// concept requirements -- taken care of in __advance
#if __cplusplus >= 201103L
template<typename _ForwardIterator>
- inline _ForwardIterator
+ inline _GLIBCXX17_CONSTEXPR _ForwardIterator
next(_ForwardIterator __x, typename
iterator_traits<_ForwardIterator>::difference_type __n = 1)
{
}
template<typename _BidirectionalIterator>
- inline _BidirectionalIterator
+ inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator
prev(_BidirectionalIterator __x, typename
iterator_traits<_BidirectionalIterator>::difference_type __n = 1)
{
{ std::swap_ranges(begin(), end(), __other.begin()); }
// Iterators.
- iterator
+ _GLIBCXX17_CONSTEXPR iterator
begin() noexcept
{ return iterator(data()); }
- const_iterator
+ _GLIBCXX17_CONSTEXPR const_iterator
begin() const noexcept
{ return const_iterator(data()); }
- iterator
+ _GLIBCXX17_CONSTEXPR iterator
end() noexcept
{ return iterator(data() + _Nm); }
- const_iterator
+ _GLIBCXX17_CONSTEXPR const_iterator
end() const noexcept
{ return const_iterator(data() + _Nm); }
- reverse_iterator
+ _GLIBCXX17_CONSTEXPR reverse_iterator
rbegin() noexcept
{ return reverse_iterator(end()); }
- const_reverse_iterator
+ _GLIBCXX17_CONSTEXPR const_reverse_iterator
rbegin() const noexcept
{ return const_reverse_iterator(end()); }
- reverse_iterator
+ _GLIBCXX17_CONSTEXPR reverse_iterator
rend() noexcept
{ return reverse_iterator(begin()); }
- const_reverse_iterator
+ _GLIBCXX17_CONSTEXPR const_reverse_iterator
rend() const noexcept
{ return const_reverse_iterator(begin()); }
- const_iterator
+ _GLIBCXX17_CONSTEXPR const_iterator
cbegin() const noexcept
{ return const_iterator(data()); }
- const_iterator
+ _GLIBCXX17_CONSTEXPR const_iterator
cend() const noexcept
{ return const_iterator(data() + _Nm); }
- const_reverse_iterator
+ _GLIBCXX17_CONSTEXPR const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
- const_reverse_iterator
+ _GLIBCXX17_CONSTEXPR const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
empty() const noexcept { return size() == 0; }
// Element access.
- reference
+ _GLIBCXX17_CONSTEXPR reference
operator[](size_type __n) noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); }
operator[](size_type __n) const noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); }
- reference
+ _GLIBCXX17_CONSTEXPR reference
at(size_type __n)
{
if (__n >= _Nm)
_AT_Type::_S_ref(_M_elems, 0));
}
- reference
+ _GLIBCXX17_CONSTEXPR reference
front() noexcept
{ return *begin(); }
front() const noexcept
{ return _AT_Type::_S_ref(_M_elems, 0); }
- reference
+ _GLIBCXX17_CONSTEXPR reference
back() noexcept
{ return _Nm ? *(end() - 1) : *end(); }
: _AT_Type::_S_ref(_M_elems, 0);
}
- pointer
+ _GLIBCXX17_CONSTEXPR pointer
data() noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
- const_pointer
+ _GLIBCXX17_CONSTEXPR const_pointer
data() const noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
};
+++ /dev/null
-// { dg-do compile { target c++11 } }
-
-// Copyright (C) 2010-2016 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <iterator>
-
-namespace std
-{
- template<class C> auto begin(C& c) -> decltype(c.begin());
- template<class C> auto begin(const C& c) -> decltype(c.begin());
-
- template<class C> auto end(C& c) -> decltype(c.end());
- template<class C> auto end(const C& c) -> decltype(c.end());
-
-#if __cplusplus >= 201402L
- template<class T, size_t N> constexpr T* begin(T (&array)[N]);
- template<class T, size_t N> constexpr T* end(T (&array)[N]);
-#else
- template<class T, size_t N> T* begin(T (&array)[N]);
- template<class T, size_t N> T* end(T (&array)[N]);
-#endif
-}
--- /dev/null
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2010-2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+
+namespace std
+{
+ template<class C> auto begin(C& c) -> decltype(c.begin());
+ template<class C> auto begin(const C& c) -> decltype(c.begin());
+
+ template<class C> auto end(C& c) -> decltype(c.end());
+ template<class C> auto end(const C& c) -> decltype(c.end());
+
+ template<class T, size_t N> T* begin(T (&array)[N]);
+ template<class T, size_t N> T* end(T (&array)[N]);
+}
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+
+namespace std
+{
+ template<class C> auto begin(C& c) -> decltype(c.begin());
+ template<class C> auto begin(const C& c) -> decltype(c.begin());
+
+ template<class C> auto end(C& c) -> decltype(c.end());
+ template<class C> auto end(const C& c) -> decltype(c.end());
+
+ template<class T, size_t N> constexpr T* begin(T (&array)[N]);
+ template<class T, size_t N> constexpr T* end(T (&array)[N]);
+
+ template<class C> auto cbegin(const C& c) -> decltype(c.begin());
+ template<class C> auto cend(const C& c) -> decltype(c.end());
+
+ template<class C> auto rbegin(C& c) -> decltype(c.rbegin());
+ template<class C> auto rbegin(const C& c) -> decltype(c.rbegin());
+
+ template<class C> auto rend(C& c) -> decltype(c.rend());
+ template<class C> auto rend(const C& c) -> decltype(c.rend());
+
+ template<class T, size_t N>
+ reverse_iterator<T*> rbegin(T (&array)[N]);
+ template<class T, size_t N>
+ reverse_iterator<T*> rend(T (&array)[N]);
+
+ template<class E>
+ reverse_iterator<const E*> rbegin(initializer_list<E>);
+ template<class E>
+ reverse_iterator<const E*> rend(initializer_list<E>);
+
+ template<class C>
+ auto crbegin(const C& c) -> decltype(std::rbegin(c));
+ template<class C>
+ auto cend(const C& c) -> decltype(std::rend(c));
+}
--- /dev/null
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+
+namespace std
+{
+ template<class C> constexpr auto begin(C& c) -> decltype(c.begin());
+ template<class C> constexpr auto begin(const C& c) -> decltype(c.begin());
+
+ template<class C> constexpr auto end(C& c) -> decltype(c.end());
+ template<class C> constexpr auto end(const C& c) -> decltype(c.end());
+
+ template<class T, size_t N> constexpr T* begin(T (&array)[N]);
+ template<class T, size_t N> constexpr T* end(T (&array)[N]);
+
+ template<class C> constexpr auto cbegin(const C& c) -> decltype(c.begin());
+ template<class C> constexpr auto cend(const C& c) -> decltype(c.end());
+
+ template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin());
+ template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin());
+
+ template<class C> constexpr auto rend(C& c) -> decltype(c.rend());
+ template<class C> constexpr auto rend(const C& c) -> decltype(c.rend());
+
+ template<class T, size_t N>
+ constexpr reverse_iterator<T*> rbegin(T (&array)[N]);
+ template<class T, size_t N>
+ constexpr reverse_iterator<T*> rend(T (&array)[N]);
+
+ template<class E>
+ constexpr reverse_iterator<const E*> rbegin(initializer_list<E>);
+ template<class E>
+ constexpr reverse_iterator<const E*> rend(initializer_list<E>);
+
+ template<class C>
+ constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c));
+ template<class C>
+ constexpr auto cend(const C& c) -> decltype(std::rend(c));
+}
#include <vector>
-// { dg-error "multiple inlined namespaces" "" { target *-*-* } 324 }
+// { dg-error "multiple inlined namespaces" "" { target *-*-* } 332 }
// "template argument 1 is invalid"
// { dg-prune-output "tuple:993" }