stl_memory.h: Rename to stl_auto_ptr.h.

2007-05-04  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/stl_memory.h: Rename to stl_auto_ptr.h.
	(__get_temporary_buffer, get_temporary_buffer,
	return_temporary_buffer): Move...
	* include/bits/stl_tempbuf.h: ... here.
	* include/std/memory: Adjust includes.
	* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust dg-error line
	numbers.
	* include/Makefile.am: Adjust.
	* include/Makefile.in: Regenerate.

	* testsuite/util/testsuite_iterators.h: Do not include the entire
	<iterator>.
	* include/bits/stl_iterator_base_types.h: Adjust includes.
	* testsuite/25_algorithms/unique_copy/2.cc: Include <functional>.

From-SVN: r124438
This commit is contained in:
Paolo Carlini 2007-05-04 18:07:10 +00:00 committed by Paolo Carlini
parent dcdc26dfd5
commit acb8a4ef2d
10 changed files with 109 additions and 86 deletions

View file

@ -1,3 +1,20 @@
2007-05-04 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_memory.h: Rename to stl_auto_ptr.h.
(__get_temporary_buffer, get_temporary_buffer,
return_temporary_buffer): Move...
* include/bits/stl_tempbuf.h: ... here.
* include/std/memory: Adjust includes.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust dg-error line
numbers.
* include/Makefile.am: Adjust.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_iterators.h: Do not include the entire
<iterator>.
* include/bits/stl_iterator_base_types.h: Adjust includes.
* testsuite/25_algorithms/unique_copy/2.cc: Include <functional>.
2007-05-04 Mark Mitchell <mark@codesourcery.com>
* libsupc++/atexit_arm.cc: New file.

View file

@ -115,7 +115,7 @@ bits_headers = \
${bits_srcdir}/stl_iterator_base_types.h \
${bits_srcdir}/stl_list.h \
${bits_srcdir}/stl_map.h \
${bits_srcdir}/stl_memory.h \
${bits_srcdir}/stl_auto_ptr.h \
${bits_srcdir}/stl_multimap.h \
${bits_srcdir}/stl_multiset.h \
${bits_srcdir}/stl_numeric.h \

View file

@ -349,7 +349,7 @@ bits_headers = \
${bits_srcdir}/stl_iterator_base_types.h \
${bits_srcdir}/stl_list.h \
${bits_srcdir}/stl_map.h \
${bits_srcdir}/stl_memory.h \
${bits_srcdir}/stl_auto_ptr.h \
${bits_srcdir}/stl_multimap.h \
${bits_srcdir}/stl_multiset.h \
${bits_srcdir}/stl_numeric.h \

View file

@ -1,4 +1,4 @@
// Memory implementation -*- C++ -*-
// auto_ptr implementation -*- C++ -*-
// Copyright (C) 2007 Free Software Foundation, Inc.
//
@ -27,85 +27,19 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file stl_memory.h
/** @file stl_auto_ptr.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#ifndef _STL_MEMORY_H
#define _STL_MEMORY_H 1
#ifndef _STL_AUTO_PTR_H
#define _STL_AUTO_PTR_H 1
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_raw_storage_iter.h>
#include <bits/c++config.h>
#include <debug/debug.h>
_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.
*
* XXX This should perhaps use the pool.
* @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),
nothrow));
if (__tmp != 0)
return pair<_Tp*, ptrdiff_t>(__tmp, __len);
__len /= 2;
}
return pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0);
}
/**
* @brief Allocates a temporary buffer.
* @param len The number of objects of type Tp.
* @return See full description.
*
* Reinventing the wheel, but this time with prettier spokes!
*
* This function tries to obtain storage for @c len adjacent Tp
* objects. The objects themselves are not constructed, of course.
* A pair<> is returned containing "the buffer s address and
* capacity (in the units of sizeof(Tp)), or a pair of 0 values if
* no storage can be obtained." Note that the capacity obtained
* may be less than that requested if the memory is unavailable;
* you should compare len with the .second return value.
*
* Provides the nothrow exception guarantee.
*/
template<typename _Tp>
inline pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __len)
{ return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); }
/**
* @brief The companion to get_temporary_buffer().
* @param p A buffer previously allocated by get_temporary_buffer.
* @return None.
*
* Frees the memory pointed to by p.
*/
template<typename _Tp>
void
return_temporary_buffer(_Tp* __p)
{ ::operator delete(__p, nothrow); }
/**
* A wrapper class to provide auto_ptr with reference semantics.
* For example, an auto_ptr can be assigned (or constructed from)
@ -364,4 +298,4 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_END_NAMESPACE
#endif /* _STL_MEMORY_H */
#endif /* _STL_AUTO_PTR_H */

View file

@ -1,6 +1,7 @@
// Types used in iterator implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -66,6 +67,9 @@
#pragma GCC system_header
#include <bits/c++config.h>
#include <cstddef>
_GLIBCXX_BEGIN_NAMESPACE(std)
//@{

View file

@ -62,10 +62,73 @@
#ifndef _TEMPBUF_H
#define _TEMPBUF_H 1
#include <bits/stl_memory.h>
#include <bits/stl_algobase.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
_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.
* @return See full description.
*
* Reinventing the wheel, but this time with prettier spokes!
*
* This function tries to obtain storage for @c len adjacent Tp
* objects. The objects themselves are not constructed, of course.
* A pair<> is returned containing "the buffer s address and
* capacity (in the units of sizeof(Tp)), or a pair of 0 values if
* no storage can be obtained." Note that the capacity obtained
* may be less than that requested if the memory is unavailable;
* you should compare len with the .second return value.
*
* Provides the nothrow exception guarantee.
*/
template<typename _Tp>
inline pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __len)
{ return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); }
/**
* @brief The companion to get_temporary_buffer().
* @param p A buffer previously allocated by get_temporary_buffer.
* @return None.
*
* Frees the memory pointed to by p.
*/
template<typename _Tp>
void
return_temporary_buffer(_Tp* __p)
{ ::operator delete(__p, nothrow); }
/**
* @if maint
* This class is used in two places: stl_algo.h and ext/memory,
@ -131,7 +194,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
operator=(const _Temporary_buffer&);
};
template<typename _ForwardIterator, typename _Tp>
_Temporary_buffer<_ForwardIterator, _Tp>::
_Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
@ -140,8 +202,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
try
{
pair<pointer, size_type> __p(get_temporary_buffer<
value_type>(_M_original_len));
std::pair<pointer, size_type> __p(std::get_temporary_buffer<
value_type>(_M_original_len));
_M_buffer = __p.first;
_M_len = __p.second;
if (!__is_pod(_Tp) && _M_len > 0)

View file

@ -51,8 +51,13 @@
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/stl_memory.h>
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_tempbuf.h>
#include <bits/stl_auto_ptr.h>
#include <bits/stl_raw_storage_iter.h>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
# include <tr1/memory>

View file

@ -46,5 +46,5 @@ main()
test01();
return 0;
}
// { dg-error "candidates" "" { target *-*-* } 207 }
// { dg-error "::auto_ptr" "" { target *-*-* } 337 }
// { dg-error "candidates" "" { target *-*-* } 141 }
// { dg-error "::auto_ptr" "" { target *-*-* } 271 }

View file

@ -1,4 +1,4 @@
// Copyright (C) 2006 Free Software Foundation, Inc.
// Copyright (C) 2006, 2007 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -19,6 +19,7 @@
// 25.2.8 [lib.alg.unique]
#include <algorithm>
#include <functional>
#include <testsuite_hooks.h>
#include <testsuite_iterators.h>

View file

@ -1,7 +1,7 @@
// -*- C++ -*-
// Iterator Wrappers for the C++ library testsuite.
//
// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -37,7 +37,7 @@
// test_container, which is given two pointers to T and an iterator type.
#include <testsuite_hooks.h>
#include <iterator>
#include <bits/stl_iterator_base_types.h>
#ifndef _TESTSUITE_ITERATORS
#define _TESTSUITE_ITERATORS