Commit 02d92e3b by Stephen M. Webb Committed by Benjamin Kosnik

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
parent 860a1536
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/README: Add notes on naming test cases.
* testsuite/22_locale/members.cc: Mark as xfail. * testsuite/22_locale/members.cc: Mark as xfail.
......
...@@ -145,44 +145,7 @@ MULTICLEAN = true ...@@ -145,44 +145,7 @@ MULTICLEAN = true
# Work around what appears to be a GNU make bug handling MAKEFLAGS # 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 # values defined in terms of make variables, as is the case for CC and
# friends when we are called from the top level Makefile. # friends when we are called from the top level Makefile.
AM_MAKEFLAGS = \ 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)"
"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 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
CONFIG_HEADER = config.h CONFIG_HEADER = config.h
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -131,254 +131,43 @@ glibcpp_builddir = @glibcpp_builddir@ ...@@ -131,254 +131,43 @@ glibcpp_builddir = @glibcpp_builddir@
bits_srcdir = ${glibcpp_srcdir}/include/bits bits_srcdir = ${glibcpp_srcdir}/include/bits
bits_builddir = ./bits bits_builddir = ./bits
bits_headers = \ 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_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_srcdir = ${glibcpp_srcdir}/include/backward
backward_builddir = ./backward backward_builddir = ./backward
backward_headers = \ 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_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_srcdir = ${glibcpp_srcdir}/include/ext
ext_builddir = ./ext ext_builddir = ./ext
ext_headers = \ 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_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. # This is the common subset of files that all three "C" header models use.
c_base_srcdir = @C_INCLUDE_DIR@/bits c_base_srcdir = @C_INCLUDE_DIR@/bits
c_base_builddir = ./bits c_base_builddir = ./bits
c_base_headers = \ 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_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_srcdir = ${glibcpp_srcdir}/include/std
std_builddir = ./ std_builddir = ./
std_headers = \ 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_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_srcdir = ${glibcpp_srcdir}/@OS_INC_SRCDIR@
target_builddir = ./${target_alias}/bits target_builddir = ./${target_alias}/bits
target_headers = \ 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_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_builddir = ./${target_alias}/bits
thread_headers = \ thread_headers = ${thread_builddir}/gthr.h ${thread_builddir}/gthr-single.h ${thread_builddir}/gthr-default.h
${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 # List of all timestamp files. By keeping only one copy of this list, both
# CLEANFILES and all-local are kept up-to-date. # CLEANFILES and all-local are kept up-to-date.
# XXX stamp-c_compatibility # XXX stamp-c_compatibility
allstamps = stamp-std stamp-bits stamp-c_base stamp-backward stamp-ext \ allstamps = stamp-std stamp-bits stamp-c_base stamp-backward stamp-ext stamp-target stamp-thread stamp-file_model stamp-io stamp-locale
stamp-target stamp-thread stamp-file_model stamp-io stamp-locale
# By adding these files here, automake will remove them for 'make clean' # By adding these files here, automake will remove them for 'make clean'
......
...@@ -54,9 +54,20 @@ using std::random_access_iterator; ...@@ -54,9 +54,20 @@ using std::random_access_iterator;
using std::iterator_traits; using std::iterator_traits;
using std::iterator_category; template <class _Iter>
using std::distance_type; inline typename iterator_traits<_Iter>::iterator_category
using std::value_type; 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::distance;
using std::advance; using std::advance;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -62,12 +62,8 @@ ...@@ -62,12 +62,8 @@
#define __SGI_STL_INTERNAL_ALGOBASE_H #define __SGI_STL_INTERNAL_ALGOBASE_H
#include <bits/c++config.h> #include <bits/c++config.h>
#ifndef __SGI_STL_INTERNAL_PAIR_H
#include <bits/stl_pair.h> #include <bits/stl_pair.h>
#endif
#ifndef _CPP_BITS_TYPE_TRAITS_H
#include <bits/type_traits.h> #include <bits/type_traits.h>
#endif
#include <bits/std_cstring.h> #include <bits/std_cstring.h>
#include <bits/std_climits.h> #include <bits/std_climits.h>
#include <bits/std_cstdlib.h> #include <bits/std_cstdlib.h>
...@@ -83,648 +79,663 @@ ...@@ -83,648 +79,663 @@
namespace std namespace std
{ {
// swap and iter_swap // swap and iter_swap
template <class _ForwardIter1, class _ForwardIter2, class _Tp> template<typename _ForwardIter1, typename _ForwardIter2>
inline void __iter_swap(_ForwardIter1 __a, _ForwardIter2 __b, _Tp*) inline void
{ iter_swap(_ForwardIter1 __a, _ForwardIter2 __b)
_Tp __tmp = *__a; {
*__a = *__b; typedef typename iterator_traits<_ForwardIter1>::value_type _ValueType1;
*__b = __tmp; typedef typename iterator_traits<_ForwardIter2>::value_type _ValueType2;
}
// concept requirements
template <class _ForwardIter1, class _ForwardIter2> __glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter1>);
inline void iter_swap(_ForwardIter1 __a, _ForwardIter2 __b) __glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter2>);
{ __glibcpp_function_requires(_ConvertibleConcept<_ValueType1, _ValueType2>);
// concept requirements __glibcpp_function_requires(_ConvertibleConcept<_ValueType2, _ValueType1>);
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter1>);
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter2>); _ValueType1 __tmp = *__a;
__glibcpp_function_requires(_ConvertibleConcept< *__a = *__b;
typename iterator_traits<_ForwardIter1>::value_type, *__b = __tmp;
typename iterator_traits<_ForwardIter2>::value_type>); }
__glibcpp_function_requires(_ConvertibleConcept<
typename iterator_traits<_ForwardIter2>::value_type, template<typename _Tp>
typename iterator_traits<_ForwardIter1>::value_type>); inline void
swap(_Tp& __a, _Tp& __b)
__iter_swap(__a, __b, __value_type(__a)); {
} // concept requirements
__glibcpp_function_requires(_SGIAssignableConcept<_Tp>);
template <class _Tp>
inline void swap(_Tp& __a, _Tp& __b) _Tp __tmp = __a;
{ __a = __b;
// concept requirements __b = __tmp;
__glibcpp_function_requires(_SGIAssignableConcept<_Tp>); }
_Tp __tmp = __a; //--------------------------------------------------
__a = __b; // min and max
__b = __tmp;
} #undef min
#undef max
//--------------------------------------------------
// min and max template<typename _Tp>
inline const _Tp&
#undef min min(const _Tp& __a, const _Tp& __b)
#undef max {
// concept requirements
template <class _Tp> __glibcpp_function_requires(_LessThanComparableConcept<_Tp>);
inline const _Tp& min(const _Tp& __a, const _Tp& __b) { //return __b < __a ? __b : __a;
// concept requirements if (__b < __a) return __b; return __a;
__glibcpp_function_requires(_LessThanComparableConcept<_Tp>); }
//return __b < __a ? __b : __a;
if (__b < __a) return __b; return __a; template<typename _Tp>
} inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
template <class _Tp> {
inline const _Tp& max(const _Tp& __a, const _Tp& __b) { // concept requirements
// concept requirements __glibcpp_function_requires(_LessThanComparableConcept<_Tp>);
__glibcpp_function_requires(_LessThanComparableConcept<_Tp>); //return __a < __b ? __b : __a;
//return __a < __b ? __b : __a; if (__a < __b) return __b; return __a;
if (__a < __b) return __b; return __a; }
}
template<typename _Tp, typename _Compare>
template <class _Tp, class _Compare> inline const _Tp&
inline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { min(const _Tp& __a, const _Tp& __b, _Compare __comp)
//return __comp(__b, __a) ? __b : __a; {
if (__comp(__b, __a)) return __b; return __a; //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>
//return __comp(__a, __b) ? __b : __a; inline const _Tp&
if (__comp(__a, __b)) return __b; return __a; max(const _Tp& __a, const _Tp& __b, _Compare __comp)
} {
//return __comp(__a, __b) ? __b : __a;
//-------------------------------------------------- if (__comp(__a, __b)) return __b; return __a;
// copy }
// All of these auxiliary functions serve two purposes. (1) Replace //--------------------------------------------------
// calls to copy with memmove whenever possible. (Memmove, not memcpy, // copy
// because the input and output ranges are permitted to overlap.)
// (2) If we're using random access iterators, then write the loop as // All of these auxiliary functions serve two purposes. (1) Replace
// a for loop with an explicit count. // calls to copy with memmove whenever possible. (Memmove, not memcpy,
// because the input and output ranges are permitted to overlap.)
template <class _InputIter, class _OutputIter, class _Distance> // (2) If we're using random access iterators, then write the loop as
inline _OutputIter __copy(_InputIter __first, _InputIter __last, // a for loop with an explicit count.
_OutputIter __result,
input_iterator_tag, _Distance*) template<typename _InputIter, typename _OutputIter>
{ inline _OutputIter
for ( ; __first != __last; ++__result, ++__first) __copy(_InputIter __first, _InputIter __last,
*__result = *__first; _OutputIter __result,
return __result; input_iterator_tag)
} {
for ( ; __first != __last; ++__result, ++__first)
template <class _RandomAccessIter, class _OutputIter, class _Distance> *__result = *__first;
inline _OutputIter return __result;
__copy(_RandomAccessIter __first, _RandomAccessIter __last, }
_OutputIter __result, random_access_iterator_tag, _Distance*)
{ template<typename _RandomAccessIter, typename _OutputIter>
for (_Distance __n = __last - __first; __n > 0; --__n) { inline _OutputIter
*__result = *__first; __copy(_RandomAccessIter __first, _RandomAccessIter __last,
++__first; _OutputIter __result,
++__result; random_access_iterator_tag)
} {
return __result; typedef typename iterator_traits<_RandomAccessIter>::difference_type
}
template <class _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,
_OutputIter __result, __false_type)
{
return __copy(__first, __last, __result,
__iterator_category(__first),
__distance_type(__first));
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_aux2(_InputIter __first, _InputIter __last,
_OutputIter __result, __true_type)
{
return __copy(__first, __last, __result,
__iterator_category(__first),
__distance_type(__first));
}
template <class _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 <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
_Trivial;
return __copy_aux2(__first, __last, __result, _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,
_OutputIter __result, __false_type)
{
return __copy_aux(__first, __last, __result, __value_type(__first));
}
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,
_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)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>);
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
typename iterator_traits<_InputIter>::value_type>);
typedef typename _Is_normal_iterator<_InputIter>::_Normal __Normal;
return __copy_ni1(__first, __last, __result, __Normal());
}
//--------------------------------------------------
// copy_backward
template <class _BidirectionalIter1, class _BidirectionalIter2,
class _Distance>
inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
_BidirectionalIter1 __last,
_BidirectionalIter2 __result,
bidirectional_iterator_tag,
_Distance*)
{
while (__first != __last)
*--__result = *--__last;
return __result;
}
template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
_RandomAccessIter __last,
_BidirectionalIter __result,
random_access_iterator_tag,
_Distance*)
{
for (_Distance __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; _Distance;
for (_Distance __n = __last - __first; __n > 0; --__n) {
static _BidirectionalIter2 copy(_BidirectionalIter1 __first, *__result = *__first;
_BidirectionalIter1 __last, ++__first;
_BidirectionalIter2 __result) { ++__result;
return __copy_backward(__first, __last, __result, _Cat(), (_Distance*) 0); }
} return __result;
}; }
template <class _Tp> template<typename _Tp>
struct __copy_backward_dispatch<_Tp*, _Tp*, __true_type> inline _Tp*
{ __copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result)
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { {
const ptrdiff_t _Num = __last - __first; memmove(__result, __first, sizeof(_Tp) * (__last - __first));
memmove(__result - _Num, __first, sizeof(_Tp) * _Num); return __result + (__last - __first);
return __result - _Num; }
}
}; template<typename _InputIter, typename _OutputIter>
inline _OutputIter
template <class _Tp> __copy_aux2(_InputIter __first, _InputIter __last,
struct __copy_backward_dispatch<const _Tp*, _Tp*, __true_type> _OutputIter __result, __false_type)
{ { return __copy(__first, __last, __result, __iterator_category(__first)); }
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {
return __copy_backward_dispatch<_Tp*, _Tp*, __true_type> template<typename _InputIter, typename _OutputIter>
::copy(__first, __last, __result); inline _OutputIter
} __copy_aux2(_InputIter __first, _InputIter __last,
}; _OutputIter __result, __true_type)
{ return __copy(__first, __last, __result, __iterator_category(__first)); }
template <class _BI1, class _BI2>
inline _BI2 __copy_backward_aux(_BI1 __first, _BI1 __last, _BI2 __result) { template<typename _Tp>
typedef typename __type_traits<typename iterator_traits<_BI2>::value_type> inline _Tp*
::has_trivial_assignment_operator __copy_aux2(_Tp* __first, _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<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 _OutputIter(__copy_aux2(__first, __last,
__result.base(),
_Trivial()));
}
template<typename _InputIter, typename _OutputIter>
inline _OutputIter
__copy_ni2(_InputIter __first, _InputIter __last,
_OutputIter __result, __false_type)
{
typedef typename iterator_traits<_InputIter>::value_type
_ValueType;
typedef typename __type_traits<_ValueType>::has_trivial_assignment_operator
_Trivial; _Trivial;
return __copy_backward_dispatch<_BI1, _BI2, _Trivial> return __copy_aux2(__first, __last,
::copy(__first, __last, __result); __result,
} _Trivial());
}
template <typename _BI1, typename _BI2>
inline _BI2 __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last, template<typename _InputIter, typename _OutputIter>
_BI2 __result, __true_type) { inline _OutputIter
return _BI2(__copy_backward_aux(__first, __last, __result.base())); __copy_ni1(_InputIter __first, _InputIter __last,
} _OutputIter __result, __true_type)
{
template <typename _BI1, typename _BI2> typedef typename _Is_normal_iterator<_OutputIter>::_Normal __Normal;
inline _BI2 __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last, return __copy_ni2(__first.base(), __last.base(), __result, __Normal());
_BI2 __result, __false_type){ }
return __copy_backward_aux(__first, __last, __result);
} template<typename _InputIter, typename _OutputIter>
inline _OutputIter
template <typename _BI1, typename _BI2> __copy_ni1(_InputIter __first, _InputIter __last,
inline _BI2 __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last, _OutputIter __result, __false_type)
_BI2 __result, __true_type) { {
typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal; typedef typename _Is_normal_iterator<_OutputIter>::_Normal __Normal;
return __copy_backward_output_normal_iterator(__first.base(), __last.base(), return __copy_ni2(__first, __last, __result, __Normal());
__result, __Normal()); }
}
template<typename _InputIter, typename _OutputIter>
template <typename _BI1, typename _BI2> inline _OutputIter
inline _BI2 __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last, copy(_InputIter __first, _InputIter __last, _OutputIter __result)
_BI2 __result, __false_type) { {
typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal; // concept requirements
return __copy_backward_output_normal_iterator(__first, __last, __result, __glibcpp_function_requires(_InputIteratorConcept<_InputIter>);
__Normal()); __glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
} typename iterator_traits<_InputIter>::value_type>);
template <typename _BI1, typename _BI2> typedef typename _Is_normal_iterator<_InputIter>::_Normal __Normal;
inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) return __copy_ni1(__first, __last, __result, __Normal());
{ }
// concept requirements
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BI1>); //--------------------------------------------------
__glibcpp_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>); // copy_backward
__glibcpp_function_requires(_ConvertibleConcept<
typename iterator_traits<_BI1>::value_type, template<typename _BidirectionalIter1, typename _BidirectionalIter2>
typename iterator_traits<_BI2>::value_type>); inline _BidirectionalIter2
__copy_backward(_BidirectionalIter1 __first, _BidirectionalIter1 __last,
typedef typename _Is_normal_iterator<_BI1>::_Normal __Normal; _BidirectionalIter2 __result,
return __copy_backward_input_normal_iterator(__first, __last, __result, bidirectional_iterator_tag)
__Normal()); {
} while (__first != __last)
*--__result = *--__last;
//-------------------------------------------------- return __result;
// copy_n (not part of the C++ standard) }
template <class _InputIter, class _Size, class _OutputIter> template<typename _RandomAccessIter, typename _BidirectionalIter>
pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count, inline _BidirectionalIter
_OutputIter __result, __copy_backward(_RandomAccessIter __first, _RandomAccessIter __last,
input_iterator_tag) { _BidirectionalIter __result,
for ( ; __count > 0; --__count) { random_access_iterator_tag)
*__result = *__first; {
++__first; typename iterator_traits<_RandomAccessIter>::difference_type __n;
++__result; 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<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<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<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;
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, __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)
{
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)
{
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)
{
// concept requirements
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BI1>);
__glibcpp_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>);
__glibcpp_function_requires(_ConvertibleConcept<
typename iterator_traits<_BI1>::value_type,
typename iterator_traits<_BI2>::value_type>);
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)
template<typename _InputIter, typename _Size, typename _OutputIter>
pair<_InputIter, _OutputIter>
__copy_n(_InputIter __first, _Size __count,
_OutputIter __result,
input_iterator_tag)
{
for ( ; __count > 0; --__count) {
*__result = *__first;
++__first;
++__result;
}
return pair<_InputIter, _OutputIter>(__first, __result);
}
template<typename _RAIter, typename _Size, typename _OutputIter>
inline pair<_RAIter, _OutputIter>
__copy_n(_RAIter __first, _Size __count,
_OutputIter __result,
random_access_iterator_tag)
{
_RAIter __last = __first + __count;
return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
}
template<typename _InputIter, typename _Size, typename _OutputIter>
inline pair<_InputIter, _OutputIter>
copy_n(_InputIter __first, _Size __count, _OutputIter __result)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>);
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
typename iterator_traits<_InputIter>::value_type>);
return __copy_n(__first, __count, __result, __iterator_category(__first));
}
//--------------------------------------------------
// fill and fill_n
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<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.
inline void
fill(unsigned char* __first, unsigned char* __last, const unsigned char& __c)
{
unsigned char __tmp = __c;
memset(__first, __tmp, __last - __first);
} }
return pair<_InputIter, _OutputIter>(__first, __result);
}
template <class _RAIter, class _Size, class _OutputIter>
inline pair<_RAIter, _OutputIter>
__copy_n(_RAIter __first, _Size __count,
_OutputIter __result,
random_access_iterator_tag) {
_RAIter __last = __first + __count;
return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
}
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)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>);
__glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,
typename iterator_traits<_InputIter>::value_type>);
return __copy_n(__first, __count, __result);
}
//--------------------------------------------------
// fill and fill_n
template <class _ForwardIter, class _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)
{
// 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. inline void
fill(signed char* __first, signed char* __last, const signed char& __c)
inline void fill(unsigned char* __first, unsigned char* __last, {
const unsigned char& __c) signed char __tmp = __c;
{ memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
unsigned char __tmp = __c;
memset(__first, __tmp, __last - __first);
}
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)
{
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)
{
fill(__first, __first + __n, __c);
return __first + __n;
}
template <class _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)
{
fill(__first, __first + __n, __c);
return __first + __n;
}
//--------------------------------------------------
// equal and mismatch
template <class _InputIter1, class _InputIter2>
pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
_InputIter1 __last1,
_InputIter2 __first2)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
__glibcpp_function_requires(_EqualityComparableConcept<
typename iterator_traits<_InputIter1>::value_type>);
__glibcpp_function_requires(_EqualityComparableConcept<
typename iterator_traits<_InputIter2>::value_type>);
while (__first1 != __last1 && *__first1 == *__first2) {
++__first1;
++__first2;
} }
return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
template <class _InputIter1, class _InputIter2, class _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>);
while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) { inline void
++__first1; fill(char* __first, char* __last, const char& __c)
++__first2; {
char __tmp = __c;
memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
} }
return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
template <class _InputIter1, class _InputIter2> template<typename _Size>
inline bool equal(_InputIter1 __first1, _InputIter1 __last1, inline unsigned char*
_InputIter2 __first2) fill_n(unsigned char* __first, _Size __n, const unsigned char& __c)
{ {
// concept requirements fill(__first, __first + __n, __c);
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>); return __first + __n;
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>); }
__glibcpp_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIter1>::value_type, template<typename _Size>
typename iterator_traits<_InputIter2>::value_type>); inline signed char*
fill_n(char* __first, _Size __n, const signed char& __c)
for ( ; __first1 != __last1; ++__first1, ++__first2) {
if (!(*__first1 == *__first2)) fill(__first, __first + __n, __c);
return false; return __first + __n;
return true; }
}
template<typename _Size>
template <class _InputIter1, class _InputIter2, class _BinaryPredicate> inline char*
inline bool equal(_InputIter1 __first1, _InputIter1 __last1, fill_n(char* __first, _Size __n, const char& __c)
_InputIter2 __first2, _BinaryPredicate __binary_pred) {
{ fill(__first, __first + __n, __c);
// concept requirements return __first + __n;
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>); }
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
for ( ; __first1 != __last1; ++__first1, ++__first2) //--------------------------------------------------
if (!__binary_pred(*__first1, *__first2)) // equal and mismatch
return false;
return true; template<typename _InputIter1, typename _InputIter2>
} pair<_InputIter1, _InputIter2>
mismatch(_InputIter1 __first1, _InputIter1 __last1,
//-------------------------------------------------- _InputIter2 __first2)
// lexicographical_compare and lexicographical_compare_3way. {
// (the latter is not part of the C++ standard.) // concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
template <class _InputIter1, class _InputIter2> __glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, __glibcpp_function_requires(_EqualityComparableConcept<
_InputIter2 __first2, _InputIter2 __last2) typename iterator_traits<_InputIter1>::value_type>);
{ __glibcpp_function_requires(_EqualityComparableConcept<
// concept requirements typename iterator_traits<_InputIter2>::value_type>);
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>); while (__first1 != __last1 && *__first1 == *__first2) {
__glibcpp_function_requires(_LessThanComparableConcept< ++__first1;
typename iterator_traits<_InputIter1>::value_type>); ++__first2;
__glibcpp_function_requires(_LessThanComparableConcept< }
typename iterator_traits<_InputIter2>::value_type>); return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
for ( ; __first1 != __last1 && __first2 != __last2
; ++__first1, ++__first2) { template<typename _InputIter1, typename _InputIter2, typename _BinaryPredicate>
if (*__first1 < *__first2) 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>);
while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
++__first1;
++__first2;
}
return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
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>);
__glibcpp_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIter1>::value_type,
typename iterator_traits<_InputIter2>::value_type>);
for ( ; __first1 != __last1; ++__first1, ++__first2)
if (!(*__first1 == *__first2))
return false;
return true; return true;
if (*__first2 < *__first1) }
return false;
} template<typename _InputIter1, typename _InputIter2, typename _BinaryPredicate>
return __first1 == __last1 && __first2 != __last2; inline bool
} equal(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2,
template <class _InputIter1, class _InputIter2, class _Compare> _BinaryPredicate __binary_pred)
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, {
_InputIter2 __first2, _InputIter2 __last2, // concept requirements
_Compare __comp) __glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
{ __glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>); for ( ; __first1 != __last1; ++__first1, ++__first2)
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>); if (!__binary_pred(*__first1, *__first2))
return false;
for ( ; __first1 != __last1 && __first2 != __last2
; ++__first1, ++__first2) {
if (__comp(*__first1, *__first2))
return true; return true;
if (__comp(*__first2, *__first1)) }
return false;
//--------------------------------------------------
// lexicographical_compare and lexicographical_compare_3way.
// (the latter is not part of the C++ standard.)
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>);
__glibcpp_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIter1>::value_type>);
__glibcpp_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIter2>::value_type>);
for ( ; __first1 != __last1 && __first2 != __last2
; ++__first1, ++__first2) {
if (*__first1 < *__first2)
return true;
if (*__first2 < *__first1)
return false;
}
return __first1 == __last1 && __first2 != __last2;
}
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>);
for ( ; __first1 != __last1 && __first2 != __last2
; ++__first1, ++__first2) {
if (__comp(*__first1, *__first2))
return true;
if (__comp(*__first2, *__first1))
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)
{
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;
} }
return __first1 == __last1 && __first2 != __last2;
} inline bool
lexicographical_compare(const char* __first1, const char* __last1,
inline bool const char* __first2, const char* __last2)
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,
const char* __first2, const char* __last2)
{
#if CHAR_MAX == SCHAR_MAX #if CHAR_MAX == SCHAR_MAX
return lexicographical_compare((const signed char*) __first1, return lexicographical_compare((const signed char*) __first1,
(const signed char*) __last1, (const signed char*) __last1,
(const signed char*) __first2, (const signed char*) __first2,
(const signed char*) __last2); (const signed char*) __last2);
#else /* CHAR_MAX == SCHAR_MAX */ #else /* CHAR_MAX == SCHAR_MAX */
return lexicographical_compare((const unsigned char*) __first1, return lexicographical_compare((const unsigned char*) __first1,
(const unsigned char*) __last1, (const unsigned char*) __last1,
(const unsigned char*) __first2, (const unsigned char*) __first2,
(const unsigned char*) __last2); (const unsigned char*) __last2);
#endif /* CHAR_MAX == SCHAR_MAX */ #endif /* CHAR_MAX == SCHAR_MAX */
}
template <class _InputIter1, class _InputIter2>
int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2)
{
while (__first1 != __last1 && __first2 != __last2) {
if (*__first1 < *__first2)
return -1;
if (*__first2 < *__first1)
return 1;
++__first1;
++__first2;
}
if (__first2 == __last2) {
return !(__first1 == __last1);
} }
else {
return -1; template<typename _InputIter1, typename _InputIter2>
int
__lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2)
{
while (__first1 != __last1 && __first2 != __last2) {
if (*__first1 < *__first2)
return -1;
if (*__first2 < *__first1)
return 1;
++__first1;
++__first2;
}
if (__first2 == __last2) {
return !(__first1 == __last1);
}
else {
return -1;
}
}
inline int
__lexicographical_compare_3way(const unsigned char* __first1,
const unsigned char* __last1,
const unsigned char* __first2,
const unsigned char* __last2)
{
const ptrdiff_t __len1 = __last1 - __first1;
const ptrdiff_t __len2 = __last2 - __first2;
const int __result = memcmp(__first1, __first2, min(__len1, __len2));
return __result != 0 ? __result
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
} }
}
inline int inline int
__lexicographical_compare_3way(const unsigned char* __first1, __lexicographical_compare_3way(const char* __first1, const char* __last1,
const unsigned char* __last1, const char* __first2, const char* __last2)
const unsigned char* __first2, {
const unsigned char* __last2)
{
const ptrdiff_t __len1 = __last1 - __first1;
const ptrdiff_t __len2 = __last2 - __first2;
const int __result = memcmp(__first1, __first2, min(__len1, __len2));
return __result != 0 ? __result
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
}
inline int
__lexicographical_compare_3way(const char* __first1, const char* __last1,
const char* __first2, const char* __last2)
{
#if CHAR_MAX == SCHAR_MAX #if CHAR_MAX == SCHAR_MAX
return __lexicographical_compare_3way( return __lexicographical_compare_3way(
(const signed char*) __first1, (const signed char*) __first1,
(const signed char*) __last1, (const signed char*) __last1,
(const signed char*) __first2, (const signed char*) __first2,
(const signed char*) __last2); (const signed char*) __last2);
#else #else
return __lexicographical_compare_3way((const unsigned char*) __first1, return __lexicographical_compare_3way((const unsigned char*) __first1,
(const unsigned char*) __last1, (const unsigned char*) __last1,
(const unsigned char*) __first2, (const unsigned char*) __first2,
(const unsigned char*) __last2); (const unsigned char*) __last2);
#endif #endif
} }
template <class _InputIter1, class _InputIter2> template<typename _InputIter1, typename _InputIter2>
int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, int
_InputIter2 __first2, _InputIter2 __last2) lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
{ _InputIter2 __first2, _InputIter2 __last2)
// concept requirements {
__glibcpp_function_requires(_InputIteratorConcept<_InputIter1>); // concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter2>); __glibcpp_function_requires(_InputIteratorConcept<_InputIter1>);
__glibcpp_function_requires(_LessThanComparableConcept< __glibcpp_function_requires(_InputIteratorConcept<_InputIter2>);
typename iterator_traits<_InputIter1>::value_type>); __glibcpp_function_requires(_LessThanComparableConcept<
__glibcpp_function_requires(_LessThanComparableConcept< typename iterator_traits<_InputIter1>::value_type>);
typename iterator_traits<_InputIter2>::value_type>); __glibcpp_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIter2>::value_type>);
return __lexicographical_compare_3way(__first1, __last1, __first2, __last2);
} return __lexicographical_compare_3way(__first1, __last1, __first2, __last2);
}
} // namespace std } // namespace std
......
...@@ -62,277 +62,241 @@ ...@@ -62,277 +62,241 @@
namespace std 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> template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
void void
__push_heap(_RandomAccessIterator __first, __push_heap(_RandomAccessIterator __first,
_Distance __holeIndex, _Distance __topIndex, _Tp __value) _Distance __holeIndex, _Distance __topIndex, _Tp __value)
{ {
_Distance __parent = (__holeIndex - 1) / 2; _Distance __parent = (__holeIndex - 1) / 2;
while (__holeIndex > __topIndex && *(__first + __parent) < __value) { while (__holeIndex > __topIndex && *(__first + __parent) < __value) {
*(__first + __holeIndex) = *(__first + __parent); *(__first + __holeIndex) = *(__first + __parent);
__holeIndex = __parent; __holeIndex = __parent;
__parent = (__holeIndex - 1) / 2; __parent = (__holeIndex - 1) / 2;
} }
*(__first + __holeIndex) = __value; *(__first + __holeIndex) = __value;
} }
template <class _RandomAccessIterator, class _Distance, class _Tp> template<typename _RandomAccessIterator>
inline void inline void
__push_heap_aux(_RandomAccessIterator __first, push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
_RandomAccessIterator __last, _Distance*, _Tp*) {
{ typedef typename iterator_traits<_RandomAccessIterator>::value_type
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), _ValueType;
_Tp(*(__last - 1))); typedef typename iterator_traits<_RandomAccessIterator>::difference_type
} _DistanceType;
template <class _RandomAccessIterator> // concept requirements
inline void __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) _RandomAccessIterator>);
{ __glibcpp_function_requires(_LessThanComparableConcept<_ValueType>);
// concept requirements
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept< __push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
_RandomAccessIterator>); _ValueType(*(__last - 1)));
__glibcpp_function_requires(_LessThanComparableConcept< }
typename iterator_traits<_RandomAccessIterator>::value_type>);
template<typename _RandomAccessIterator, typename _Distance, typename _Tp,
__push_heap_aux(__first, __last, typename _Compare>
__distance_type(__first), __value_type(__first)); void
} __push_heap(_RandomAccessIterator __first, _Distance __holeIndex,
_Distance __topIndex, _Tp __value, _Compare __comp)
template <class _RandomAccessIterator, class _Distance, class _Tp, {
class _Compare> _Distance __parent = (__holeIndex - 1) / 2;
void while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) {
__push_heap(_RandomAccessIterator __first, _Distance __holeIndex, *(__first + __holeIndex) = *(__first + __parent);
_Distance __topIndex, _Tp __value, _Compare __comp) __holeIndex = __parent;
{ __parent = (__holeIndex - 1) / 2;
_Distance __parent = (__holeIndex - 1) / 2; }
while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) { *(__first + __holeIndex) = __value;
*(__first + __holeIndex) = *(__first + __parent); }
__holeIndex = __parent;
__parent = (__holeIndex - 1) / 2; template<typename _RandomAccessIterator, typename _Compare>
} inline void
*(__first + __holeIndex) = __value; push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
} _Compare __comp)
{
template <class _RandomAccessIterator, class _Compare, typedef typename iterator_traits<_RandomAccessIterator>::value_type
class _Distance, class _Tp> _ValueType;
inline void typedef typename iterator_traits<_RandomAccessIterator>::difference_type
__push_heap_aux(_RandomAccessIterator __first, _DistanceType;
_RandomAccessIterator __last, _Compare __comp,
_Distance*, _Tp*) // concept requirements
{ __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), _RandomAccessIterator>);
_Tp(*(__last - 1)), __comp);
} __push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
_ValueType(*(__last - 1)), __comp);
template <class _RandomAccessIterator, class _Compare> }
inline void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
_Compare __comp) void
{ __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
// concept requirements _Distance __len, _Tp __value)
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept< {
_RandomAccessIterator>); _Distance __topIndex = __holeIndex;
_Distance __secondChild = 2 * __holeIndex + 2;
__push_heap_aux(__first, __last, __comp, while (__secondChild < __len) {
__distance_type(__first), __value_type(__first)); if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))
} __secondChild--;
*(__first + __holeIndex) = *(__first + __secondChild);
template <class _RandomAccessIterator, class _Distance, class _Tp> __holeIndex = __secondChild;
void __secondChild = 2 * (__secondChild + 1);
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, }
_Distance __len, _Tp __value) if (__secondChild == __len) {
{ *(__first + __holeIndex) = *(__first + (__secondChild - 1));
_Distance __topIndex = __holeIndex; __holeIndex = __secondChild - 1;
_Distance __secondChild = 2 * __holeIndex + 2; }
while (__secondChild < __len) { __push_heap(__first, __holeIndex, __topIndex, __value);
if (*(__first + __secondChild) < *(__first + (__secondChild - 1))) }
__secondChild--;
*(__first + __holeIndex) = *(__first + __secondChild); template<typename _RandomAccessIterator, typename _Tp>
__holeIndex = __secondChild; inline void
__secondChild = 2 * (__secondChild + 1); __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
} _RandomAccessIterator __result, _Tp __value)
if (__secondChild == __len) { {
*(__first + __holeIndex) = *(__first + (__secondChild - 1)); typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance;
__holeIndex = __secondChild - 1; *__result = *__first;
} __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value);
__push_heap(__first, __holeIndex, __topIndex, __value); }
}
template<typename _RandomAccessIterator>
template <class _RandomAccessIterator, class _Tp, class _Distance> inline void
inline void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, {
_RandomAccessIterator __result, _Tp __value, _Distance*) typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType;
{
*__result = *__first; // concept requirements
__adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value); __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
} _RandomAccessIterator>);
__glibcpp_function_requires(_LessThanComparableConcept<_ValueType>);
template <class _RandomAccessIterator, class _Tp>
inline void __pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)));
__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, }
_Tp*)
{ template<typename _RandomAccessIterator, typename _Distance,
__pop_heap(__first, __last - 1, __last - 1, typename _Tp, typename _Compare>
_Tp(*(__last - 1)), __distance_type(__first)); void
} __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
_Distance __len, _Tp __value, _Compare __comp)
template <class _RandomAccessIterator> {
inline void pop_heap(_RandomAccessIterator __first, _Distance __topIndex = __holeIndex;
_RandomAccessIterator __last) _Distance __secondChild = 2 * __holeIndex + 2;
{ while (__secondChild < __len) {
// concept requirements if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1))))
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept< __secondChild--;
_RandomAccessIterator>); *(__first + __holeIndex) = *(__first + __secondChild);
__glibcpp_function_requires(_LessThanComparableConcept< __holeIndex = __secondChild;
typename iterator_traits<_RandomAccessIterator>::value_type>); __secondChild = 2 * (__secondChild + 1);
}
__pop_heap_aux(__first, __last, __value_type(__first)); if (__secondChild == __len) {
} *(__first + __holeIndex) = *(__first + (__secondChild - 1));
__holeIndex = __secondChild - 1;
template <class _RandomAccessIterator, class _Distance, }
class _Tp, class _Compare> __push_heap(__first, __holeIndex, __topIndex, __value, __comp);
void }
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
_Distance __len, _Tp __value, _Compare __comp) template<typename _RandomAccessIterator, typename _Tp, typename _Compare>
{ inline void
_Distance __topIndex = __holeIndex; __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Distance __secondChild = 2 * __holeIndex + 2; _RandomAccessIterator __result, _Tp __value, _Compare __comp)
while (__secondChild < __len) { {
if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance;
__secondChild--; *__result = *__first;
*(__first + __holeIndex) = *(__first + __secondChild); __adjust_heap(__first, _Distance(0), _Distance(__last - __first),
__holeIndex = __secondChild; __value, __comp);
__secondChild = 2 * (__secondChild + 1); }
}
if (__secondChild == __len) { template<typename _RandomAccessIterator, typename _Compare>
*(__first + __holeIndex) = *(__first + (__secondChild - 1)); inline void
__holeIndex = __secondChild - 1; pop_heap(_RandomAccessIterator __first,
} _RandomAccessIterator __last, _Compare __comp)
__push_heap(__first, __holeIndex, __topIndex, __value, __comp); {
} // concept requirements
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
template <class _RandomAccessIterator, class _Tp, class _Compare, _RandomAccessIterator>);
class _Distance>
inline void typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType;
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, __pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)), __comp);
_RandomAccessIterator __result, _Tp __value, _Compare __comp, }
_Distance*)
{ template<typename _RandomAccessIterator>
*__result = *__first; void
__adjust_heap(__first, _Distance(0), _Distance(__last - __first), make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
__value, __comp); {
} typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
template <class _RandomAccessIterator, class _Tp, class _Compare> typedef typename iterator_traits<_RandomAccessIterator>::difference_type
inline void _DistanceType;
__pop_heap_aux(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Tp*, _Compare __comp) // concept requirements
{ __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
__pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp, _RandomAccessIterator>);
__distance_type(__first)); __glibcpp_function_requires(_LessThanComparableConcept<_ValueType>);
}
if (__last - __first < 2) return;
template <class _RandomAccessIterator, class _Compare> _DistanceType __len = __last - __first;
inline void _DistanceType __parent = (__len - 2)/2;
pop_heap(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp) while (true) {
{ __adjust_heap(__first, __parent, __len, _ValueType(*(__first + __parent)));
// concept requirements if (__parent == 0) return;
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept< __parent--;
_RandomAccessIterator>); }
}
__pop_heap_aux(__first, __last, __value_type(__first), __comp);
} template<typename _RandomAccessIterator, typename _Compare>
inline void
template <class _RandomAccessIterator, class _Tp, class _Distance> make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
void _Compare __comp)
__make_heap(_RandomAccessIterator __first, {
_RandomAccessIterator __last, _Tp*, _Distance*) typedef typename iterator_traits<_RandomAccessIterator>::value_type
{ _ValueType;
if (__last - __first < 2) return; typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_Distance __len = __last - __first; _DistanceType;
_Distance __parent = (__len - 2)/2;
// concept requirements
while (true) { __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent))); _RandomAccessIterator>);
if (__parent == 0) return;
__parent--; if (__last - __first < 2) return;
} _DistanceType __len = __last - __first;
} _DistanceType __parent = (__len - 2)/2;
template <class _RandomAccessIterator> while (true) {
inline void __adjust_heap(__first, __parent, __len,
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) _ValueType(*(__first + __parent)), __comp);
{ if (__parent == 0) return;
// concept requirements __parent--;
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept< }
_RandomAccessIterator>); }
__glibcpp_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>); template<typename _RandomAccessIterator>
void
__make_heap(__first, __last, sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
__value_type(__first), __distance_type(__first)); {
} // concept requirements
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
template <class _RandomAccessIterator, class _Compare, _RandomAccessIterator>);
class _Tp, class _Distance> __glibcpp_function_requires(_LessThanComparableConcept<
void typename iterator_traits<_RandomAccessIterator>::value_type>);
__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp, _Tp*, _Distance*) while (__last - __first > 1)
{ pop_heap(__first, __last--);
if (__last - __first < 2) return; }
_Distance __len = __last - __first;
_Distance __parent = (__len - 2)/2; template<typename _RandomAccessIterator, typename _Compare>
void
while (true) { sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)), _Compare __comp)
__comp); {
if (__parent == 0) return; // concept requirements
__parent--; __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
} _RandomAccessIterator>);
}
while (__last - __first > 1)
template <class _RandomAccessIterator, class _Compare> pop_heap(__first, __last--, __comp);
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)
{
// concept requirements
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>);
__glibcpp_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>);
while (__last - __first > 1)
pop_heap(__first, __last--);
}
template <class _RandomAccessIterator, class _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 } // namespace std
......
...@@ -71,105 +71,107 @@ ...@@ -71,105 +71,107 @@
namespace std namespace std
{ {
// There are two signatures for distance. In addition to the one taking // There are two signatures for distance. In addition to the one taking
// two iterators and returning a result, there is another taking two // two iterators and returning a result, there is another taking two
// iterators and a reference-to-result variable, and returning nothing. // iterators and a reference-to-result variable, and returning nothing.
// The latter seems to be an SGI extension. -- pedwards // The latter seems to be an SGI extension. -- pedwards
template <class _InputIterator, class _Distance> template<typename _InputIterator, typename _Distance>
inline void __distance(_InputIterator __first, _InputIterator __last, inline void
_Distance& __n, input_iterator_tag) __distance(_InputIterator __first, _InputIterator __last,
{ _Distance& __n, input_iterator_tag)
// concept requirements {
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>); // concept requirements
while (__first != __last) { ++__first; ++__n; } __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
} while (__first != __last) { ++__first; ++__n; }
}
template <class _RandomAccessIterator, class _Distance>
inline void __distance(_RandomAccessIterator __first, template<typename _RandomAccessIterator, typename _Distance>
_RandomAccessIterator __last, inline void
_Distance& __n, random_access_iterator_tag) __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
{ _Distance& __n, random_access_iterator_tag)
// concept requirements {
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>); // concept requirements
__n += __last - __first; __glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>);
} __n += __last - __first;
}
template <class _InputIterator, class _Distance>
inline void distance(_InputIterator __first, template<typename _InputIterator, typename _Distance>
_InputIterator __last, _Distance& __n) inline void
{ distance(_InputIterator __first, _InputIterator __last,
// concept requirements -- taken care of in __distance _Distance& __n)
__distance(__first, __last, __n, iterator_category(__first)); {
} // concept requirements -- taken care of in __distance
__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
// concept requirements __distance(_InputIterator __first, _InputIterator __last, input_iterator_tag)
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>); {
typename iterator_traits<_InputIterator>::difference_type __n = 0; // concept requirements
while (__first != __last) { __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
++__first; ++__n; typename iterator_traits<_InputIterator>::difference_type __n = 0;
} while (__first != __last) {
return __n; ++__first; ++__n;
} }
return __n;
template <class _RandomAccessIterator> }
inline typename iterator_traits<_RandomAccessIterator>::difference_type
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last, template<typename _RandomAccessIterator>
random_access_iterator_tag) inline typename iterator_traits<_RandomAccessIterator>::difference_type
{ __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
// concept requirements random_access_iterator_tag)
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>); {
return __last - __first; // 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
// concept requirements -- taken care of in __distance distance(_InputIterator __first, _InputIterator __last)
typedef typename iterator_traits<_InputIterator>::iterator_category {
_Category; // concept requirements -- taken care of in __distance
return __distance(__first, __last, _Category()); return __distance(__first, __last, __iterator_category(__first));
} }
template <class _InputIter, class _Distance> template<typename _InputIter, typename _Distance>
inline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag) inline void
{ __advance(_InputIter& __i, _Distance __n, input_iterator_tag)
// concept requirements {
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>); // concept requirements
while (__n--) ++__i; __glibcpp_function_requires(_InputIteratorConcept<_InputIter>);
} while (__n--) ++__i;
}
template <class _BidirectionalIterator, class _Distance>
inline void __advance(_BidirectionalIterator& __i, _Distance __n, template<typename _BidirectionalIterator, typename _Distance>
bidirectional_iterator_tag) inline void
{ __advance(_BidirectionalIterator& __i, _Distance __n, bidirectional_iterator_tag)
// concept requirements {
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>); // concept requirements
if (__n > 0) __glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>);
while (__n--) ++__i; if (__n > 0)
else while (__n--) ++__i;
while (__n++) --__i; else
} while (__n++) --__i;
}
template <class _RandomAccessIterator, class _Distance>
inline void __advance(_RandomAccessIterator& __i, _Distance __n, template<typename _RandomAccessIterator, typename _Distance>
random_access_iterator_tag) inline void
{ __advance(_RandomAccessIterator& __i, _Distance __n, random_access_iterator_tag)
// concept requirements {
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>); // concept requirements
__i += __n; __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
// concept requirements -- taken care of in __advance advance(_InputIterator& __i, _Distance __n)
__advance(__i, __n, iterator_category(__i)); {
} // concept requirements -- taken care of in __advance
__advance(__i, __n, __iterator_category(__i));
}
} // namespace std } // namespace std
......
...@@ -67,142 +67,108 @@ ...@@ -67,142 +67,108 @@
#pragma GCC system_header #pragma GCC system_header
#include <bits/std_cstddef.h> // for ptrdiff_t
namespace std namespace std
{ {
struct input_iterator_tag {}; struct input_iterator_tag {};
struct output_iterator_tag {}; struct output_iterator_tag {};
struct forward_iterator_tag : public input_iterator_tag {}; struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {}; struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {}; struct random_access_iterator_tag : public bidirectional_iterator_tag {};
// The base classes input_iterator, output_iterator, forward_iterator, // The base classes input_iterator, output_iterator, forward_iterator,
// bidirectional_iterator, and random_access_iterator are not part of // bidirectional_iterator, and random_access_iterator are not part of
// the C++ standard. (They have been replaced by struct iterator.) // the C++ standard. (They have been replaced by struct iterator.)
// They are included for backward compatibility with the HP STL. // They are included for backward compatibility with the HP STL.
template <class _Tp, class _Distance> struct input_iterator { template<typename _Tp, typename _Distance>
typedef input_iterator_tag iterator_category; struct input_iterator {
typedef _Tp value_type; typedef input_iterator_tag iterator_category;
typedef _Distance difference_type; typedef _Tp value_type;
typedef _Tp* pointer; typedef _Distance difference_type;
typedef _Tp& reference; typedef _Tp* pointer;
}; typedef _Tp& reference;
};
struct output_iterator {
typedef output_iterator_tag iterator_category; struct output_iterator {
typedef void value_type; typedef output_iterator_tag iterator_category;
typedef void difference_type; typedef void value_type;
typedef void pointer; typedef void difference_type;
typedef void reference; typedef void pointer;
}; typedef void reference;
};
template <class _Tp, class _Distance> struct forward_iterator {
typedef forward_iterator_tag iterator_category; template<typename _Tp, typename _Distance>
typedef _Tp value_type; struct forward_iterator {
typedef _Distance difference_type; typedef forward_iterator_tag iterator_category;
typedef _Tp* pointer; typedef _Tp value_type;
typedef _Tp& reference; typedef _Distance difference_type;
}; typedef _Tp* pointer;
typedef _Tp& reference;
};
template <class _Tp, class _Distance> struct bidirectional_iterator {
typedef bidirectional_iterator_tag iterator_category; template<typename _Tp, typename _Distance>
typedef _Tp value_type; struct bidirectional_iterator {
typedef _Distance difference_type; typedef bidirectional_iterator_tag iterator_category;
typedef _Tp* pointer; typedef _Tp value_type;
typedef _Tp& reference; typedef _Distance difference_type;
}; typedef _Tp* pointer;
typedef _Tp& reference;
template <class _Tp, class _Distance> struct random_access_iterator { };
typedef random_access_iterator_tag iterator_category;
typedef _Tp value_type; template<typename _Tp, typename _Distance>
typedef _Distance difference_type; struct random_access_iterator {
typedef _Tp* pointer; typedef random_access_iterator_tag iterator_category;
typedef _Tp& reference; typedef _Tp value_type;
}; typedef _Distance difference_type;
typedef _Tp* pointer;
template <class _Category, class _Tp, class _Distance = ptrdiff_t, typedef _Tp& reference;
class _Pointer = _Tp*, class _Reference = _Tp&> };
struct iterator {
typedef _Category iterator_category; template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
typedef _Tp value_type; typename _Pointer = _Tp*, typename _Reference = _Tp&>
typedef _Distance difference_type; struct iterator {
typedef _Pointer pointer; typedef _Category iterator_category;
typedef _Reference reference; typedef _Tp value_type;
}; typedef _Distance difference_type;
typedef _Pointer pointer;
template <class _Iterator> typedef _Reference reference;
struct iterator_traits { };
typedef typename _Iterator::iterator_category iterator_category;
typedef typename _Iterator::value_type value_type; template<typename _Iterator>
typedef typename _Iterator::difference_type difference_type; struct iterator_traits {
typedef typename _Iterator::pointer pointer; typedef typename _Iterator::iterator_category iterator_category;
typedef typename _Iterator::reference reference; typedef typename _Iterator::value_type value_type;
}; typedef typename _Iterator::difference_type difference_type;
typedef typename _Iterator::pointer pointer;
template <class _Tp> typedef typename _Iterator::reference reference;
struct iterator_traits<_Tp*> { };
typedef random_access_iterator_tag iterator_category;
typedef _Tp value_type; template<typename _Tp>
typedef ptrdiff_t difference_type; struct iterator_traits<_Tp*> {
typedef _Tp* pointer; typedef random_access_iterator_tag iterator_category;
typedef _Tp& reference; typedef _Tp value_type;
}; typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
template <class _Tp> typedef _Tp& reference;
struct iterator_traits<const _Tp*> { };
typedef random_access_iterator_tag iterator_category;
typedef _Tp value_type; template<typename _Tp>
typedef ptrdiff_t difference_type; struct iterator_traits<const _Tp*> {
typedef const _Tp* pointer; typedef random_access_iterator_tag iterator_category;
typedef const _Tp& reference; typedef _Tp value_type;
}; typedef ptrdiff_t difference_type;
typedef const _Tp* pointer;
// The overloaded functions iterator_category, distance_type, and typedef const _Tp& reference;
// 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<typename _Iter>
template <class _Iter> inline typename iterator_traits<_Iter>::iterator_category
inline typename iterator_traits<_Iter>::iterator_category __iterator_category(const _Iter&)
__iterator_category(const _Iter&) { return typename iterator_traits<_Iter>::iterator_category(); }
{
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); }
} // namespace std } // namespace std
......
...@@ -64,240 +64,208 @@ ...@@ -64,240 +64,208 @@
namespace std namespace std
{ {
template <class _InputIterator, class _Tp> template<typename _InputIterator, typename _Tp>
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) _Tp
{ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
// concept requirements {
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>); // concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
for ( ; __first != __last; ++__first)
__init = __init + *__first; for ( ; __first != __last; ++__first)
return __init; __init = __init + *__first;
} return __init;
}
template <class _InputIterator, class _Tp, class _BinaryOperation>
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
_BinaryOperation __binary_op)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
for ( ; __first != __last; ++__first) template<typename _InputIterator, typename _Tp, typename _BinaryOperation>
__init = __binary_op(__init, *__first); _Tp
return __init; 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> template<typename _InputIterator1, typename _InputIterator2, typename _Tp>
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _Tp
_InputIterator2 __first2, _Tp __init) inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
{ _InputIterator2 __first2, _Tp __init)
// concept requirements {
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator1>); // concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator2>); __glibcpp_function_requires(_InputIteratorConcept<_InputIterator1>);
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator2>);
for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __init + (*__first1 * *__first2); for ( ; __first1 != __last1; ++__first1, ++__first2)
return __init; __init = __init + (*__first1 * *__first2);
} return __init;
template <class _InputIterator1, class _InputIterator2, class _Tp,
class _BinaryOperation1, class _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>);
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;
while (++__first != __last) {
__value = __value + *__first;
*++__result = __value;
}
return ++__result;
}
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>);
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;
while (++__first != __last) {
__value = __binary_op(__value, *__first);
*++__result = __value;
}
return ++__result;
}
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>);
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;
while (++__first != __last) {
_Tp __tmp = *__first;
*++__result = __tmp - __value;
__value = __tmp;
}
return ++__result;
}
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>);
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;
while (++__first != __last) {
_Tp __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.
template <class _Tp, class _Integer, class _MonoidOperation>
_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
{
if (__n == 0)
return identity_element(__monoid_op);
else {
while ((__n & 1) == 0) {
__n >>= 1;
__x = __monoid_op(__x, __x);
} }
_Tp __result = __x; template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
__n >>= 1; typename _BinaryOperation1, typename _BinaryOperation2>
while (__n != 0) { _Tp
__x = __monoid_op(__x, __x); inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
if ((__n & 1) != 0) _InputIterator2 __first2, _Tp __init,
__result = __monoid_op(__result, __x); _BinaryOperation1 __binary_op1,
__n >>= 1; _BinaryOperation2 __binary_op2)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator1>);
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator2>);
for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
return __init;
} }
return __result;
}
}
template <class _Tp, class _Integer> template<typename _InputIterator, typename _OutputIterator>
inline _Tp __power(_Tp __x, _Integer __n) _OutputIterator
{ partial_sum(_InputIterator __first, _InputIterator __last,
return __power(__x, __n, multiplies<_Tp>()); _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;
}
// Alias for the internal name __power. Note that power is an extension, template<typename _InputIterator, typename _OutputIterator, typename _BinaryOperation>
// not part of the C++ standard. _OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOperation __binary_op)
{
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 = __binary_op(__value, *__first);
*++__result = __value;
}
return ++__result;
}
template <class _Tp, class _Integer, class _MonoidOperation> template<typename _InputIterator, typename _OutputIterator>
inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op) _OutputIterator
{ adjacent_difference(_InputIterator __first,
return __power(__x, __n, __monoid_op); _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) {
_ValueType __tmp = *__first;
*++__result = __tmp - __value;
__value = __tmp;
}
return ++__result;
}
template <class _Tp, class _Integer> template<typename _InputIterator, typename _OutputIterator, typename _BinaryOperation>
inline _Tp power(_Tp __x, _Integer __n) _OutputIterator
{ adjacent_difference(_InputIterator __first, _InputIterator __last,
return __power(__x, __n); _OutputIterator __result, _BinaryOperation __binary_op)
} {
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) {
_ValueType __tmp = *__first;
*++__result = __binary_op(__tmp, __value);
__value = __tmp;
}
return ++__result;
}
// iota is not part of the C++ standard. It is an extension. // Returns __x ** __n, where __n >= 0. _Note that "multiplication"
// is required to be associative, but not necessarily commutative.
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 {
while ((__n & 1) == 0) {
__n >>= 1;
__x = __monoid_op(__x, __x);
}
_Tp __result = __x;
__n >>= 1;
while (__n != 0) {
__x = __monoid_op(__x, __x);
if ((__n & 1) != 0)
__result = __monoid_op(__result, __x);
__n >>= 1;
}
return __result;
}
}
template <class _ForwardIter, class _Tp> template<typename _Tp, typename _Integer>
void inline _Tp
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value) __power(_Tp __x, _Integer __n)
{ { return __power(__x, __n, multiplies<_Tp>()); }
// concept requirements
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>); // Alias for the internal name __power. Note that power is an extension,
__glibcpp_function_requires(_ConvertibleConcept<_Tp, // not part of the C++ standard.
typename iterator_traits<_ForwardIter>::value_type>);
template<typename _Tp, typename _Integer, typename _MonoidOperation>
while (__first != __last) inline _Tp
*__first++ = __value++; power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
} { return __power(__x, __n, __monoid_op); }
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.
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,
typename iterator_traits<_ForwardIter>::value_type>);
while (__first != __last)
*__first++ = __value++;
}
} // namespace std } // namespace std
......
...@@ -65,242 +65,214 @@ ...@@ -65,242 +65,214 @@
namespace std namespace std
{ {
// uninitialized_copy // uninitialized_copy
// Valid if copy construction is equivalent to assignment, and if the template<typename _InputIter, typename _ForwardIter>
// destructor is trivial. inline _ForwardIter
template <class _InputIter, class _ForwardIter> __uninitialized_copy_aux(_InputIter __first, _InputIter __last,
inline _ForwardIter _ForwardIter __result,
__uninitialized_copy_aux(_InputIter __first, _InputIter __last, __true_type)
_ForwardIter __result, { return copy(__first, __last, __result); }
__true_type)
{ template<typename _InputIter, typename _ForwardIter>
return copy(__first, __last, __result); _ForwardIter
} __uninitialized_copy_aux(_InputIter __first, _InputIter __last,
_ForwardIter __result,
template <class _InputIter, class _ForwardIter> __false_type)
_ForwardIter {
__uninitialized_copy_aux(_InputIter __first, _InputIter __last, _ForwardIter __cur = __result;
_ForwardIter __result, __STL_TRY {
__false_type) for ( ; __first != __last; ++__first, ++__cur)
{ _Construct(&*__cur, *__first);
_ForwardIter __cur = __result; return __cur;
__STL_TRY { }
for ( ; __first != __last; ++__first, ++__cur) __STL_UNWIND(_Destroy(__result, __cur));
_Construct(&*__cur, *__first); }
return __cur;
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());
}
inline char*
uninitialized_copy(const char* __first, const char* __last, char* __result)
{
memmove(__result, __first, __last - __first);
return __result + (__last - __first);
} }
__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;
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) {
memmove(__result, __first, __last - __first);
return __result + (__last - __first);
}
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)
template <class _InputIter, class _Size, class _ForwardIter> inline wchar_t*
pair<_InputIter, _ForwardIter> uninitialized_copy(const wchar_t* __first, const wchar_t* __last,
__uninitialized_copy_n(_InputIter __first, _Size __count, wchar_t* __result)
_ForwardIter __result, {
input_iterator_tag) memmove(__result, __first, sizeof(wchar_t) * (__last - __first));
{ return __result + (__last - __first);
_ForwardIter __cur = __result;
__STL_TRY {
for ( ; __count > 0 ; --__count, ++__first, ++__cur)
_Construct(&*__cur, *__first);
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,
_ForwardIter __result,
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,
_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,
_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,
const _Tp& __x, __true_type)
{
fill(__first, __last, __x);
}
template <class _ForwardIter, class _Tp> // uninitialized_copy_n (not part of the C++ standard)
void
__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, template<typename _InputIter, typename _Size, typename _ForwardIter>
const _Tp& __x, __false_type) pair<_InputIter, _ForwardIter>
{ __uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __cur = __first; _ForwardIter __result,
__STL_TRY { input_iterator_tag)
for ( ; __cur != __last; ++__cur) {
_Construct(&*__cur, __x); _ForwardIter __cur = __result;
} __STL_TRY {
__STL_UNWIND(_Destroy(__first, __cur)); for ( ; __count > 0 ; --__count, ++__first, ++__cur)
} _Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
template <class _ForwardIter, class _Tp, class _Tp1> }
inline void __uninitialized_fill(_ForwardIter __first, __STL_UNWIND(_Destroy(__result, __cur));
_ForwardIter __last, const _Tp& __x, _Tp1*) }
{
typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
__uninitialized_fill_aux(__first, __last, __x, _Is_POD()); inline pair<_RandomAccessIter, _ForwardIter>
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
} _ForwardIter __result,
random_access_iterator_tag)
template <class _ForwardIter, class _Tp> {
inline void uninitialized_fill(_ForwardIter __first, _RandomAccessIter __last = __first + __count;
_ForwardIter __last, return pair<_RandomAccessIter, _ForwardIter>(
const _Tp& __x) __last,
{ uninitialized_copy(__first, __last, __result));
__uninitialized_fill(__first, __last, __x, __value_type(__first)); }
}
template<typename _InputIter, typename _Size, typename _ForwardIter>
// Valid if copy construction is equivalent to assignment, and if the inline pair<_InputIter, _ForwardIter>
// destructor is trivial. __uninitialized_copy_n(_InputIter __first, _Size __count,
template <class _ForwardIter, class _Size, class _Tp> _ForwardIter __result) {
inline _ForwardIter return __uninitialized_copy_n(__first, __count, __result,
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, __iterator_category(__first));
const _Tp& __x, __true_type) }
{
return fill_n(__first, __n, __x); template<typename _InputIter, typename _Size, typename _ForwardIter>
} inline pair<_InputIter, _ForwardIter>
uninitialized_copy_n(_InputIter __first, _Size __count,
template <class _ForwardIter, class _Size, class _Tp> _ForwardIter __result) {
_ForwardIter return __uninitialized_copy_n(__first, __count, __result,
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, __iterator_category(__first));
const _Tp& __x, __false_type) }
{
_ForwardIter __cur = __first; // Valid if copy construction is equivalent to assignment, and if the
__STL_TRY { // destructor is trivial.
for ( ; __n > 0; --__n, ++__cur) template<typename _ForwardIter, typename _Tp>
_Construct(&*__cur, __x); inline void
return __cur; __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
} const _Tp& __x, __true_type)
__STL_UNWIND(_Destroy(__first, __cur)); { fill(__first, __last, __x); }
}
template<typename _ForwardIter, typename _Tp>
template <class _ForwardIter, class _Size, class _Tp, class _Tp1> void
inline _ForwardIter __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
__uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*) const _Tp& __x, __false_type)
{ {
typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; _ForwardIter __cur = __first;
return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); __STL_TRY {
} for ( ; __cur != __last; ++__cur)
_Construct(&*__cur, __x);
template <class _ForwardIter, class _Size, class _Tp> }
inline _ForwardIter __STL_UNWIND(_Destroy(__first, __cur));
uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) }
{
return __uninitialized_fill_n(__first, __n, __x, __value_type(__first)); template<typename _ForwardIter, typename _Tp>
} inline void
uninitialized_fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x)
// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, {
// __uninitialized_fill_copy. typedef typename iterator_traits<_ForwardIter>::value_type _ValueType;
typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD;
// __uninitialized_copy_copy __uninitialized_fill_aux(__first, __last, __x, _Is_POD());
// Copies [first1, last1) into [result, result + (last1 - first1)), and }
// copies [first2, last2) into
// [result, result + (last1 - first1) + (last2 - first2)). // Valid if copy construction is equivalent to assignment, and if the
// destructor is trivial.
template <class _InputIter1, class _InputIter2, class _ForwardIter> template<typename _ForwardIter, typename _Size, typename _Tp>
inline _ForwardIter inline _ForwardIter
__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
_InputIter2 __first2, _InputIter2 __last2, const _Tp& __x, __true_type)
_ForwardIter __result) {
{ return fill_n(__first, __n, __x);
_ForwardIter __mid = uninitialized_copy(__first1, __last1, __result); }
__STL_TRY {
return uninitialized_copy(__first2, __last2, __mid); template<typename _ForwardIter, typename _Size, typename _Tp>
} _ForwardIter
__STL_UNWIND(_Destroy(__result, __mid)); __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
} const _Tp& __x, __false_type)
{
// __uninitialized_fill_copy _ForwardIter __cur = __first;
// Fills [result, mid) with x, and copies [first, last) into __STL_TRY {
// [mid, mid + (last - first)). for ( ; __n > 0; --__n, ++__cur)
template <class _ForwardIter, class _Tp, class _InputIter> _Construct(&*__cur, __x);
inline _ForwardIter return __cur;
__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, }
const _Tp& __x, __STL_UNWIND(_Destroy(__first, __cur));
_InputIter __first, _InputIter __last) }
{
uninitialized_fill(__result, __mid, __x); template<typename _ForwardIter, typename _Size, typename _Tp>
__STL_TRY { inline _ForwardIter
return uninitialized_copy(__first, __last, __mid); uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x)
} {
__STL_UNWIND(_Destroy(__result, __mid)); 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());
// __uninitialized_copy_fill }
// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and
// fills [first2 + (last1 - first1), last2) with x. // Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill,
template <class _InputIter, class _ForwardIter, class _Tp> // __uninitialized_fill_copy.
inline void
__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1, // __uninitialized_copy_copy
_ForwardIter __first2, _ForwardIter __last2, // Copies [first1, last1) into [result, result + (last1 - first1)), and
const _Tp& __x) // copies [first2, last2) into
{ // [result, result + (last1 - first1) + (last2 - first2)).
_ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2);
__STL_TRY { template<typename _InputIter1, typename _InputIter2, typename _ForwardIter>
uninitialized_fill(__mid2, __last2, __x); inline _ForwardIter
} __uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
__STL_UNWIND(_Destroy(__first2, __mid2)); _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<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<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 } // namespace std
......
...@@ -124,7 +124,7 @@ toplevel_srcdir = @toplevel_srcdir@ ...@@ -124,7 +124,7 @@ toplevel_srcdir = @toplevel_srcdir@
AUTOMAKE_OPTIONS = 1.3 cygnus AUTOMAKE_OPTIONS = 1.3 cygnus
mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs 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 = @GLIBCPP_BUILD_LIBIO_FALSE@noinst_LTLIBRARIES =
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES # Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
...@@ -132,20 +132,14 @@ GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@ ...@@ -132,20 +132,14 @@ GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@ TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
LIBIO_INCLUDES = @LIBIO_INCLUDES@ LIBIO_INCLUDES = @LIBIO_INCLUDES@
INCLUDES = \ INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBIO_INCLUDES) $(TOPLEVEL_INCLUDES)
-nostdinc++ \
$(GLIBCPP_INCLUDES) $(LIBIO_INCLUDES) $(TOPLEVEL_INCLUDES)
libio_headers = \ libio_headers = libio.h libioP.h iolibio.h
libio.h libioP.h iolibio.h
@GLIBCPP_NEED_LIBIO_TRUE@LIBIO_SRCS = @GLIBCPP_NEED_LIBIO_TRUE@\ @GLIBCPP_NEED_LIBIO_TRUE@LIBIO_SRCS = filedoalloc.c genops.c fileops.c stdfiles.c c_codecvt.c iofclose.c iofopen.c
@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_FALSE@LIBIO_SRCS = @GLIBCPP_NEED_LIBIO_FALSE@LIBIO_SRCS =
@GLIBCPP_NEED_WLIBIO_TRUE@LIBIO_WSRCS = @GLIBCPP_NEED_WLIBIO_TRUE@\ @GLIBCPP_NEED_WLIBIO_TRUE@LIBIO_WSRCS = wfiledoalloc.c wfileops.c wgenops.c iofwide.c
@GLIBCPP_NEED_WLIBIO_TRUE@ wfiledoalloc.c wfileops.c wgenops.c iofwide.c
@GLIBCPP_NEED_WLIBIO_FALSE@LIBIO_WSRCS = @GLIBCPP_NEED_WLIBIO_FALSE@LIBIO_WSRCS =
EXTRA_DIST = iostreamP.h EXTRA_DIST = iostreamP.h
......
...@@ -129,18 +129,13 @@ mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs ...@@ -129,18 +129,13 @@ mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
noinst_LTLIBRARIES = libmath.la noinst_LTLIBRARIES = libmath.la
EXTRA_LONG_DOUBLE_yes = \ EXTRA_LONG_DOUBLE_yes = hypotl.c signbitl.c
hypotl.c signbitl.c
EXTRA_DIST = \ EXTRA_DIST = hypot.c hypotf.c $(EXTRA_LONG_DOUBLE_yes)
hypot.c hypotf.c \
$(EXTRA_LONG_DOUBLE_yes)
libmath_la_LIBADD = \ libmath_la_LIBADD = @LIBMATHOBJS@ $(EXTRA_LONG_DOUBLE_$(USE_COMPLEX_LONG_DOUBLE))
@LIBMATHOBJS@ \
$(EXTRA_LONG_DOUBLE_$(USE_COMPLEX_LONG_DOUBLE))
libmath_la_DEPENDENCIES = $(libmath_la_LIBADD) libmath_la_DEPENDENCIES = $(libmath_la_LIBADD)
...@@ -152,8 +147,7 @@ LINK = $(LIBTOOL) --mode=link "$(CCLD)" $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ ...@@ -152,8 +147,7 @@ LINK = $(LIBTOOL) --mode=link "$(CCLD)" $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES # Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@ TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
INCLUDES = \ INCLUDES = $(TOPLEVEL_INCLUDES)
$(TOPLEVEL_INCLUDES)
CONFIG_HEADER = ../config.h CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
......
...@@ -144,50 +144,24 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@ ...@@ -144,50 +144,24 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@
# These bits are all figured out from configure. Look in acinclude.m4 # 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 # 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. # NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
CONFIG_CXXFLAGS = \ CONFIG_CXXFLAGS = @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
@EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
# Warning flags to use. # Warning flags to use.
WARN_CXXFLAGS = \ WARN_CXXFLAGS = @WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
@WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES # Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@ GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@ LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
INCLUDES = \ INCLUDES = -I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include $(GLIBCPP_INCLUDES) $(LIBSUPCXX_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) libsupc___la_SOURCES = $(sources)
...@@ -203,12 +177,7 @@ LIBSUPCXX_CXXFLAGS = $(LIBSUPCXX_PICFLAGS) ...@@ -203,12 +177,7 @@ LIBSUPCXX_CXXFLAGS = $(LIBSUPCXX_PICFLAGS)
# set this option because CONFIG_CXXFLAGS has to be after # set this option because CONFIG_CXXFLAGS has to be after
# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
# as the occasion call for it. (ie, --enable-debug) # as the occasion call for it. (ie, --enable-debug)
AM_CXXFLAGS = \ AM_CXXFLAGS = -fno-implicit-templates $(LIBSUPCXX_CXXFLAGS) $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
-fno-implicit-templates \
$(LIBSUPCXX_CXXFLAGS) \
$(WARN_CXXFLAGS) \
$(OPTIMIZE_CXXFLAGS) \
$(CONFIG_CXXFLAGS)
# libstdc++ libtool notes # libstdc++ libtool notes
...@@ -232,9 +201,7 @@ AM_CXXFLAGS = \ ...@@ -232,9 +201,7 @@ AM_CXXFLAGS = \
# #
# We have to put --tag disable-shared after --tag CXX lest things # We have to put --tag disable-shared after --tag CXX lest things
# CXX undo the affect of disable-shared. # CXX undo the affect of disable-shared.
LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared \ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared --mode=compile $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
--mode=compile $(CXX) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
# 3) We'd have a problem when building the shared libstdc++ object if # 3) We'd have a problem when building the shared libstdc++ object if
...@@ -243,9 +210,7 @@ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared \ ...@@ -243,9 +210,7 @@ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared \
# course is problematic at this point. So, we get the top-level # course is problematic at this point. So, we get the top-level
# directory to configure libstdc++-v3 to use gcc as the C++ # directory to configure libstdc++-v3 to use gcc as the C++
# compilation driver. # compilation driver.
CXXLINK = $(LIBTOOL) --tag CXX --tag disable-shared \ CXXLINK = $(LIBTOOL) --tag CXX --tag disable-shared --mode=link $(CXX) @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
--mode=link $(CXX) \
@OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
CONFIG_HEADER = ../config.h CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
......
...@@ -134,13 +134,11 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@ ...@@ -134,13 +134,11 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@
# These bits are all figured out from configure. Look in acinclude.m4 # 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 # 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. # NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
CONFIG_CXXFLAGS = \ CONFIG_CXXFLAGS = @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
@EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@
# Warning flags to use. # Warning flags to use.
WARN_CXXFLAGS = \ WARN_CXXFLAGS = @WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
@WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES # Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
...@@ -150,28 +148,17 @@ LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@ ...@@ -150,28 +148,17 @@ LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
LIBIO_INCLUDES = @LIBIO_INCLUDES@ LIBIO_INCLUDES = @LIBIO_INCLUDES@
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@ TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
INCLUDES = \ INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES) $(LIBIO_INCLUDES) $(LIBMATH_INCLUDES) $(TOPLEVEL_INCLUDES)
-nostdinc++ \
$(GLIBCPP_INCLUDES) \
$(LIBSUPCXX_INCLUDES) $(LIBIO_INCLUDES) $(LIBMATH_INCLUDES) \
$(TOPLEVEL_INCLUDES)
sources = \ 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
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 VPATH = $(top_srcdir):$(top_srcdir)/src
libstdc___la_SOURCES = $(sources) libstdc___la_SOURCES = $(sources)
libstdc___la_LIBADD = \ libstdc___la_LIBADD = ../libmath/libmath.la @libio_la@ ../libsupc++/libsupc++convenience.la
../libmath/libmath.la @libio_la@ \
../libsupc++/libsupc++convenience.la
libstdc___la_LDFLAGS = -version-info 3:0:0 -lm libstdc___la_LDFLAGS = -version-info 3:0:0 -lm
...@@ -191,12 +178,7 @@ GLIBCPP_INCLUDE_DIR = @glibcpp_builddir@/include ...@@ -191,12 +178,7 @@ GLIBCPP_INCLUDE_DIR = @glibcpp_builddir@/include
# The no-implicit-templates flag will generate unresolved references to # The no-implicit-templates flag will generate unresolved references to
# the concept-checking symbols. So we must disable the checks while # the concept-checking symbols. So we must disable the checks while
# actually building the library. # actually building the library.
AM_CXXFLAGS = \ AM_CXXFLAGS = -fno-implicit-templates $(LIBSUPCXX_CXXFLAGS) $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
-fno-implicit-templates \
$(LIBSUPCXX_CXXFLAGS) \
$(WARN_CXXFLAGS) \
$(OPTIMIZE_CXXFLAGS) \
$(CONFIG_CXXFLAGS)
# libstdc++ libtool notes # libstdc++ libtool notes
...@@ -217,8 +199,7 @@ AM_CXXFLAGS = \ ...@@ -217,8 +199,7 @@ AM_CXXFLAGS = \
# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
# attempt to infer which configuration to use # attempt to infer which configuration to use
LTCXXCOMPILE = $(LIBTOOL) --tag CXX --mode=compile $(CXX) $(INCLUDES) \ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --mode=compile $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
$(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
# 3) We'd have a problem when building the shared libstdc++ object if # 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) \ ...@@ -227,8 +208,7 @@ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --mode=compile $(CXX) $(INCLUDES) \
# course is problematic at this point. So, we get the top-level # course is problematic at this point. So, we get the top-level
# directory to configure libstdc++-v3 to use gcc as the C++ # directory to configure libstdc++-v3 to use gcc as the C++
# compilation driver. # compilation driver.
CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) \ CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
@OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
CONFIG_HEADER = ../config.h CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
......
// 1999-06-29 // 1999-06-29 bkoz
// 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 // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -57,10 +56,36 @@ void test02() ...@@ -57,10 +56,36 @@ void test02()
std::vector<int> v2 (v1); 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() int main()
{ {
test01(); test01();
test02(); test02();
test03();
return 0; return 0;
} }
// 1999-11-09 bkoz // 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 // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
// 23.2.4.3 vector modifiers // 23.2.4.3 vector modifiers
#include <vector> #include <vector>
#include <debug_assert.h> #include "debug_assert.h"
bool test = true;
template<typename T> template<typename T>
struct A { }; struct A { };
...@@ -29,10 +31,9 @@ template<typename T> ...@@ -29,10 +31,9 @@ template<typename T>
struct B { }; struct B { };
// vector::insert(iterator, inputiterator first, inputiterator last) // vector::insert(iterator, inputiterator first, inputiterator last)
bool test01() void
test01()
{ {
bool test = true;
// POD types // POD types
typedef std::vector<int> vec_POD; typedef std::vector<int> vec_POD;
vec_POD vec01; vec_POD vec01;
...@@ -46,20 +47,42 @@ bool test01() ...@@ -46,20 +47,42 @@ bool test01()
A<B> np01; A<B> np01;
A<B>* pnp01 = &np01; A<B>* pnp01 = &np01;
vec02.insert(vec02.begin(), pnp01, pnp01 + 1); vec02.insert(vec02.begin(), pnp01, pnp01 + 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;
// 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);
// Test that assign compiles. // assign from iterator range
vec01.assign (pi01, pi01 + 1); 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()));
#ifdef DEBUG_ASSERT // assign from initializer range with resize
assert(test); v4.assign(M, K);
#endif VERIFY(std::equal(v4.begin(), v4.end(), B));
VERIFY(std::equal(B, B + M, v4.begin()));
return test; VERIFY((v4.size() == M) && (M != N));
} }
int main() int main()
{ {
test01(); test01();
test03();
return 0; return !test;
} }
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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 ...@@ -128,14 +128,10 @@ AUTOMAKE_OPTIONS = foreign dejagnu
DEJATOOL = libstdc++-v3 DEJATOOL = libstdc++-v3
EXPECT = `if [ -f @glibcpp_builddir@/../../expect/expect ] ; then \ EXPECT = `if [ -f @glibcpp_builddir@/../../expect/expect ] ; then echo @glibcpp_builddir@/../../expect/expect ; else echo expect ; fi`
echo @glibcpp_builddir@/../../expect/expect ; \
else echo expect ; fi`
RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then \ RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then echo @glibcpp_srcdir@/../dejagnu/runtest ; else echo runtest; fi`
echo @glibcpp_srcdir@/../dejagnu/runtest ; \
else echo runtest; fi`
RUNTESTFLAGS = RUNTESTFLAGS =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment