c_locale.h: Change ::malloc() to new char[].

2004-01-29  Stephen M. Webb  <stephen.webb@bregmasoft.com>

	* config/local/generic/c_locale.h: Change ::malloc() to new char[].
  	* config/local/gnu/c_locale.h: Change ::malloc() to new char[].
  	* include/bits/stl_tempbuf.h: Convert _Temporary_buffer to use
	std::get_temporary_buffer() instead of duplicating its code.
	Update to C++STYLE conventions.
  	* include/std/std_memory.h (get_temporary_buffer): Use ::operator
	new() instead of std::malloc().
	(return_temporary_buffer): Use ::operator delete() instead of
	std::free().

From-SVN: r76922
This commit is contained in:
Stephen M. Webb 2004-01-30 03:43:00 +00:00 committed by Benjamin Kosnik
parent ae8f0c1773
commit 917a9fd4d5
7 changed files with 194 additions and 154 deletions

View File

@ -1,3 +1,15 @@
2004-01-29 Stephen M. Webb <stephen.webb@bregmasoft.com>
* config/local/generic/c_locale.h: Change ::malloc() to new char[].
* config/local/gnu/c_locale.h: Change ::malloc() to new char[].
* include/bits/stl_tempbuf.h: Convert _Temporary_buffer to use
std::get_temporary_buffer() instead of duplicating its code.
Update to C++STYLE conventions.
* include/std/std_memory.h (get_temporary_buffer): Use ::operator
new() instead of std::malloc().
(return_temporary_buffer): Use ::operator delete() instead of
std::free().
2004-01-29 Benjamin Kosnik <bkoz@redhat.com> 2004-01-29 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/allocator.h: Temporary switch to new_allocator as * include/bits/allocator.h: Temporary switch to new_allocator as

View File

@ -1,6 +1,6 @@
// Wrapper for underlying C-language localization -*- C++ -*- // Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
@ -39,7 +39,6 @@
#pragma GCC system_header #pragma GCC system_header
#include <clocale> #include <clocale>
#include <cstdlib> // get std::malloc
#include <cstring> // get std::strlen #include <cstring> // get std::strlen
#include <cstdio> // get std::snprintf or std::sprintf #include <cstdio> // get std::snprintf or std::sprintf
@ -61,9 +60,8 @@ namespace std
_Tv __v, const __c_locale&, int __prec = -1) _Tv __v, const __c_locale&, int __prec = -1)
{ {
char* __old = std::setlocale(LC_ALL, NULL); char* __old = std::setlocale(LC_ALL, NULL);
char* __sav = static_cast<char*>(std::malloc(std::strlen(__old) + 1)); char* __sav = new char[std::strlen(__old) + 1];
if (__sav) std::strcpy(__sav, __old);
std::strcpy(__sav, __old);
std::setlocale(LC_ALL, "C"); std::setlocale(LC_ALL, "C");
int __ret; int __ret;
@ -79,7 +77,7 @@ namespace std
__ret = std::sprintf(__out, __fmt, __v); __ret = std::sprintf(__out, __fmt, __v);
#endif #endif
std::setlocale(LC_ALL, __sav); std::setlocale(LC_ALL, __sav);
std::free(__sav); delete [] __sav;
return __ret; return __ret;
} }
} }

View File

@ -1,6 +1,6 @@
// Wrapper for underlying C-language localization -*- C++ -*- // Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
@ -39,7 +39,6 @@
#pragma GCC system_header #pragma GCC system_header
#include <cstring> // get std::strlen #include <cstring> // get std::strlen
#include <cstdlib> // get std::malloc
#include <cstdio> // get std::snprintf or std::sprintf #include <cstdio> // get std::snprintf or std::sprintf
#include <clocale> #include <clocale>
#include <langinfo.h> // For codecvt #include <langinfo.h> // For codecvt
@ -76,9 +75,8 @@ namespace std
_Tv __v, const __c_locale&, int __prec = -1) _Tv __v, const __c_locale&, int __prec = -1)
{ {
char* __old = std::setlocale(LC_ALL, NULL); char* __old = std::setlocale(LC_ALL, NULL);
char* __sav = static_cast<char*>(std::malloc(std::strlen(__old) + 1)); char* __sav = new char[std::strlen(__old) + 1];
if (__sav) std::strcpy(__sav, __old);
std::strcpy(__sav, __old);
std::setlocale(LC_ALL, "C"); std::setlocale(LC_ALL, "C");
#endif #endif
@ -99,7 +97,7 @@ namespace std
__gnu_cxx::__uselocale(__old); __gnu_cxx::__uselocale(__old);
#else #else
std::setlocale(LC_ALL, __sav); std::setlocale(LC_ALL, __sav);
std::free(__sav); delete [] __sav;
#endif #endif
return __ret; return __ret;
} }

View File

@ -1,6 +1,6 @@
// Temporary buffer implementation -*- C++ -*- // Temporary buffer implementation -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
@ -61,88 +61,107 @@
#ifndef _TEMPBUF_H #ifndef _TEMPBUF_H
#define _TEMPBUF_H 1 #define _TEMPBUF_H 1
#include <memory>
namespace std namespace std
{ {
/**
* @if maint
* This class is used in two places: stl_algo.h and ext/memory,
* where it is wrapped as the temporary_buffer class. See
* temporary_buffer docs for more notes.
* @endif
*/
template<typename _ForwardIterator, typename _Tp>
class _Temporary_buffer
{
// concept requirements
__glibcxx_class_requires(_ForwardIterator, _ForwardIteratorConcept)
/** public:
* @if maint typedef _Tp value_type;
* This class is used in two places: stl_algo.h and ext/memory, where it typedef value_type* pointer;
* is wrapped as the temporary_buffer class. See temporary_buffer docs for typedef pointer iterator;
* more notes. typedef ptrdiff_t size_type;
* @endif
*/ protected:
template <class _ForwardIterator, class _Tp> size_type _M_original_len;
class _Temporary_buffer size_type _M_len;
{ pointer _M_buffer;
// concept requirements
__glibcxx_class_requires(_ForwardIterator, _ForwardIteratorConcept) void
_M_initialize_buffer(const _Tp&, __true_type) { }
ptrdiff_t _M_original_len; void
ptrdiff_t _M_len; _M_initialize_buffer(const _Tp& val, __false_type)
_Tp* _M_buffer; { std::uninitialized_fill_n(_M_buffer, _M_len, val); }
public:
/// As per Table mumble.
size_type
size() const
{ return _M_len; }
/// Returns the size requested by the constructor; may be >size().
size_type
requested_size() const
{ return _M_original_len; }
/// As per Table mumble.
iterator
begin()
{ return _M_buffer; }
/// As per Table mumble.
iterator
end()
{ return _M_buffer + _M_len; }
/**
* Constructs a temporary buffer of a size somewhere between
* zero and the size of the given range.
*/
_Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last);
~_Temporary_buffer()
{
std::_Destroy(_M_buffer, _M_buffer + _M_len);
std::return_temporary_buffer(_M_buffer);
}
private:
// Disable copy constructor and assignment operator.
_Temporary_buffer(const _Temporary_buffer&);
void operator=(const _Temporary_buffer&);
};
// this is basically get_temporary_buffer() all over again template<typename _ForwardIterator, typename _Tp>
void _M_allocate_buffer() { _Temporary_buffer<_ForwardIterator, _Tp>::
_M_original_len = _M_len; _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
_M_buffer = 0; : _M_original_len(std::distance(__first, __last)),
_M_len(0) , _M_buffer(0)
{
// Workaround for a __type_traits bug in the pre-7.3 compiler.
typedef typename __type_traits<_Tp>::has_trivial_default_constructor
_Trivial;
if (_M_len > (ptrdiff_t)(INT_MAX / sizeof(_Tp))) try
_M_len = INT_MAX / sizeof(_Tp); {
pair<pointer, size_type> __p(get_temporary_buffer<value_type>(_M_original_len));
while (_M_len > 0) { _M_buffer = __p.first;
_M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp)); _M_len = __p.second;
if (_M_buffer) if (_M_len > 0)
break; _M_initialize_buffer(*__first, _Trivial());
_M_len /= 2; }
} catch(...)
}
void _M_initialize_buffer(const _Tp&, __true_type) {}
void _M_initialize_buffer(const _Tp& val, __false_type) {
std::uninitialized_fill_n(_M_buffer, _M_len, val);
}
public:
/// As per Table mumble.
ptrdiff_t size() const { return _M_len; }
/// Returns the size requested by the constructor; may be >size().
ptrdiff_t requested_size() const { return _M_original_len; }
/// As per Table mumble.
_Tp* begin() { return _M_buffer; }
/// As per Table mumble.
_Tp* end() { return _M_buffer + _M_len; }
_Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) {
// Workaround for a __type_traits bug in the pre-7.3 compiler.
typedef typename __type_traits<_Tp>::has_trivial_default_constructor
_Trivial;
try {
_M_len = std::distance(__first, __last);
_M_allocate_buffer();
if (_M_len > 0)
_M_initialize_buffer(*__first, _Trivial());
}
catch(...)
{ {
std::free(_M_buffer); std::return_temporary_buffer(_M_buffer);
_M_buffer = 0; _M_buffer = 0;
_M_len = 0; _M_len = 0;
__throw_exception_again; __throw_exception_again;
} }
} }
~_Temporary_buffer() {
std::_Destroy(_M_buffer, _M_buffer + _M_len);
std::free(_M_buffer);
}
private:
// Disable copy constructor and assignment operator.
_Temporary_buffer(const _Temporary_buffer&) {}
void operator=(const _Temporary_buffer&) {}
};
} // namespace std } // namespace std
#endif /* _TEMPBUF_H */ #endif /* _TEMPBUF_H */

View File

@ -65,9 +65,7 @@
namespace std namespace std
{ {
// uninitialized_copy // uninitialized_copy
template<typename _InputIterator, typename _ForwardIterator> template<typename _InputIterator, typename _ForwardIterator>
inline _ForwardIterator inline _ForwardIterator
__uninitialized_copy_aux(_InputIterator __first, _InputIterator __last, __uninitialized_copy_aux(_InputIterator __first, _InputIterator __last,
@ -76,17 +74,18 @@ namespace std
{ return std::copy(__first, __last, __result); } { return std::copy(__first, __last, __result); }
template<typename _InputIterator, typename _ForwardIterator> template<typename _InputIterator, typename _ForwardIterator>
_ForwardIterator inline _ForwardIterator
__uninitialized_copy_aux(_InputIterator __first, _InputIterator __last, __uninitialized_copy_aux(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result, _ForwardIterator __result,
__false_type) __false_type)
{ {
_ForwardIterator __cur = __result; _ForwardIterator __cur = __result;
try { try
for ( ; __first != __last; ++__first, ++__cur) {
std::_Construct(&*__cur, *__first); for ( ; __first != __last; ++__first, ++__cur)
return __cur; std::_Construct(&*__cur, *__first);
} return __cur;
}
catch(...) catch(...)
{ {
std::_Destroy(__result, __cur); std::_Destroy(__result, __cur);
@ -105,7 +104,8 @@ namespace std
*/ */
template<typename _InputIterator, typename _ForwardIterator> template<typename _InputIterator, typename _ForwardIterator>
inline _ForwardIterator inline _ForwardIterator
uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result) uninitialized_copy(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result)
{ {
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD; typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD;
@ -131,13 +131,15 @@ namespace std
// destructor is trivial. // destructor is trivial.
template<typename _ForwardIterator, typename _Tp> template<typename _ForwardIterator, typename _Tp>
inline void inline void
__uninitialized_fill_aux(_ForwardIterator __first, _ForwardIterator __last, __uninitialized_fill_aux(_ForwardIterator __first,
_ForwardIterator __last,
const _Tp& __x, __true_type) const _Tp& __x, __true_type)
{ std::fill(__first, __last, __x); } { std::fill(__first, __last, __x); }
template<typename _ForwardIterator, typename _Tp> template<typename _ForwardIterator, typename _Tp>
void void
__uninitialized_fill_aux(_ForwardIterator __first, _ForwardIterator __last, __uninitialized_fill_aux(_ForwardIterator __first,
_ForwardIterator __last,
const _Tp& __x, __false_type) const _Tp& __x, __false_type)
{ {
_ForwardIterator __cur = __first; _ForwardIterator __cur = __first;
@ -163,7 +165,8 @@ namespace std
*/ */
template<typename _ForwardIterator, typename _Tp> template<typename _ForwardIterator, typename _Tp>
inline void inline void
uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x) uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __x)
{ {
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD; typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD;
@ -176,9 +179,7 @@ namespace std
inline _ForwardIterator inline _ForwardIterator
__uninitialized_fill_n_aux(_ForwardIterator __first, _Size __n, __uninitialized_fill_n_aux(_ForwardIterator __first, _Size __n,
const _Tp& __x, __true_type) const _Tp& __x, __true_type)
{ { return std::fill_n(__first, __n, __x); }
return std::fill_n(__first, __n, __x);
}
template<typename _ForwardIterator, typename _Size, typename _Tp> template<typename _ForwardIterator, typename _Size, typename _Tp>
_ForwardIterator _ForwardIterator
@ -186,11 +187,12 @@ namespace std
const _Tp& __x, __false_type) const _Tp& __x, __false_type)
{ {
_ForwardIterator __cur = __first; _ForwardIterator __cur = __first;
try { try
for ( ; __n > 0; --__n, ++__cur) {
std::_Construct(&*__cur, __x); for ( ; __n > 0; --__n, ++__cur)
return __cur; std::_Construct(&*__cur, __x);
} return __cur;
}
catch(...) catch(...)
{ {
std::_Destroy(__first, __cur); std::_Destroy(__first, __cur);
@ -224,10 +226,13 @@ namespace std
// copies [first2, last2) into // copies [first2, last2) into
// [result, result + (last1 - first1) + (last2 - first2)). // [result, result + (last1 - first1) + (last2 - first2)).
template<typename _InputIterator1, typename _InputIterator2, typename _ForwardIterator> template<typename _InputIterator1, typename _InputIterator2,
typename _ForwardIterator>
inline _ForwardIterator inline _ForwardIterator
__uninitialized_copy_copy(_InputIterator1 __first1, _InputIterator1 __last1, __uninitialized_copy_copy(_InputIterator1 __first1,
_InputIterator2 __first2, _InputIterator2 __last2, _InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_ForwardIterator __result) _ForwardIterator __result)
{ {
_ForwardIterator __mid = std::uninitialized_copy(__first1, __last1, __result); _ForwardIterator __mid = std::uninitialized_copy(__first1, __last1, __result);
@ -270,10 +275,12 @@ namespace std
_ForwardIterator __first2, _ForwardIterator __last2, _ForwardIterator __first2, _ForwardIterator __last2,
const _Tp& __x) const _Tp& __x)
{ {
_ForwardIterator __mid2 = std::uninitialized_copy(__first1, __last1, __first2); _ForwardIterator __mid2 = std::uninitialized_copy(__first1, __last1,
try { __first2);
std::uninitialized_fill(__mid2, __last2, __x); try
} {
std::uninitialized_fill(__mid2, __last2, __x);
}
catch(...) catch(...)
{ {
std::_Destroy(__first2, __mid2); std::_Destroy(__first2, __mid2);

View File

@ -1,6 +1,6 @@
// <memory> -*- C++ -*- // <memory> -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
@ -78,33 +78,36 @@ namespace std
while (__len > 0) while (__len > 0)
{ {
_Tp* __tmp = (_Tp*) std::malloc((std::size_t)__len * sizeof(_Tp)); _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp),
nothrow));
if (__tmp != 0) if (__tmp != 0)
return pair<_Tp*, ptrdiff_t>(__tmp, __len); return pair<_Tp*, ptrdiff_t>(__tmp, __len);
__len /= 2; __len /= 2;
} }
return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); return pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0);
} }
/** /**
* @brief This is a mostly-useless wrapper around malloc(). * @brief Allocates a temporary buffer.
* @param len The number of objects of type Tp. * @param len The number of objects of type Tp.
* @return See full description. * @return See full description.
* *
* Reinventing the wheel, but this time with prettier spokes! * Reinventing the wheel, but this time with prettier spokes!
* *
* This function tries to obtain storage for @c len adjacent Tp objects. * This function tries to obtain storage for @c len adjacent Tp
* The objects themselves are not constructed, of course. A pair<> is * objects. The objects themselves are not constructed, of course.
* returned containing "the buffer s address and capacity (in the units of * A pair<> is returned containing "the buffer s address and
* sizeof(Tp)), or a pair of 0 values if no storage can be obtained." * capacity (in the units of sizeof(Tp)), or a pair of 0 values if
* Note that the capacity obtained may be less than that requested if the * no storage can be obtained." Note that the capacity obtained
* memory is unavailable; you should compare len with the .second return * may be less than that requested if the memory is unavailable;
* value. * you should compare len with the .second return value.
*
* Provides the nothrow exception guarantee.
*/ */
template<typename _Tp> template<typename _Tp>
inline pair<_Tp*,ptrdiff_t> inline pair<_Tp*,ptrdiff_t>
get_temporary_buffer(ptrdiff_t __len) get_temporary_buffer(ptrdiff_t __len)
{ return std::__get_temporary_buffer(__len, (_Tp*) 0); } { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); }
/** /**
* @brief The companion to get_temporary_buffer(). * @brief The companion to get_temporary_buffer().
@ -116,12 +119,12 @@ namespace std
template<typename _Tp> template<typename _Tp>
void void
return_temporary_buffer(_Tp* __p) return_temporary_buffer(_Tp* __p)
{ std::free(__p); } { ::operator delete(__p, nothrow); }
/** /**
* A wrapper class to provide auto_ptr with reference semantics. For * A wrapper class to provide auto_ptr with reference semantics.
* example, an auto_ptr can be assigned (or constructed from) the result of * For example, an auto_ptr can be assigned (or constructed from)
* a function which returns an auto_ptr by value. * the result of a function which returns an auto_ptr by value.
* *
* All the auto_ptr_ref stuff should happen behind the scenes. * All the auto_ptr_ref stuff should happen behind the scenes.
*/ */
@ -140,23 +143,25 @@ namespace std
* *
* The Standard says: * The Standard says:
* <pre> * <pre>
* An @c auto_ptr owns the object it holds a pointer to. Copying an * An @c auto_ptr owns the object it holds a pointer to. Copying
* @c auto_ptr copies the pointer and transfers ownership to the destination. * an @c auto_ptr copies the pointer and transfers ownership to the
* If more than one @c auto_ptr owns the same object at the same time the * destination. If more than one @c auto_ptr owns the same object
* behavior of the program is undefined. * at the same time the behavior of the program is undefined.
* *
* The uses of @c auto_ptr include providing temporary exception-safety for * The uses of @c auto_ptr include providing temporary
* dynamically allocated memory, passing ownership of dynamically allocated * exception-safety for dynamically allocated memory, passing
* memory to a function, and returning dynamically allocated memory from a * ownership of dynamically allocated memory to a function, and
* function. @c auto_ptr does not meet the CopyConstructible and Assignable * returning dynamically allocated memory from a function. @c
* requirements for Standard Library <a href="tables.html#65">container</a> * auto_ptr does not meet the CopyConstructible and Assignable
* elements and thus instantiating a Standard Library container with an * requirements for Standard Library <a
* @c auto_ptr results in undefined behavior. * href="tables.html#65">container</a> elements and thus
* instantiating a Standard Library container with an @c auto_ptr
* results in undefined behavior.
* </pre> * </pre>
* Quoted from [20.4.5]/3. * Quoted from [20.4.5]/3.
* *
* Good examples of what can and cannot be done with auto_ptr can be found * Good examples of what can and cannot be done with auto_ptr can
* in the libstdc++ testsuite. * be found in the libstdc++ testsuite.
* *
* @if maint * @if maint
* _GLIBCXX_RESOLVE_LIB_DEFECTS * _GLIBCXX_RESOLVE_LIB_DEFECTS
@ -196,7 +201,8 @@ namespace std
* @brief An %auto_ptr can be constructed from another %auto_ptr. * @brief An %auto_ptr can be constructed from another %auto_ptr.
* @param a Another %auto_ptr of a different but related type. * @param a Another %auto_ptr of a different but related type.
* *
* A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. * A pointer-to-Tp1 must be convertible to a
* pointer-to-Tp/element_type.
* *
* This object now @e owns the object previously owned by @a a, * This object now @e owns the object previously owned by @a a,
* which has given up ownsership. * which has given up ownsership.
@ -238,9 +244,9 @@ namespace std
} }
/** /**
* When the %auto_ptr goes out of scope, the object it owns is deleted. * When the %auto_ptr goes out of scope, the object it owns is
* If it no longer owns anything (i.e., @c get() is @c NULL), then this * deleted. If it no longer owns anything (i.e., @c get() is
* has no effect. * @c NULL), then this has no effect.
* *
* @if maint * @if maint
* The C++ standard says there is supposed to be an empty throw * The C++ standard says there is supposed to be an empty throw
@ -284,8 +290,8 @@ namespace std
* @return The raw pointer being managed. * @return The raw pointer being managed.
* *
* You can get a copy of the pointer that this object owns, for * You can get a copy of the pointer that this object owns, for
* situations such as passing to a function which only accepts a raw * situations such as passing to a function which only accepts
* pointer. * a raw pointer.
* *
* @note This %auto_ptr still owns the memory. * @note This %auto_ptr still owns the memory.
*/ */
@ -297,8 +303,8 @@ namespace std
* @return The raw pointer being managed. * @return The raw pointer being managed.
* *
* You can get a copy of the pointer that this object owns, for * You can get a copy of the pointer that this object owns, for
* situations such as passing to a function which only accepts a raw * situations such as passing to a function which only accepts
* pointer. * a raw pointer.
* *
* @note This %auto_ptr no longer owns the memory. When this object * @note This %auto_ptr no longer owns the memory. When this object
* goes out of scope, nothing will happen. * goes out of scope, nothing will happen.
@ -315,8 +321,8 @@ namespace std
* @brief Forcibly deletes the managed object. * @brief Forcibly deletes the managed object.
* @param p A pointer (defaults to NULL). * @param p A pointer (defaults to NULL).
* *
* This object now @e owns the object pointed to by @a p. The previous * This object now @e owns the object pointed to by @a p. The
* object has been deleted. * previous object has been deleted.
*/ */
void void
reset(element_type* __p = 0) throw() reset(element_type* __p = 0) throw()

View File

@ -1,6 +1,6 @@
// { dg-do compile } // { dg-do compile }
// Copyright (C) 2002, 2003 Free Software Foundation // Copyright (C) 2002, 2003, 2004 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
@ -46,5 +46,5 @@ main()
test01(); test01();
return 0; return 0;
} }
// { dg-error "candidates" "" { target *-*-* } 217 } // { dg-error "candidates" "" { target *-*-* } 223 }
// { dg-error "std::auto_ptr" "" { target *-*-* } 347 } // { dg-error "std::auto_ptr" "" { target *-*-* } 353 }