[v3] Move stl_algobase.h extensions and uninitialized_copy_n to include/ext
Paolo Carlini
pcarlini@unitus.it
Wed Jan 2 04:24:00 GMT 2002
Hi,
this patch continues the task of moving HP/SGI extensions to new include/ext
files in namespace __gnu_cxx. Tested i686-pc-linux-gnu, approved by Benjamin
Kosnik and committed.
Cheers,
Paolo.
///////////////////
2002-01-02 Paolo Carlini <pcarlini@unitus.it>
* include/bits/stl_algobase.h (copy_n + helpers,
lexicographical_compare_3way + helpers): Move to...
* include/ext/algorithm: ...here.
* 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> and
<ext/algorithm>, tweak.
* include/ext/ropeimpl.h: Include <ext/memory>, tweak.
* include/ext/stl_rope.h: Include <ext/memory>, tweak.
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/ext/headers.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- gcc/libstdc++-v3/testsuite/ext/headers.cc 2001/12/31 19:30:22 1.4
+++ gcc/libstdc++-v3/testsuite/ext/headers.cc 2002/01/02 12:16:53 1.5
@@ -27,6 +27,7 @@
#include <ext/hash_map>
#include <ext/hash_set>
#include <ext/iterator>
+#include <ext/memory>
#include <ext/rope>
#include <ext/slist>
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_algobase.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- gcc/libstdc++-v3/include/bits/stl_algobase.h 2001/12/06 20:29:31
1.17
+++ gcc/libstdc++-v3/include/bits/stl_algobase.h 2002/01/02 12:16:54
1.18
@@ -492,58 +492,6 @@
__Normal());
}
- //--------------------------------------------------
- // copy_n (not part of the C++ standard)
-
- template<typename _InputIter, typename _Size, typename _OutputIter>
- pair<_InputIter, _OutputIter>
- __copy_n(_InputIter __first, _Size __count,
- _OutputIter __result,
- input_iterator_tag)
- {
- for ( ; __count > 0; --__count) {
- *__result = *__first;
- ++__first;
- ++__result;
- }
- return pair<_InputIter, _OutputIter>(__first, __result);
- }
-
- template<typename _RAIter, typename _Size, typename _OutputIter>
- inline pair<_RAIter, _OutputIter>
- __copy_n(_RAIter __first, _Size __count,
- _OutputIter __result,
- random_access_iterator_tag)
- {
- _RAIter __last = __first + __count;
- return pair<_RAIter, _OutputIter>(__last, copy(__first, __last,
__result));
- }
-
- /**
- * @brief Copies the range [first,first+count) into [result,result+count).
- * @param first An input iterator.
- * @param count The number of elements to copy.
- * @param result An output iterator.
- * @return A std::pair composed of first+count and result+count.
- *
- * This is an SGI extension.
- * This inline function will boil down to a call to @c memmove whenever
- * possible. Failing that, if random access iterators are passed, then the
- * loop count will be known (and therefore a candidate for compiler
- * optimizations such as unrolling).
- * @ingroup SGIextensions
- */
- template<typename _InputIter, typename _Size, typename _OutputIter>
- inline pair<_InputIter, _OutputIter>
- copy_n(_InputIter __first, _Size __count, _OutputIter __result)
- {
- // concept requirements
- __glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
- __glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
- typename iterator_traits<_InputIter>::value_type>)
-
- return __copy_n(__first, __count, __result,
__iterator_category(__first));
- }
//--------------------------------------------------
// fill and fill_n
@@ -767,8 +715,7 @@
}
//--------------------------------------------------
- // lexicographical_compare and lexicographical_compare_3way.
- // (the latter is not part of the C++ standard.)
+ // lexicographical_compare
/**
* @brief Performs "dictionary" comparison on ranges.
@@ -865,88 +812,6 @@
(const unsigned char*) __last2);
#endif /* CHAR_MAX == SCHAR_MAX */
}
-
- template<typename _InputIter1, typename _InputIter2>
- int
- __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
- _InputIter2 __first2, _InputIter2 __last2)
- {
- while (__first1 != __last1 && __first2 != __last2) {
- if (*__first1 < *__first2)
- return -1;
- if (*__first2 < *__first1)
- return 1;
- ++__first1;
- ++__first2;
- }
- if (__first2 == __last2) {
- return !(__first1 == __last1);
- }
- else {
- return -1;
- }
- }
-
- inline int
- __lexicographical_compare_3way(const unsigned char* __first1,
- const unsigned char* __last1,
- const unsigned char* __first2,
- const unsigned char* __last2)
- {
- const ptrdiff_t __len1 = __last1 - __first1;
- const ptrdiff_t __len2 = __last2 - __first2;
- const int __result = memcmp(__first1, __first2, min(__len1, __len2));
- return __result != 0 ? __result
- : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
- }
-
- inline int
- __lexicographical_compare_3way(const char* __first1, const char* __last1,
- const char* __first2, const char* __last2)
- {
-#if CHAR_MAX == SCHAR_MAX
- return __lexicographical_compare_3way(
- (const signed char*) __first1,
- (const signed char*) __last1,
- (const signed char*) __first2,
- (const signed char*) __last2);
-#else
- return __lexicographical_compare_3way((const unsigned char*) __first1,
- (const unsigned char*) __last1,
- (const unsigned char*) __first2,
- (const unsigned char*) __last2);
-#endif
- }
-
- /**
- * @brief @c memcmp on steroids.
- * @param first1 An input iterator.
- * @param last1 An input iterator.
- * @param first2 An input iterator.
- * @param last2 An input iterator.
- * @return An int, as with @c memcmp.
- *
- * The return value will be less than zero if the first range is
- * "lexigraphically less than" the second, greater than zero if the second
- * range is "lexigraphically less than" the first, and zero otherwise.
- * This is an SGI extension.
- * @ingroup SGIextensions
- */
- template<typename _InputIter1, typename _InputIter2>
- int
- lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
- _InputIter2 __first2, _InputIter2 __last2)
- {
- // concept requirements
- __glibcpp_function_requires(_InputIteratorConcept<_InputIter1>)
- __glibcpp_function_requires(_InputIteratorConcept<_InputIter2>)
- __glibcpp_function_requires(_LessThanComparableConcept<
- typename iterator_traits<_InputIter1>::value_type>)
- __glibcpp_function_requires(_LessThanComparableConcept<
- typename iterator_traits<_InputIter2>::value_type>)
-
- return __lexicographical_compare_3way(__first1, __last1, __first2,
__last2);
- }
} // namespace std
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_uninitialized.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- gcc/libstdc++-v3/include/bits/stl_uninitialized.h 2001/12/19 21:57:42
1.10
+++ gcc/libstdc++-v3/include/bits/stl_uninitialized.h 2002/01/02 12:16:54
1.11
@@ -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>
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/algorithm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- gcc/libstdc++-v3/include/ext/algorithm 2001/12/31 18:03:47 1.2
+++ gcc/libstdc++-v3/include/ext/algorithm 2002/01/02 12:16:54 1.3
@@ -61,6 +61,150 @@
namespace __gnu_cxx
{
+ using std::ptrdiff_t;
+ using std::min;
+ using std::pair;
+ using std::input_iterator_tag;
+ using std::random_access_iterator_tag;
+ using std::iterator_traits;
+
+ //--------------------------------------------------
+ // copy_n (not part of the C++ standard)
+
+ template<typename _InputIter, typename _Size, typename _OutputIter>
+ pair<_InputIter, _OutputIter>
+ __copy_n(_InputIter __first, _Size __count,
+ _OutputIter __result,
+ input_iterator_tag)
+ {
+ for ( ; __count > 0; --__count) {
+ *__result = *__first;
+ ++__first;
+ ++__result;
+ }
+ return pair<_InputIter, _OutputIter>(__first, __result);
+ }
+
+ template<typename _RAIter, typename _Size, typename _OutputIter>
+ inline pair<_RAIter, _OutputIter>
+ __copy_n(_RAIter __first, _Size __count,
+ _OutputIter __result,
+ random_access_iterator_tag)
+ {
+ _RAIter __last = __first + __count;
+ return pair<_RAIter, _OutputIter>(__last,
+ std::copy(__first, __last, __result));
+ }
+
+ /**
+ * @brief Copies the range [first,first+count) into [result,result+count).
+ * @param first An input iterator.
+ * @param count The number of elements to copy.
+ * @param result An output iterator.
+ * @return A std::pair composed of first+count and result+count.
+ *
+ * This is an SGI extension.
+ * This inline function will boil down to a call to @c memmove whenever
+ * possible. Failing that, if random access iterators are passed, then the
+ * loop count will be known (and therefore a candidate for compiler
+ * optimizations such as unrolling).
+ * @ingroup SGIextensions
+ */
+ template<typename _InputIter, typename _Size, typename _OutputIter>
+ inline pair<_InputIter, _OutputIter>
+ copy_n(_InputIter __first, _Size __count, _OutputIter __result)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
+ __glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
+ typename iterator_traits<_InputIter>::value_type>)
+
+ return __copy_n(__first, __count, __result,
+ std::__iterator_category(__first));
+ }
+
+ template<typename _InputIter1, typename _InputIter2>
+ int
+ __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
+ _InputIter2 __first2, _InputIter2 __last2)
+ {
+ while (__first1 != __last1 && __first2 != __last2) {
+ if (*__first1 < *__first2)
+ return -1;
+ if (*__first2 < *__first1)
+ return 1;
+ ++__first1;
+ ++__first2;
+ }
+ if (__first2 == __last2) {
+ return !(__first1 == __last1);
+ }
+ else {
+ return -1;
+ }
+ }
+
+ inline int
+ __lexicographical_compare_3way(const unsigned char* __first1,
+ const unsigned char* __last1,
+ const unsigned char* __first2,
+ const unsigned char* __last2)
+ {
+ const ptrdiff_t __len1 = __last1 - __first1;
+ const ptrdiff_t __len2 = __last2 - __first2;
+ const int __result = std::memcmp(__first1, __first2, min(__len1, __len2));
+ return __result != 0 ? __result
+ : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
+ }
+
+ inline int
+ __lexicographical_compare_3way(const char* __first1, const char* __last1,
+ const char* __first2, const char* __last2)
+ {
+#if CHAR_MAX == SCHAR_MAX
+ return __lexicographical_compare_3way(
+ (const signed char*) __first1,
+ (const signed char*) __last1,
+ (const signed char*) __first2,
+ (const signed char*) __last2);
+#else
+ return __lexicographical_compare_3way((const unsigned char*) __first1,
+ (const unsigned char*) __last1,
+ (const unsigned char*) __first2,
+ (const unsigned char*) __last2);
+#endif
+ }
+
+ /**
+ * @brief @c memcmp on steroids.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @param last2 An input iterator.
+ * @return An int, as with @c memcmp.
+ *
+ * The return value will be less than zero if the first range is
+ * "lexigraphically less than" the second, greater than zero if the second
+ * range is "lexigraphically less than" the first, and zero otherwise.
+ * This is an SGI extension.
+ * @ingroup SGIextensions
+ */
+ template<typename _InputIter1, typename _InputIter2>
+ int
+ lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
+ _InputIter2 __first2, _InputIter2 __last2)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIter1>)
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIter2>)
+ __glibcpp_function_requires(_LessThanComparableConcept<
+ typename iterator_traits<_InputIter1>::value_type>)
+ __glibcpp_function_requires(_LessThanComparableConcept<
+ typename iterator_traits<_InputIter2>::value_type>)
+
+ return __lexicographical_compare_3way(__first1, __last1, __first2,
__last2);
+ }
+
// count and count_if: this version, whose return type is void, was present
// in the HP STL, and is retained as an extension for backward compatibility.
@@ -73,7 +217,7 @@
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
__glibcpp_function_requires(_EqualityComparableConcept<
- typename std::iterator_traits<_InputIter>::value_type >)
+ typename iterator_traits<_InputIter>::value_type >)
__glibcpp_function_requires(_EqualityComparableConcept<_Tp>)
for ( ; __first != __last; ++__first)
if (*__first == __value)
@@ -89,7 +233,7 @@
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
__glibcpp_function_requires(_UnaryPredicateConcept<_Predicate,
- typename std::iterator_traits<_InputIter>::value_type>)
+ typename iterator_traits<_InputIter>::value_type>)
for ( ; __first != __last; ++__first)
if (__pred(*__first))
++__n;
@@ -105,10 +249,10 @@
// concept requirements
__glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>)
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
- typename std::iterator_traits<_ForwardIter>::value_type>)
+ typename iterator_traits<_ForwardIter>::value_type>)
_Distance __remaining = std::distance(__first, __last);
- _Distance __m = std::min(__n, __remaining);
+ _Distance __m = min(__n, __remaining);
while (__m > 0) {
if (std::__random_number(__remaining) < __m) {
@@ -133,12 +277,12 @@
// concept requirements
__glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>)
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
- typename std::iterator_traits<_ForwardIter>::value_type>)
+ typename iterator_traits<_ForwardIter>::value_type>)
__glibcpp_function_requires(_UnaryFunctionConcept<
_RandomNumberGenerator, _Distance, _Distance>)
_Distance __remaining = std::distance(__first, __last);
- _Distance __m = std::min(__n, __remaining);
+ _Distance __m = min(__n, __remaining);
while (__m > 0) {
if (__rand(__remaining) < __m) {
@@ -275,7 +419,7 @@
// concept requirements
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIter>)
__glibcpp_function_requires(_LessThanComparableConcept<
- typename std::iterator_traits<_RandomAccessIter>::value_type>)
+ typename iterator_traits<_RandomAccessIter>::value_type>)
return __is_heap(__first, __last - __first);
}
@@ -288,8 +432,8 @@
// concept requirements
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIter>)
__glibcpp_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
- typename std::iterator_traits<_RandomAccessIter>::value_type,
- typename std::iterator_traits<_RandomAccessIter>::value_type>)
+ typename iterator_traits<_RandomAccessIter>::value_type,
+ typename iterator_traits<_RandomAccessIter>::value_type>)
return __is_heap(__first, __comp, __last - __first);
}
@@ -305,7 +449,7 @@
// concept requirements
__glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>)
__glibcpp_function_requires(_LessThanComparableConcept<
- typename std::iterator_traits<_ForwardIter>::value_type>)
+ typename iterator_traits<_ForwardIter>::value_type>)
if (__first == __last)
return true;
@@ -326,8 +470,8 @@
// concept requirements
__glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>)
__glibcpp_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
- typename std::iterator_traits<_ForwardIter>::value_type,
- typename std::iterator_traits<_ForwardIter>::value_type>)
+ typename iterator_traits<_ForwardIter>::value_type,
+ typename iterator_traits<_ForwardIter>::value_type>)
if (__first == __last)
return true;
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/ropeimpl.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- gcc/libstdc++-v3/include/ext/ropeimpl.h 2001/12/31 10:22:00 1.12
+++ gcc/libstdc++-v3/include/ext/ropeimpl.h 2002/01/02 12:16:54 1.13
@@ -49,6 +49,9 @@
#include <bits/std_iostream.h>
#include <bits/functexcept.h>
+#include <ext/algorithm> // For copy_n and lexicographical_compare_3way
+#include <ext/memory> // For uninitialized_copy_n
+
namespace __gnu_cxx
{
using std::size_t;
@@ -58,8 +61,6 @@
using std::__alloc;
using std::_Destroy;
using std::uninitialized_fill_n;
-using std::lexicographical_compare_3way;
-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.
@@ -983,7 +984,7 @@
case _RopeRep::_S_leaf:
{
_RopeLeaf* __l = (_RopeLeaf*)__r;
- return std::copy_n(__l->_M_data, __l->_M_size, __buffer).second;
+ return copy_n(__l->_M_data, __l->_M_size, __buffer).second;
}
case _RopeRep::_S_function:
case _RopeRep::_S_substringfn:
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/stl_rope.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- gcc/libstdc++-v3/include/ext/stl_rope.h 2001/12/31 10:22:00 1.14
+++ gcc/libstdc++-v3/include/ext/stl_rope.h 2002/01/02 12:16:55 1.15
@@ -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.
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/Makefile.am,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- gcc/libstdc++-v3/include/Makefile.am 2001/12/31 16:16:14 1.16
+++ gcc/libstdc++-v3/include/Makefile.am 2002/01/02 12:16:55 1.17
@@ -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 \
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/backward/algobase.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- gcc/libstdc++-v3/include/backward/algobase.h 2001/06/27 17:09:52
1.7
+++ gcc/libstdc++-v3/include/backward/algobase.h 2002/01/02 12:16:56
1.8
@@ -60,6 +60,8 @@
#include "iterator.h"
#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;
@@ -68,19 +70,23 @@
using std::max;
using std::copy;
using std::copy_backward;
-using std::copy_n;
using std::fill;
using std::fill_n;
using std::mismatch;
using std::equal;
using std::lexicographical_compare;
-using std::lexicographical_compare_3way;
// 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/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) 2002 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 */
+
More information about the Gcc-patches
mailing list