Make vector::data() return type consistent in C++98
authorJonathan Wakely <jwakely@redhat.com>
Mon, 24 Oct 2016 12:25:28 +0000 (13:25 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 24 Oct 2016 12:25:28 +0000 (13:25 +0100)
* include/bits/stl_vector.h (vector::_M_data_ptr, vector::data):
Change return type of non-standard C++98 extension to match C++11.

From-SVN: r241475

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_vector.h

index c344441..7d0a002 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-24  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/bits/stl_vector.h (vector::_M_data_ptr, vector::data):
+       Change return type of non-standard C++98 extension to match C++11.
+
 2016-10-22  François Dumont  <fdumont@gcc.gnu.org>
 
        * include/bits/c++config (_GLIBCXX_BEGIN_NAMESPACE_ALGO)
index efc569b..697a73c 100644 (file)
@@ -914,19 +914,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *   Returns a pointer such that [data(), data() + size()) is a valid
        *   range.  For a non-empty %vector, data() == &front().
        */
-#if __cplusplus >= 201103L
       _Tp*
-#else
-      pointer
-#endif
       data() _GLIBCXX_NOEXCEPT
       { return _M_data_ptr(this->_M_impl._M_start); }
 
-#if __cplusplus >= 201103L
       const _Tp*
-#else
-      const_pointer
-#endif
       data() const _GLIBCXX_NOEXCEPT
       { return _M_data_ptr(this->_M_impl._M_start); }
 
@@ -1558,21 +1550,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       }
 #endif
 
-#if __cplusplus >= 201103L
       template<typename _Up>
        _Up*
-       _M_data_ptr(_Up* __ptr) const
+       _M_data_ptr(_Up* __ptr) const _GLIBCXX_NOEXCEPT
        { return __ptr; }
 
+#if __cplusplus >= 201103L
       template<typename _Ptr>
        typename std::pointer_traits<_Ptr>::element_type*
        _M_data_ptr(_Ptr __ptr) const
        { return empty() ? nullptr : std::__addressof(*__ptr); }
 #else
+      template<typename _Up>
+       _Up*
+       _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
+       { return __ptr; }
+
+      template<typename _Ptr>
+       value_type*
+       _M_data_ptr(_Ptr __ptr)
+       { return __ptr.operator->(); }
+
       template<typename _Ptr>
-       _Ptr
+       const value_type*
        _M_data_ptr(_Ptr __ptr) const
-       { return __ptr; }
+       { return __ptr.operator->(); }
 #endif
     };