This was deprecated in C++17, and has been removed from the current draft. This adds the dprecated attribute for C++17 and later.
We can't actually remove it for C++2a because we use it (indirectly) in stl_algo.h. We could rename it to __get_temporary_buffer for our internal uses, and then add back get_temporary_buffer as a simple forwarding function guarded by: #if __cplusplus <= 201703L || _GLIBCXX_USE_DEPRECATED This patch doesn't do that though. Does anybody object to adding the deprecated attribute here? Does anybody want to argue in favour of completely removing it for C++2a?
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 182c0ed2ff3..ed2f92d0089 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2018-08-14 Jonathan Wakely <jwak...@redhat.com> + * include/bits/stl_tempbuf.h (get_temporary_buffer) + (return_temporary_buffer): Add deprecated attribute for C++17. + (_Temporary_buffer): Disable -Wdeprecated-declarations warnings. + PR libstdc++/86954 * include/bits/stl_tempbuf.h (return_temporary_buffer): Use non-placement delete. diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h index 0abd3c12de7..2ccaf3e3bd0 100644 --- a/libstdc++-v3/include/bits/stl_tempbuf.h +++ b/libstdc++-v3/include/bits/stl_tempbuf.h @@ -81,6 +81,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Provides the nothrow exception guarantee. */ template<typename _Tp> +#if __cplusplus >= 201703L + _GLIBCXX_DEPRECATED +#endif pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) _GLIBCXX_NOEXCEPT { @@ -108,11 +111,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Frees the memory pointed to by __p. */ template<typename _Tp> +#if __cplusplus >= 201703L + _GLIBCXX_DEPRECATED +#endif inline void return_temporary_buffer(_Tp* __p) { ::operator delete(__p); } - /** * This class is used in two places: stl_algo.h and ext/memory, * where it is wrapped as the temporary_buffer class. See @@ -162,11 +167,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ _Temporary_buffer(_ForwardIterator __seed, size_type __original_len); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" ~_Temporary_buffer() { std::_Destroy(_M_buffer, _M_buffer + _M_len); std::return_temporary_buffer(_M_buffer); } +#pragma GCC diagnostic pop private: // Disable copy constructor and assignment operator. @@ -239,6 +247,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __ucr(__first, __last, __seed); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" template<typename _ForwardIterator, typename _Tp> _Temporary_buffer<_ForwardIterator, _Tp>:: _Temporary_buffer(_ForwardIterator __seed, size_type __original_len) @@ -262,6 +272,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __throw_exception_again; } } +#pragma GCC diagnostic pop _GLIBCXX_END_NAMESPACE_VERSION } // namespace