This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Implement DR 685
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Tue, 07 Oct 2008 16:51:18 +0200
- Subject: [v3] Implement DR 685
Hi,
this patchlet used to cause 2 ICEs before the last mangling patch from
Jason, I'm committing it now, may also help not regressing on those
issues...
Tested x86_64-linux.
Paolo.
//////////////////
2008-10-07 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_iterator.h (operator-(const reverse_iterator<>&,
const reverse_iterator<>&), operator-(const __normal_iterator<>&,
const __normal_iterator<>&), operator-(const move_iterator<>&,
const move_iterator<>&)): Use the auto -> return type syntax,
implement DR 685.
Index: include/bits/stl_iterator.h
===================================================================
*** include/bits/stl_iterator.h (revision 140176)
--- include/bits/stl_iterator.h (working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 365,373 ****
--- 365,381 ----
{ return !(__x < __y); }
template<typename _IteratorL, typename _IteratorR>
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // DR 685.
+ inline auto
+ operator-(const reverse_iterator<_IteratorL>& __x,
+ const reverse_iterator<_IteratorR>& __y)
+ -> decltype(__y.base() - __x.base())
+ #else
inline typename reverse_iterator<_IteratorL>::difference_type
operator-(const reverse_iterator<_IteratorL>& __x,
const reverse_iterator<_IteratorR>& __y)
+ #endif
{ return __y.base() - __x.base(); }
//@}
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 835,843 ****
--- 843,859 ----
// operators but also operator- must accept mixed iterator/const_iterator
// parameters.
template<typename _IteratorL, typename _IteratorR, typename _Container>
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // DR 685.
+ inline auto
+ operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
+ const __normal_iterator<_IteratorR, _Container>& __rhs)
+ -> decltype(__lhs.base() - __rhs.base())
+ #else
inline typename __normal_iterator<_IteratorL, _Container>::difference_type
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
+ #endif
{ return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Container>
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 1001,1010 ****
const move_iterator<_IteratorR>& __y)
{ return !(__x < __y); }
template<typename _IteratorL, typename _IteratorR>
! inline typename move_iterator<_IteratorL>::difference_type
operator-(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
{ return __x.base() - __y.base(); }
template<typename _Iterator>
--- 1017,1028 ----
const move_iterator<_IteratorR>& __y)
{ return !(__x < __y); }
+ // DR 685.
template<typename _IteratorL, typename _IteratorR>
! inline 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>