mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-28 22:34:03 +08:00
All occurrences of the __value_type() and __distance_type() functions...
2001-07-17 Stephen M. Webb <stephen@bregmasoft.com>r All occurrences of the __value_type() and __distance_type() functions, which were required to support the HP STL, have been removed along with all the auxiliary forwarding functions that were required to support their use. The __iterator_category() function was pretty much left alone because there was no benefit to removing it and its use made code just a little more readable. Incidences of distance() with nonstandard argument list were replaced by calls to the standard function (only in the files affected by the removal of the other HP functions). The signature of the rotate() algorithm was changed to match the standard. Headers were reformatted under C++STYLE guidelines (indentation, linebreaks, typename keyword). * include/bits/stl_algo.h: replaced __value_type() and __distance_type() with iterator_traits, eliminated auxiliary support functions required to support said function usage. Changed nonstandard distance() call to standard call. * include/bits/stl_algobase.h: Same. * include/bits/stl_heap.h: Same. * include/bits/stl_numeric.h: Same. * include/bits/stl_uninitialized.h: Same. * include/bits/stl_iterator_base_types.h (__value_type()): Removed. (__distance_type()): Removed. (value_type()): Gone. (distance_type()): Done in. (iterator_category()): Hasta la vista, baby. * include/bits/stl_iterator_base_funcs.h (iterator_category()): Replaced with __iterator_category(). * include/backward/iterator.h: moved definition of value_type(), distance_type(), and iterator_category() out of std:: and into here. * testsuite/23_containers/vector_ctor.cc (test03): New testcases. * testsuite/23_containers/vector_modifiers.cc (test03): New testcases. * testsuite/25_algorithms/rotate.cc: New testcase. * testsuite/25_algorithms/copy.cc: New testcase. * testsuite/25_algorithms/sort.cc: Same. * testsuite/25_algorithms/heap.cc: Same. * testsuite/25_algorithms/partition.cc: Same. * testsuite/25_algorithms/binary_search.cc: Same. * testsuite/26_numerics/sum_diff.cc: Ditto. From-SVN: r44117
This commit is contained in:
parent
860a15368d
commit
02d92e3b70
@ -1,4 +1,56 @@
|
||||
2001-07-17 Benjamin Kosnik <bkoz@redhat.com>
|
||||
2001-07-17 Stephen M. Webb <stephen@bregmasoft.com>r
|
||||
|
||||
All occurrences of the __value_type() and __distance_type()
|
||||
functions, which were required to support the HP STL, have been
|
||||
removed along with all the auxiliary forwarding functions that
|
||||
were required to support their use.
|
||||
|
||||
The __iterator_category() function was pretty much left alone
|
||||
because there was no benefit to removing it and its use made code
|
||||
just a little more readable.
|
||||
|
||||
Incidences of distance() with nonstandard argument list were
|
||||
replaced by calls to the standard function (only in the files
|
||||
affected by the removal of the other HP functions).
|
||||
|
||||
The signature of the rotate() algorithm was changed to match the
|
||||
standard.
|
||||
|
||||
Headers were reformatted under C++STYLE guidelines (indentation,
|
||||
linebreaks, typename keyword).
|
||||
|
||||
* include/bits/stl_algo.h: replaced __value_type() and
|
||||
__distance_type() with iterator_traits, eliminated auxiliary
|
||||
support functions required to support said function usage.
|
||||
Changed nonstandard distance() call to standard call.
|
||||
|
||||
* include/bits/stl_algobase.h: Same.
|
||||
* include/bits/stl_heap.h: Same.
|
||||
* include/bits/stl_numeric.h: Same.
|
||||
* include/bits/stl_uninitialized.h: Same.
|
||||
* include/bits/stl_iterator_base_types.h (__value_type()):
|
||||
Removed.
|
||||
(__distance_type()): Removed.
|
||||
(value_type()): Gone.
|
||||
(distance_type()): Done in.
|
||||
(iterator_category()): Hasta la vista, baby.
|
||||
|
||||
* include/bits/stl_iterator_base_funcs.h (iterator_category()):
|
||||
Replaced with __iterator_category().
|
||||
* include/backward/iterator.h: moved definition of value_type(),
|
||||
distance_type(), and iterator_category() out of std:: and into
|
||||
here.
|
||||
* testsuite/23_containers/vector_ctor.cc (test03): New testcases.
|
||||
* testsuite/23_containers/vector_modifiers.cc (test03): New testcases.
|
||||
* testsuite/25_algorithms/rotate.cc: New testcase.
|
||||
* testsuite/25_algorithms/copy.cc: New testcase.
|
||||
* testsuite/25_algorithms/sort.cc: Same.
|
||||
* testsuite/25_algorithms/heap.cc: Same.
|
||||
* testsuite/25_algorithms/partition.cc: Same.
|
||||
* testsuite/25_algorithms/binary_search.cc: Same.
|
||||
* testsuite/26_numerics/sum_diff.cc: Ditto.
|
||||
|
||||
001-07-17 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* testsuite/README: Add notes on naming test cases.
|
||||
* testsuite/22_locale/members.cc: Mark as xfail.
|
||||
|
@ -145,44 +145,7 @@ MULTICLEAN = true
|
||||
# Work around what appears to be a GNU make bug handling MAKEFLAGS
|
||||
# values defined in terms of make variables, as is the case for CC and
|
||||
# friends when we are called from the top level Makefile.
|
||||
AM_MAKEFLAGS = \
|
||||
"AR_FLAGS=$(AR_FLAGS)" \
|
||||
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
|
||||
"CC_FOR_TARGET=$(CC_FOR_TARGET)" \
|
||||
"CFLAGS=$(CFLAGS)" \
|
||||
"CXXFLAGS=$(CXXFLAGS)" \
|
||||
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
|
||||
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
|
||||
"INSTALL=$(INSTALL)" \
|
||||
"INSTALL_DATA=$(INSTALL_DATA)" \
|
||||
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
|
||||
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
|
||||
"LDFLAGS=$(LDFLAGS)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
|
||||
"MAKE=$(MAKE)" \
|
||||
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
|
||||
"SHELL=$(SHELL)" \
|
||||
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
|
||||
"exec_prefix=$(exec_prefix)" \
|
||||
"infodir=$(infodir)" \
|
||||
"libdir=$(libdir)" \
|
||||
"includedir=$(includedir)" \
|
||||
"prefix=$(prefix)" \
|
||||
"tooldir=$(tooldir)" \
|
||||
"AR=$(AR)" \
|
||||
"AS=$(AS)" \
|
||||
"LD=$(LD)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"RANLIB=$(RANLIB)" \
|
||||
"NM=$(NM)" \
|
||||
"NM_FOR_BUILD=$(NM_FOR_BUILD)" \
|
||||
"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
|
||||
"DESTDIR=$(DESTDIR)" \
|
||||
"WERROR=$(WERROR)"
|
||||
AM_MAKEFLAGS = "AR_FLAGS=$(AR_FLAGS)" "CC_FOR_BUILD=$(CC_FOR_BUILD)" "CC_FOR_TARGET=$(CC_FOR_TARGET)" "CFLAGS=$(CFLAGS)" "CXXFLAGS=$(CXXFLAGS)" "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" "INSTALL=$(INSTALL)" "INSTALL_DATA=$(INSTALL_DATA)" "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" "LDFLAGS=$(LDFLAGS)" "LIBCFLAGS=$(LIBCFLAGS)" "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" "MAKE=$(MAKE)" "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" "PICFLAG=$(PICFLAG)" "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" "SHELL=$(SHELL)" "RUNTESTFLAGS=$(RUNTESTFLAGS)" "exec_prefix=$(exec_prefix)" "infodir=$(infodir)" "libdir=$(libdir)" "includedir=$(includedir)" "prefix=$(prefix)" "tooldir=$(tooldir)" "AR=$(AR)" "AS=$(AS)" "LD=$(LD)" "LIBCFLAGS=$(LIBCFLAGS)" "PICFLAG=$(PICFLAG)" "RANLIB=$(RANLIB)" "NM=$(NM)" "NM_FOR_BUILD=$(NM_FOR_BUILD)" "NM_FOR_TARGET=$(NM_FOR_TARGET)" "DESTDIR=$(DESTDIR)" "WERROR=$(WERROR)"
|
||||
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
CONFIG_HEADER = config.h
|
||||
|
1711
libstdc++-v3/configure
vendored
1711
libstdc++-v3/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -131,254 +131,43 @@ glibcpp_builddir = @glibcpp_builddir@
|
||||
|
||||
bits_srcdir = ${glibcpp_srcdir}/include/bits
|
||||
bits_builddir = ./bits
|
||||
bits_headers = \
|
||||
${bits_srcdir}/basic_file.h \
|
||||
${bits_srcdir}/basic_ios.h \
|
||||
${bits_srcdir}/basic_ios.tcc \
|
||||
${bits_srcdir}/basic_string.h \
|
||||
${bits_srcdir}/basic_string.tcc \
|
||||
${bits_srcdir}/boost_concept_check.h \
|
||||
${bits_srcdir}/char_traits.h \
|
||||
${bits_srcdir}/codecvt.h \
|
||||
${bits_srcdir}/concept_check.h \
|
||||
${bits_srcdir}/cpp_type_traits.h \
|
||||
${bits_srcdir}/fpos.h \
|
||||
${bits_srcdir}/fstream.tcc \
|
||||
${bits_srcdir}/functexcept.h \
|
||||
${bits_srcdir}/generic_shadow.h \
|
||||
${bits_srcdir}/gslice.h \
|
||||
${bits_srcdir}/gslice_array.h \
|
||||
${bits_srcdir}/indirect_array.h \
|
||||
${bits_srcdir}/ios_base.h \
|
||||
${bits_srcdir}/istream.tcc \
|
||||
${bits_srcdir}/locale_facets.h \
|
||||
${bits_srcdir}/locale_facets.tcc \
|
||||
${bits_srcdir}/localefwd.h \
|
||||
${bits_srcdir}/mask_array.h \
|
||||
${bits_srcdir}/ostream.tcc \
|
||||
${bits_srcdir}/pthread_allocimpl.h \
|
||||
${bits_srcdir}/stream_iterator.h \
|
||||
${bits_srcdir}/streambuf_iterator.h \
|
||||
${bits_srcdir}/slice.h \
|
||||
${bits_srcdir}/slice_array.h \
|
||||
${bits_srcdir}/sstream.tcc \
|
||||
${bits_srcdir}/std_algorithm.h \
|
||||
${bits_srcdir}/std_bitset.h \
|
||||
${bits_srcdir}/std_complex.h \
|
||||
${bits_srcdir}/std_deque.h \
|
||||
${bits_srcdir}/std_fstream.h \
|
||||
${bits_srcdir}/std_functional.h \
|
||||
${bits_srcdir}/std_iomanip.h \
|
||||
${bits_srcdir}/std_ios.h \
|
||||
${bits_srcdir}/std_iosfwd.h \
|
||||
${bits_srcdir}/std_iostream.h \
|
||||
${bits_srcdir}/std_istream.h \
|
||||
${bits_srcdir}/std_iterator.h \
|
||||
${bits_srcdir}/std_list.h \
|
||||
${bits_srcdir}/std_locale.h \
|
||||
${bits_srcdir}/std_map.h \
|
||||
${bits_srcdir}/std_memory.h \
|
||||
${bits_srcdir}/std_numeric.h \
|
||||
${bits_srcdir}/std_ostream.h \
|
||||
${bits_srcdir}/std_queue.h \
|
||||
${bits_srcdir}/std_set.h \
|
||||
${bits_srcdir}/std_sstream.h \
|
||||
${bits_srcdir}/std_stack.h \
|
||||
${bits_srcdir}/std_stdexcept.h \
|
||||
${bits_srcdir}/std_streambuf.h \
|
||||
${bits_srcdir}/std_string.h \
|
||||
${bits_srcdir}/std_utility.h \
|
||||
${bits_srcdir}/std_valarray.h \
|
||||
${bits_srcdir}/std_vector.h \
|
||||
${bits_srcdir}/stl_algo.h \
|
||||
${bits_srcdir}/stl_algobase.h \
|
||||
${bits_srcdir}/stl_alloc.h \
|
||||
${bits_srcdir}/stl_bvector.h \
|
||||
${bits_srcdir}/stl_construct.h \
|
||||
${bits_srcdir}/stl_deque.h \
|
||||
${bits_srcdir}/stl_function.h \
|
||||
${bits_srcdir}/stl_heap.h \
|
||||
${bits_srcdir}/stl_iterator.h \
|
||||
${bits_srcdir}/stl_iterator_base_funcs.h \
|
||||
${bits_srcdir}/stl_iterator_base_types.h \
|
||||
${bits_srcdir}/stl_list.h \
|
||||
${bits_srcdir}/stl_map.h \
|
||||
${bits_srcdir}/stl_multimap.h \
|
||||
${bits_srcdir}/stl_multiset.h \
|
||||
${bits_srcdir}/stl_numeric.h \
|
||||
${bits_srcdir}/stl_pair.h \
|
||||
${bits_srcdir}/stl_pthread_alloc.h \
|
||||
${bits_srcdir}/stl_queue.h \
|
||||
${bits_srcdir}/stl_raw_storage_iter.h \
|
||||
${bits_srcdir}/stl_relops.h \
|
||||
${bits_srcdir}/stl_set.h \
|
||||
${bits_srcdir}/stl_stack.h \
|
||||
${bits_srcdir}/stl_tempbuf.h \
|
||||
${bits_srcdir}/stl_threads.h \
|
||||
${bits_srcdir}/stl_tree.h \
|
||||
${bits_srcdir}/stl_uninitialized.h \
|
||||
${bits_srcdir}/stl_vector.h \
|
||||
${bits_srcdir}/streambuf.tcc \
|
||||
${bits_srcdir}/stringfwd.h \
|
||||
${bits_srcdir}/type_traits.h \
|
||||
${bits_srcdir}/valarray_array.h \
|
||||
${bits_srcdir}/valarray_array.tcc \
|
||||
${bits_srcdir}/valarray_meta.h
|
||||
bits_headers = ${bits_srcdir}/basic_file.h ${bits_srcdir}/basic_ios.h ${bits_srcdir}/basic_ios.tcc ${bits_srcdir}/basic_string.h ${bits_srcdir}/basic_string.tcc ${bits_srcdir}/boost_concept_check.h ${bits_srcdir}/char_traits.h ${bits_srcdir}/codecvt.h ${bits_srcdir}/concept_check.h ${bits_srcdir}/cpp_type_traits.h ${bits_srcdir}/fpos.h ${bits_srcdir}/fstream.tcc ${bits_srcdir}/functexcept.h ${bits_srcdir}/generic_shadow.h ${bits_srcdir}/gslice.h ${bits_srcdir}/gslice_array.h ${bits_srcdir}/indirect_array.h ${bits_srcdir}/ios_base.h ${bits_srcdir}/istream.tcc ${bits_srcdir}/locale_facets.h ${bits_srcdir}/locale_facets.tcc ${bits_srcdir}/localefwd.h ${bits_srcdir}/mask_array.h ${bits_srcdir}/ostream.tcc ${bits_srcdir}/pthread_allocimpl.h ${bits_srcdir}/stream_iterator.h ${bits_srcdir}/streambuf_iterator.h ${bits_srcdir}/slice.h ${bits_srcdir}/slice_array.h ${bits_srcdir}/sstream.tcc ${bits_srcdir}/std_algorithm.h ${bits_srcdir}/std_bitset.h ${bits_srcdir}/std_complex.h ${bits_srcdir}/std_deque.h ${bits_srcdir}/std_fstream.h ${bits_srcdir}/std_functional.h ${bits_srcdir}/std_iomanip.h ${bits_srcdir}/std_ios.h ${bits_srcdir}/std_iosfwd.h ${bits_srcdir}/std_iostream.h ${bits_srcdir}/std_istream.h ${bits_srcdir}/std_iterator.h ${bits_srcdir}/std_list.h ${bits_srcdir}/std_locale.h ${bits_srcdir}/std_map.h ${bits_srcdir}/std_memory.h ${bits_srcdir}/std_numeric.h ${bits_srcdir}/std_ostream.h ${bits_srcdir}/std_queue.h ${bits_srcdir}/std_set.h ${bits_srcdir}/std_sstream.h ${bits_srcdir}/std_stack.h ${bits_srcdir}/std_stdexcept.h ${bits_srcdir}/std_streambuf.h ${bits_srcdir}/std_string.h ${bits_srcdir}/std_utility.h ${bits_srcdir}/std_valarray.h ${bits_srcdir}/std_vector.h ${bits_srcdir}/stl_algo.h ${bits_srcdir}/stl_algobase.h ${bits_srcdir}/stl_alloc.h ${bits_srcdir}/stl_bvector.h ${bits_srcdir}/stl_construct.h ${bits_srcdir}/stl_deque.h ${bits_srcdir}/stl_function.h ${bits_srcdir}/stl_heap.h ${bits_srcdir}/stl_iterator.h ${bits_srcdir}/stl_iterator_base_funcs.h ${bits_srcdir}/stl_iterator_base_types.h ${bits_srcdir}/stl_list.h ${bits_srcdir}/stl_map.h ${bits_srcdir}/stl_multimap.h ${bits_srcdir}/stl_multiset.h ${bits_srcdir}/stl_numeric.h ${bits_srcdir}/stl_pair.h ${bits_srcdir}/stl_pthread_alloc.h ${bits_srcdir}/stl_queue.h ${bits_srcdir}/stl_raw_storage_iter.h ${bits_srcdir}/stl_relops.h ${bits_srcdir}/stl_set.h ${bits_srcdir}/stl_stack.h ${bits_srcdir}/stl_tempbuf.h ${bits_srcdir}/stl_threads.h ${bits_srcdir}/stl_tree.h ${bits_srcdir}/stl_uninitialized.h ${bits_srcdir}/stl_vector.h ${bits_srcdir}/streambuf.tcc ${bits_srcdir}/stringfwd.h ${bits_srcdir}/type_traits.h ${bits_srcdir}/valarray_array.h ${bits_srcdir}/valarray_array.tcc ${bits_srcdir}/valarray_meta.h
|
||||
|
||||
|
||||
backward_srcdir = ${glibcpp_srcdir}/include/backward
|
||||
backward_builddir = ./backward
|
||||
backward_headers = \
|
||||
${backward_srcdir}/complex.h \
|
||||
${backward_srcdir}/iomanip.h \
|
||||
${backward_srcdir}/istream.h \
|
||||
${backward_srcdir}/ostream.h \
|
||||
${backward_srcdir}/stream.h \
|
||||
${backward_srcdir}/streambuf.h \
|
||||
${backward_srcdir}/algo.h \
|
||||
${backward_srcdir}/algobase.h \
|
||||
${backward_srcdir}/alloc.h \
|
||||
${backward_srcdir}/bvector.h \
|
||||
${backward_srcdir}/defalloc.h \
|
||||
${backward_srcdir}/deque.h \
|
||||
${backward_srcdir}/function.h \
|
||||
${backward_srcdir}/hash_map.h \
|
||||
${backward_srcdir}/hash_set.h \
|
||||
${backward_srcdir}/hashtable.h \
|
||||
${backward_srcdir}/heap.h \
|
||||
${backward_srcdir}/iostream.h \
|
||||
${backward_srcdir}/iterator.h \
|
||||
${backward_srcdir}/list.h \
|
||||
${backward_srcdir}/map.h \
|
||||
${backward_srcdir}/multimap.h \
|
||||
${backward_srcdir}/new.h \
|
||||
${backward_srcdir}/multiset.h \
|
||||
${backward_srcdir}/pair.h \
|
||||
${backward_srcdir}/queue.h \
|
||||
${backward_srcdir}/rope.h \
|
||||
${backward_srcdir}/set.h \
|
||||
${backward_srcdir}/slist.h \
|
||||
${backward_srcdir}/stack.h \
|
||||
${backward_srcdir}/tempbuf.h \
|
||||
${backward_srcdir}/tree.h \
|
||||
${backward_srcdir}/vector.h \
|
||||
${backward_srcdir}/fstream.h \
|
||||
${backward_srcdir}/strstream.h \
|
||||
${backward_srcdir}/strstream \
|
||||
${backward_srcdir}/backward_warning.h
|
||||
backward_headers = ${backward_srcdir}/complex.h ${backward_srcdir}/iomanip.h ${backward_srcdir}/istream.h ${backward_srcdir}/ostream.h ${backward_srcdir}/stream.h ${backward_srcdir}/streambuf.h ${backward_srcdir}/algo.h ${backward_srcdir}/algobase.h ${backward_srcdir}/alloc.h ${backward_srcdir}/bvector.h ${backward_srcdir}/defalloc.h ${backward_srcdir}/deque.h ${backward_srcdir}/function.h ${backward_srcdir}/hash_map.h ${backward_srcdir}/hash_set.h ${backward_srcdir}/hashtable.h ${backward_srcdir}/heap.h ${backward_srcdir}/iostream.h ${backward_srcdir}/iterator.h ${backward_srcdir}/list.h ${backward_srcdir}/map.h ${backward_srcdir}/multimap.h ${backward_srcdir}/new.h ${backward_srcdir}/multiset.h ${backward_srcdir}/pair.h ${backward_srcdir}/queue.h ${backward_srcdir}/rope.h ${backward_srcdir}/set.h ${backward_srcdir}/slist.h ${backward_srcdir}/stack.h ${backward_srcdir}/tempbuf.h ${backward_srcdir}/tree.h ${backward_srcdir}/vector.h ${backward_srcdir}/fstream.h ${backward_srcdir}/strstream.h ${backward_srcdir}/strstream ${backward_srcdir}/backward_warning.h
|
||||
|
||||
|
||||
ext_srcdir = ${glibcpp_srcdir}/include/ext
|
||||
ext_builddir = ./ext
|
||||
ext_headers = \
|
||||
${ext_srcdir}/rope \
|
||||
${ext_srcdir}/ropeimpl.h \
|
||||
${ext_srcdir}/stl_rope.h \
|
||||
${ext_srcdir}/slist \
|
||||
${ext_srcdir}/hash_map \
|
||||
${ext_srcdir}/hash_set \
|
||||
${ext_srcdir}/stl_hashtable.h \
|
||||
${ext_srcdir}/stl_hash_fun.h
|
||||
ext_headers = ${ext_srcdir}/rope ${ext_srcdir}/ropeimpl.h ${ext_srcdir}/stl_rope.h ${ext_srcdir}/slist ${ext_srcdir}/hash_map ${ext_srcdir}/hash_set ${ext_srcdir}/stl_hashtable.h ${ext_srcdir}/stl_hash_fun.h
|
||||
|
||||
|
||||
# This is the common subset of files that all three "C" header models use.
|
||||
c_base_srcdir = @C_INCLUDE_DIR@/bits
|
||||
c_base_builddir = ./bits
|
||||
c_base_headers = \
|
||||
${c_base_srcdir}/std_cassert.h \
|
||||
${c_base_srcdir}/std_cctype.h \
|
||||
${c_base_srcdir}/std_cerrno.h \
|
||||
${c_base_srcdir}/std_cfloat.h \
|
||||
${c_base_srcdir}/std_climits.h \
|
||||
${c_base_srcdir}/std_clocale.h \
|
||||
${c_base_srcdir}/std_cmath.h \
|
||||
${c_base_srcdir}/std_csetjmp.h \
|
||||
${c_base_srcdir}/std_csignal.h \
|
||||
${c_base_srcdir}/std_cstdarg.h \
|
||||
${c_base_srcdir}/std_cstddef.h \
|
||||
${c_base_srcdir}/std_cstdio.h \
|
||||
${c_base_srcdir}/std_cstdlib.h \
|
||||
${c_base_srcdir}/std_cstring.h \
|
||||
${c_base_srcdir}/std_ctime.h \
|
||||
${c_base_srcdir}/std_cwchar.h \
|
||||
${c_base_srcdir}/std_cwctype.h \
|
||||
${c_base_srcdir}/cmath.tcc
|
||||
c_base_headers = ${c_base_srcdir}/std_cassert.h ${c_base_srcdir}/std_cctype.h ${c_base_srcdir}/std_cerrno.h ${c_base_srcdir}/std_cfloat.h ${c_base_srcdir}/std_climits.h ${c_base_srcdir}/std_clocale.h ${c_base_srcdir}/std_cmath.h ${c_base_srcdir}/std_csetjmp.h ${c_base_srcdir}/std_csignal.h ${c_base_srcdir}/std_cstdarg.h ${c_base_srcdir}/std_cstddef.h ${c_base_srcdir}/std_cstdio.h ${c_base_srcdir}/std_cstdlib.h ${c_base_srcdir}/std_cstring.h ${c_base_srcdir}/std_ctime.h ${c_base_srcdir}/std_cwchar.h ${c_base_srcdir}/std_cwctype.h ${c_base_srcdir}/cmath.tcc
|
||||
|
||||
|
||||
std_srcdir = ${glibcpp_srcdir}/include/std
|
||||
std_builddir = ./
|
||||
std_headers = \
|
||||
${std_srcdir}/algorithm \
|
||||
${std_srcdir}/bitset \
|
||||
${std_srcdir}/complex \
|
||||
${std_srcdir}/deque \
|
||||
${std_srcdir}/fstream \
|
||||
${std_srcdir}/functional \
|
||||
${std_srcdir}/iomanip \
|
||||
${std_srcdir}/ios \
|
||||
${std_srcdir}/iosfwd \
|
||||
${std_srcdir}/iostream \
|
||||
${std_srcdir}/istream \
|
||||
${std_srcdir}/iterator \
|
||||
${std_srcdir}/limits \
|
||||
${std_srcdir}/list \
|
||||
${std_srcdir}/locale \
|
||||
${std_srcdir}/map \
|
||||
${std_srcdir}/memory \
|
||||
${std_srcdir}/numeric \
|
||||
${std_srcdir}/ostream \
|
||||
${std_srcdir}/queue \
|
||||
${std_srcdir}/set \
|
||||
${std_srcdir}/sstream \
|
||||
${std_srcdir}/stack \
|
||||
${std_srcdir}/stdexcept \
|
||||
${std_srcdir}/streambuf \
|
||||
${std_srcdir}/string \
|
||||
${std_srcdir}/utility \
|
||||
${std_srcdir}/valarray \
|
||||
${std_srcdir}/vector \
|
||||
${std_srcdir}/cassert \
|
||||
${std_srcdir}/cctype \
|
||||
${std_srcdir}/cerrno \
|
||||
${std_srcdir}/cfloat \
|
||||
${std_srcdir}/climits \
|
||||
${std_srcdir}/clocale \
|
||||
${std_srcdir}/ciso646 \
|
||||
${std_srcdir}/cmath \
|
||||
${std_srcdir}/csetjmp \
|
||||
${std_srcdir}/csignal \
|
||||
${std_srcdir}/cstdarg \
|
||||
${std_srcdir}/cstddef \
|
||||
${std_srcdir}/cstdio \
|
||||
${std_srcdir}/cstdlib \
|
||||
${std_srcdir}/cstring \
|
||||
${std_srcdir}/ctime \
|
||||
${std_srcdir}/cwchar \
|
||||
${std_srcdir}/cwctype
|
||||
std_headers = ${std_srcdir}/algorithm ${std_srcdir}/bitset ${std_srcdir}/complex ${std_srcdir}/deque ${std_srcdir}/fstream ${std_srcdir}/functional ${std_srcdir}/iomanip ${std_srcdir}/ios ${std_srcdir}/iosfwd ${std_srcdir}/iostream ${std_srcdir}/istream ${std_srcdir}/iterator ${std_srcdir}/limits ${std_srcdir}/list ${std_srcdir}/locale ${std_srcdir}/map ${std_srcdir}/memory ${std_srcdir}/numeric ${std_srcdir}/ostream ${std_srcdir}/queue ${std_srcdir}/set ${std_srcdir}/sstream ${std_srcdir}/stack ${std_srcdir}/stdexcept ${std_srcdir}/streambuf ${std_srcdir}/string ${std_srcdir}/utility ${std_srcdir}/valarray ${std_srcdir}/vector ${std_srcdir}/cassert ${std_srcdir}/cctype ${std_srcdir}/cerrno ${std_srcdir}/cfloat ${std_srcdir}/climits ${std_srcdir}/clocale ${std_srcdir}/ciso646 ${std_srcdir}/cmath ${std_srcdir}/csetjmp ${std_srcdir}/csignal ${std_srcdir}/cstdarg ${std_srcdir}/cstddef ${std_srcdir}/cstdio ${std_srcdir}/cstdlib ${std_srcdir}/cstring ${std_srcdir}/ctime ${std_srcdir}/cwchar ${std_srcdir}/cwctype
|
||||
|
||||
|
||||
target_srcdir = ${glibcpp_srcdir}/@OS_INC_SRCDIR@
|
||||
target_builddir = ./${target_alias}/bits
|
||||
target_headers = \
|
||||
${target_srcdir}/ctype_base.h \
|
||||
${target_srcdir}/ctype_inline.h \
|
||||
${target_srcdir}/ctype_noninline.h \
|
||||
${target_srcdir}/os_defines.h \
|
||||
${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
|
||||
target_headers = ${target_srcdir}/ctype_base.h ${target_srcdir}/ctype_inline.h ${target_srcdir}/ctype_noninline.h ${target_srcdir}/os_defines.h ${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
|
||||
|
||||
|
||||
thread_builddir = ./${target_alias}/bits
|
||||
thread_headers = \
|
||||
${thread_builddir}/gthr.h \
|
||||
${thread_builddir}/gthr-single.h \
|
||||
${thread_builddir}/gthr-default.h
|
||||
thread_headers = ${thread_builddir}/gthr.h ${thread_builddir}/gthr-single.h ${thread_builddir}/gthr-default.h
|
||||
|
||||
|
||||
# List of all timestamp files. By keeping only one copy of this list, both
|
||||
# CLEANFILES and all-local are kept up-to-date.
|
||||
# XXX stamp-c_compatibility
|
||||
allstamps = stamp-std stamp-bits stamp-c_base stamp-backward stamp-ext \
|
||||
stamp-target stamp-thread stamp-file_model stamp-io stamp-locale
|
||||
allstamps = stamp-std stamp-bits stamp-c_base stamp-backward stamp-ext stamp-target stamp-thread stamp-file_model stamp-io stamp-locale
|
||||
|
||||
|
||||
# By adding these files here, automake will remove them for 'make clean'
|
||||
|
@ -54,9 +54,20 @@ using std::random_access_iterator;
|
||||
|
||||
using std::iterator_traits;
|
||||
|
||||
using std::iterator_category;
|
||||
using std::distance_type;
|
||||
using std::value_type;
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::iterator_category
|
||||
iterator_category(const _Iter& __i)
|
||||
{ return __iterator_category(__i); }
|
||||
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::difference_type*
|
||||
distance_type(const _Iter&)
|
||||
{ return static_cast<typename iterator_traits<_Iter>::difference_type*>(0); }
|
||||
|
||||
template<class _Iter>
|
||||
inline typename iterator_traits<_Iter>::value_type*
|
||||
value_type(const _Iter& __i)
|
||||
{ return static_cast<typename iterator_traits<_Iter>::value_type*>(0); }
|
||||
|
||||
using std::distance;
|
||||
using std::advance;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -62,12 +62,8 @@
|
||||
#define __SGI_STL_INTERNAL_ALGOBASE_H
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#ifndef __SGI_STL_INTERNAL_PAIR_H
|
||||
#include <bits/stl_pair.h>
|
||||
#endif
|
||||
#ifndef _CPP_BITS_TYPE_TRAITS_H
|
||||
#include <bits/type_traits.h>
|
||||
#endif
|
||||
#include <bits/std_cstring.h>
|
||||
#include <bits/std_climits.h>
|
||||
#include <bits/std_cstdlib.h>
|
||||
@ -83,195 +79,198 @@
|
||||
namespace std
|
||||
{
|
||||
|
||||
// swap and iter_swap
|
||||
// swap and iter_swap
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2, class _Tp>
|
||||
inline void __iter_swap(_ForwardIter1 __a, _ForwardIter2 __b, _Tp*)
|
||||
{
|
||||
_Tp __tmp = *__a;
|
||||
*__a = *__b;
|
||||
*__b = __tmp;
|
||||
}
|
||||
template<typename _ForwardIter1, typename _ForwardIter2>
|
||||
inline void
|
||||
iter_swap(_ForwardIter1 __a, _ForwardIter2 __b)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIter1>::value_type _ValueType1;
|
||||
typedef typename iterator_traits<_ForwardIter2>::value_type _ValueType2;
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
inline void iter_swap(_ForwardIter1 __a, _ForwardIter2 __b)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter1>);
|
||||
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter2>);
|
||||
__glibcpp_function_requires(_ConvertibleConcept<
|
||||
typename iterator_traits<_ForwardIter1>::value_type,
|
||||
typename iterator_traits<_ForwardIter2>::value_type>);
|
||||
__glibcpp_function_requires(_ConvertibleConcept<
|
||||
typename iterator_traits<_ForwardIter2>::value_type,
|
||||
typename iterator_traits<_ForwardIter1>::value_type>);
|
||||
__glibcpp_function_requires(_ConvertibleConcept<_ValueType1, _ValueType2>);
|
||||
__glibcpp_function_requires(_ConvertibleConcept<_ValueType2, _ValueType1>);
|
||||
|
||||
__iter_swap(__a, __b, __value_type(__a));
|
||||
}
|
||||
_ValueType1 __tmp = *__a;
|
||||
*__a = *__b;
|
||||
*__b = __tmp;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline void swap(_Tp& __a, _Tp& __b)
|
||||
{
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
swap(_Tp& __a, _Tp& __b)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_SGIAssignableConcept<_Tp>);
|
||||
|
||||
_Tp __tmp = __a;
|
||||
__a = __b;
|
||||
__b = __tmp;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// min and max
|
||||
//--------------------------------------------------
|
||||
// min and max
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
template <class _Tp>
|
||||
inline const _Tp& min(const _Tp& __a, const _Tp& __b) {
|
||||
template<typename _Tp>
|
||||
inline const _Tp&
|
||||
min(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<_Tp>);
|
||||
//return __b < __a ? __b : __a;
|
||||
if (__b < __a) return __b; return __a;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline const _Tp& max(const _Tp& __a, const _Tp& __b) {
|
||||
template<typename _Tp>
|
||||
inline const _Tp&
|
||||
max(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<_Tp>);
|
||||
//return __a < __b ? __b : __a;
|
||||
if (__a < __b) return __b; return __a;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) {
|
||||
template<typename _Tp, typename _Compare>
|
||||
inline const _Tp&
|
||||
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
//return __comp(__b, __a) ? __b : __a;
|
||||
if (__comp(__b, __a)) return __b; return __a;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) {
|
||||
template<typename _Tp, typename _Compare>
|
||||
inline const _Tp&
|
||||
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
//return __comp(__a, __b) ? __b : __a;
|
||||
if (__comp(__a, __b)) return __b; return __a;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// copy
|
||||
//--------------------------------------------------
|
||||
// copy
|
||||
|
||||
// All of these auxiliary functions serve two purposes. (1) Replace
|
||||
// calls to copy with memmove whenever possible. (Memmove, not memcpy,
|
||||
// because the input and output ranges are permitted to overlap.)
|
||||
// (2) If we're using random access iterators, then write the loop as
|
||||
// a for loop with an explicit count.
|
||||
// All of these auxiliary functions serve two purposes. (1) Replace
|
||||
// calls to copy with memmove whenever possible. (Memmove, not memcpy,
|
||||
// because the input and output ranges are permitted to overlap.)
|
||||
// (2) If we're using random access iterators, then write the loop as
|
||||
// a for loop with an explicit count.
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter __copy(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result,
|
||||
input_iterator_tag, _Distance*)
|
||||
{
|
||||
input_iterator_tag)
|
||||
{
|
||||
for ( ; __first != __last; ++__result, ++__first)
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter
|
||||
__copy(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_OutputIter __result, random_access_iterator_tag, _Distance*)
|
||||
{
|
||||
template<typename _RandomAccessIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_OutputIter __result,
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIter>::difference_type
|
||||
_Distance;
|
||||
for (_Distance __n = __last - __first; __n > 0; --__n) {
|
||||
*__result = *__first;
|
||||
++__first;
|
||||
++__result;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp*
|
||||
__copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result)
|
||||
{
|
||||
template<typename _Tp>
|
||||
inline _Tp*
|
||||
__copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result)
|
||||
{
|
||||
memmove(__result, __first, sizeof(_Tp) * (__last - __first));
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_aux2(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy_aux2(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, __false_type)
|
||||
{
|
||||
return __copy(__first, __last, __result,
|
||||
__iterator_category(__first),
|
||||
__distance_type(__first));
|
||||
}
|
||||
{ return __copy(__first, __last, __result, __iterator_category(__first)); }
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_aux2(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy_aux2(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, __true_type)
|
||||
{
|
||||
return __copy(__first, __last, __result,
|
||||
__iterator_category(__first),
|
||||
__distance_type(__first));
|
||||
}
|
||||
{ return __copy(__first, __last, __result, __iterator_category(__first)); }
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp* __copy_aux2(_Tp* __first, _Tp* __last, _Tp* __result,
|
||||
__true_type)
|
||||
{
|
||||
return __copy_trivial(__first, __last, __result);
|
||||
}
|
||||
template<typename _Tp>
|
||||
inline _Tp*
|
||||
__copy_aux2(_Tp* __first, _Tp* __last,
|
||||
_Tp* __result, __true_type)
|
||||
{ return __copy_trivial(__first, __last, __result); }
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp* __copy_aux2(const _Tp* __first, const _Tp* __last, _Tp* __result,
|
||||
__true_type)
|
||||
{
|
||||
return __copy_trivial(__first, __last, __result);
|
||||
}
|
||||
template<typename _Tp>
|
||||
inline _Tp*
|
||||
__copy_aux2(const _Tp* __first, const _Tp* __last,
|
||||
_Tp* __result, __true_type)
|
||||
{ return __copy_trivial(__first, __last, __result); }
|
||||
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Tp>
|
||||
inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, _Tp*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp>::has_trivial_assignment_operator
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy_ni2(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, __true_type)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIter>::value_type
|
||||
_ValueType;
|
||||
typedef typename __type_traits<_ValueType>::has_trivial_assignment_operator
|
||||
_Trivial;
|
||||
return __copy_aux2(__first, __last, __result, _Trivial());
|
||||
}
|
||||
return _OutputIter(__copy_aux2(__first, __last,
|
||||
__result.base(),
|
||||
_Trivial()));
|
||||
}
|
||||
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter __copy_ni2(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, __true_type)
|
||||
{
|
||||
return _OutputIter(__copy_aux(__first, __last, __result.base(),
|
||||
__value_type(__first)));
|
||||
}
|
||||
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter __copy_ni2(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy_ni2(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, __false_type)
|
||||
{
|
||||
return __copy_aux(__first, __last, __result, __value_type(__first));
|
||||
}
|
||||
{
|
||||
typedef typename iterator_traits<_InputIter>::value_type
|
||||
_ValueType;
|
||||
typedef typename __type_traits<_ValueType>::has_trivial_assignment_operator
|
||||
_Trivial;
|
||||
return __copy_aux2(__first, __last,
|
||||
__result,
|
||||
_Trivial());
|
||||
}
|
||||
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter __copy_ni1(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy_ni1(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, __true_type)
|
||||
{
|
||||
{
|
||||
typedef typename _Is_normal_iterator<_OutputIter>::_Normal __Normal;
|
||||
return __copy_ni2(__first.base(), __last.base(), __result, __Normal());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter __copy_ni1(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
__copy_ni1(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, __false_type)
|
||||
{
|
||||
{
|
||||
typedef typename _Is_normal_iterator<_OutputIter>::_Normal __Normal;
|
||||
return __copy_ni2(__first, __last, __result, __Normal());
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result)
|
||||
{
|
||||
template<typename _InputIter, typename _OutputIter>
|
||||
inline _OutputIter
|
||||
copy(_InputIter __first, _InputIter __last, _OutputIter __result)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
|
||||
@ -279,117 +278,123 @@ inline _OutputIter copy(_InputIter __first, _InputIter __last,
|
||||
|
||||
typedef typename _Is_normal_iterator<_InputIter>::_Normal __Normal;
|
||||
return __copy_ni1(__first, __last, __result, __Normal());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// copy_backward
|
||||
//--------------------------------------------------
|
||||
// copy_backward
|
||||
|
||||
template <class _BidirectionalIter1, class _BidirectionalIter2,
|
||||
class _Distance>
|
||||
inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
|
||||
_BidirectionalIter1 __last,
|
||||
template<typename _BidirectionalIter1, typename _BidirectionalIter2>
|
||||
inline _BidirectionalIter2
|
||||
__copy_backward(_BidirectionalIter1 __first, _BidirectionalIter1 __last,
|
||||
_BidirectionalIter2 __result,
|
||||
bidirectional_iterator_tag,
|
||||
_Distance*)
|
||||
{
|
||||
bidirectional_iterator_tag)
|
||||
{
|
||||
while (__first != __last)
|
||||
*--__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
|
||||
inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
|
||||
_RandomAccessIter __last,
|
||||
template<typename _RandomAccessIter, typename _BidirectionalIter>
|
||||
inline _BidirectionalIter
|
||||
__copy_backward(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_BidirectionalIter __result,
|
||||
random_access_iterator_tag,
|
||||
_Distance*)
|
||||
{
|
||||
for (_Distance __n = __last - __first; __n > 0; --__n)
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
typename iterator_traits<_RandomAccessIter>::difference_type __n;
|
||||
for (__n = __last - __first; __n > 0; --__n)
|
||||
*--__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
|
||||
|
||||
// This dispatch class is a workaround for compilers that do not
|
||||
// have partial ordering of function templates. All we're doing is
|
||||
// creating a specialization so that we can turn a call to copy_backward
|
||||
// into a memmove whenever possible.
|
||||
|
||||
template <class _BidirectionalIter1, class _BidirectionalIter2,
|
||||
class _BoolType>
|
||||
struct __copy_backward_dispatch
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIter1>::iterator_category
|
||||
_Cat;
|
||||
typedef typename iterator_traits<_BidirectionalIter1>::difference_type
|
||||
_Distance;
|
||||
|
||||
static _BidirectionalIter2 copy(_BidirectionalIter1 __first,
|
||||
_BidirectionalIter1 __last,
|
||||
_BidirectionalIter2 __result) {
|
||||
return __copy_backward(__first, __last, __result, _Cat(), (_Distance*) 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __copy_backward_dispatch<_Tp*, _Tp*, __true_type>
|
||||
{
|
||||
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {
|
||||
|
||||
// This dispatch class is a workaround for compilers that do not
|
||||
// have partial ordering of function templates. All we're doing is
|
||||
// creating a specialization so that we can turn a call to copy_backward
|
||||
// into a memmove whenever possible.
|
||||
|
||||
template<typename _BidirectionalIter1, typename _BidirectionalIter2,
|
||||
typename _BoolType>
|
||||
struct __copy_backward_dispatch
|
||||
{
|
||||
static _BidirectionalIter2
|
||||
copy(_BidirectionalIter1 __first, _BidirectionalIter1 __last,
|
||||
_BidirectionalIter2 __result)
|
||||
{
|
||||
return __copy_backward(__first, __last,
|
||||
__result,
|
||||
__iterator_category(__first));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
struct __copy_backward_dispatch<_Tp*, _Tp*, __true_type>
|
||||
{
|
||||
static _Tp*
|
||||
copy(const _Tp* __first, const _Tp* __last, _Tp* __result)
|
||||
{
|
||||
const ptrdiff_t _Num = __last - __first;
|
||||
memmove(__result - _Num, __first, sizeof(_Tp) * _Num);
|
||||
return __result - _Num;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __copy_backward_dispatch<const _Tp*, _Tp*, __true_type>
|
||||
{
|
||||
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {
|
||||
template<typename _Tp>
|
||||
struct __copy_backward_dispatch<const _Tp*, _Tp*, __true_type>
|
||||
{
|
||||
static _Tp*
|
||||
copy(const _Tp* __first, const _Tp* __last, _Tp* __result)
|
||||
{
|
||||
return __copy_backward_dispatch<_Tp*, _Tp*, __true_type>
|
||||
::copy(__first, __last, __result);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <class _BI1, class _BI2>
|
||||
inline _BI2 __copy_backward_aux(_BI1 __first, _BI1 __last, _BI2 __result) {
|
||||
template<typename _BI1, typename _BI2>
|
||||
inline _BI2
|
||||
__copy_backward_aux(_BI1 __first, _BI1 __last, _BI2 __result)
|
||||
{
|
||||
typedef typename __type_traits<typename iterator_traits<_BI2>::value_type>
|
||||
::has_trivial_assignment_operator
|
||||
_Trivial;
|
||||
::has_trivial_assignment_operator _Trivial;
|
||||
return __copy_backward_dispatch<_BI1, _BI2, _Trivial>
|
||||
::copy(__first, __last, __result);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2 __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __true_type) {
|
||||
return _BI2(__copy_backward_aux(__first, __last, __result.base()));
|
||||
}
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2
|
||||
__copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __true_type)
|
||||
{ return _BI2(__copy_backward_aux(__first, __last, __result.base())); }
|
||||
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2 __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __false_type){
|
||||
return __copy_backward_aux(__first, __last, __result);
|
||||
}
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2
|
||||
__copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __false_type)
|
||||
{ return __copy_backward_aux(__first, __last, __result); }
|
||||
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2 __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __true_type) {
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2
|
||||
__copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __true_type)
|
||||
{
|
||||
typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal;
|
||||
return __copy_backward_output_normal_iterator(__first.base(), __last.base(),
|
||||
__result, __Normal());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2 __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __false_type) {
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2
|
||||
__copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last,
|
||||
_BI2 __result, __false_type)
|
||||
{
|
||||
typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal;
|
||||
return __copy_backward_output_normal_iterator(__first, __last, __result,
|
||||
__Normal());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
|
||||
{
|
||||
template <typename _BI1, typename _BI2>
|
||||
inline _BI2
|
||||
copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BI1>);
|
||||
__glibcpp_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>);
|
||||
@ -400,130 +405,130 @@ inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
|
||||
typedef typename _Is_normal_iterator<_BI1>::_Normal __Normal;
|
||||
return __copy_backward_input_normal_iterator(__first, __last, __result,
|
||||
__Normal());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count,
|
||||
template<typename _InputIter, typename _Size, typename _OutputIter>
|
||||
pair<_InputIter, _OutputIter>
|
||||
__copy_n(_InputIter __first, _Size __count,
|
||||
_OutputIter __result,
|
||||
input_iterator_tag) {
|
||||
input_iterator_tag)
|
||||
{
|
||||
for ( ; __count > 0; --__count) {
|
||||
*__result = *__first;
|
||||
++__first;
|
||||
++__result;
|
||||
}
|
||||
return pair<_InputIter, _OutputIter>(__first, __result);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RAIter, class _Size, class _OutputIter>
|
||||
inline pair<_RAIter, _OutputIter>
|
||||
__copy_n(_RAIter __first, _Size __count,
|
||||
template<typename _RAIter, typename _Size, typename _OutputIter>
|
||||
inline pair<_RAIter, _OutputIter>
|
||||
__copy_n(_RAIter __first, _Size __count,
|
||||
_OutputIter __result,
|
||||
random_access_iterator_tag) {
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
_RAIter __last = __first + __count;
|
||||
return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
inline pair<_InputIter, _OutputIter>
|
||||
__copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
|
||||
return __copy_n(__first, __count, __result,
|
||||
__iterator_category(__first));
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
inline pair<_InputIter, _OutputIter>
|
||||
copy_n(_InputIter __first, _Size __count, _OutputIter __result)
|
||||
{
|
||||
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);
|
||||
}
|
||||
return __copy_n(__first, __count, __result, __iterator_category(__first));
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// fill and fill_n
|
||||
//--------------------------------------------------
|
||||
// fill and fill_n
|
||||
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value)
|
||||
{
|
||||
template<typename _ForwardIter, typename _Tp>
|
||||
void
|
||||
fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>);
|
||||
|
||||
for ( ; __first != __last; ++__first)
|
||||
*__first = __value;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _OutputIter, class _Size, class _Tp>
|
||||
_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __value)
|
||||
{
|
||||
template<typename _OutputIter, typename _Size, typename _Tp>
|
||||
_OutputIter
|
||||
fill_n(_OutputIter __first, _Size __n, const _Tp& __value)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,_Tp>);
|
||||
|
||||
for ( ; __n > 0; --__n, ++__first)
|
||||
*__first = __value;
|
||||
return __first;
|
||||
}
|
||||
}
|
||||
|
||||
// Specialization: for one-byte types we can use memset.
|
||||
// Specialization: for one-byte types we can use memset.
|
||||
|
||||
inline void fill(unsigned char* __first, unsigned char* __last,
|
||||
const unsigned char& __c)
|
||||
{
|
||||
inline void
|
||||
fill(unsigned char* __first, unsigned char* __last, const unsigned char& __c)
|
||||
{
|
||||
unsigned char __tmp = __c;
|
||||
memset(__first, __tmp, __last - __first);
|
||||
}
|
||||
}
|
||||
|
||||
inline void fill(signed char* __first, signed char* __last,
|
||||
const signed char& __c)
|
||||
{
|
||||
inline void
|
||||
fill(signed char* __first, signed char* __last, const signed char& __c)
|
||||
{
|
||||
signed char __tmp = __c;
|
||||
memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
|
||||
}
|
||||
}
|
||||
|
||||
inline void fill(char* __first, char* __last, const char& __c)
|
||||
{
|
||||
inline void
|
||||
fill(char* __first, char* __last, const char& __c)
|
||||
{
|
||||
char __tmp = __c;
|
||||
memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Size>
|
||||
inline unsigned char* fill_n(unsigned char* __first, _Size __n,
|
||||
const unsigned char& __c)
|
||||
{
|
||||
template<typename _Size>
|
||||
inline unsigned char*
|
||||
fill_n(unsigned char* __first, _Size __n, const unsigned char& __c)
|
||||
{
|
||||
fill(__first, __first + __n, __c);
|
||||
return __first + __n;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Size>
|
||||
inline signed char* fill_n(char* __first, _Size __n,
|
||||
const signed char& __c)
|
||||
{
|
||||
template<typename _Size>
|
||||
inline signed char*
|
||||
fill_n(char* __first, _Size __n, const signed char& __c)
|
||||
{
|
||||
fill(__first, __first + __n, __c);
|
||||
return __first + __n;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Size>
|
||||
inline char* fill_n(char* __first, _Size __n, const char& __c)
|
||||
{
|
||||
template<typename _Size>
|
||||
inline char*
|
||||
fill_n(char* __first, _Size __n, const char& __c)
|
||||
{
|
||||
fill(__first, __first + __n, __c);
|
||||
return __first + __n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// equal and mismatch
|
||||
//--------------------------------------------------
|
||||
// equal and mismatch
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
_InputIter1 __last1,
|
||||
template<typename _InputIter1, typename _InputIter2>
|
||||
pair<_InputIter1, _InputIter2>
|
||||
mismatch(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
|
||||
@ -537,14 +542,14 @@ pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
++__first2;
|
||||
}
|
||||
return pair<_InputIter1, _InputIter2>(__first1, __first2);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
|
||||
pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
_InputIter1 __last1,
|
||||
template<typename _InputIter1, typename _InputIter2, typename _BinaryPredicate>
|
||||
pair<_InputIter1, _InputIter2>
|
||||
mismatch(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2,
|
||||
_BinaryPredicate __binary_pred)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
|
||||
@ -554,12 +559,13 @@ pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
++__first2;
|
||||
}
|
||||
return pair<_InputIter1, _InputIter2>(__first1, __first2);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
inline bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
template<typename _InputIter1, typename _InputIter2>
|
||||
inline bool
|
||||
equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
|
||||
@ -571,12 +577,14 @@ inline bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
if (!(*__first1 == *__first2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
|
||||
inline bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _BinaryPredicate __binary_pred)
|
||||
{
|
||||
template<typename _InputIter1, typename _InputIter2, typename _BinaryPredicate>
|
||||
inline bool
|
||||
equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2,
|
||||
_BinaryPredicate __binary_pred)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
|
||||
@ -585,16 +593,17 @@ inline bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
if (!__binary_pred(*__first1, *__first2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// lexicographical_compare and lexicographical_compare_3way.
|
||||
// (the latter is not part of the C++ standard.)
|
||||
//--------------------------------------------------
|
||||
// lexicographical_compare and lexicographical_compare_3way.
|
||||
// (the latter is not part of the C++ standard.)
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
template<typename _InputIter1, typename _InputIter2>
|
||||
bool
|
||||
lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
|
||||
@ -611,13 +620,14 @@ bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
return false;
|
||||
}
|
||||
return __first1 == __last1 && __first2 != __last2;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _Compare>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
template<typename _InputIter1, typename _InputIter2, typename _Compare>
|
||||
bool
|
||||
lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_Compare __comp)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
|
||||
@ -630,23 +640,22 @@ bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
return false;
|
||||
}
|
||||
return __first1 == __last1 && __first2 != __last2;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool
|
||||
lexicographical_compare(const unsigned char* __first1,
|
||||
const unsigned char* __last1,
|
||||
const unsigned char* __first2,
|
||||
const unsigned char* __last2)
|
||||
{
|
||||
inline bool
|
||||
lexicographical_compare(const unsigned char* __first1, const unsigned char* __last1,
|
||||
const unsigned char* __first2, const unsigned char* __last2)
|
||||
{
|
||||
const size_t __len1 = __last1 - __first1;
|
||||
const size_t __len2 = __last2 - __first2;
|
||||
const int __result = memcmp(__first1, __first2, min(__len1, __len2));
|
||||
return __result != 0 ? __result < 0 : __len1 < __len2;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool lexicographical_compare(const char* __first1, const char* __last1,
|
||||
inline bool
|
||||
lexicographical_compare(const char* __first1, const char* __last1,
|
||||
const char* __first2, const char* __last2)
|
||||
{
|
||||
{
|
||||
#if CHAR_MAX == SCHAR_MAX
|
||||
return lexicographical_compare((const signed char*) __first1,
|
||||
(const signed char*) __last1,
|
||||
@ -658,12 +667,13 @@ inline bool lexicographical_compare(const char* __first1, const char* __last1,
|
||||
(const unsigned char*) __first2,
|
||||
(const unsigned char*) __last2);
|
||||
#endif /* CHAR_MAX == SCHAR_MAX */
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
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;
|
||||
@ -678,25 +688,25 @@ int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline int
|
||||
__lexicographical_compare_3way(const unsigned char* __first1,
|
||||
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,
|
||||
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,
|
||||
@ -709,12 +719,13 @@ __lexicographical_compare_3way(const char* __first1, const char* __last1,
|
||||
(const unsigned char*) __first2,
|
||||
(const unsigned char*) __last2);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
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>);
|
||||
@ -724,7 +735,7 @@ int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
typename iterator_traits<_InputIter2>::value_type>);
|
||||
|
||||
return __lexicographical_compare_3way(__first1, __last1, __first2, __last2);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
@ -62,13 +62,13 @@
|
||||
namespace std
|
||||
{
|
||||
|
||||
// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
|
||||
// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first,
|
||||
template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first,
|
||||
_Distance __holeIndex, _Distance __topIndex, _Tp __value)
|
||||
{
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && *(__first + __parent) < __value) {
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
@ -76,37 +76,32 @@ __push_heap(_RandomAccessIterator __first,
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(__first + __holeIndex) = __value;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
inline void
|
||||
__push_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Distance*, _Tp*)
|
||||
{
|
||||
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
|
||||
_Tp(*(__last - 1)));
|
||||
}
|
||||
template<typename _RandomAccessIterator>
|
||||
inline void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type
|
||||
_ValueType;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
_DistanceType;
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type>);
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<_ValueType>);
|
||||
|
||||
__push_heap_aux(__first, __last,
|
||||
__distance_type(__first), __value_type(__first));
|
||||
}
|
||||
__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
|
||||
_ValueType(*(__last - 1)));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp,
|
||||
class _Compare>
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
template<typename _RandomAccessIterator, typename _Distance, typename _Tp,
|
||||
typename _Compare>
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __topIndex, _Tp __value, _Compare __comp)
|
||||
{
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) {
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
@ -114,37 +109,31 @@ __push_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(__first + __holeIndex) = __value;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare,
|
||||
class _Distance, class _Tp>
|
||||
inline void
|
||||
__push_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp,
|
||||
_Distance*, _Tp*)
|
||||
{
|
||||
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
|
||||
_Tp(*(__last - 1)), __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
template<typename _RandomAccessIterator, typename _Compare>
|
||||
inline void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type
|
||||
_ValueType;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
_DistanceType;
|
||||
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
|
||||
__push_heap_aux(__first, __last, __comp,
|
||||
__distance_type(__first), __value_type(__first));
|
||||
}
|
||||
__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
|
||||
_ValueType(*(__last - 1)), __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __value)
|
||||
{
|
||||
{
|
||||
_Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
@ -159,45 +148,38 @@ __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
__push_heap(__first, __holeIndex, __topIndex, __value);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Distance>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value, _Distance*)
|
||||
{
|
||||
template<typename _RandomAccessIterator, typename _Tp>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance;
|
||||
*__result = *__first;
|
||||
__adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp>
|
||||
inline void
|
||||
__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Tp*)
|
||||
{
|
||||
__pop_heap(__first, __last - 1, __last - 1,
|
||||
_Tp(*(__last - 1)), __distance_type(__first));
|
||||
}
|
||||
template<typename _RandomAccessIterator>
|
||||
inline void
|
||||
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType;
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline void pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type>);
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<_ValueType>);
|
||||
|
||||
__pop_heap_aux(__first, __last, __value_type(__first));
|
||||
}
|
||||
__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance,
|
||||
class _Tp, class _Compare>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
template<typename _RandomAccessIterator, typename _Distance,
|
||||
typename _Tp, typename _Compare>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __value, _Compare __comp)
|
||||
{
|
||||
{
|
||||
_Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
@ -212,105 +194,87 @@ __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
__push_heap(__first, __holeIndex, __topIndex, __value, __comp);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Compare,
|
||||
class _Distance>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value, _Compare __comp,
|
||||
_Distance*)
|
||||
{
|
||||
template<typename _RandomAccessIterator, typename _Tp, typename _Compare>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance;
|
||||
*__result = *__first;
|
||||
__adjust_heap(__first, _Distance(0), _Distance(__last - __first),
|
||||
__value, __comp);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Compare>
|
||||
inline void
|
||||
__pop_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Tp*, _Compare __comp)
|
||||
{
|
||||
__pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp,
|
||||
__distance_type(__first));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline void
|
||||
pop_heap(_RandomAccessIterator __first,
|
||||
template<typename _RandomAccessIterator, typename _Compare>
|
||||
inline void
|
||||
pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
|
||||
__pop_heap_aux(__first, __last, __value_type(__first), __comp);
|
||||
}
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType;
|
||||
__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)), __comp);
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIterator>
|
||||
void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type
|
||||
_ValueType;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
_DistanceType;
|
||||
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<_ValueType>);
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Distance>
|
||||
void
|
||||
__make_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Tp*, _Distance*)
|
||||
{
|
||||
if (__last - __first < 2) return;
|
||||
_Distance __len = __last - __first;
|
||||
_Distance __parent = (__len - 2)/2;
|
||||
_DistanceType __len = __last - __first;
|
||||
_DistanceType __parent = (__len - 2)/2;
|
||||
|
||||
while (true) {
|
||||
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)));
|
||||
__adjust_heap(__first, __parent, __len, _ValueType(*(__first + __parent)));
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIterator, typename _Compare>
|
||||
inline void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type
|
||||
_ValueType;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
_DistanceType;
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
__glibcpp_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type>);
|
||||
|
||||
__make_heap(__first, __last,
|
||||
__value_type(__first), __distance_type(__first));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare,
|
||||
class _Tp, class _Distance>
|
||||
void
|
||||
__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp, _Tp*, _Distance*)
|
||||
{
|
||||
if (__last - __first < 2) return;
|
||||
_Distance __len = __last - __first;
|
||||
_Distance __parent = (__len - 2)/2;
|
||||
_DistanceType __len = __last - __first;
|
||||
_DistanceType __parent = (__len - 2)/2;
|
||||
|
||||
while (true) {
|
||||
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)),
|
||||
__comp);
|
||||
__adjust_heap(__first, __parent, __len,
|
||||
_ValueType(*(__first + __parent)), __comp);
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline void
|
||||
make_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
|
||||
__make_heap(__first, __last, __comp,
|
||||
__value_type(__first), __distance_type(__first));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
template<typename _RandomAccessIterator>
|
||||
void
|
||||
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
@ -319,20 +283,20 @@ void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
|
||||
while (__last - __first > 1)
|
||||
pop_heap(__first, __last--);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
sort_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
template<typename _RandomAccessIterator, typename _Compare>
|
||||
void
|
||||
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>);
|
||||
|
||||
while (__last - __first > 1)
|
||||
pop_heap(__first, __last--, __comp);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
@ -71,41 +71,43 @@
|
||||
namespace std
|
||||
{
|
||||
|
||||
// There are two signatures for distance. In addition to the one taking
|
||||
// two iterators and returning a result, there is another taking two
|
||||
// iterators and a reference-to-result variable, and returning nothing.
|
||||
// The latter seems to be an SGI extension. -- pedwards
|
||||
template <class _InputIterator, class _Distance>
|
||||
inline void __distance(_InputIterator __first, _InputIterator __last,
|
||||
// There are two signatures for distance. In addition to the one taking
|
||||
// two iterators and returning a result, there is another taking two
|
||||
// iterators and a reference-to-result variable, and returning nothing.
|
||||
// The latter seems to be an SGI extension. -- pedwards
|
||||
template<typename _InputIterator, typename _Distance>
|
||||
inline void
|
||||
__distance(_InputIterator __first, _InputIterator __last,
|
||||
_Distance& __n, input_iterator_tag)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
while (__first != __last) { ++__first; ++__n; }
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance>
|
||||
inline void __distance(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last,
|
||||
template<typename _RandomAccessIterator, typename _Distance>
|
||||
inline void
|
||||
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Distance& __n, random_access_iterator_tag)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>);
|
||||
__n += __last - __first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _Distance>
|
||||
inline void distance(_InputIterator __first,
|
||||
_InputIterator __last, _Distance& __n)
|
||||
{
|
||||
template<typename _InputIterator, typename _Distance>
|
||||
inline void
|
||||
distance(_InputIterator __first, _InputIterator __last,
|
||||
_Distance& __n)
|
||||
{
|
||||
// concept requirements -- taken care of in __distance
|
||||
__distance(__first, __last, __n, iterator_category(__first));
|
||||
}
|
||||
__distance(__first, __last, __n, __iterator_category(__first));
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
inline typename iterator_traits<_InputIterator>::difference_type
|
||||
__distance(_InputIterator __first, _InputIterator __last, input_iterator_tag)
|
||||
{
|
||||
template<typename _InputIterator>
|
||||
inline typename iterator_traits<_InputIterator>::difference_type
|
||||
__distance(_InputIterator __first, _InputIterator __last, input_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
typename iterator_traits<_InputIterator>::difference_type __n = 0;
|
||||
@ -113,63 +115,63 @@ __distance(_InputIterator __first, _InputIterator __last, input_iterator_tag)
|
||||
++__first; ++__n;
|
||||
}
|
||||
return __n;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
template<typename _RandomAccessIterator>
|
||||
inline typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>);
|
||||
return __last - __first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
inline typename iterator_traits<_InputIterator>::difference_type
|
||||
distance(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
template<typename _InputIterator>
|
||||
inline typename iterator_traits<_InputIterator>::difference_type
|
||||
distance(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
// concept requirements -- taken care of in __distance
|
||||
typedef typename iterator_traits<_InputIterator>::iterator_category
|
||||
_Category;
|
||||
return __distance(__first, __last, _Category());
|
||||
}
|
||||
return __distance(__first, __last, __iterator_category(__first));
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Distance>
|
||||
inline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag)
|
||||
{
|
||||
template<typename _InputIter, typename _Distance>
|
||||
inline void
|
||||
__advance(_InputIter& __i, _Distance __n, input_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>);
|
||||
while (__n--) ++__i;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator, class _Distance>
|
||||
inline void __advance(_BidirectionalIterator& __i, _Distance __n,
|
||||
bidirectional_iterator_tag)
|
||||
{
|
||||
template<typename _BidirectionalIterator, typename _Distance>
|
||||
inline void
|
||||
__advance(_BidirectionalIterator& __i, _Distance __n, bidirectional_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>);
|
||||
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>);
|
||||
if (__n > 0)
|
||||
while (__n--) ++__i;
|
||||
else
|
||||
while (__n++) --__i;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance>
|
||||
inline void __advance(_RandomAccessIterator& __i, _Distance __n,
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
template<typename _RandomAccessIterator, typename _Distance>
|
||||
inline void
|
||||
__advance(_RandomAccessIterator& __i, _Distance __n, random_access_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>);
|
||||
__i += __n;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _Distance>
|
||||
inline void advance(_InputIterator& __i, _Distance __n)
|
||||
{
|
||||
template<typename _InputIterator, typename _Distance>
|
||||
inline void
|
||||
advance(_InputIterator& __i, _Distance __n)
|
||||
{
|
||||
// concept requirements -- taken care of in __advance
|
||||
__advance(__i, __n, iterator_category(__i));
|
||||
}
|
||||
__advance(__i, __n, __iterator_category(__i));
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
@ -67,142 +67,108 @@
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/std_cstddef.h> // for ptrdiff_t
|
||||
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
struct input_iterator_tag {};
|
||||
struct output_iterator_tag {};
|
||||
struct forward_iterator_tag : public input_iterator_tag {};
|
||||
struct bidirectional_iterator_tag : public forward_iterator_tag {};
|
||||
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
|
||||
struct input_iterator_tag {};
|
||||
struct output_iterator_tag {};
|
||||
struct forward_iterator_tag : public input_iterator_tag {};
|
||||
struct bidirectional_iterator_tag : public forward_iterator_tag {};
|
||||
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
|
||||
|
||||
// The base classes input_iterator, output_iterator, forward_iterator,
|
||||
// bidirectional_iterator, and random_access_iterator are not part of
|
||||
// the C++ standard. (They have been replaced by struct iterator.)
|
||||
// They are included for backward compatibility with the HP STL.
|
||||
// The base classes input_iterator, output_iterator, forward_iterator,
|
||||
// bidirectional_iterator, and random_access_iterator are not part of
|
||||
// the C++ standard. (They have been replaced by struct iterator.)
|
||||
// They are included for backward compatibility with the HP STL.
|
||||
|
||||
template <class _Tp, class _Distance> struct input_iterator {
|
||||
template<typename _Tp, typename _Distance>
|
||||
struct input_iterator {
|
||||
typedef input_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
};
|
||||
};
|
||||
|
||||
struct output_iterator {
|
||||
struct output_iterator {
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <class _Tp, class _Distance> struct forward_iterator {
|
||||
template<typename _Tp, typename _Distance>
|
||||
struct forward_iterator {
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp, class _Distance> struct bidirectional_iterator {
|
||||
template<typename _Tp, typename _Distance>
|
||||
struct bidirectional_iterator {
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <class _Tp, class _Distance> struct random_access_iterator {
|
||||
template<typename _Tp, typename _Distance>
|
||||
struct random_access_iterator {
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <class _Category, class _Tp, class _Distance = ptrdiff_t,
|
||||
class _Pointer = _Tp*, class _Reference = _Tp&>
|
||||
struct iterator {
|
||||
template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
|
||||
typename _Pointer = _Tp*, typename _Reference = _Tp&>
|
||||
struct iterator {
|
||||
typedef _Category iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
typedef _Pointer pointer;
|
||||
typedef _Reference reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <class _Iterator>
|
||||
struct iterator_traits {
|
||||
template<typename _Iterator>
|
||||
struct iterator_traits {
|
||||
typedef typename _Iterator::iterator_category iterator_category;
|
||||
typedef typename _Iterator::value_type value_type;
|
||||
typedef typename _Iterator::difference_type difference_type;
|
||||
typedef typename _Iterator::pointer pointer;
|
||||
typedef typename _Iterator::reference reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct iterator_traits<_Tp*> {
|
||||
template<typename _Tp>
|
||||
struct iterator_traits<_Tp*> {
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct iterator_traits<const _Tp*> {
|
||||
template<typename _Tp>
|
||||
struct iterator_traits<const _Tp*> {
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef const _Tp* pointer;
|
||||
typedef const _Tp& reference;
|
||||
};
|
||||
};
|
||||
|
||||
// The overloaded functions iterator_category, distance_type, and
|
||||
// value_type are not part of the C++ standard. (They have been
|
||||
// replaced by struct iterator_traits.) They are included for
|
||||
// backward compatibility with the HP STL.
|
||||
// This function is not a part of the C++ standard but is syntactic
|
||||
// sugar for internal library use only.
|
||||
|
||||
// We introduce internal names for these functions.
|
||||
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::iterator_category
|
||||
__iterator_category(const _Iter&)
|
||||
{
|
||||
typedef typename iterator_traits<_Iter>::iterator_category _Category;
|
||||
return _Category();
|
||||
}
|
||||
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::difference_type*
|
||||
__distance_type(const _Iter&)
|
||||
{
|
||||
return static_cast<typename iterator_traits<_Iter>::difference_type*>(0);
|
||||
}
|
||||
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::value_type*
|
||||
__value_type(const _Iter&)
|
||||
{
|
||||
return static_cast<typename iterator_traits<_Iter>::value_type*>(0);
|
||||
}
|
||||
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::iterator_category
|
||||
iterator_category(const _Iter& __i) { return __iterator_category(__i); }
|
||||
|
||||
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::difference_type*
|
||||
distance_type(const _Iter& __i) { return __distance_type(__i); }
|
||||
|
||||
template <class _Iter>
|
||||
inline typename iterator_traits<_Iter>::value_type*
|
||||
value_type(const _Iter& __i) { return __value_type(__i); }
|
||||
template<typename _Iter>
|
||||
inline typename iterator_traits<_Iter>::iterator_category
|
||||
__iterator_category(const _Iter&)
|
||||
{ return typename iterator_traits<_Iter>::iterator_category(); }
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
@ -64,33 +64,36 @@
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <class _InputIterator, class _Tp>
|
||||
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
|
||||
{
|
||||
template<typename _InputIterator, typename _Tp>
|
||||
_Tp
|
||||
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
|
||||
for ( ; __first != __last; ++__first)
|
||||
__init = __init + *__first;
|
||||
return __init;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _Tp, class _BinaryOperation>
|
||||
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
|
||||
template<typename _InputIterator, typename _Tp, typename _BinaryOperation>
|
||||
_Tp
|
||||
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
|
||||
_BinaryOperation __binary_op)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
|
||||
for ( ; __first != __last; ++__first)
|
||||
__init = __binary_op(__init, *__first);
|
||||
return __init;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp>
|
||||
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
template<typename _InputIterator1, typename _InputIterator2, typename _Tp>
|
||||
_Tp
|
||||
inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp __init)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator2>);
|
||||
@ -98,15 +101,16 @@ _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
__init = __init + (*__first1 * *__first2);
|
||||
return __init;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp,
|
||||
class _BinaryOperation1, class _BinaryOperation2>
|
||||
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
|
||||
typename _BinaryOperation1, typename _BinaryOperation2>
|
||||
_Tp
|
||||
inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp __init,
|
||||
_BinaryOperation1 __binary_op1,
|
||||
_BinaryOperation2 __binary_op2)
|
||||
{
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator1>);
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator2>);
|
||||
@ -114,135 +118,102 @@ _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
|
||||
return __init;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
_OutputIterator
|
||||
__partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*)
|
||||
{
|
||||
_Tp __value = *__first;
|
||||
template<typename _InputIterator, typename _OutputIterator>
|
||||
_OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
|
||||
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>);
|
||||
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
_ValueType __value = *__first;
|
||||
while (++__first != __last) {
|
||||
__value = __value + *__first;
|
||||
*++__result = __value;
|
||||
}
|
||||
return ++__result;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _OutputIterator, typename _BinaryOperation>
|
||||
_OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
_OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
|
||||
typename iterator_traits<_InputIterator>::value_type>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>);
|
||||
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __partial_sum(__first, __last, __result, __value_type(__first));
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*, _BinaryOperation __binary_op)
|
||||
{
|
||||
_Tp __value = *__first;
|
||||
_ValueType __value = *__first;
|
||||
while (++__first != __last) {
|
||||
__value = __binary_op(__value, *__first);
|
||||
*++__result = __value;
|
||||
}
|
||||
return ++__result;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _OutputIterator>
|
||||
_OutputIterator
|
||||
adjacent_difference(_InputIterator __first,
|
||||
_InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
|
||||
_OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
|
||||
typename iterator_traits<_InputIterator>::value_type>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>);
|
||||
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __partial_sum(__first, __last, __result, __value_type(__first),
|
||||
__binary_op);
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
_OutputIterator
|
||||
__adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*)
|
||||
{
|
||||
_Tp __value = *__first;
|
||||
_ValueType __value = *__first;
|
||||
while (++__first != __last) {
|
||||
_Tp __tmp = *__first;
|
||||
_ValueType __tmp = *__first;
|
||||
*++__result = __tmp - __value;
|
||||
__value = __tmp;
|
||||
}
|
||||
return ++__result;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _OutputIterator, typename _BinaryOperation>
|
||||
_OutputIterator
|
||||
adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
_OutputIterator
|
||||
adjacent_difference(_InputIterator __first,
|
||||
_InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
|
||||
typename iterator_traits<_InputIterator>::value_type>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>);
|
||||
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __adjacent_difference(__first, __last, __result,
|
||||
__value_type(__first));
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*,
|
||||
_BinaryOperation __binary_op) {
|
||||
_Tp __value = *__first;
|
||||
_ValueType __value = *__first;
|
||||
while (++__first != __last) {
|
||||
_Tp __tmp = *__first;
|
||||
_ValueType __tmp = *__first;
|
||||
*++__result = __binary_op(__tmp, __value);
|
||||
__value = __tmp;
|
||||
}
|
||||
return ++__result;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
|
||||
_OutputIterator
|
||||
adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
|
||||
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
|
||||
typename iterator_traits<_InputIterator>::value_type>);
|
||||
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __adjacent_difference(__first, __last, __result,
|
||||
__value_type(__first),
|
||||
__binary_op);
|
||||
}
|
||||
|
||||
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
|
||||
// is required to be associative, but not necessarily commutative.
|
||||
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
|
||||
// is required to be associative, but not necessarily commutative.
|
||||
|
||||
|
||||
template <class _Tp, class _Integer, class _MonoidOperation>
|
||||
_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
|
||||
{
|
||||
template<typename _Tp, typename _Integer, typename _MonoidOperation>
|
||||
_Tp
|
||||
__power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
|
||||
{
|
||||
if (__n == 0)
|
||||
return identity_element(__monoid_op);
|
||||
else {
|
||||
@ -261,35 +232,32 @@ _Tp __power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Integer>
|
||||
inline _Tp __power(_Tp __x, _Integer __n)
|
||||
{
|
||||
return __power(__x, __n, multiplies<_Tp>());
|
||||
}
|
||||
template<typename _Tp, typename _Integer>
|
||||
inline _Tp
|
||||
__power(_Tp __x, _Integer __n)
|
||||
{ return __power(__x, __n, multiplies<_Tp>()); }
|
||||
|
||||
// Alias for the internal name __power. Note that power is an extension,
|
||||
// not part of the C++ standard.
|
||||
// Alias for the internal name __power. Note that power is an extension,
|
||||
// not part of the C++ standard.
|
||||
|
||||
template <class _Tp, class _Integer, class _MonoidOperation>
|
||||
inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
|
||||
{
|
||||
return __power(__x, __n, __monoid_op);
|
||||
}
|
||||
template<typename _Tp, typename _Integer, typename _MonoidOperation>
|
||||
inline _Tp
|
||||
power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
|
||||
{ return __power(__x, __n, __monoid_op); }
|
||||
|
||||
template <class _Tp, class _Integer>
|
||||
inline _Tp power(_Tp __x, _Integer __n)
|
||||
{
|
||||
return __power(__x, __n);
|
||||
}
|
||||
template<typename _Tp, typename _Integer>
|
||||
inline _Tp
|
||||
power(_Tp __x, _Integer __n)
|
||||
{ return __power(__x, __n); }
|
||||
|
||||
// iota is not part of the C++ standard. It is an extension.
|
||||
// iota is not part of the C++ standard. It is an extension.
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
void
|
||||
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
|
||||
{
|
||||
template<typename _ForwardIter, typename _Tp>
|
||||
void
|
||||
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>);
|
||||
__glibcpp_function_requires(_ConvertibleConcept<_Tp,
|
||||
@ -297,7 +265,7 @@ iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
|
||||
|
||||
while (__first != __last)
|
||||
*__first++ = __value++;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
@ -65,25 +65,21 @@
|
||||
namespace std
|
||||
{
|
||||
|
||||
// uninitialized_copy
|
||||
// uninitialized_copy
|
||||
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy_aux(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _ForwardIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy_aux(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result,
|
||||
__true_type)
|
||||
{
|
||||
return copy(__first, __last, __result);
|
||||
}
|
||||
{ return copy(__first, __last, __result); }
|
||||
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
_ForwardIter
|
||||
__uninitialized_copy_aux(_InputIter __first, _InputIter __last,
|
||||
template<typename _InputIter, typename _ForwardIter>
|
||||
_ForwardIter
|
||||
__uninitialized_copy_aux(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result,
|
||||
__false_type)
|
||||
{
|
||||
{
|
||||
_ForwardIter __cur = __result;
|
||||
__STL_TRY {
|
||||
for ( ; __first != __last; ++__first, ++__cur)
|
||||
@ -91,49 +87,40 @@ __uninitialized_copy_aux(_InputIter __first, _InputIter __last,
|
||||
return __cur;
|
||||
}
|
||||
__STL_UNWIND(_Destroy(__result, __cur));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class _InputIter, class _ForwardIter, class _Tp>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result, _Tp*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp>::is_POD_type _Is_POD;
|
||||
template<typename _InputIter, typename _ForwardIter>
|
||||
inline _ForwardIter
|
||||
uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIter>::value_type _ValueType;
|
||||
typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD;
|
||||
return __uninitialized_copy_aux(__first, __last, __result, _Is_POD());
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
inline _ForwardIter
|
||||
uninitialized_copy(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result)
|
||||
{
|
||||
return __uninitialized_copy(__first, __last, __result,
|
||||
__value_type(__result));
|
||||
}
|
||||
|
||||
inline char* uninitialized_copy(const char* __first, const char* __last,
|
||||
char* __result) {
|
||||
inline char*
|
||||
uninitialized_copy(const char* __first, const char* __last, char* __result)
|
||||
{
|
||||
memmove(__result, __first, __last - __first);
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
}
|
||||
|
||||
inline wchar_t*
|
||||
uninitialized_copy(const wchar_t* __first, const wchar_t* __last,
|
||||
inline wchar_t*
|
||||
uninitialized_copy(const wchar_t* __first, const wchar_t* __last,
|
||||
wchar_t* __result)
|
||||
{
|
||||
{
|
||||
memmove(__result, __first, sizeof(wchar_t) * (__last - __first));
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
}
|
||||
|
||||
// uninitialized_copy_n (not part of the C++ standard)
|
||||
// uninitialized_copy_n (not part of the C++ standard)
|
||||
|
||||
template <class _InputIter, class _Size, class _ForwardIter>
|
||||
pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
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;
|
||||
__STL_TRY {
|
||||
for ( ; __count > 0 ; --__count, ++__first, ++__cur)
|
||||
@ -141,90 +128,81 @@ __uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
return pair<_InputIter, _ForwardIter>(__first, __cur);
|
||||
}
|
||||
__STL_UNWIND(_Destroy(__result, __cur));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIter, class _Size, class _ForwardIter>
|
||||
inline pair<_RandomAccessIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
|
||||
template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
|
||||
inline pair<_RandomAccessIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
|
||||
_ForwardIter __result,
|
||||
random_access_iterator_tag) {
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
_RandomAccessIter __last = __first + __count;
|
||||
return pair<_RandomAccessIter, _ForwardIter>(
|
||||
__last,
|
||||
uninitialized_copy(__first, __last, __result));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Size, class _ForwardIter>
|
||||
inline pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Size, class _ForwardIter>
|
||||
inline pair<_InputIter, _ForwardIter>
|
||||
uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
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 <class _ForwardIter, class _Tp>
|
||||
inline void
|
||||
__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template<typename _ForwardIter, typename _Tp>
|
||||
inline void
|
||||
__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __x, __true_type)
|
||||
{
|
||||
fill(__first, __last, __x);
|
||||
}
|
||||
{ fill(__first, __last, __x); }
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
void
|
||||
__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
|
||||
template<typename _ForwardIter, typename _Tp>
|
||||
void
|
||||
__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __x, __false_type)
|
||||
{
|
||||
{
|
||||
_ForwardIter __cur = __first;
|
||||
__STL_TRY {
|
||||
for ( ; __cur != __last; ++__cur)
|
||||
_Construct(&*__cur, __x);
|
||||
}
|
||||
__STL_UNWIND(_Destroy(__first, __cur));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Tp1>
|
||||
inline void __uninitialized_fill(_ForwardIter __first,
|
||||
_ForwardIter __last, const _Tp& __x, _Tp1*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;
|
||||
template<typename _ForwardIter, typename _Tp>
|
||||
inline void
|
||||
uninitialized_fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIter>::value_type _ValueType;
|
||||
typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD;
|
||||
__uninitialized_fill_aux(__first, __last, __x, _Is_POD());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline void uninitialized_fill(_ForwardIter __first,
|
||||
_ForwardIter __last,
|
||||
const _Tp& __x)
|
||||
{
|
||||
__uninitialized_fill(__first, __last, __x, __value_type(__first));
|
||||
}
|
||||
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template <class _ForwardIter, class _Size, class _Tp>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template<typename _ForwardIter, typename _Size, typename _Tp>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
|
||||
const _Tp& __x, __true_type)
|
||||
{
|
||||
{
|
||||
return fill_n(__first, __n, __x);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Size, class _Tp>
|
||||
_ForwardIter
|
||||
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
|
||||
template<typename _ForwardIter, typename _Size, typename _Tp>
|
||||
_ForwardIter
|
||||
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
|
||||
const _Tp& __x, __false_type)
|
||||
{
|
||||
{
|
||||
_ForwardIter __cur = __first;
|
||||
__STL_TRY {
|
||||
for ( ; __n > 0; --__n, ++__cur)
|
||||
@ -232,75 +210,69 @@ __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
|
||||
return __cur;
|
||||
}
|
||||
__STL_UNWIND(_Destroy(__first, __cur));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Size, class _Tp, class _Tp1>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;
|
||||
template<typename _ForwardIter, typename _Size, typename _Tp>
|
||||
inline _ForwardIter
|
||||
uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIter>::value_type _ValueType;
|
||||
typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD;
|
||||
return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD());
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Size, class _Tp>
|
||||
inline _ForwardIter
|
||||
uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x)
|
||||
{
|
||||
return __uninitialized_fill_n(__first, __n, __x, __value_type(__first));
|
||||
}
|
||||
// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill,
|
||||
// __uninitialized_fill_copy.
|
||||
|
||||
// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill,
|
||||
// __uninitialized_fill_copy.
|
||||
// __uninitialized_copy_copy
|
||||
// Copies [first1, last1) into [result, result + (last1 - first1)), and
|
||||
// copies [first2, last2) into
|
||||
// [result, result + (last1 - first1) + (last2 - first2)).
|
||||
|
||||
// __uninitialized_copy_copy
|
||||
// Copies [first1, last1) into [result, result + (last1 - first1)), and
|
||||
// copies [first2, last2) into
|
||||
// [result, result + (last1 - first1) + (last2 - first2)).
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _ForwardIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
|
||||
template<typename _InputIter1, typename _InputIter2, typename _ForwardIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_ForwardIter __result)
|
||||
{
|
||||
{
|
||||
_ForwardIter __mid = uninitialized_copy(__first1, __last1, __result);
|
||||
__STL_TRY {
|
||||
return uninitialized_copy(__first2, __last2, __mid);
|
||||
}
|
||||
__STL_UNWIND(_Destroy(__result, __mid));
|
||||
}
|
||||
}
|
||||
|
||||
// __uninitialized_fill_copy
|
||||
// Fills [result, mid) with x, and copies [first, last) into
|
||||
// [mid, mid + (last - first)).
|
||||
template <class _ForwardIter, class _Tp, class _InputIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid,
|
||||
// __uninitialized_fill_copy
|
||||
// Fills [result, mid) with x, and copies [first, last) into
|
||||
// [mid, mid + (last - first)).
|
||||
template<typename _ForwardIter, typename _Tp, typename _InputIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid,
|
||||
const _Tp& __x,
|
||||
_InputIter __first, _InputIter __last)
|
||||
{
|
||||
{
|
||||
uninitialized_fill(__result, __mid, __x);
|
||||
__STL_TRY {
|
||||
return uninitialized_copy(__first, __last, __mid);
|
||||
}
|
||||
__STL_UNWIND(_Destroy(__result, __mid));
|
||||
}
|
||||
}
|
||||
|
||||
// __uninitialized_copy_fill
|
||||
// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and
|
||||
// fills [first2 + (last1 - first1), last2) with x.
|
||||
template <class _InputIter, class _ForwardIter, class _Tp>
|
||||
inline void
|
||||
__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
|
||||
// __uninitialized_copy_fill
|
||||
// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and
|
||||
// fills [first2 + (last1 - first1), last2) with x.
|
||||
template<typename _InputIter, typename _ForwardIter, typename _Tp>
|
||||
inline void
|
||||
__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2,
|
||||
const _Tp& __x)
|
||||
{
|
||||
{
|
||||
_ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2);
|
||||
__STL_TRY {
|
||||
uninitialized_fill(__mid2, __last2, __x);
|
||||
}
|
||||
__STL_UNWIND(_Destroy(__first2, __mid2));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
@ -124,7 +124,7 @@ toplevel_srcdir = @toplevel_srcdir@
|
||||
AUTOMAKE_OPTIONS = 1.3 cygnus
|
||||
|
||||
mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
|
||||
@GLIBCPP_BUILD_LIBIO_TRUE@noinst_LTLIBRARIES = @GLIBCPP_BUILD_LIBIO_TRUE@libio.la
|
||||
@GLIBCPP_BUILD_LIBIO_TRUE@noinst_LTLIBRARIES = libio.la
|
||||
@GLIBCPP_BUILD_LIBIO_FALSE@noinst_LTLIBRARIES =
|
||||
|
||||
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
|
||||
@ -132,20 +132,14 @@ GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
|
||||
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
|
||||
LIBIO_INCLUDES = @LIBIO_INCLUDES@
|
||||
|
||||
INCLUDES = \
|
||||
-nostdinc++ \
|
||||
$(GLIBCPP_INCLUDES) $(LIBIO_INCLUDES) $(TOPLEVEL_INCLUDES)
|
||||
INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBIO_INCLUDES) $(TOPLEVEL_INCLUDES)
|
||||
|
||||
|
||||
libio_headers = \
|
||||
libio.h libioP.h iolibio.h
|
||||
libio_headers = libio.h libioP.h iolibio.h
|
||||
|
||||
@GLIBCPP_NEED_LIBIO_TRUE@LIBIO_SRCS = @GLIBCPP_NEED_LIBIO_TRUE@\
|
||||
@GLIBCPP_NEED_LIBIO_TRUE@ filedoalloc.c genops.c fileops.c stdfiles.c c_codecvt.c \
|
||||
@GLIBCPP_NEED_LIBIO_TRUE@ iofclose.c iofopen.c
|
||||
@GLIBCPP_NEED_LIBIO_TRUE@LIBIO_SRCS = filedoalloc.c genops.c fileops.c stdfiles.c c_codecvt.c iofclose.c iofopen.c
|
||||
@GLIBCPP_NEED_LIBIO_FALSE@LIBIO_SRCS =
|
||||
@GLIBCPP_NEED_WLIBIO_TRUE@LIBIO_WSRCS = @GLIBCPP_NEED_WLIBIO_TRUE@\
|
||||
@GLIBCPP_NEED_WLIBIO_TRUE@ wfiledoalloc.c wfileops.c wgenops.c iofwide.c
|
||||
@GLIBCPP_NEED_WLIBIO_TRUE@LIBIO_WSRCS = wfiledoalloc.c wfileops.c wgenops.c iofwide.c
|
||||
@GLIBCPP_NEED_WLIBIO_FALSE@LIBIO_WSRCS =
|
||||
|
||||
EXTRA_DIST = iostreamP.h
|
||||
|
@ -129,18 +129,13 @@ mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
|
||||
|
||||
noinst_LTLIBRARIES = libmath.la
|
||||
|
||||
EXTRA_LONG_DOUBLE_yes = \
|
||||
hypotl.c signbitl.c
|
||||
EXTRA_LONG_DOUBLE_yes = hypotl.c signbitl.c
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
hypot.c hypotf.c \
|
||||
$(EXTRA_LONG_DOUBLE_yes)
|
||||
EXTRA_DIST = hypot.c hypotf.c $(EXTRA_LONG_DOUBLE_yes)
|
||||
|
||||
|
||||
libmath_la_LIBADD = \
|
||||
@LIBMATHOBJS@ \
|
||||
$(EXTRA_LONG_DOUBLE_$(USE_COMPLEX_LONG_DOUBLE))
|
||||
libmath_la_LIBADD = @LIBMATHOBJS@ $(EXTRA_LONG_DOUBLE_$(USE_COMPLEX_LONG_DOUBLE))
|
||||
|
||||
|
||||
libmath_la_DEPENDENCIES = $(libmath_la_LIBADD)
|
||||
@ -152,8 +147,7 @@ LINK = $(LIBTOOL) --mode=link "$(CCLD)" $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
|
||||
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
|
||||
|
||||
INCLUDES = \
|
||||
$(TOPLEVEL_INCLUDES)
|
||||
INCLUDES = $(TOPLEVEL_INCLUDES)
|
||||
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
|
@ -144,50 +144,24 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@
|
||||
# These bits are all figured out from configure. Look in acinclude.m4
|
||||
# or configure.in to see how they are set. See GLIBCPP_EXPORT_FLAGS
|
||||
# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
|
||||
CONFIG_CXXFLAGS = \
|
||||
@EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
|
||||
CONFIG_CXXFLAGS = @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
|
||||
|
||||
|
||||
# Warning flags to use.
|
||||
WARN_CXXFLAGS = \
|
||||
@WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
|
||||
WARN_CXXFLAGS = @WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
|
||||
|
||||
|
||||
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
|
||||
GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
|
||||
LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
|
||||
|
||||
INCLUDES = \
|
||||
-I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include \
|
||||
$(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES)
|
||||
INCLUDES = -I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include $(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES)
|
||||
|
||||
|
||||
headers = \
|
||||
exception new typeinfo cxxabi.h exception_defines.h
|
||||
headers = exception new typeinfo cxxabi.h exception_defines.h
|
||||
|
||||
|
||||
sources = \
|
||||
del_op.cc \
|
||||
del_opnt.cc \
|
||||
del_opv.cc \
|
||||
del_opvnt.cc \
|
||||
eh_alloc.cc \
|
||||
eh_aux_runtime.cc \
|
||||
eh_catch.cc \
|
||||
eh_exception.cc \
|
||||
eh_globals.cc \
|
||||
eh_personality.cc \
|
||||
eh_terminate.cc \
|
||||
eh_throw.cc \
|
||||
new_handler.cc \
|
||||
new_op.cc \
|
||||
new_opnt.cc \
|
||||
new_opv.cc \
|
||||
new_opvnt.cc \
|
||||
pure.cc \
|
||||
tinfo.cc \
|
||||
tinfo2.cc \
|
||||
vec.cc
|
||||
sources = del_op.cc del_opnt.cc del_opv.cc del_opvnt.cc eh_alloc.cc eh_aux_runtime.cc eh_catch.cc eh_exception.cc eh_globals.cc eh_personality.cc eh_terminate.cc eh_throw.cc new_handler.cc new_op.cc new_opnt.cc new_opv.cc new_opvnt.cc pure.cc tinfo.cc tinfo2.cc vec.cc
|
||||
|
||||
|
||||
libsupc___la_SOURCES = $(sources)
|
||||
@ -203,12 +177,7 @@ LIBSUPCXX_CXXFLAGS = $(LIBSUPCXX_PICFLAGS)
|
||||
# set this option because CONFIG_CXXFLAGS has to be after
|
||||
# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
|
||||
# as the occasion call for it. (ie, --enable-debug)
|
||||
AM_CXXFLAGS = \
|
||||
-fno-implicit-templates \
|
||||
$(LIBSUPCXX_CXXFLAGS) \
|
||||
$(WARN_CXXFLAGS) \
|
||||
$(OPTIMIZE_CXXFLAGS) \
|
||||
$(CONFIG_CXXFLAGS)
|
||||
AM_CXXFLAGS = -fno-implicit-templates $(LIBSUPCXX_CXXFLAGS) $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
|
||||
|
||||
|
||||
# libstdc++ libtool notes
|
||||
@ -232,9 +201,7 @@ AM_CXXFLAGS = \
|
||||
#
|
||||
# We have to put --tag disable-shared after --tag CXX lest things
|
||||
# CXX undo the affect of disable-shared.
|
||||
LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared \
|
||||
--mode=compile $(CXX) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared --mode=compile $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
|
||||
|
||||
|
||||
# 3) We'd have a problem when building the shared libstdc++ object if
|
||||
@ -243,9 +210,7 @@ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared \
|
||||
# course is problematic at this point. So, we get the top-level
|
||||
# directory to configure libstdc++-v3 to use gcc as the C++
|
||||
# compilation driver.
|
||||
CXXLINK = $(LIBTOOL) --tag CXX --tag disable-shared \
|
||||
--mode=link $(CXX) \
|
||||
@OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
|
||||
CXXLINK = $(LIBTOOL) --tag CXX --tag disable-shared --mode=link $(CXX) @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
|
@ -134,13 +134,11 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@
|
||||
# These bits are all figured out from configure. Look in acinclude.m4
|
||||
# or configure.in to see how they are set. See GLIBCPP_EXPORT_FLAGS
|
||||
# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
|
||||
CONFIG_CXXFLAGS = \
|
||||
@EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
|
||||
CONFIG_CXXFLAGS = @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
|
||||
|
||||
|
||||
# Warning flags to use.
|
||||
WARN_CXXFLAGS = \
|
||||
@WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
|
||||
WARN_CXXFLAGS = @WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
|
||||
|
||||
|
||||
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
|
||||
@ -150,28 +148,17 @@ LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
|
||||
LIBIO_INCLUDES = @LIBIO_INCLUDES@
|
||||
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
|
||||
|
||||
INCLUDES = \
|
||||
-nostdinc++ \
|
||||
$(GLIBCPP_INCLUDES) \
|
||||
$(LIBSUPCXX_INCLUDES) $(LIBIO_INCLUDES) $(LIBMATH_INCLUDES) \
|
||||
$(TOPLEVEL_INCLUDES)
|
||||
INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES) $(LIBIO_INCLUDES) $(LIBMATH_INCLUDES) $(TOPLEVEL_INCLUDES)
|
||||
|
||||
|
||||
sources = \
|
||||
basic_file.cc bitset.cc c++locale.cc cmath.cc codecvt.cc \
|
||||
complex_io.cc functexcept.cc globals.cc ios.cc limitsMEMBERS.cc \
|
||||
locale.cc locale-inst.cc localename.cc misc-inst.cc stdexcept.cc \
|
||||
stl-inst.cc string-inst.cc strstream.cc valarray-inst.cc \
|
||||
wstring-inst.cc
|
||||
sources = basic_file.cc bitset.cc c++locale.cc cmath.cc codecvt.cc complex_io.cc functexcept.cc globals.cc ios.cc limitsMEMBERS.cc locale.cc locale-inst.cc localename.cc misc-inst.cc stdexcept.cc stl-inst.cc string-inst.cc strstream.cc valarray-inst.cc wstring-inst.cc
|
||||
|
||||
|
||||
VPATH = $(top_srcdir):$(top_srcdir)/src
|
||||
|
||||
libstdc___la_SOURCES = $(sources)
|
||||
|
||||
libstdc___la_LIBADD = \
|
||||
../libmath/libmath.la @libio_la@ \
|
||||
../libsupc++/libsupc++convenience.la
|
||||
libstdc___la_LIBADD = ../libmath/libmath.la @libio_la@ ../libsupc++/libsupc++convenience.la
|
||||
|
||||
|
||||
libstdc___la_LDFLAGS = -version-info 3:0:0 -lm
|
||||
@ -191,12 +178,7 @@ GLIBCPP_INCLUDE_DIR = @glibcpp_builddir@/include
|
||||
# The no-implicit-templates flag will generate unresolved references to
|
||||
# the concept-checking symbols. So we must disable the checks while
|
||||
# actually building the library.
|
||||
AM_CXXFLAGS = \
|
||||
-fno-implicit-templates \
|
||||
$(LIBSUPCXX_CXXFLAGS) \
|
||||
$(WARN_CXXFLAGS) \
|
||||
$(OPTIMIZE_CXXFLAGS) \
|
||||
$(CONFIG_CXXFLAGS)
|
||||
AM_CXXFLAGS = -fno-implicit-templates $(LIBSUPCXX_CXXFLAGS) $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
|
||||
|
||||
|
||||
# libstdc++ libtool notes
|
||||
@ -217,8 +199,7 @@ AM_CXXFLAGS = \
|
||||
# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
|
||||
# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
|
||||
# attempt to infer which configuration to use
|
||||
LTCXXCOMPILE = $(LIBTOOL) --tag CXX --mode=compile $(CXX) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) --tag CXX --mode=compile $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
|
||||
|
||||
|
||||
# 3) We'd have a problem when building the shared libstdc++ object if
|
||||
@ -227,8 +208,7 @@ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --mode=compile $(CXX) $(INCLUDES) \
|
||||
# course is problematic at this point. So, we get the top-level
|
||||
# directory to configure libstdc++-v3 to use gcc as the C++
|
||||
# compilation driver.
|
||||
CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) \
|
||||
@OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
|
||||
CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 1999-06-29
|
||||
// bkoz
|
||||
// 1999-06-29 bkoz
|
||||
|
||||
// Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
||||
// Copyright (C) 1999-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
|
||||
@ -57,10 +56,36 @@ void test02()
|
||||
std::vector<int> v2 (v1);
|
||||
}
|
||||
|
||||
// test range constructors and range-fill constructor
|
||||
void
|
||||
test03()
|
||||
{
|
||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
const int B[] = {7, 7, 7, 7, 7};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
const int M = sizeof(B) / sizeof(int);
|
||||
bool test = true;
|
||||
|
||||
std::vector<int> v3(A, A + N);
|
||||
VERIFY(std::equal(v3.begin(), v3.end(), A));
|
||||
|
||||
std::vector<int> v4(v3.begin(), v3.end());
|
||||
VERIFY(std::equal(v4.begin(), v4.end(), A));
|
||||
|
||||
std::vector<int> v5(M, 7);
|
||||
VERIFY(std::equal(v5.begin(), v5.end(), B));
|
||||
VERIFY(std::equal(B, B + M, v5.begin()));
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
assert(test);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 1999-11-09 bkoz
|
||||
|
||||
// Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
// Copyright (C) 1999, 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
|
||||
@ -21,7 +21,9 @@
|
||||
// 23.2.4.3 vector modifiers
|
||||
|
||||
#include <vector>
|
||||
#include <debug_assert.h>
|
||||
#include "debug_assert.h"
|
||||
|
||||
bool test = true;
|
||||
|
||||
template<typename T>
|
||||
struct A { };
|
||||
@ -29,10 +31,9 @@ template<typename T>
|
||||
struct B { };
|
||||
|
||||
// vector::insert(iterator, inputiterator first, inputiterator last)
|
||||
bool test01()
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
// POD types
|
||||
typedef std::vector<int> vec_POD;
|
||||
vec_POD vec01;
|
||||
@ -46,20 +47,42 @@ bool test01()
|
||||
A<B> np01;
|
||||
A<B>* pnp01 = &np01;
|
||||
vec02.insert(vec02.begin(), pnp01, pnp01 + 1);
|
||||
}
|
||||
|
||||
// Test that assign compiles.
|
||||
vec01.assign (pi01, pi01 + 1);
|
||||
// test the assign() function
|
||||
void
|
||||
test03()
|
||||
{
|
||||
const int K = 417;
|
||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
const int B[] = {K, K, K, K, K};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
const int M = sizeof(B) / sizeof(int);
|
||||
bool test = true;
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
assert(test);
|
||||
#endif
|
||||
// assign from pointer range
|
||||
std::vector<int> v3;
|
||||
v3.assign(A, A + N);
|
||||
VERIFY(std::equal(v3.begin(), v3.end(), A));
|
||||
VERIFY(v3.size() == N);
|
||||
|
||||
return test;
|
||||
// assign from iterator range
|
||||
std::vector<int> v4;
|
||||
v4.assign(v3.begin(), v3.end());
|
||||
VERIFY(std::equal(v4.begin(), v4.end(), A));
|
||||
VERIFY(std::equal(A, A + N, v4.begin()));
|
||||
|
||||
// assign from initializer range with resize
|
||||
v4.assign(M, K);
|
||||
VERIFY(std::equal(v4.begin(), v4.end(), B));
|
||||
VERIFY(std::equal(B, B + M, v4.begin()));
|
||||
VERIFY((v4.size() == M) && (M != N));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test03();
|
||||
|
||||
return 0;
|
||||
return !test;
|
||||
}
|
||||
|
183
libstdc++-v3/testsuite/25_algorithms/binary_search.cc
Normal file
183
libstdc++-v3/testsuite/25_algorithms/binary_search.cc
Normal file
@ -0,0 +1,183 @@
|
||||
// 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.
|
||||
|
||||
// 25.3.3 [lib.alg.binary.search] Binary search algorithms.
|
||||
|
||||
#include <algorithm>
|
||||
#include <debug_assert.h>
|
||||
|
||||
bool test = true;
|
||||
|
||||
const int A[] = {1, 2, 3, 3, 3, 5, 8};
|
||||
const int C[] = {8, 5, 3, 3, 3, 2, 1};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
|
||||
// A comparison, equalivalent to std::greater<int> without the
|
||||
// dependency on <functional>.
|
||||
|
||||
struct gt
|
||||
{
|
||||
bool
|
||||
operator()(const int& x, const int& y) const
|
||||
{ return x > y; }
|
||||
};
|
||||
|
||||
// Each test performs general-case, bookend, not-found condition,
|
||||
// and predicate functional checks.
|
||||
|
||||
// 25.3.3.1 lower_bound, with and without comparison predicate
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using std::lower_bound;
|
||||
|
||||
const int first = A[0];
|
||||
const int last = A[N - 1];
|
||||
|
||||
const int* p = lower_bound(A, A + N, 3);
|
||||
VERIFY(p == A + 2);
|
||||
|
||||
const int* q = lower_bound(A, A + N, first);
|
||||
VERIFY(q == A + 0);
|
||||
|
||||
const int* r = lower_bound(A, A + N, last);
|
||||
VERIFY(r == A + N - 1);
|
||||
|
||||
const int* s = lower_bound(A, A + N, 4);
|
||||
VERIFY(s == A + 5);
|
||||
|
||||
const int* t = lower_bound(C, C + N, 3, gt());
|
||||
VERIFY(t == C + 2);
|
||||
|
||||
const int* u = lower_bound(C, C + N, first, gt());
|
||||
VERIFY(u == C + N - 1);
|
||||
|
||||
const int* v = lower_bound(C, C + N, last, gt());
|
||||
VERIFY(v == C + 0);
|
||||
|
||||
const int* w = lower_bound(C, C + N, 4, gt());
|
||||
VERIFY(w == C + 2);
|
||||
}
|
||||
|
||||
// 25.3.3.2 upper_bound, with and without comparison predicate
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using std::upper_bound;
|
||||
|
||||
const int first = A[0];
|
||||
const int last = A[N - 1];
|
||||
|
||||
const int* p = upper_bound(A, A + N, 3);
|
||||
VERIFY(p == A + 5);
|
||||
|
||||
const int* q = upper_bound(A, A + N, first);
|
||||
VERIFY(q == A + 1);
|
||||
|
||||
const int* r = upper_bound(A, A + N, last);
|
||||
VERIFY(r == A + N);
|
||||
|
||||
const int* s = upper_bound(A, A + N, 4);
|
||||
VERIFY(s == A + 5);
|
||||
|
||||
const int* t = upper_bound(C, C + N, 3, gt());
|
||||
VERIFY(t == C + 5);
|
||||
|
||||
const int* u = upper_bound(C, C + N, first, gt());
|
||||
VERIFY(u == C + N);
|
||||
|
||||
const int* v = upper_bound(C, C + N, last, gt());
|
||||
VERIFY(v == C + 1);
|
||||
|
||||
const int* w = upper_bound(C, C + N, 4, gt());
|
||||
VERIFY(w == C + 2);
|
||||
}
|
||||
|
||||
// 25.3.3.3 equal_range, with and without comparison predicate
|
||||
void
|
||||
test03()
|
||||
{
|
||||
using std::equal_range;
|
||||
typedef std::pair<const int*, const int*> Ipair;
|
||||
|
||||
const int first = A[0];
|
||||
const int last = A[N - 1];
|
||||
|
||||
Ipair p = equal_range(A, A + N, 3);
|
||||
VERIFY(p.first == A + 2);
|
||||
VERIFY(p.second == A + 5);
|
||||
|
||||
Ipair q = equal_range(A, A + N, first);
|
||||
VERIFY(q.first == A + 0);
|
||||
VERIFY(q.second == A + 1);
|
||||
|
||||
Ipair r = equal_range(A, A + N, last);
|
||||
VERIFY(r.first == A + N - 1);
|
||||
VERIFY(r.second == A + N);
|
||||
|
||||
Ipair s = equal_range(A, A + N, 4);
|
||||
VERIFY(s.first == A + 5);
|
||||
VERIFY(s.second == A + 5);
|
||||
|
||||
Ipair t = equal_range(C, C + N, 3, gt());
|
||||
VERIFY(t.first == C + 2);
|
||||
VERIFY(t.second == C + 5);
|
||||
|
||||
Ipair u = equal_range(C, C + N, first, gt());
|
||||
VERIFY(u.first == C + N - 1);
|
||||
VERIFY(u.second == C + N);
|
||||
|
||||
Ipair v = equal_range(C, C + N, last, gt());
|
||||
VERIFY(v.first == C + 0);
|
||||
VERIFY(v.second == C + 1);
|
||||
|
||||
Ipair w = equal_range(C, C + N, 4, gt());
|
||||
VERIFY(w.first == C + 2);
|
||||
VERIFY(w.second == C + 2);
|
||||
}
|
||||
|
||||
// 25.3.3.4 binary_search, with and without comparison predicate
|
||||
void
|
||||
test04()
|
||||
{
|
||||
using std::binary_search;
|
||||
|
||||
const int first = A[0];
|
||||
const int last = A[N - 1];
|
||||
|
||||
VERIFY(binary_search(A, A + N, 5));
|
||||
VERIFY(binary_search(A, A + N, first));
|
||||
VERIFY(binary_search(A, A + N, last));
|
||||
VERIFY(!binary_search(A, A + N, 4));
|
||||
|
||||
VERIFY(binary_search(C, C + N, 5, gt()));
|
||||
VERIFY(binary_search(C, C + N, first, gt()));
|
||||
VERIFY(binary_search(C, C + N, last, gt()));
|
||||
VERIFY(!binary_search(C, C + N, 4, gt()));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
test04();
|
||||
|
||||
return !test;
|
||||
}
|
58
libstdc++-v3/testsuite/25_algorithms/copy.cc
Normal file
58
libstdc++-v3/testsuite/25_algorithms/copy.cc
Normal file
@ -0,0 +1,58 @@
|
||||
// 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 Pred 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.
|
||||
|
||||
// 25.2.12 [lib.alg.partitions] Partitions.
|
||||
|
||||
#include <algorithm>
|
||||
#include <debug_assert.h>
|
||||
|
||||
bool test = true;
|
||||
|
||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
|
||||
// copy
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using std::copy;
|
||||
|
||||
int s1[N];
|
||||
copy(A, A + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, A));
|
||||
}
|
||||
|
||||
// copy_backward
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using std::copy_backward;
|
||||
|
||||
int s1[N];
|
||||
copy_backward(A, A + N, s1 + N);
|
||||
VERIFY(std::equal(s1, s1 + N, A));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return !test;
|
||||
}
|
132
libstdc++-v3/testsuite/25_algorithms/heap.cc
Normal file
132
libstdc++-v3/testsuite/25_algorithms/heap.cc
Normal file
@ -0,0 +1,132 @@
|
||||
// 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 Pred 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.
|
||||
|
||||
// 25.3.6 Heap operations [lib.alg.heap.operations]
|
||||
|
||||
#include <algorithm>
|
||||
//#include <cmath>
|
||||
#include <debug_assert.h>
|
||||
|
||||
bool test = true;
|
||||
|
||||
const int A[] = {1, 11, 12, 3, 10, 6, 17, 4, 8, 2, 5, 13, 9, 15, 14, 16, 7};
|
||||
const int B[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
const int C[] = {17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
|
||||
// This functor has the equivalent functionality of std::geater<>,
|
||||
// but there is no dependency on <functional> and it also tracks the
|
||||
// number of invocations since creation.
|
||||
class Gt
|
||||
{
|
||||
public:
|
||||
static int count() { return itsCount; }
|
||||
static void reset() { itsCount = 0; }
|
||||
|
||||
bool
|
||||
operator()(const int& x, const int& y)
|
||||
{
|
||||
++itsCount;
|
||||
return x > y;
|
||||
}
|
||||
|
||||
private:
|
||||
static int itsCount;
|
||||
};
|
||||
|
||||
int Gt::itsCount = 0;
|
||||
|
||||
// Exercise all of the heap functions for operator<. The
|
||||
// intermediate results between push_heap and pop_heap and
|
||||
// make_heap and sort_heap are not checked (they could be).
|
||||
void
|
||||
test01()
|
||||
{
|
||||
// sort array s1 using push_heap/pop_heap
|
||||
int s1[N];
|
||||
std::copy(A, A + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, A));
|
||||
|
||||
for (int i = 2; i <= N; ++i) {
|
||||
std::push_heap(s1, s1 + i);
|
||||
}
|
||||
for (int i = N; i >= 2; --i) {
|
||||
std::pop_heap(s1, s1 + i);
|
||||
}
|
||||
VERIFY(std::equal(s1, s1 + N, B));
|
||||
|
||||
// sort array s2 using make_heap/sort_heap
|
||||
int s2[N];
|
||||
std::copy(A, A + N, s2);
|
||||
VERIFY(std::equal(s2, s2 + N, A));
|
||||
|
||||
std::make_heap(s2, s2 + N);
|
||||
std::sort_heap(s2, s2 + N);
|
||||
VERIFY(std::equal(s2, s2 + N, B));
|
||||
}
|
||||
|
||||
// Perform same tests as above but with the comparison predicate
|
||||
// versions, and add complexity constraint checks.
|
||||
void
|
||||
test02()
|
||||
{
|
||||
Gt gt;
|
||||
// const int logN = static_cast<int>(std::log(static_cast<double>(N)) + 0.5);
|
||||
const int logN = 3;
|
||||
|
||||
int s1[N];
|
||||
std::copy(A, A + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, A));
|
||||
|
||||
for (int i = 2; i <= N; ++i) {
|
||||
std::push_heap(s1, s1 + i, gt);
|
||||
VERIFY(gt.count() <= logN);
|
||||
gt.reset();
|
||||
}
|
||||
|
||||
for (int i = N; i >= 2; --i) {
|
||||
std::pop_heap(s1, s1 + i, gt);
|
||||
VERIFY(gt.count() <= 2 * logN);
|
||||
gt.reset();
|
||||
}
|
||||
|
||||
VERIFY(std::equal(s1, s1 + N, C));
|
||||
|
||||
// sort array s2 using make_heap/sort_heap
|
||||
int s2[N];
|
||||
std::copy(A, A + N, s2);
|
||||
VERIFY(std::equal(s2, s2 + N, A));
|
||||
|
||||
std::make_heap(s2, s2 + N, gt);
|
||||
VERIFY(gt.count() <= 3 * N);
|
||||
gt.reset();
|
||||
|
||||
std::sort_heap(s2, s2 + N, gt);
|
||||
VERIFY(gt.count() <= N * logN);
|
||||
|
||||
VERIFY(std::equal(s2, s2 + N, C));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return !test;
|
||||
}
|
73
libstdc++-v3/testsuite/25_algorithms/partition.cc
Normal file
73
libstdc++-v3/testsuite/25_algorithms/partition.cc
Normal file
@ -0,0 +1,73 @@
|
||||
// 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 Pred 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.
|
||||
|
||||
// 25.2.12 [lib.alg.partitions] Partitions.
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <debug_assert.h>
|
||||
|
||||
bool test = true;
|
||||
|
||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
|
||||
struct Pred
|
||||
{
|
||||
bool
|
||||
operator()(const int& x) const
|
||||
{ return (x % 2) == 0; }
|
||||
};
|
||||
|
||||
// 25.2.12 partition()
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using std::partition;
|
||||
|
||||
int s1[N];
|
||||
std::copy(A, A + N, s1);
|
||||
|
||||
Pred pred;
|
||||
int* m = partition(s1, s1 + N, pred);
|
||||
for (const int* i = s1; i < m; ++i) VERIFY(pred(*i));
|
||||
for (const int* i = m; i < s1 + N; ++i) VERIFY(!pred(*i));
|
||||
}
|
||||
|
||||
// 25.2.12 stable_partition()
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using std::stable_partition;
|
||||
|
||||
int s1[N];
|
||||
std::copy(A, A + N, s1);
|
||||
|
||||
stable_partition(s1, s1 + N, Pred());
|
||||
VERIFY(std::equal(s1, s1 + N, B));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return !test;
|
||||
}
|
80
libstdc++-v3/testsuite/25_algorithms/rotate.cc
Normal file
80
libstdc++-v3/testsuite/25_algorithms/rotate.cc
Normal file
@ -0,0 +1,80 @@
|
||||
// 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.
|
||||
|
||||
// 25.?? algorithms, rotate()
|
||||
|
||||
#include <algorithm>
|
||||
#include <debug_assert.h>
|
||||
#include <list>
|
||||
|
||||
bool test = true;
|
||||
|
||||
int A[] = {1, 2, 3, 4, 5, 6, 7};
|
||||
int B[] = {2, 3, 4, 5, 6, 7, 1};
|
||||
int C[] = {1, 2, 3, 4, 5, 6, 7};
|
||||
int D[] = {5, 6, 7, 1, 2, 3, 4};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
|
||||
/* need a test for a forward iterator -- can't think of one that makes sense */
|
||||
|
||||
/* biderectional iterator */
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using std::rotate;
|
||||
typedef std::list<int> Container;
|
||||
|
||||
Container a(A, A + N);
|
||||
VERIFY(std::equal(a.begin(), a.end(), A));
|
||||
|
||||
Container::iterator i = a.begin();
|
||||
rotate(a.begin(), ++i, a.end());
|
||||
VERIFY(std::equal(a.begin(), a.end(), B));
|
||||
|
||||
i = a.end();
|
||||
rotate(a.begin(), --i, a.end());
|
||||
VERIFY(std::equal(a.begin(), a.end(), C));
|
||||
|
||||
i = a.begin();
|
||||
std::advance(i, 3);
|
||||
rotate(a.begin(), ++i, a.end());
|
||||
VERIFY(std::equal(a.begin(), a.end(), D));
|
||||
}
|
||||
|
||||
/* random iterator */
|
||||
void
|
||||
test03()
|
||||
{
|
||||
using std::rotate;
|
||||
rotate(A, A + 1, A + N);
|
||||
VERIFY(std::equal(A, A + N, B));
|
||||
|
||||
rotate(A, A + N - 1, A + N);
|
||||
VERIFY(std::equal(A, A + N, C));
|
||||
|
||||
rotate(A, A + 4, A + N);
|
||||
VERIFY(std::equal(A, A + N, D));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
test02();
|
||||
test03();
|
||||
return !test;
|
||||
}
|
171
libstdc++-v3/testsuite/25_algorithms/sort.cc
Normal file
171
libstdc++-v3/testsuite/25_algorithms/sort.cc
Normal file
@ -0,0 +1,171 @@
|
||||
// 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.
|
||||
|
||||
// 25.3.1 algorithms, sort()
|
||||
|
||||
#include <algorithm>
|
||||
#include <debug_assert.h>
|
||||
|
||||
bool test = true;
|
||||
|
||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
|
||||
const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19};
|
||||
const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
const int logN = 3; // ln(N) rounded up
|
||||
const int P = 7;
|
||||
|
||||
// comparison predicate for stable_sort: order by rightmost digit
|
||||
struct CompLast
|
||||
{
|
||||
bool
|
||||
operator()(const int x, const int y)
|
||||
{ return x % 10 < y % 10; }
|
||||
};
|
||||
|
||||
// This functor has the equivalent functionality of std::geater<>,
|
||||
// but there is no dependency on <functional> and it also tracks the
|
||||
// number of invocations since creation.
|
||||
class Gt
|
||||
{
|
||||
public:
|
||||
static int count() { return itsCount; }
|
||||
static void reset() { itsCount = 0; }
|
||||
|
||||
bool
|
||||
operator()(const int& x, const int& y)
|
||||
{
|
||||
++itsCount;
|
||||
return x > y;
|
||||
}
|
||||
|
||||
private:
|
||||
static int itsCount;
|
||||
};
|
||||
|
||||
int Gt::itsCount = 0;
|
||||
|
||||
|
||||
// 25.3.1.1 sort()
|
||||
void
|
||||
test01()
|
||||
{
|
||||
int s1[N];
|
||||
std::copy(B, B + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, B));
|
||||
|
||||
std::sort(s1, s1 + N);
|
||||
VERIFY(std::equal(s1, s1 + N, A));
|
||||
|
||||
Gt gt;
|
||||
gt.reset();
|
||||
std::sort(s1, s1 + N, gt);
|
||||
VERIFY(std::equal(s1, s1 + N, C));
|
||||
}
|
||||
|
||||
// 25.3.1.2 stable_sort()
|
||||
void
|
||||
test02()
|
||||
{
|
||||
int s1[N];
|
||||
std::copy(A, A + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, A));
|
||||
|
||||
std::stable_sort(s1, s1 + N, CompLast());
|
||||
VERIFY(std::equal(s1, s1 + N, B));
|
||||
|
||||
std::stable_sort(s1, s1 + N);
|
||||
VERIFY(std::equal(s1, s1 + N, A));
|
||||
|
||||
Gt gt;
|
||||
gt.reset();
|
||||
std::stable_sort(s1, s1 + N, gt);
|
||||
VERIFY(std::equal(s1, s1 + N, C));
|
||||
VERIFY(gt.count() <= N * logN * logN);
|
||||
}
|
||||
|
||||
// 25.3.1.3 partial_sort()
|
||||
void
|
||||
test03()
|
||||
{
|
||||
int s1[N];
|
||||
std::copy(B, B + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, B));
|
||||
|
||||
std::partial_sort(s1, s1 + P, s1 + N);
|
||||
VERIFY(std::equal(s1, s1 + P, A));
|
||||
|
||||
Gt gt;
|
||||
gt.reset();
|
||||
std::partial_sort(s1, s1 + P, s1 + N, gt);
|
||||
VERIFY(std::equal(s1, s1 + P, C));
|
||||
}
|
||||
|
||||
// 25.3.1.4 partial_sort_copy()
|
||||
void
|
||||
test04()
|
||||
{
|
||||
using std::partial_sort_copy;
|
||||
|
||||
int s1[N];
|
||||
std::copy(B, B + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, B));
|
||||
|
||||
int s2[2*N];
|
||||
|
||||
partial_sort_copy(s1, s1 + N, s2, s2 + P);
|
||||
VERIFY(std::equal(s2, s2 + P, A));
|
||||
|
||||
Gt gt;
|
||||
gt.reset();
|
||||
partial_sort_copy(s1, s1 + N, s2, s2 + P, gt);
|
||||
VERIFY(std::equal(s2, s2 + P, C));
|
||||
|
||||
VERIFY(std::equal(s2, partial_sort_copy(s1, s1 + N, s2, s2 + 2*N), A));
|
||||
}
|
||||
|
||||
// 25.3.2 nth_element()
|
||||
void
|
||||
test05()
|
||||
{
|
||||
using std::nth_element;
|
||||
|
||||
int s1[N];
|
||||
std::copy(B, B + N, s1);
|
||||
VERIFY(std::equal(s1, s1 + N, B));
|
||||
|
||||
int* pn = s1 + (N / 2) - 1;
|
||||
nth_element(s1, pn, s1 + N);
|
||||
for (const int* i = pn; i < s1 + N; ++i) VERIFY(!(*i < *pn));
|
||||
|
||||
CompLast pred;
|
||||
nth_element(s1, pn, s1 + N, pred);
|
||||
for (const int* i = pn; i < s1 + N; ++i) VERIFY(!pred(*i, *pn));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
test04();
|
||||
test05();
|
||||
|
||||
return !test;
|
||||
}
|
47
libstdc++-v3/testsuite/26_numerics/sum_diff.cc
Normal file
47
libstdc++-v3/testsuite/26_numerics/sum_diff.cc
Normal file
@ -0,0 +1,47 @@
|
||||
// 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.
|
||||
|
||||
// 26.4.3 [lib.partial.sum]
|
||||
// 26.4.4 [lib.adjacent.difference]
|
||||
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
|
||||
int A[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100};
|
||||
int B[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
|
||||
const int N = sizeof(A) / sizeof(int);
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
int D[N];
|
||||
|
||||
std::adjacent_difference(A, A + N, D);
|
||||
assert(std::equal(D, D + N, B));
|
||||
|
||||
std::partial_sum(D, D + N, D);
|
||||
assert(std::equal(D, D + N, A));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -128,14 +128,10 @@ AUTOMAKE_OPTIONS = foreign dejagnu
|
||||
|
||||
DEJATOOL = libstdc++-v3
|
||||
|
||||
EXPECT = `if [ -f @glibcpp_builddir@/../../expect/expect ] ; then \
|
||||
echo @glibcpp_builddir@/../../expect/expect ; \
|
||||
else echo expect ; fi`
|
||||
EXPECT = `if [ -f @glibcpp_builddir@/../../expect/expect ] ; then echo @glibcpp_builddir@/../../expect/expect ; else echo expect ; fi`
|
||||
|
||||
|
||||
RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then \
|
||||
echo @glibcpp_srcdir@/../dejagnu/runtest ; \
|
||||
else echo runtest; fi`
|
||||
RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then echo @glibcpp_srcdir@/../dejagnu/runtest ; else echo runtest; fi`
|
||||
|
||||
|
||||
RUNTESTFLAGS =
|
||||
|
Loading…
Reference in New Issue
Block a user