diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-05-14 15:17:18 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-05-14 15:17:18 +0000 |
commit | a5244b2ed5ccd1d1697ac1e288a9e1acc4a335cc (patch) | |
tree | d7823be7ad3e63f6690c637339505180ab033e19 | |
parent | fc21784dec6ab2642059b2a988af355a08cbba1a (diff) | |
download | gcc-a5244b2ed5ccd1d1697ac1e288a9e1acc4a335cc.zip gcc-a5244b2ed5ccd1d1697ac1e288a9e1acc4a335cc.tar.gz gcc-a5244b2ed5ccd1d1697ac1e288a9e1acc4a335cc.tar.bz2 |
stl_iterator.h (__normal_iterator<>::_M_const_cast): Use std::pointer_traits.
2013-05-14 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
Use std::pointer_traits.
From-SVN: r198891
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_iterator.h | 16 |
2 files changed, 17 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index dc7d410e..c808738 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2013-05-14 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast): + Use std::pointer_traits. + 2013-05-13 Benjamin Kosnik <bkoz@redhat.com> * libsupc++/Makefile.am (sources): Add bad_array_length.cc, diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index a276230..50b55eb 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -63,7 +63,7 @@ #include <bits/cpp_type_traits.h> #include <ext/type_traits.h> #include <bits/move.h> -#include <ext/cast.h> +#include <bits/ptr_traits.h> namespace std _GLIBCXX_VISIBILITY(default) { @@ -736,9 +736,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __normal_iterator<typename _Container::pointer, _Container> _M_const_cast() const - { return __normal_iterator<typename _Container::pointer, _Container> - (__gnu_cxx::__const_pointer_cast<typename _Container::pointer> - (_M_current)); } + { +#if __cplusplus >= 201103L + using _PTraits = std::pointer_traits<typename _Container::pointer>; + return __normal_iterator<typename _Container::pointer, _Container> + (_PTraits::pointer_to(const_cast<typename _PTraits::element_type&> + (*_M_current))); +#else + return __normal_iterator<typename _Container::pointer, _Container> + (const_cast<typename _Container::pointer>(_M_current)); +#endif + } // Forward iterator requirements reference |