// Iterators -*- C++ -*-
-// Copyright (C) 2001-2013 Free Software Foundation, Inc.
+// Copyright (C) 2001-2015 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
#include <bits/cpp_type_traits.h>
#include <ext/type_traits.h>
#include <bits/move.h>
+#include <bits/ptr_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
{ return __y.base() - __x.base(); }
//@}
+#if __cplusplus > 201103L
+#define __cpp_lib_make_reverse_iterator 201402
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 2285. make_reverse_iterator
+ /// Generator function for reverse_iterator.
+ template<typename _Iterator>
+ inline reverse_iterator<_Iterator>
+ make_reverse_iterator(_Iterator __i)
+ { return reverse_iterator<_Iterator>(__i); }
+#endif
+
// 24.4.2.2.1 back_insert_iterator
/**
* @brief Turns assignment into insertion.
typedef typename __traits_type::reference reference;
typedef typename __traits_type::pointer pointer;
- _GLIBCXX_CONSTEXPR __normal_iterator() : _M_current(_Iterator()) { }
+ _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
+ : _M_current(_Iterator()) { }
explicit
- __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
+ __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT
+ : _M_current(__i) { }
// Allow iterator to const_iterator conversion
template<typename _Iter>
__normal_iterator(const __normal_iterator<_Iter,
typename __enable_if<
(std::__are_same<_Iter, typename _Container::pointer>::__value),
- _Container>::__type>& __i)
+ _Container>::__type>& __i) _GLIBCXX_NOEXCEPT
: _M_current(__i.base()) { }
// Forward iterator requirements
reference
- operator*() const
+ operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_current; }
pointer
- operator->() const
+ operator->() const _GLIBCXX_NOEXCEPT
{ return _M_current; }
__normal_iterator&
- operator++()
+ operator++() _GLIBCXX_NOEXCEPT
{
++_M_current;
return *this;
}
__normal_iterator
- operator++(int)
+ operator++(int) _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current++); }
// Bidirectional iterator requirements
__normal_iterator&
- operator--()
+ operator--() _GLIBCXX_NOEXCEPT
{
--_M_current;
return *this;
}
__normal_iterator
- operator--(int)
+ operator--(int) _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current--); }
// Random access iterator requirements
reference
- operator[](const difference_type& __n) const
+ operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{ return _M_current[__n]; }
__normal_iterator&
- operator+=(const difference_type& __n)
+ operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
{ _M_current += __n; return *this; }
__normal_iterator
- operator+(const difference_type& __n) const
+ operator+(difference_type __n) const _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current + __n); }
__normal_iterator&
- operator-=(const difference_type& __n)
+ operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
{ _M_current -= __n; return *this; }
__normal_iterator
- operator-(const difference_type& __n) const
+ operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current - __n); }
const _Iterator&
- base() const
+ base() const _GLIBCXX_NOEXCEPT
{ return _M_current; }
};
inline bool
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() == __rhs.base(); }
template<typename _Iterator, typename _Container>
inline bool
operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() == __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() != __rhs.base(); }
template<typename _Iterator, typename _Container>
inline bool
operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() != __rhs.base(); }
// Random access iterator requirements
inline bool
operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() < __rhs.base(); }
template<typename _Iterator, typename _Container>
inline bool
operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() < __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() > __rhs.base(); }
template<typename _Iterator, typename _Container>
inline bool
operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() > __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() <= __rhs.base(); }
template<typename _Iterator, typename _Container>
inline bool
operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() <= __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() >= __rhs.base(); }
template<typename _Iterator, typename _Container>
inline bool
operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() >= __rhs.base(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 685.
inline auto
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
+ const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept
-> decltype(__lhs.base() - __rhs.base())
#else
inline typename __normal_iterator<_IteratorL, _Container>::difference_type
inline typename __normal_iterator<_Iterator, _Container>::difference_type
operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs)
+ _GLIBCXX_NOEXCEPT
{ return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Container>
inline __normal_iterator<_Iterator, _Container>
operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
__n, const __normal_iterator<_Iterator, _Container>& __i)
+ _GLIBCXX_NOEXCEPT
{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
_GLIBCXX_END_NAMESPACE_VERSION
_Iterator _M_current;
typedef iterator_traits<_Iterator> __traits_type;
+ typedef typename __traits_type::reference __base_ref;
public:
typedef _Iterator iterator_type;
typedef typename __traits_type::difference_type difference_type;
// NB: DR 680.
typedef _Iterator pointer;
- typedef value_type&& reference;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2106. move_iterator wrapping iterators returning prvalues
+ typedef typename conditional<is_reference<__base_ref>::value,
+ typename remove_reference<__base_ref>::type&&,
+ __base_ref>::type reference;
move_iterator()
: _M_current() { }
reference
operator*() const
- { return std::move(*_M_current); }
+ { return static_cast<reference>(*_M_current); }
pointer
operator->() const