stl_tempbuf.h (__get_temporary_buffer): Fold in get_temporary_buffer.

2007-12-01  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/stl_tempbuf.h (__get_temporary_buffer): Fold
	in get_temporary_buffer.

From-SVN: r130557
This commit is contained in:
Paolo Carlini 2007-12-01 16:29:22 +00:00
parent 353301145b
commit d87135d45a
2 changed files with 23 additions and 29 deletions

View File

@ -1,6 +1,11 @@
2007-12-01 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_tempbuf.h (__get_temporary_buffer): Fold
in get_temporary_buffer.
2007-11-29 Andris Pavenis <andris.pavenis@iki.fi>
* src/Makefile.am: Use separate vpath lines for each path.
* src/Makefile.am: Use separate vpath lines for each path.
2007-11-28 Johannes Singler <singler@ira.uka.de>

View File

@ -68,32 +68,6 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
/**
* @if maint
* This is a helper function. The unused second parameter exists to
* permit the real get_temporary_buffer to use template parameter deduction.
* @endif
*/
template<typename _Tp>
pair<_Tp*, ptrdiff_t>
__get_temporary_buffer(ptrdiff_t __len, _Tp*)
{
const ptrdiff_t __max =
__gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);
if (__len > __max)
__len = __max;
while (__len > 0)
{
_Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp),
std::nothrow));
if (__tmp != 0)
return std::pair<_Tp*, ptrdiff_t>(__tmp, __len);
__len /= 2;
}
return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0);
}
/**
* @brief Allocates a temporary buffer.
* @param len The number of objects of type Tp.
@ -112,9 +86,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* Provides the nothrow exception guarantee.
*/
template<typename _Tp>
inline pair<_Tp*, ptrdiff_t>
pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __len)
{ return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); }
{
const ptrdiff_t __max =
__gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);
if (__len > __max)
__len = __max;
while (__len > 0)
{
_Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp),
std::nothrow));
if (__tmp != 0)
return std::pair<_Tp*, ptrdiff_t>(__tmp, __len);
__len /= 2;
}
return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0);
}
/**
* @brief The companion to get_temporary_buffer().