This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] Move uninitialized_copy_n to <ext/memory>
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: bkoz at redhat dot com
- Date: Tue, 01 Jan 2002 13:12:53 +0100
- Subject: [PATCH] Move uninitialized_copy_n to <ext/memory>
Hi,
this patch(*) moves 'uninitialized_copy_n' + helpers to a new <ext/memory> and
adjusts some bits elsewhere in the light of this.
Tested i686-pc-linux-gnu, as usual.
Ok to commit?
Cheers,
Paolo.
(*) The patch depends on the previous one.
///////////////
2002-01-01 Paolo Carlini <pcarlini@unitus.it>
* include/bits/stl_uninitialized.h (uninitialized_copy_n +
helpers): Move to...
* include/ext/memory: ...here, new file.
* include/Makefile.am (ext_headers): Add new file.
* include/Makefile.in: Regenerate.
* testsuite/ext/headers.cc: Include <ext/memory>.
* include/backward/algobase.h: Include <ext/memory>, tweak.
* include/ext/ropeimpl.h: Include <ext/memory>, tweak.
* include/ext/stl_rope.h: Include <ext/memory>, tweak.
diff -urN libstdc++-v3-current/include/Makefile.am
libstdc++-v3/include/Makefile.am
--- libstdc++-v3-current/include/Makefile.am Mon Dec 31 17:32:41 2001
+++ libstdc++-v3/include/Makefile.am Tue Jan 1 11:56:58 2002
@@ -176,6 +176,7 @@
${ext_srcdir}/hash_map \
${ext_srcdir}/hash_set \
${ext_srcdir}/iterator \
+ ${ext_srcdir}/memory \
${ext_srcdir}/rope \
${ext_srcdir}/ropeimpl.h \
${ext_srcdir}/slist \
diff -urN libstdc++-v3-current/include/backward/algobase.h
libstdc++-v3/include/backward/algobase.h
--- libstdc++-v3-current/include/backward/algobase.h Mon Dec 31 23:34:39 2001
+++ libstdc++-v3/include/backward/algobase.h Tue Jan 1 12:20:49 2002
@@ -61,6 +61,7 @@
#include <bits/stl_algobase.h>
#include <bits/stl_uninitialized.h>
#include <ext/algorithm>
+#include <ext/memory>
// Names from stl_algobase.h
using std::iter_swap;
@@ -77,13 +78,15 @@
// Names from stl_uninitialized.h
using std::uninitialized_copy;
-using std::uninitialized_copy_n;
using std::uninitialized_fill;
using std::uninitialized_fill_n;
// Names from ext/algorithm
using __gnu_cxx::copy_n;
using __gnu_cxx::lexicographical_compare_3way;
+
+// Names from ext/memory
+using __gnu_cxx::uninitialized_copy_n;
#endif /* _CPP_BACKWARD_ALGOBASE_H */
diff -urN libstdc++-v3-current/include/bits/stl_uninitialized.h
libstdc++-v3/include/bits/stl_uninitialized.h
--- libstdc++-v3-current/include/bits/stl_uninitialized.h Wed Dec 19 22:57:42
2001
+++ libstdc++-v3/include/bits/stl_uninitialized.h Tue Jan 1 11:43:48 2002
@@ -127,64 +127,6 @@
return __result + (__last - __first);
}
- // uninitialized_copy_n (not part of the C++ standard)
-
- template<typename _InputIter, typename _Size, typename _ForwardIter>
- pair<_InputIter, _ForwardIter>
- __uninitialized_copy_n(_InputIter __first, _Size __count,
- _ForwardIter __result,
- input_iterator_tag)
- {
- _ForwardIter __cur = __result;
- try {
- for ( ; __count > 0 ; --__count, ++__first, ++__cur)
- _Construct(&*__cur, *__first);
- return pair<_InputIter, _ForwardIter>(__first, __cur);
- }
- catch(...)
- {
- _Destroy(__result, __cur);
- __throw_exception_again;
- }
- }
-
- template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
- inline pair<_RandomAccessIter, _ForwardIter>
- __uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
- _ForwardIter __result,
- random_access_iterator_tag)
- {
- _RandomAccessIter __last = __first + __count;
- return pair<_RandomAccessIter, _ForwardIter>(
- __last,
- uninitialized_copy(__first, __last, __result));
- }
-
- template<typename _InputIter, typename _Size, typename _ForwardIter>
- inline pair<_InputIter, _ForwardIter>
- __uninitialized_copy_n(_InputIter __first, _Size __count,
- _ForwardIter __result) {
- return __uninitialized_copy_n(__first, __count, __result,
- __iterator_category(__first));
- }
-
- /**
- * @brief Copies the range [first,last) into result.
- * @param first An input iterator.
- * @param last An input iterator.
- * @param result An output iterator.
- * @return result + (first - last)
- *
- * Like copy(), but does not require an initialized output range.
- */
- template<typename _InputIter, typename _Size, typename _ForwardIter>
- inline pair<_InputIter, _ForwardIter>
- uninitialized_copy_n(_InputIter __first, _Size __count,
- _ForwardIter __result) {
- return __uninitialized_copy_n(__first, __count, __result,
- __iterator_category(__first));
- }
-
// Valid if copy construction is equivalent to assignment, and if the
// destructor is trivial.
template<typename _ForwardIter, typename _Tp>
diff -urN libstdc++-v3-current/include/ext/memory
libstdc++-v3/include/ext/memory
--- libstdc++-v3-current/include/ext/memory Thu Jan 1 01:00:00 1970
+++ libstdc++-v3/include/ext/memory Tue Jan 1 12:11:42 2002
@@ -0,0 +1,128 @@
+// Memory extensions -*- C++ -*-
+
+// Copyright (C) 2001 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+#ifndef _EXT_MEMORY
+#define _EXT_MEMORY
+
+#pragma GCC system_header
+#include <bits/std_memory.h>
+
+namespace __gnu_cxx
+{
+ using std::pair;
+ using std::__iterator_category;
+
+ // uninitialized_copy_n (not part of the C++ standard)
+
+ template<typename _InputIter, typename _Size, typename _ForwardIter>
+ pair<_InputIter, _ForwardIter>
+ __uninitialized_copy_n(_InputIter __first, _Size __count,
+ _ForwardIter __result,
+ std::input_iterator_tag)
+ {
+ _ForwardIter __cur = __result;
+ try {
+ for ( ; __count > 0 ; --__count, ++__first, ++__cur)
+ std::_Construct(&*__cur, *__first);
+ return pair<_InputIter, _ForwardIter>(__first, __cur);
+ }
+ catch(...)
+ {
+ std::_Destroy(__result, __cur);
+ __throw_exception_again;
+ }
+ }
+
+ template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
+ inline pair<_RandomAccessIter, _ForwardIter>
+ __uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
+ _ForwardIter __result,
+ std::random_access_iterator_tag)
+ {
+ _RandomAccessIter __last = __first + __count;
+ return pair<_RandomAccessIter, _ForwardIter>(
+ __last,
+ std::uninitialized_copy(__first, __last, __result));
+ }
+
+ template<typename _InputIter, typename _Size, typename _ForwardIter>
+ inline pair<_InputIter, _ForwardIter>
+ __uninitialized_copy_n(_InputIter __first, _Size __count,
+ _ForwardIter __result) {
+ return __uninitialized_copy_n(__first, __count, __result,
+ __iterator_category(__first));
+ }
+
+ /**
+ * @brief Copies the range [first,last) into result.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @param result An output iterator.
+ * @return result + (first - last)
+ *
+ * Like copy(), but does not require an initialized output range.
+ */
+ template<typename _InputIter, typename _Size, typename _ForwardIter>
+ inline pair<_InputIter, _ForwardIter>
+ uninitialized_copy_n(_InputIter __first, _Size __count,
+ _ForwardIter __result) {
+ return __uninitialized_copy_n(__first, __count, __result,
+ __iterator_category(__first));
+ }
+
+} // namespace __gnu_cxx
+
+#endif /* _EXT_MEMORY */
+
diff -urN libstdc++-v3-current/include/ext/ropeimpl.h
libstdc++-v3/include/ext/ropeimpl.h
--- libstdc++-v3-current/include/ext/ropeimpl.h Mon Dec 31 23:15:24 2001
+++ libstdc++-v3/include/ext/ropeimpl.h Tue Jan 1 11:53:47 2002
@@ -50,6 +50,7 @@
#include <bits/functexcept.h>
#include <ext/algorithm> // For copy_n and lexicographical_compare_3way
+#include <ext/memory> // For uninitialized_copy_n
namespace __gnu_cxx
{
@@ -60,7 +61,6 @@
using std::__alloc;
using std::_Destroy;
using std::uninitialized_fill_n;
-using std::uninitialized_copy_n;
// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf
// if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct.
diff -urN libstdc++-v3-current/include/ext/stl_rope.h
libstdc++-v3/include/ext/stl_rope.h
--- libstdc++-v3-current/include/ext/stl_rope.h Sun Dec 30 09:51:36 2001
+++ libstdc++-v3/include/ext/stl_rope.h Tue Jan 1 11:54:34 2002
@@ -61,6 +61,8 @@
# define __GC_CONST // constant except for deallocation
# endif
+#include <ext/memory> // For uninitialized_copy_n
+
namespace __gnu_cxx
{
using std::size_t;
@@ -71,7 +73,6 @@
using std::_Alloc_traits;
using std::_Destroy;
using std::_Refcount_Base;
-using std::uninitialized_copy_n;
// The _S_eos function is used for those functions that
// convert to/from C-like strings to detect the end of the string.
diff -urN libstdc++-v3-current/testsuite/ext/headers.cc
libstdc++-v3/testsuite/ext/headers.cc
--- libstdc++-v3-current/testsuite/ext/headers.cc Mon Dec 31 18:46:22 2001
+++ libstdc++-v3/testsuite/ext/headers.cc Tue Jan 1 12:03:11 2002
@@ -27,6 +27,7 @@
#include <ext/hash_map>
#include <ext/hash_set>
#include <ext/iterator>
+#include <ext/memory>
#include <ext/rope>
#include <ext/slist>