Commit 285b36d6 by Benjamin Kosnik

[multiple changes]


2003-11-11  Doug Gregor  <gregod@cs.rpi.edu>

	* docs/html/debug.html: Document libstdc++ debug mode.
	* docs/html/debug_mode.html: Document libstdc++ debug mode design.
	* docs/html/test.html: Document how to test under debug mode.
	* docs/html/17_intro/howto.html: Document debug-mode macros.
	* include/Makefile.am: Install debug-mode headers.
	* src/Makefile.am: Include debug.cc.
	* include/bits/basic_string.tcc:
	  (basic_string::_S_construct): Fix NULL pointer check.
	  (__is_null_pointer): New.
	  Add precondition annotations.
	* include/bits/stream_iterator.h (istream_iterator,
	ostream_iterator): Added precondition annotations.
	* include/bits/streambuf_iterator.h (istreambuf_iterator): Ditto.
	* include/bits/stl_queue.h (queue, priority_queue): Ditto.
	* include/bits/stl_stack.h (stack): Ditto.
	* include/bits/basic_string.h (basic_string): Ditto.
	* include/bits/basic_string.tcc (basic_string): Ditto.
	* include/std/std_memory.h (auto_ptr): Ditto.
	* include/std/std_valarray.h (valarray): Ditto.
	* include/bits/stl_algo.h: Added algorithm precondition
	annotations.
	* include/bits/stl_algobase.h: Added algorithm precondition
	annotations.
	* include/bits/stl_numeric.h: Ditto.
	* include/ext/algorithm: Added algorithm precondition
	annotations.
	(__is_heap): Moved away from here.
	* include/bits/stl_heap.h: Added algorithm precondition
	annotations.
	(__is_heap): Moved to the top of this file.
	(__is_heap): Added iterator range overloads.
	* testsuite/20_util/auto_ptr_neg.cc: Fix line numbers to match up
	with changes in std_memory.h.
	* testsuite/23_containers/list/operators/4.cc: Don't verify
	performance guarantees when in debug mode.
	* testsuite/23_containers/bitset/invalidation/1.cc: New.
	* testsuite/23_containers/deque/invalidation/1.cc: New.
	* testsuite/23_containers/deque/invalidation/2.cc: New.
	* testsuite/23_containers/deque/invalidation/3.cc: New.
	* testsuite/23_containers/deque/invalidation/4.cc: New.
	* testsuite/23_containers/list/invalidation/1.cc: New.
	* testsuite/23_containers/list/invalidation/2.cc: New.
	* testsuite/23_containers/list/invalidation/3.cc: New.
	* testsuite/23_containers/list/invalidation/4.cc: New.
	* testsuite/23_containers/map/invalidation/1.cc: New.
	* testsuite/23_containers/map/invalidation/2.cc: New.
	* testsuite/23_containers/multimap/invalidation/1.cc: New.
	* testsuite/23_containers/multimap/invalidation/2.cc: New.
	* testsuite/23_containers/multiset/invalidation/1.cc: New.
	* testsuite/23_containers/multiset/invalidation/2.cc: New.
	* testsuite/23_containers/set/invalidation/1.cc: New.
	* testsuite/23_containers/set/invalidation/2.cc: New.
	* testsuite/23_containers/vector/invalidation/1.cc: New.
	* testsuite/23_containers/vector/invalidation/2.cc: New.
	* testsuite/23_containers/vector/invalidation/3.cc: New.
	* testsuite/23_containers/vector/invalidation/4.cc: New.
	* testsuite/25_algorithms/heap.cc: Don't verify
	performance guarantees when in debug mode.
	* include/debug/bitset: New.
	* include/debug/debug.h: New.
	* include/debug/deque: New.
	* include/debug/formatter.h: New.
	* include/debug/hash_map: New.
	* include/debug/hash_map.h: New.
	* include/debug/hash_multimap.h: New.
	* include/debug/hash_set: New.
	* include/debug/hash_set.h: New.
	* include/debug/hash_multiset.h: New.
	* include/debug/list: New.
	* include/debug/map: New.
	* include/debug/map.h: New.
	* include/debug/multimap.h: New.
	* include/debug/multiset.h: New.
	* include/debug/safe_base.h: New.
	* include/debug/safe_iterator.h: New.
	* include/debug/safe_iterator.tcc: New.
	* include/debug/safe_sequence.h: New.
	* include/debug/set: New.
	* include/debug/set.h: New.
	* include/debug/string: New.
	* include/debug/vector: New.
	* src/debug.cc: New.
	* config/linker-map.gnu: Add debug mode symbols.

2003-11-11  Benjamin Kosnik  <bkoz@redhat.com>

	* src/string-inst.cc: Tweak namespaces.
	* src/misc-inst.cc: Same.
	* docs/html/debug.html: Edits.
	* config/link-map.gnu: Remove cruft.

	* include/bits/c++config: Add in namespace associations.
	* include/std/std_bitset.h: Adjust namespace to __gnu_norm,
	comment tweaks.
	* include/bits/deque.tcc: Same.
	* include/bits/list.tcc: Same.
	* include/bits/stl_bvector.h: Same.
	* include/bits/stl_deque.h: Same.
	* include/bits/stl_list.h: Same.
	* include/bits/stl_map.h: Same.
	* include/bits/stl_multimap.h: Same.
	* include/bits/stl_multiset.h: Same.
	* include/bits/stl_set.h: Same.
	* include/bits/stl_vector.h: Same.
	* include/bits/vector.tcc: Same.

	* include/std/std_algorithm.h: Remove markup comments.
	* include/std/std_functional.h: Same.
	* include/std/std_iterator.h: Same.
	* include/std/std_numeric.h: Same.
	* include/std/std_utility.h: Same.
	* include/bits/stl_queue.h: Formatting tweaks.
	* include/bits/stl_stack.h: Same.
	* include/std/std_deque.h: Include debugging version in debug mode.
	* include/std/std_list.h: Same.
	* include/std/std_map.h: Same.
	* include/std/std_set.h: Same.
	* include/std/std_vector.h: Same.
	* include/std/std_queue.h: Use deque, vector.
	* include/std/std_stack.h: Same.

From-SVN: r73459
parent 0259239a
2003-11-11 Doug Gregor <gregod@cs.rpi.edu>
* docs/html/debug.html: Document libstdc++ debug mode.
* docs/html/debug_mode.html: Document libstdc++ debug mode design.
* docs/html/test.html: Document how to test under debug mode.
* docs/html/17_intro/howto.html: Document debug-mode macros.
* include/Makefile.am: Install debug-mode headers.
* src/Makefile.am: Include debug.cc.
* include/bits/basic_string.tcc:
(basic_string::_S_construct): Fix NULL pointer check.
(__is_null_pointer): New.
Add precondition annotations.
* include/bits/stream_iterator.h (istream_iterator,
ostream_iterator): Added precondition annotations.
* include/bits/streambuf_iterator.h (istreambuf_iterator): Ditto.
* include/bits/stl_queue.h (queue, priority_queue): Ditto.
* include/bits/stl_stack.h (stack): Ditto.
* include/bits/basic_string.h (basic_string): Ditto.
* include/bits/basic_string.tcc (basic_string): Ditto.
* include/std/std_memory.h (auto_ptr): Ditto.
* include/std/std_valarray.h (valarray): Ditto.
* include/bits/stl_algo.h: Added algorithm precondition
annotations.
* include/bits/stl_algobase.h: Added algorithm precondition
annotations.
* include/bits/stl_numeric.h: Ditto.
* include/ext/algorithm: Added algorithm precondition
annotations.
(__is_heap): Moved away from here.
* include/bits/stl_heap.h: Added algorithm precondition
annotations.
(__is_heap): Moved to the top of this file.
(__is_heap): Added iterator range overloads.
* testsuite/20_util/auto_ptr_neg.cc: Fix line numbers to match up
with changes in std_memory.h.
* testsuite/23_containers/list/operators/4.cc: Don't verify
performance guarantees when in debug mode.
* testsuite/23_containers/bitset/invalidation/1.cc: New.
* testsuite/23_containers/deque/invalidation/1.cc: New.
* testsuite/23_containers/deque/invalidation/2.cc: New.
* testsuite/23_containers/deque/invalidation/3.cc: New.
* testsuite/23_containers/deque/invalidation/4.cc: New.
* testsuite/23_containers/list/invalidation/1.cc: New.
* testsuite/23_containers/list/invalidation/2.cc: New.
* testsuite/23_containers/list/invalidation/3.cc: New.
* testsuite/23_containers/list/invalidation/4.cc: New.
* testsuite/23_containers/map/invalidation/1.cc: New.
* testsuite/23_containers/map/invalidation/2.cc: New.
* testsuite/23_containers/multimap/invalidation/1.cc: New.
* testsuite/23_containers/multimap/invalidation/2.cc: New.
* testsuite/23_containers/multiset/invalidation/1.cc: New.
* testsuite/23_containers/multiset/invalidation/2.cc: New.
* testsuite/23_containers/set/invalidation/1.cc: New.
* testsuite/23_containers/set/invalidation/2.cc: New.
* testsuite/23_containers/vector/invalidation/1.cc: New.
* testsuite/23_containers/vector/invalidation/2.cc: New.
* testsuite/23_containers/vector/invalidation/3.cc: New.
* testsuite/23_containers/vector/invalidation/4.cc: New.
* testsuite/25_algorithms/heap.cc: Don't verify
performance guarantees when in debug mode.
* include/debug/bitset: New.
* include/debug/debug.h: New.
* include/debug/deque: New.
* include/debug/formatter.h: New.
* include/debug/hash_map: New.
* include/debug/hash_map.h: New.
* include/debug/hash_multimap.h: New.
* include/debug/hash_set: New.
* include/debug/hash_set.h: New.
* include/debug/hash_multiset.h: New.
* include/debug/list: New.
* include/debug/map: New.
* include/debug/map.h: New.
* include/debug/multimap.h: New.
* include/debug/multiset.h: New.
* include/debug/safe_base.h: New.
* include/debug/safe_iterator.h: New.
* include/debug/safe_iterator.tcc: New.
* include/debug/safe_sequence.h: New.
* include/debug/set: New.
* include/debug/set.h: New.
* include/debug/string: New.
* include/debug/vector: New.
* src/debug.cc: New.
* config/linker-map.gnu: Add debug mode symbols.
2003-11-11 Benjamin Kosnik <bkoz@redhat.com>
* src/string-inst.cc: Tweak namespaces.
* src/misc-inst.cc: Same.
* docs/html/debug.html: Edits.
* config/link-map.gnu: Remove cruft.
* include/bits/c++config: Add in namespace associations.
* include/std/std_bitset.h: Adjust namespace to __gnu_norm,
comment tweaks.
* include/bits/deque.tcc: Same.
* include/bits/list.tcc: Same.
* include/bits/stl_bvector.h: Same.
* include/bits/stl_deque.h: Same.
* include/bits/stl_list.h: Same.
* include/bits/stl_map.h: Same.
* include/bits/stl_multimap.h: Same.
* include/bits/stl_multiset.h: Same.
* include/bits/stl_set.h: Same.
* include/bits/stl_vector.h: Same.
* include/bits/vector.tcc: Same.
* include/std/std_algorithm.h: Remove markup comments.
* include/std/std_functional.h: Same.
* include/std/std_iterator.h: Same.
* include/std/std_numeric.h: Same.
* include/std/std_utility.h: Same.
* include/bits/stl_queue.h: Formatting tweaks.
* include/bits/stl_stack.h: Same.
* include/std/std_deque.h: Include debugging version in debug mode.
* include/std/std_list.h: Same.
* include/std/std_map.h: Same.
* include/std/std_set.h: Same.
* include/std/std_vector.h: Same.
* include/std/std_queue.h: Use deque, vector.
* include/std/std_stack.h: Same.
2003-11-09 Paolo Carlini <pcarlini@suse.de> 2003-11-09 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (_M_insert_int, * include/bits/locale_facets.tcc (_M_insert_int,
......
...@@ -57,7 +57,11 @@ GLIBCXX_3.4 { ...@@ -57,7 +57,11 @@ GLIBCXX_3.4 {
std::__num_base::_S_atoms_out; std::__num_base::_S_atoms_out;
std::__moneypunct_cache*; std::__moneypunct_cache*;
std::__numpunct_cache*; std::__numpunct_cache*;
std::__timepunct_cache* std::__timepunct_cache*;
__gnu_norm::*;
__gnu_debug::_Safe_iterator_base*;
__gnu_debug::_Safe_sequence_base*;
__gnu_debug::_Error_formatter*
}; };
# Names not in an 'extern' block are mangled names. # Names not in an 'extern' block are mangled names.
...@@ -88,7 +92,7 @@ GLIBCXX_3.4 { ...@@ -88,7 +92,7 @@ GLIBCXX_3.4 {
# std::locale::facet destructors # std::locale::facet destructors
_ZNSt6locale5facetD*; _ZNSt6locale5facetD*;
# std::locale::_Impl constructors, destrutors # std::locale::_Impl constructors, destructors
_ZNSt6locale5_ImplC*; _ZNSt6locale5_ImplC*;
_ZNSt6locale5_ImplD*; _ZNSt6locale5_ImplD*;
...@@ -104,9 +108,6 @@ GLIBCXX_3.4 { ...@@ -104,9 +108,6 @@ GLIBCXX_3.4 {
_ZSt21_Rb_tree_rotate_rightPSt18_Rb_tree_node_baseRS0_; _ZSt21_Rb_tree_rotate_rightPSt18_Rb_tree_node_baseRS0_;
_ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_; _ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_;
# std::__ctype_abstract_base*
_ZNSt21__ctype_abstract_base*;
# std::__codecvt_abstract_base* # std::__codecvt_abstract_base*
_ZNStSt23__codecvt_abstract_base*; _ZNStSt23__codecvt_abstract_base*;
......
...@@ -339,6 +339,18 @@ ...@@ -339,6 +339,18 @@
violations of the requirements of the standard. This is described violations of the requirements of the standard. This is described
in more detail <a href="../19_diagnostics/howto.html#3">here</a>. in more detail <a href="../19_diagnostics/howto.html#3">here</a>.
</dd> </dd>
<dt><code>_GLIBCXX_DEBUG</code></dt>
<dd>Undefined by default. Configurable. When defined, compiles
user code using the <a href="../debug.html#safe">libstdc++ debug
mode</a>.
</dd>
<dt><code>_GLIBCXX_DEBUG_PEDANTIC</code></dt>
<dd>Undefined by default. Configurable. When defined while
compiling with the <a href="../debug.html#safe">libstdc++ debug
mode</a>, makes the debug mode extremely picky by making the use
of libstdc++ extensions and libstdc++-specific behavior into
errors.
</dd>
<!-- <!--
<dt><code></code></dt> <dt><code></code></dt>
<dd> <dd>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
<li><a href="#util">Utilities: abicheck and libv3test</a></li> <li><a href="#util">Utilities: abicheck and libv3test</a></li>
<li><a href="#new">How to write a new test case</a></li> <li><a href="#new">How to write a new test case</a></li>
<li><a href="#check">Options for running the tests</a></li> <li><a href="#check">Options for running the tests</a></li>
<li><a href="#debug">Running debug-mode tests</a></li>
<li><a href="#future">Future</a></li> <li><a href="#future">Future</a></li>
<li><a href="#internals">DejaGNU internals</a></li> <li><a href="#internals">DejaGNU internals</a></li>
</ul> </ul>
...@@ -544,6 +545,19 @@ make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=arm-sim" ...@@ -544,6 +545,19 @@ make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=arm-sim"
for which files to examine. for which files to examine.
</p> </p>
<hr/>
<h2><a name="debug">Running debug-mode tests</a></h2>
<p>To run the libstdc++ test suite under the <a
href="debug.html#safe">debug mode</a>,
edit <code>libstdc++/scripts/testsuite_flags</code> to add the
compile-time flag <code>-D_GLIBCXX_DEBUG</code> to the result
printed by the <code>--build-cxx</code> option. Additionally, add
the <code>-D_GLIBCXX_DEBUG_PEDANTIC</code> flag to turn on pedantic
checking. The libstdc++ test suite should produce precisely the same
results under debug mode that it does under release mode: any
deviation indicates an error in either the library or the test
suite.</p>
<hr /> <hr />
<h2><a name="future">Future</a></h2> <h2><a name="future">Future</a></h2>
......
...@@ -224,7 +224,6 @@ ext_headers = \ ...@@ -224,7 +224,6 @@ ext_headers = \
${ext_srcdir}/hash_fun.h \ ${ext_srcdir}/hash_fun.h \
${ext_srcdir}/hashtable.h ${ext_srcdir}/hashtable.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) c_base_srcdir = $(C_INCLUDE_DIR)
c_base_builddir = . c_base_builddir = .
...@@ -290,6 +289,34 @@ c_compatibility_headers = \ ...@@ -290,6 +289,34 @@ c_compatibility_headers = \
${c_compatibility_srcdir}/wchar.h \ ${c_compatibility_srcdir}/wchar.h \
${c_compatibility_srcdir}/wctype.h ${c_compatibility_srcdir}/wctype.h
# Debug mode headers
debug_srcdir = ${glibcxx_srcdir}/include/debug
debug_builddir = ./debug
debug_headers = \
${debug_srcdir}/bitset \
${debug_srcdir}/debug.h \
${debug_srcdir}/deque \
${debug_srcdir}/formatter.h \
${debug_srcdir}/hash_map \
${debug_srcdir}/hash_map.h \
${debug_srcdir}/hash_multimap.h \
${debug_srcdir}/hash_multiset.h \
${debug_srcdir}/hash_set \
${debug_srcdir}/hash_set.h \
${debug_srcdir}/list \
${debug_srcdir}/map \
${debug_srcdir}/map.h \
${debug_srcdir}/multimap.h \
${debug_srcdir}/multiset.h \
${debug_srcdir}/safe_base.h \
${debug_srcdir}/safe_iterator.h \
${debug_srcdir}/safe_iterator.tcc \
${debug_srcdir}/safe_sequence.h \
${debug_srcdir}/set \
${debug_srcdir}/set.h \
${debug_srcdir}/string \
${debug_srcdir}/vector
# Some of the different "C" header models need extra files. # Some of the different "C" header models need extra files.
# Some "C" header schemes require the "C" compatibility headers. # Some "C" header schemes require the "C" compatibility headers.
# For --enable-cheaders=c_std # For --enable-cheaders=c_std
...@@ -350,7 +377,7 @@ endif ...@@ -350,7 +377,7 @@ endif
# CLEANFILES and all-local are kept up-to-date. # CLEANFILES and all-local are kept up-to-date.
allstamped = \ allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
stamp-backward stamp-ext stamp-host stamp-backward stamp-ext stamp-debug stamp-host
# List of all files that are created by explicit building, editing, or # List of all files that are created by explicit building, editing, or
# catenation. # catenation.
...@@ -429,6 +456,15 @@ stamp-ext: ${ext_headers} ...@@ -429,6 +456,15 @@ stamp-ext: ${ext_headers}
fi ;\ fi ;\
$(STAMP) stamp-ext $(STAMP) stamp-ext
stamp-debug: ${debug_headers}
@if [ ! -d "${debug_builddir}" ]; then \
mkdir -p ${debug_builddir} ;\
fi ;\
if [ ! -f stamp-debug ]; then \
(cd ${debug_builddir} && @LN_S@ $? . || true) ;\
fi ;\
$(STAMP) stamp-debug
stamp-${host_alias}: stamp-${host_alias}:
@if [ ! -d ${host_builddir} ]; then \ @if [ ! -d ${host_builddir} ]; then \
mkdir -p ${host_builddir} ;\ mkdir -p ${host_builddir} ;\
...@@ -556,6 +592,9 @@ install-headers: ...@@ -556,6 +592,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir}
for file in ${std_headers_rename}; do \ for file in ${std_headers_rename}; do \
$(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${debug_builddir}
for file in ${debug_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${debug_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir}
for file in ${host_headers} ${host_headers_extra} \ for file in ${host_headers} ${host_headers_extra} \
${thread_host_headers}; do \ ${thread_host_headers}; do \
......
...@@ -491,11 +491,40 @@ c_compatibility_headers = \ ...@@ -491,11 +491,40 @@ c_compatibility_headers = \
${c_compatibility_srcdir}/wctype.h ${c_compatibility_srcdir}/wctype.h
# Debug mode headers
debug_srcdir = ${glibcxx_srcdir}/include/debug
debug_builddir = ./debug
debug_headers = \
${debug_srcdir}/bitset \
${debug_srcdir}/debug.h \
${debug_srcdir}/deque \
${debug_srcdir}/formatter.h \
${debug_srcdir}/hash_map \
${debug_srcdir}/hash_map.h \
${debug_srcdir}/hash_multimap.h \
${debug_srcdir}/hash_multiset.h \
${debug_srcdir}/hash_set \
${debug_srcdir}/hash_set.h \
${debug_srcdir}/list \
${debug_srcdir}/map \
${debug_srcdir}/map.h \
${debug_srcdir}/multimap.h \
${debug_srcdir}/multiset.h \
${debug_srcdir}/safe_base.h \
${debug_srcdir}/safe_iterator.h \
${debug_srcdir}/safe_iterator.tcc \
${debug_srcdir}/safe_sequence.h \
${debug_srcdir}/set \
${debug_srcdir}/set.h \
${debug_srcdir}/string \
${debug_srcdir}/vector
@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra =
# Some of the different "C" header models need extra files. # Some of the different "C" header models need extra files.
# Some "C" header schemes require the "C" compatibility headers. # Some "C" header schemes require the "C" compatibility headers.
# For --enable-cheaders=c_std # For --enable-cheaders=c_std
@GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc @GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc
@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra =
@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = @GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
@GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers} @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers}
...@@ -546,7 +575,7 @@ PCHFLAGS = -Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS) ...@@ -546,7 +575,7 @@ PCHFLAGS = -Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS)
# CLEANFILES and all-local are kept up-to-date. # CLEANFILES and all-local are kept up-to-date.
allstamped = \ allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
stamp-backward stamp-ext stamp-host stamp-backward stamp-ext stamp-debug stamp-host
# List of all files that are created by explicit building, editing, or # List of all files that are created by explicit building, editing, or
...@@ -783,6 +812,15 @@ stamp-ext: ${ext_headers} ...@@ -783,6 +812,15 @@ stamp-ext: ${ext_headers}
fi ;\ fi ;\
$(STAMP) stamp-ext $(STAMP) stamp-ext
stamp-debug: ${debug_headers}
@if [ ! -d "${debug_builddir}" ]; then \
mkdir -p ${debug_builddir} ;\
fi ;\
if [ ! -f stamp-debug ]; then \
(cd ${debug_builddir} && @LN_S@ $? . || true) ;\
fi ;\
$(STAMP) stamp-debug
stamp-${host_alias}: stamp-${host_alias}:
@if [ ! -d ${host_builddir} ]; then \ @if [ ! -d ${host_builddir} ]; then \
mkdir -p ${host_builddir} ;\ mkdir -p ${host_builddir} ;\
...@@ -904,6 +942,9 @@ install-headers: ...@@ -904,6 +942,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir}
for file in ${std_headers_rename}; do \ for file in ${std_headers_rename}; do \
$(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${debug_builddir}
for file in ${debug_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${debug_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir}
for file in ${host_headers} ${host_headers_extra} \ for file in ${host_headers} ${host_headers_extra} \
${thread_host_headers}; do \ ${thread_host_headers}; do \
......
...@@ -45,6 +45,16 @@ ...@@ -45,6 +45,16 @@
namespace std namespace std
{ {
template<typename _Type>
inline bool
__is_null_pointer(_Type* __ptr)
{ return __ptr == 0; }
template<typename _Type>
inline bool
__is_null_pointer(const _Type&)
{ return false; }
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
const typename basic_string<_CharT, _Traits, _Alloc>::size_type const typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
...@@ -141,8 +151,8 @@ namespace std ...@@ -141,8 +151,8 @@ namespace std
if (__beg == __end && __a == _Alloc()) if (__beg == __end && __a == _Alloc())
return _S_empty_rep()._M_refdata(); return _S_empty_rep()._M_refdata();
// NB: Not required, but considered best practice. // NB: Not required, but considered best practice.
if (__builtin_expect(__beg == _InIterator(), 0)) if (__builtin_expect(__is_null_pointer(__beg), 0))
__throw_logic_error("basic_string::_S_construct NULL not valid"); __throw_logic_error("basic_string::_S_construct NULL not valid");
const size_type __dnew = static_cast<size_type>(std::distance(__beg, __end)); const size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
...@@ -215,12 +225,14 @@ namespace std ...@@ -215,12 +225,14 @@ namespace std
__str._M_fold(__pos, __n), __a), __a) __str._M_fold(__pos, __n), __a), __a)
{ } { }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
basic_string(const _CharT* __s, size_type __n, const _Alloc& __a) basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
: _M_dataplus(_S_construct(__s, __s + __n, __a), __a) : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
{ } { }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
basic_string(const _CharT* __s, const _Alloc& __a) basic_string(const _CharT* __s, const _Alloc& __a)
...@@ -233,7 +245,8 @@ namespace std ...@@ -233,7 +245,8 @@ namespace std
basic_string(size_type __n, _CharT __c, const _Alloc& __a) basic_string(size_type __n, _CharT __c, const _Alloc& __a)
: _M_dataplus(_S_construct(__n, __c, __a), __a) : _M_dataplus(_S_construct(__n, __c, __a), __a)
{ } { }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator> template<typename _InputIterator>
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
...@@ -275,6 +288,7 @@ namespace std ...@@ -275,6 +288,7 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
assign(const _CharT* __s, size_type __n) assign(const _CharT* __s, size_type __n)
{ {
__glibcxx_requires_string_len(__s, __n);
if (__n > this->max_size()) if (__n > this->max_size())
__throw_length_error("basic_string::assign"); __throw_length_error("basic_string::assign");
if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data()) if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
...@@ -313,6 +327,7 @@ namespace std ...@@ -313,6 +327,7 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
insert(size_type __pos, const _CharT* __s, size_type __n) insert(size_type __pos, const _CharT* __s, size_type __n)
{ {
__glibcxx_requires_string_len(__s, __n);
const size_type __size = this->size(); const size_type __size = this->size();
if (__pos > __size) if (__pos > __size)
__throw_out_of_range("basic_string::insert"); __throw_out_of_range("basic_string::insert");
...@@ -350,6 +365,7 @@ namespace std ...@@ -350,6 +365,7 @@ namespace std
replace(size_type __pos, size_type __n1, const _CharT* __s, replace(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2) size_type __n2)
{ {
__glibcxx_requires_string_len(__s, __n2);
const size_type __size = this->size(); const size_type __size = this->size();
if (__pos > __size) if (__pos > __size)
__throw_out_of_range("basic_string::replace"); __throw_out_of_range("basic_string::replace");
...@@ -727,6 +743,7 @@ namespace std ...@@ -727,6 +743,7 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
append(const _CharT* __s, size_type __n) append(const _CharT* __s, size_type __n)
{ {
__glibcxx_requires_string_len(__s, __n);
const size_type __len = __n + this->size(); const size_type __len = __n + this->size();
if (__len > this->capacity()) if (__len > this->capacity())
this->reserve(__len); this->reserve(__len);
...@@ -749,6 +766,7 @@ namespace std ...@@ -749,6 +766,7 @@ namespace std
operator+(const _CharT* __lhs, operator+(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Alloc>& __rhs) const basic_string<_CharT, _Traits, _Alloc>& __rhs)
{ {
__glibcxx_requires_string(__lhs);
typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
typedef typename __string_type::size_type __size_type; typedef typename __string_type::size_type __size_type;
const __size_type __len = _Traits::length(__lhs); const __size_type __len = _Traits::length(__lhs);
...@@ -783,6 +801,8 @@ namespace std ...@@ -783,6 +801,8 @@ namespace std
if (__n > this->size() - __pos) if (__n > this->size() - __pos)
__n = this->size() - __pos; __n = this->size() - __pos;
__glibcxx_requires_string_len(__s, __n);
traits_type::copy(__s, _M_data() + __pos, __n); traits_type::copy(__s, _M_data() + __pos, __n);
// 21.3.5.7 par 3: do not append null. (good.) // 21.3.5.7 par 3: do not append null. (good.)
...@@ -794,6 +814,8 @@ namespace std ...@@ -794,6 +814,8 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
find(const _CharT* __s, size_type __pos, size_type __n) const find(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_requires_string_len(__s, __n);
const size_type __size = this->size(); const size_type __size = this->size();
size_t __xpos = __pos; size_t __xpos = __pos;
const _CharT* __data = _M_data(); const _CharT* __data = _M_data();
...@@ -827,6 +849,8 @@ namespace std ...@@ -827,6 +849,8 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
rfind(const _CharT* __s, size_type __pos, size_type __n) const rfind(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_requires_string_len(__s, __n);
const size_type __size = this->size(); const size_type __size = this->size();
if (__n <= __size) if (__n <= __size)
{ {
...@@ -866,6 +890,8 @@ namespace std ...@@ -866,6 +890,8 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_requires_string_len(__s, __n);
for (; __n && __pos < this->size(); ++__pos) for (; __n && __pos < this->size(); ++__pos)
{ {
const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]); const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
...@@ -880,6 +906,8 @@ namespace std ...@@ -880,6 +906,8 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_requires_string_len(__s, __n);
size_type __size = this->size(); size_type __size = this->size();
if (__size && __n) if (__size && __n)
{ {
...@@ -900,6 +928,8 @@ namespace std ...@@ -900,6 +928,8 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_requires_string_len(__s, __n);
size_t __xpos = __pos; size_t __xpos = __pos;
for (; __xpos < this->size(); ++__xpos) for (; __xpos < this->size(); ++__xpos)
if (!traits_type::find(__s, __n, _M_data()[__xpos])) if (!traits_type::find(__s, __n, _M_data()[__xpos]))
...@@ -924,6 +954,8 @@ namespace std ...@@ -924,6 +954,8 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_requires_string_len(__s, __n);
size_type __size = this->size(); size_type __size = this->size();
if (__size) if (__size)
{ {
...@@ -1004,6 +1036,8 @@ namespace std ...@@ -1004,6 +1036,8 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
compare(const _CharT* __s) const compare(const _CharT* __s) const
{ {
__glibcxx_requires_string(__s);
const size_type __size = this->size(); const size_type __size = this->size();
const size_type __osize = traits_type::length(__s); const size_type __osize = traits_type::length(__s);
const size_type __len = std::min(__size, __osize); const size_type __len = std::min(__size, __osize);
...@@ -1019,6 +1053,8 @@ namespace std ...@@ -1019,6 +1053,8 @@ namespace std
basic_string <_CharT, _Traits, _Alloc>:: basic_string <_CharT, _Traits, _Alloc>::
compare(size_type __pos, size_type __n1, const _CharT* __s) const compare(size_type __pos, size_type __n1, const _CharT* __s) const
{ {
__glibcxx_requires_string(__s);
const size_type __size = this->size(); const size_type __size = this->size();
if (__pos > __size) if (__pos > __size)
__throw_out_of_range("basic_string::compare"); __throw_out_of_range("basic_string::compare");
...@@ -1038,6 +1074,8 @@ namespace std ...@@ -1038,6 +1074,8 @@ namespace std
compare(size_type __pos, size_type __n1, const _CharT* __s, compare(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2) const size_type __n2) const
{ {
__glibcxx_requires_string_len(__s, __n2);
const size_type __size = this->size(); const size_type __size = this->size();
if (__pos > __size) if (__pos > __size)
__throw_out_of_range("basic_string::compare"); __throw_out_of_range("basic_string::compare");
......
...@@ -51,11 +51,28 @@ ...@@ -51,11 +51,28 @@
# define _GLIBCXX_EXTERN_TEMPLATE 1 # define _GLIBCXX_EXTERN_TEMPLATE 1
#endif #endif
// To enable older, ARM-style iostreams and other anachronisms use this. // To enable debug mode.
//#define _GLIBCXX_DEPRECATED 1 namespace __gnu_norm
{
using namespace std;
}
// Use corrected code from the committee library group's issues list. namespace __gnu_debug_def { }
//#define _GLIBCXX_RESOLVE_LIB_DEFECTS 1
namespace __gnu_debug
{
using namespace std;
using namespace __gnu_debug_def __attribute__ ((strong));
}
namespace std
{
#ifdef _GLIBCXX_DEBUG
using namespace __gnu_debug_def __attribute__ ((strong));
#else
using namespace __gnu_norm __attribute__ ((strong));
#endif
}
// The remainder of the prewritten config is automatic; all the // The remainder of the prewritten config is automatic; all the
// user hooks are listed above. // user hooks are listed above.
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#ifndef _DEQUE_TCC #ifndef _DEQUE_TCC
#define _DEQUE_TCC 1 #define _DEQUE_TCC 1
namespace std namespace __gnu_norm
{ {
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
deque<_Tp,_Alloc>& deque<_Tp,_Alloc>&
...@@ -707,6 +707,6 @@ namespace std ...@@ -707,6 +707,6 @@ namespace std
this->_M_start._M_set_node(__new_nstart); this->_M_start._M_set_node(__new_nstart);
this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
} }
} // namespace std } // namespace __gnu_norm
#endif #endif
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#ifndef _LIST_TCC #ifndef _LIST_TCC
#define _LIST_TCC 1 #define _LIST_TCC 1
namespace std namespace __gnu_norm
{ {
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
void void
...@@ -409,6 +409,6 @@ namespace std ...@@ -409,6 +409,6 @@ namespace std
swap(__counter[__fill-1]); swap(__counter[__fill-1]);
} }
} }
} // namespace std } // namespace __gnu_norm
#endif /* _LIST_TCC */ #endif /* _LIST_TCC */
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#include <bits/stl_iterator_base_funcs.h> #include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_iterator.h> #include <bits/stl_iterator.h>
#include <bits/concept_check.h> #include <bits/concept_check.h>
#include <debug/debug.h>
namespace std namespace std
{ {
...@@ -333,6 +334,7 @@ namespace std ...@@ -333,6 +334,7 @@ namespace std
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>) typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
typedef typename _Is_normal_iterator<_InputIterator>::_Normal __Normal; typedef typename _Is_normal_iterator<_InputIterator>::_Normal __Normal;
return std::__copy_ni1(__first, __last, __result, __Normal()); return std::__copy_ni1(__first, __last, __result, __Normal());
...@@ -471,6 +473,7 @@ namespace std ...@@ -471,6 +473,7 @@ namespace std
__glibcxx_function_requires(_ConvertibleConcept< __glibcxx_function_requires(_ConvertibleConcept<
typename iterator_traits<_BI1>::value_type, typename iterator_traits<_BI1>::value_type,
typename iterator_traits<_BI2>::value_type>) typename iterator_traits<_BI2>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
typedef typename _Is_normal_iterator<_BI1>::_Normal __Normal; typedef typename _Is_normal_iterator<_BI1>::_Normal __Normal;
return std::__copy_backward_input_normal_iterator(__first, __last, __result, return std::__copy_backward_input_normal_iterator(__first, __last, __result,
...@@ -495,6 +498,7 @@ namespace std ...@@ -495,6 +498,7 @@ namespace std
{ {
// concept requirements // concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
*__first = __value; *__first = __value;
...@@ -527,6 +531,7 @@ namespace std ...@@ -527,6 +531,7 @@ namespace std
inline void inline void
fill(unsigned char* __first, unsigned char* __last, const unsigned char& __c) fill(unsigned char* __first, unsigned char* __last, const unsigned char& __c)
{ {
__glibcxx_requires_valid_range(__first, __last);
unsigned char __tmp = __c; unsigned char __tmp = __c;
std::memset(__first, __tmp, __last - __first); std::memset(__first, __tmp, __last - __first);
} }
...@@ -534,6 +539,7 @@ namespace std ...@@ -534,6 +539,7 @@ namespace std
inline void inline void
fill(signed char* __first, signed char* __last, const signed char& __c) fill(signed char* __first, signed char* __last, const signed char& __c)
{ {
__glibcxx_requires_valid_range(__first, __last);
signed char __tmp = __c; signed char __tmp = __c;
std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first); std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
} }
...@@ -541,6 +547,7 @@ namespace std ...@@ -541,6 +547,7 @@ namespace std
inline void inline void
fill(char* __first, char* __last, const char& __c) fill(char* __first, char* __last, const char& __c)
{ {
__glibcxx_requires_valid_range(__first, __last);
char __tmp = __c; char __tmp = __c;
std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first); std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
} }
...@@ -594,6 +601,7 @@ namespace std ...@@ -594,6 +601,7 @@ namespace std
typename iterator_traits<_InputIterator1>::value_type>) typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_EqualityComparableConcept< __glibcxx_function_requires(_EqualityComparableConcept<
typename iterator_traits<_InputIterator2>::value_type>) typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
while (__first1 != __last1 && *__first1 == *__first2) while (__first1 != __last1 && *__first1 == *__first2)
{ {
...@@ -625,6 +633,7 @@ namespace std ...@@ -625,6 +633,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) while (__first1 != __last1 && __binary_pred(*__first1, *__first2))
{ {
...@@ -655,6 +664,7 @@ namespace std ...@@ -655,6 +664,7 @@ namespace std
__glibcxx_function_requires(_EqualOpConcept< __glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator1>::value_type, typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>) typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
for ( ; __first1 != __last1; ++__first1, ++__first2) for ( ; __first1 != __last1; ++__first1, ++__first2)
if (!(*__first1 == *__first2)) if (!(*__first1 == *__first2))
...@@ -684,6 +694,7 @@ namespace std ...@@ -684,6 +694,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
for ( ; __first1 != __last1; ++__first1, ++__first2) for ( ; __first1 != __last1; ++__first1, ++__first2)
if (!__binary_pred(*__first1, *__first2)) if (!__binary_pred(*__first1, *__first2))
...@@ -717,6 +728,8 @@ namespace std ...@@ -717,6 +728,8 @@ namespace std
typename iterator_traits<_InputIterator1>::value_type>) typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIterator2>::value_type>) typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
for (;__first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) for (;__first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
{ {
...@@ -749,6 +762,8 @@ namespace std ...@@ -749,6 +762,8 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
for ( ; __first1 != __last1 && __first2 != __last2 for ( ; __first1 != __last1 && __first2 != __last2
; ++__first1, ++__first2) ; ++__first1, ++__first2)
...@@ -767,6 +782,9 @@ namespace std ...@@ -767,6 +782,9 @@ namespace std
const unsigned char* __first2, const unsigned char* __first2,
const unsigned char* __last2) const unsigned char* __last2)
{ {
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
const size_t __len1 = __last1 - __first1; const size_t __len1 = __last1 - __first1;
const size_t __len2 = __last2 - __first2; const size_t __len2 = __last2 - __first2;
const int __result = std::memcmp(__first1, __first2, std::min(__len1, __len2)); const int __result = std::memcmp(__first1, __first2, std::min(__len1, __len2));
...@@ -777,6 +795,9 @@ namespace std ...@@ -777,6 +795,9 @@ namespace std
lexicographical_compare(const char* __first1, const char* __last1, lexicographical_compare(const char* __first1, const char* __last1,
const char* __first2, const char* __last2) const char* __first2, const char* __last2)
{ {
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
#if CHAR_MAX == SCHAR_MAX #if CHAR_MAX == SCHAR_MAX
return std::lexicographical_compare((const signed char*) __first1, return std::lexicographical_compare((const signed char*) __first1,
(const signed char*) __last1, (const signed char*) __last1,
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#ifndef _BVECTOR_H #ifndef _BVECTOR_H
#define _BVECTOR_H 1 #define _BVECTOR_H 1
namespace std namespace __gnu_norm
{ {
typedef unsigned long _Bit_type; typedef unsigned long _Bit_type;
enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) }; enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) };
...@@ -334,13 +334,12 @@ public: ...@@ -334,13 +334,12 @@ public:
~_Bvector_base() { _Base::_M_deallocate(); } ~_Bvector_base() { _Base::_M_deallocate(); }
}; };
} // namespace std } // namespace __gnu_norm
// Declare a partial specialization of vector<T, Alloc>. // Declare a partial specialization of vector<T, Alloc>.
#include <bits/stl_vector.h> #include <bits/stl_vector.h>
namespace std namespace __gnu_norm
{ {
template <typename _Alloc> template <typename _Alloc>
class vector<bool, _Alloc> : public _Bvector_base<_Alloc> class vector<bool, _Alloc> : public _Bvector_base<_Alloc>
{ {
...@@ -723,13 +722,8 @@ template <typename _Alloc> ...@@ -723,13 +722,8 @@ template <typename _Alloc>
void clear() { erase(begin(), end()); } void clear() { erase(begin(), end()); }
}; };
// This typedef is non-standard. It is provided for backward compatibility. // This typedef is non-standard. It is provided for backward compatibility.
typedef vector<bool, __alloc> bit_vector; typedef vector<bool, __alloc> bit_vector;
} // namespace __gnu_norm
} // namespace std
#endif /* _BVECTOR_H */ #endif /* _BVECTOR_H */
// Local Variables:
// mode:C++
// End:
...@@ -60,8 +60,53 @@ ...@@ -60,8 +60,53 @@
#ifndef _STL_HEAP_H #ifndef _STL_HEAP_H
#define _STL_HEAP_H 1 #define _STL_HEAP_H 1
#include <debug/debug.h>
namespace std namespace std
{ {
// is_heap, a predicate testing whether or not a range is
// a heap. This function is an extension, not part of the C++
// standard.
template<typename _RandomAccessIterator, typename _Distance>
bool
__is_heap(_RandomAccessIterator __first, _Distance __n)
{
_Distance __parent = 0;
for (_Distance __child = 1; __child < __n; ++__child) {
if (__first[__parent] < __first[__child])
return false;
if ((__child & 1) == 0)
++__parent;
}
return true;
}
template<typename _RandomAccessIterator, typename _Distance,
typename _StrictWeakOrdering>
bool
__is_heap(_RandomAccessIterator __first, _StrictWeakOrdering __comp,
_Distance __n)
{
_Distance __parent = 0;
for (_Distance __child = 1; __child < __n; ++__child) {
if (__comp(__first[__parent], __first[__child]))
return false;
if ((__child & 1) == 0)
++__parent;
}
return true;
}
template<typename _RandomAccessIterator>
bool
__is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{ return std::__is_heap(__first, std::distance(__first, __last)); }
template<typename _RandomAccessIterator, typename _StrictWeakOrdering>
bool
__is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_StrictWeakOrdering __comp)
{ return std::__is_heap(__first, __comp, std::distance(__first, __last)); }
// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap. // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
...@@ -101,6 +146,8 @@ namespace std ...@@ -101,6 +146,8 @@ namespace std
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
// __glibcxx_requires_heap(__first, __last - 1);
std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0), std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
_ValueType(*(__last - 1))); _ValueType(*(__last - 1)));
...@@ -145,6 +192,8 @@ namespace std ...@@ -145,6 +192,8 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_heap_pred(__first, __last - 1, __comp);
std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0), std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
_ValueType(*(__last - 1)), __comp); _ValueType(*(__last - 1)), __comp);
...@@ -200,6 +249,8 @@ namespace std ...@@ -200,6 +249,8 @@ namespace std
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_heap(__first, __last);
std::__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1))); std::__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)));
} }
...@@ -256,6 +307,8 @@ namespace std ...@@ -256,6 +307,8 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_heap_pred(__first, __last, __comp);
typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType;
std::__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)), __comp); std::__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)), __comp);
...@@ -282,6 +335,7 @@ namespace std ...@@ -282,6 +335,7 @@ namespace std
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__last - __first < 2) return; if (__last - __first < 2) return;
_DistanceType __len = __last - __first; _DistanceType __len = __last - __first;
...@@ -317,7 +371,8 @@ namespace std ...@@ -317,7 +371,8 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
if (__last - __first < 2) return; if (__last - __first < 2) return;
_DistanceType __len = __last - __first; _DistanceType __len = __last - __first;
_DistanceType __parent = (__len - 2)/2; _DistanceType __parent = (__len - 2)/2;
...@@ -347,6 +402,8 @@ namespace std ...@@ -347,6 +402,8 @@ namespace std
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>) typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
// __glibcxx_requires_heap(__first, __last);
while (__last - __first > 1) while (__last - __first > 1)
std::pop_heap(__first, __last--); std::pop_heap(__first, __last--);
...@@ -370,6 +427,8 @@ namespace std ...@@ -370,6 +427,8 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_heap_pred(__first, __last, __comp);
while (__last - __first > 1) while (__last - __first > 1)
std::pop_heap(__first, __last--, __comp); std::pop_heap(__first, __last--, __comp);
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
#include <bits/concept_check.h> #include <bits/concept_check.h>
namespace std namespace __gnu_norm
{ {
/** /**
* @brief A standard container made up of (key,value) pairs, which can be * @brief A standard container made up of (key,value) pairs, which can be
...@@ -653,6 +653,6 @@ namespace std ...@@ -653,6 +653,6 @@ namespace std
inline void inline void
swap(map<_Key,_Tp,_Compare,_Alloc>& __x, map<_Key,_Tp,_Compare,_Alloc>& __y) swap(map<_Key,_Tp,_Compare,_Alloc>& __x, map<_Key,_Tp,_Compare,_Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
} // namespace std } // namespace __gnu_norm
#endif /* _MAP_H */ #endif /* _MAP_H */
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
#include <bits/concept_check.h> #include <bits/concept_check.h>
namespace std namespace __gnu_norm
{ {
// Forward declaration of operators < and ==, needed for friend declaration. // Forward declaration of operators < and ==, needed for friend declaration.
...@@ -632,6 +632,6 @@ namespace std ...@@ -632,6 +632,6 @@ namespace std
swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x,
multimap<_Key,_Tp,_Compare,_Alloc>& __y) multimap<_Key,_Tp,_Compare,_Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
} // namespace std } // namespace __gnu_norm
#endif /* _MULTIMAP_H */ #endif /* _MULTIMAP_H */
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
#include <bits/concept_check.h> #include <bits/concept_check.h>
namespace std namespace __gnu_norm
{ {
// Forward declaration of operators < and ==, needed for friend declaration. // Forward declaration of operators < and ==, needed for friend declaration.
...@@ -256,6 +256,6 @@ inline void swap(multiset<_Key,_Compare,_Alloc>& __x, ...@@ -256,6 +256,6 @@ inline void swap(multiset<_Key,_Compare,_Alloc>& __x,
__x.swap(__y); __x.swap(__y);
} }
} // namespace std } // namespace __gnu_norm
#endif /* _MULTISET_H */ #endif /* _MULTISET_H */
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
#ifndef _STL_NUMERIC_H #ifndef _STL_NUMERIC_H
#define _STL_NUMERIC_H 1 #define _STL_NUMERIC_H 1
#include <debug/debug.h>
namespace std namespace std
{ {
...@@ -70,6 +72,7 @@ namespace std ...@@ -70,6 +72,7 @@ namespace std
{ {
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
__init = __init + *__first; __init = __init + *__first;
...@@ -83,6 +86,7 @@ namespace std ...@@ -83,6 +86,7 @@ namespace std
{ {
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
__init = __binary_op(__init, *__first); __init = __binary_op(__init, *__first);
...@@ -97,6 +101,7 @@ namespace std ...@@ -97,6 +101,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
for ( ; __first1 != __last1; ++__first1, ++__first2) for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __init + (*__first1 * *__first2); __init = __init + (*__first1 * *__first2);
...@@ -114,6 +119,7 @@ namespace std ...@@ -114,6 +119,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
for ( ; __first1 != __last1; ++__first1, ++__first2) for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
...@@ -130,6 +136,7 @@ namespace std ...@@ -130,6 +136,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
...@@ -151,6 +158,7 @@ namespace std ...@@ -151,6 +158,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
...@@ -172,6 +180,7 @@ namespace std ...@@ -172,6 +180,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
...@@ -194,6 +203,7 @@ namespace std ...@@ -194,6 +203,7 @@ namespace std
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
......
...@@ -63,37 +63,36 @@ ...@@ -63,37 +63,36 @@
#include <bits/concept_check.h> #include <bits/concept_check.h>
namespace std namespace __gnu_norm
{ {
// Forward declarations of operators < and ==, needed for friend declaration.
// Forward declarations of operators < and ==, needed for friend declaration. template<class _Key, class _Compare = less<_Key>,
class _Alloc = allocator<_Key> >
template <class _Key, class _Compare = less<_Key>, class set;
class _Alloc = allocator<_Key> >
class set; template<class _Key, class _Compare, class _Alloc>
inline bool
template <class _Key, class _Compare, class _Alloc> operator==(const set<_Key,_Compare,_Alloc>& __x,
inline bool operator==(const set<_Key,_Compare,_Alloc>& __x, const set<_Key,_Compare,_Alloc>& __y);
const set<_Key,_Compare,_Alloc>& __y);
template<class _Key, class _Compare, class _Alloc>
template <class _Key, class _Compare, class _Alloc> inline bool
inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, operator<(const set<_Key,_Compare,_Alloc>& __x,
const set<_Key,_Compare,_Alloc>& __y); const set<_Key,_Compare,_Alloc>& __y);
template<class _Key, class _Compare, class _Alloc>
template <class _Key, class _Compare, class _Alloc> class set
class set {
{ // concept requirements
// concept requirements __glibcxx_class_requires(_Key, _SGIAssignableConcept)
__glibcxx_class_requires(_Key, _SGIAssignableConcept) __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
__glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
public:
public: // typedefs:
// typedefs: typedef _Key key_type;
typedef _Key key_type; typedef _Key value_type;
typedef _Key value_type; typedef _Compare key_compare;
typedef _Compare key_compare; typedef _Compare value_compare;
typedef _Compare value_compare;
private: private:
typedef _Rb_tree<key_type, value_type, typedef _Rb_tree<key_type, value_type,
_Identity<value_type>, key_compare, _Alloc> _Rep_type; _Identity<value_type>, key_compare, _Alloc> _Rep_type;
...@@ -118,12 +117,12 @@ public: ...@@ -118,12 +117,12 @@ public:
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _M_t(__comp, __a) {} : _M_t(__comp, __a) {}
template <class _InputIterator> template<class _InputIterator>
set(_InputIterator __first, _InputIterator __last) set(_InputIterator __first, _InputIterator __last)
: _M_t(_Compare(), allocator_type()) : _M_t(_Compare(), allocator_type())
{ _M_t.insert_unique(__first, __last); } { _M_t.insert_unique(__first, __last); }
template <class _InputIterator> template<class _InputIterator>
set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
...@@ -159,7 +158,7 @@ public: ...@@ -159,7 +158,7 @@ public:
typedef typename _Rep_type::iterator _Rep_iterator; typedef typename _Rep_type::iterator _Rep_iterator;
return _M_t.insert_unique((_Rep_iterator&)__position, __x); return _M_t.insert_unique((_Rep_iterator&)__position, __x);
} }
template <class _InputIterator> template<class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last) { void insert(_InputIterator __first, _InputIterator __last) {
_M_t.insert_unique(__first, __last); _M_t.insert_unique(__first, __last);
} }
...@@ -205,54 +204,54 @@ public: ...@@ -205,54 +204,54 @@ public:
return _M_t.equal_range(__x); return _M_t.equal_range(__x);
} }
template <class _K1, class _C1, class _A1> template<class _K1, class _C1, class _A1>
friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
template <class _K1, class _C1, class _A1> template<class _K1, class _C1, class _A1>
friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
}; };
template <class _Key, class _Compare, class _Alloc> template<class _Key, class _Compare, class _Alloc>
inline bool operator==(const set<_Key,_Compare,_Alloc>& __x, inline bool operator==(const set<_Key,_Compare,_Alloc>& __x,
const set<_Key,_Compare,_Alloc>& __y) { const set<_Key,_Compare,_Alloc>& __y) {
return __x._M_t == __y._M_t; return __x._M_t == __y._M_t;
} }
template <class _Key, class _Compare, class _Alloc> template<class _Key, class _Compare, class _Alloc>
inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, inline bool operator<(const set<_Key,_Compare,_Alloc>& __x,
const set<_Key,_Compare,_Alloc>& __y) { const set<_Key,_Compare,_Alloc>& __y) {
return __x._M_t < __y._M_t; return __x._M_t < __y._M_t;
} }
template <class _Key, class _Compare, class _Alloc> template<class _Key, class _Compare, class _Alloc>
inline bool operator!=(const set<_Key,_Compare,_Alloc>& __x, inline bool operator!=(const set<_Key,_Compare,_Alloc>& __x,
const set<_Key,_Compare,_Alloc>& __y) { const set<_Key,_Compare,_Alloc>& __y) {
return !(__x == __y); return !(__x == __y);
} }
template <class _Key, class _Compare, class _Alloc> template<class _Key, class _Compare, class _Alloc>
inline bool operator>(const set<_Key,_Compare,_Alloc>& __x, inline bool operator>(const set<_Key,_Compare,_Alloc>& __x,
const set<_Key,_Compare,_Alloc>& __y) { const set<_Key,_Compare,_Alloc>& __y) {
return __y < __x; return __y < __x;
} }
template <class _Key, class _Compare, class _Alloc> template<class _Key, class _Compare, class _Alloc>
inline bool operator<=(const set<_Key,_Compare,_Alloc>& __x, inline bool operator<=(const set<_Key,_Compare,_Alloc>& __x,
const set<_Key,_Compare,_Alloc>& __y) { const set<_Key,_Compare,_Alloc>& __y) {
return !(__y < __x); return !(__y < __x);
} }
template <class _Key, class _Compare, class _Alloc> template<class _Key, class _Compare, class _Alloc>
inline bool operator>=(const set<_Key,_Compare,_Alloc>& __x, inline bool operator>=(const set<_Key,_Compare,_Alloc>& __x,
const set<_Key,_Compare,_Alloc>& __y) { const set<_Key,_Compare,_Alloc>& __y) {
return !(__x < __y); return !(__x < __y);
} }
template <class _Key, class _Compare, class _Alloc> template<class _Key, class _Compare, class _Alloc>
inline void swap(set<_Key,_Compare,_Alloc>& __x, inline void swap(set<_Key,_Compare,_Alloc>& __x,
set<_Key,_Compare,_Alloc>& __y) { set<_Key,_Compare,_Alloc>& __y) {
__x.swap(__y); __x.swap(__y);
} }
} // namespace std } // namespace __gnu_norm
#endif /* _SET_H */ #endif /* _SET_H */
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/concept_check.h> #include <bits/concept_check.h>
namespace std namespace __gnu_norm
{ {
/// @if maint Primary default version. @endif /// @if maint Primary default version. @endif
/** /**
...@@ -966,6 +966,6 @@ namespace std ...@@ -966,6 +966,6 @@ namespace std
inline void inline void
swap(vector<_Tp,_Alloc>& __x, vector<_Tp,_Alloc>& __y) swap(vector<_Tp,_Alloc>& __x, vector<_Tp,_Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
} // namespace std } // namespace __gnu_norm
#endif /* _VECTOR_H */ #endif /* _VECTOR_H */
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#pragma GCC system_header #pragma GCC system_header
#include <debug/debug.h>
namespace std namespace std
{ {
template<typename _Tp, typename _CharT = char, template<typename _Tp, typename _CharT = char,
...@@ -65,18 +67,33 @@ namespace std ...@@ -65,18 +67,33 @@ namespace std
{ } { }
const _Tp& const _Tp&
operator*() const { return _M_value; } operator*() const
{
__glibcxx_requires_cond(_M_ok,
_M_message(__gnu_debug::__msg_deref_istream)
._M_iterator(*this));
return _M_value;
}
const _Tp* const _Tp*
operator->() const { return &(operator*()); } operator->() const { return &(operator*()); }
istream_iterator& istream_iterator&
operator++() operator++()
{ _M_read(); return *this; } {
__glibcxx_requires_cond(_M_ok,
_M_message(__gnu_debug::__msg_inc_istream)
._M_iterator(*this));
_M_read();
return *this;
}
istream_iterator istream_iterator
operator++(int) operator++(int)
{ {
__glibcxx_requires_cond(_M_ok,
_M_message(__gnu_debug::__msg_inc_istream)
._M_iterator(*this));
istream_iterator __tmp = *this; istream_iterator __tmp = *this;
_M_read(); _M_read();
return __tmp; return __tmp;
...@@ -138,6 +155,9 @@ namespace std ...@@ -138,6 +155,9 @@ namespace std
ostream_iterator& ostream_iterator&
operator=(const _Tp& __value) operator=(const _Tp& __value)
{ {
__glibcxx_requires_cond(_M_stream != 0,
_M_message(__gnu_debug::__msg_output_ostream)
._M_iterator(*this));
*_M_stream << __value; *_M_stream << __value;
if (_M_string) *_M_stream << _M_string; if (_M_string) *_M_stream << _M_string;
return *this; return *this;
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#pragma GCC system_header #pragma GCC system_header
#include <streambuf> #include <streambuf>
#include <debug/debug.h>
// NB: Should specialize copy, find algorithms for streambuf iterators. // NB: Should specialize copy, find algorithms for streambuf iterators.
...@@ -82,11 +83,23 @@ namespace std ...@@ -82,11 +83,23 @@ namespace std
// NB: The result of operator*() on an end of stream is undefined. // NB: The result of operator*() on an end of stream is undefined.
char_type char_type
operator*() const operator*() const
{ return traits_type::to_char_type(_M_get()); } {
#ifdef _GLIBCXX_DEBUG_PEDANTIC
// Dereferencing a past-the-end istreambuf_iterator is a
// libstdc++ extension
__glibcxx_requires_cond(!_M_at_eof(),
_M_message(__gnu_debug::__msg_deref_istreambuf)
._M_iterator(*this));
#endif
return traits_type::to_char_type(_M_get());
}
istreambuf_iterator& istreambuf_iterator&
operator++() operator++()
{ {
__glibcxx_requires_cond(!_M_at_eof(),
_M_message(__gnu_debug::__msg_inc_istreambuf)
._M_iterator(*this));
const int_type __eof = traits_type::eof(); const int_type __eof = traits_type::eof();
if (_M_sbuf && traits_type::eq_int_type(_M_sbuf->sbumpc(), __eof)) if (_M_sbuf && traits_type::eq_int_type(_M_sbuf->sbumpc(), __eof))
_M_sbuf = 0; _M_sbuf = 0;
...@@ -98,6 +111,10 @@ namespace std ...@@ -98,6 +111,10 @@ namespace std
istreambuf_iterator istreambuf_iterator
operator++(int) operator++(int)
{ {
__glibcxx_requires_cond(!_M_at_eof(),
_M_message(__gnu_debug::__msg_inc_istreambuf)
._M_iterator(*this));
const int_type __eof = traits_type::eof(); const int_type __eof = traits_type::eof();
istreambuf_iterator __old = *this; istreambuf_iterator __old = *this;
if (_M_sbuf if (_M_sbuf
...@@ -116,8 +133,8 @@ namespace std ...@@ -116,8 +133,8 @@ namespace std
equal(const istreambuf_iterator& __b) const equal(const istreambuf_iterator& __b) const
{ {
const int_type __eof = traits_type::eof(); const int_type __eof = traits_type::eof();
bool __thiseof = traits_type::eq_int_type(_M_get(), __eof); bool __thiseof = _M_at_eof();
bool __beof = traits_type::eq_int_type(__b._M_get(), __eof); bool __beof = __b._M_at_eof();
return (__thiseof && __beof || (!__thiseof && !__beof)); return (__thiseof && __beof || (!__thiseof && !__beof));
} }
...@@ -137,6 +154,13 @@ namespace std ...@@ -137,6 +154,13 @@ namespace std
} }
return __ret; return __ret;
} }
bool
_M_at_eof() const
{
const int_type __eof = traits_type::eof();
return traits_type::eq_int_type(_M_get(), __eof);
}
}; };
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#ifndef _VECTOR_TCC #ifndef _VECTOR_TCC
#define _VECTOR_TCC 1 #define _VECTOR_TCC 1
namespace std namespace __gnu_norm
{ {
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
void void
...@@ -432,7 +432,8 @@ namespace std ...@@ -432,7 +432,8 @@ namespace std
{ {
__new_finish = std::uninitialized_copy(iterator(this->_M_start), __new_finish = std::uninitialized_copy(iterator(this->_M_start),
__position, __new_start); __position, __new_start);
__new_finish = std::uninitialized_copy(__first, __last, __new_finish); __new_finish = std::uninitialized_copy(__first, __last,
__new_finish);
__new_finish = std::uninitialized_copy(__position, __new_finish = std::uninitialized_copy(__position,
iterator(this->_M_finish), iterator(this->_M_finish),
__new_finish); __new_finish);
...@@ -452,6 +453,6 @@ namespace std ...@@ -452,6 +453,6 @@ namespace std
} }
} }
} }
} // namespace std } // namespace __gnu_norm
#endif /* _VECTOR_TCC */ #endif /* _VECTOR_TCC */
// Debugging bitset implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_BITSET
#define _GLIBCXX_DEBUG_BITSET
#include <bitset>
#include <debug/safe_sequence.h>
#include <debug/safe_iterator.h>
namespace __gnu_debug_def
{
template<size_t _Nb>
class bitset
: public __gnu_norm::bitset<_Nb>, public __gnu_debug::_Safe_sequence_base
{
typedef __gnu_norm::bitset<_Nb> _Base;
typedef __gnu_debug::_Safe_sequence_base _Safe_base;
public:
// bit reference:
class reference
: private _Base::reference, public __gnu_debug::_Safe_iterator_base
{
typedef typename _Base::reference _Base_ref;
friend class bitset;
reference();
reference(const _Base_ref& __base, bitset* __seq)
: _Base_ref(__base), _Safe_iterator_base(__seq, false)
{ }
public:
reference(const reference& __x)
: _Base_ref(__x), _Safe_iterator_base(__x, false)
{ }
reference&
operator=(bool __x)
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(::__gnu_debug::__msg_bad_bitset_write)
._M_iterator(*this));
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
reference&
operator=(const reference& __x)
{
_GLIBCXX_DEBUG_VERIFY(! __x._M_singular(),
_M_message(::__gnu_debug::__msg_bad_bitset_read)
._M_iterator(__x));
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(::__gnu_debug::__msg_bad_bitset_write)
._M_iterator(*this));
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
bool
operator~() const
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(::__gnu_debug::__msg_bad_bitset_read)
._M_iterator(*this));
return ~(*static_cast<const _Base_ref*>(this));
}
operator bool() const
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(::__gnu_debug::__msg_bad_bitset_read)
._M_iterator(*this));
return *static_cast<const _Base_ref*>(this);
}
reference&
flip()
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(::__gnu_debug::__msg_bad_bitset_flip)
._M_iterator(*this));
_Base_ref::flip();
return *this;
}
};
// 23.3.5.1 constructors:
bitset() : _Base() { }
bitset(unsigned long __val) : _Base(__val) { }
template<typename _CharT, typename _Traits, typename _Allocator>
explicit
bitset(const std::basic_string<_CharT,_Traits,_Allocator>& __str,
typename std::basic_string<_CharT,_Traits,_Allocator>::size_type
__pos = 0,
typename std::basic_string<_CharT,_Traits,_Allocator>::size_type
__n = (std::basic_string<_CharT,_Traits,_Allocator>::npos))
: _Base(__str, __pos, __n) { }
bitset(const _Base& __x) : _Base(__x), _Safe_base() { }
// 23.3.5.2 bitset operations:
bitset<_Nb>&
operator&=(const bitset<_Nb>& __rhs)
{
_M_base() &= __rhs;
return *this;
}
bitset<_Nb>&
operator|=(const bitset<_Nb>& __rhs)
{
_M_base() != __rhs;
return *this;
}
bitset<_Nb>&
operator^=(const bitset<_Nb>& __rhs)
{
_M_base() ^= __rhs;
return *this;
}
bitset<_Nb>&
operator<<=(size_t __pos)
{
_M_base() <<= __pos;
return *this;
}
bitset<_Nb>&
operator>>=(size_t __pos)
{
_M_base() >>= __pos;
return *this;
}
bitset<_Nb>&
set()
{
_Base::set();
return *this;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 186. bitset::set() second parameter should be bool
bitset<_Nb>&
set(size_t __pos, bool __val = true)
{
_Base::set(__pos, __val);
return *this;
}
bitset<_Nb>&
reset()
{
_Base::reset();
return *this;
}
bitset<_Nb>&
reset(size_t __pos)
{
_Base::reset(__pos);
return *this;
}
bitset<_Nb> operator~() const { return bitset(~_M_base()); }
bitset<_Nb>&
flip()
{
_Base::flip();
return *this;
}
bitset<_Nb>&
flip(size_t __pos)
{
_Base::flip(__pos);
return *this;
}
// element access:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 11. Bitset minor problems
reference
operator[](size_t __pos)
{
__glibcxx_check_subscript(__pos);
return reference(_M_base()[__pos], this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 11. Bitset minor problems
bool
operator[](size_t __pos) const
{
__glibcxx_check_subscript(__pos);
return _M_base()[__pos];
}
using _Base::to_ulong;
template <typename _CharT, typename _Traits, typename _Allocator>
std::basic_string<_CharT, _Traits, _Allocator>
to_string() const
{ return _M_base().template to_string<_CharT, _Traits, _Allocator>(); }
using _Base::count;
using _Base::size;
bool
operator==(const bitset<_Nb>& __rhs) const
{ return _M_base() == __rhs; }
bool
operator!=(const bitset<_Nb>& __rhs) const
{ return _M_base() != __rhs; }
using _Base::test;
using _Base::any;
using _Base::none;
bitset<_Nb>
operator<<(size_t __pos) const
{ return bitset<_Nb>(_M_base() << __pos); }
bitset<_Nb>
operator>>(size_t __pos) const
{ return bitset<_Nb>(_M_base() >> __pos); }
_Base&
_M_base() { return *this; }
const _Base&
_M_base() const { return *this; }
};
template<size_t _Nb>
bitset<_Nb>
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
{ return bitset<_Nb>(__x) &= __y; }
template<size_t _Nb>
bitset<_Nb>
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
{ return bitset<_Nb>(__x) |= __y; }
template<size_t _Nb>
bitset<_Nb>
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
{ return bitset<_Nb>(__x) ^= __y; }
template<typename _CharT, typename _Traits, size_t _Nb>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
{ return __is >> __x._M_base(); }
template<typename _CharT, typename _Traits, size_t _Nb>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const bitset<_Nb>& __x)
{ return __os << __x._M_base(); }
} // namespace __gnu_debug_def
#endif
// Debugging hash_map/hash_multimap implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_HASH_MAP
#define _GLIBCXX_DEBUG_HASH_MAP 1
#include <hash_map>
#include <debug/dbg_hash_map.h>
#include <debug/dbg_hash_multimap.h>
#endif
// Debugging hash_map implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_HASH_MAP_H
#define _GLIBCXX_DEBUG_HASH_MAP_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_iterator.h>
namespace __gnu_debug_def
{
template<typename _Value, typename _Tp,
typename _HashFcn = __gnu_cxx::hash<_Value>,
typename _EqualKey = std::equal_to<_Value>,
typename _Alloc = std::allocator<_Value> >
class hash_map
: public __gnu_cxx::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>,
public __gnu_debug::_Safe_sequence<hash_map<_Value, _Tp, _HashFcn,
_EqualKey, _Alloc> >
{
typedef __gnu_cxx::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>
_Base;
typedef __gnu_debug::_Safe_sequence<hash_map> _Safe_base;
public:
typedef typename _Base::key_type key_type;
typedef typename _Base::data_type data_type;
typedef typename _Base::mapped_type mapped_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, hash_map>
iterator;
typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
hash_map>
const_iterator;
typedef typename _Base::allocator_type allocator_type;
using _Base::hash_funct;
using _Base::key_eq;
using _Base::get_allocator;
hash_map() { }
explicit hash_map(size_type __n) : _Base(__n) { }
hash_map(size_type __n, const hasher& __hf) : _Base(__n, __hf) { }
hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a) { }
template<typename _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { }
template<typename _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) { }
template<typename _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) { }
template<typename _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf,
__eql, __a) { }
hash_map(const _Base& __x) : _Base(__x), _Safe_base() { }
using _Base::size;
using _Base::max_size;
using _Base::empty;
void
swap(hash_map& __x)
{
_Base::swap(__x);
this->_M_swap(__x);
}
iterator
begin() { return iterator(_Base::begin(), this); }
iterator
end() { return iterator(_Base::end(), this); }
const_iterator
begin() const
{ return const_iterator(_Base::begin(), this); }
const_iterator
end() const
{ return const_iterator(_Base::end(), this); }
std::pair<iterator, bool>
insert(const value_type& __obj)
{
std::pair<typename _Base::iterator, bool> __res = _Base::insert(__obj);
return std::make_pair(iterator(__res.first, this), __res.second);
}
template <typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
__glibcxx_check_valid_range(__first, __last);
_Base::insert(__first.base(), __last.base());
}
std::pair<iterator, bool>
insert_noresize(const value_type& __obj)
{
std::pair<typename _Base::iterator, bool> __res =
_Base::insert_noresize(__obj);
return std::make_pair(iterator(__res.first, this), __res.second);
}
iterator
find(const key_type& __key)
{ return iterator(_Base::find(__key), this); }
const_iterator
find(const key_type& __key) const
{ return const_iterator(_Base::find(__key), this); }
using _Base::operator[];
using _Base::count;
std::pair<iterator, iterator>
equal_range(const key_type& __key)
{
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, _Base_iterator> __res =
_Base::equal_range(__key);
return std::make_pair(iterator(__res.first, this),
iterator(__res.second, this));
}
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const
{
typedef typename _Base::const_iterator _Base_iterator;
std::pair<_Base_iterator, _Base_iterator> __res =
_Base::equal_range(__key);
return std::make_pair(const_iterator(__res.first, this),
const_iterator(__res.second, this));
}
size_type
erase(const key_type& __key)
{
iterator __victim(_Base::find(__key), this);
if (__victim != end())
return this->erase(__victim), 1;
else
return 0;
}
void
erase(iterator __it)
{
__glibcxx_check_erase(__it);
__it._M_invalidate();
_Base::erase(__it.base());
}
void
erase(iterator __first, iterator __last)
{
__glibcxx_check_erase_range(__first, __last);
for (iterator __tmp = __first; __tmp != __last;)
{
iterator __victim = __tmp++;
__victim._M_invalidate();
}
_Base::erase(__first.base(), __last.base());
}
void
clear()
{
_Base::clear();
this->_M_invalidate_all();
}
using _Base::resize;
using _Base::bucket_count;
using _Base::max_bucket_count;
using _Base::elems_in_bucket;
_Base&
_M_base() { return *this; }
const _Base&
_M_base() const { return *this; }
private:
void
_M_invalidate_all()
{
typedef typename _Base::const_iterator _Base_const_iterator;
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_M_base().end()));
}
};
template<typename _Value, typename _Tp, typename _HashFcn,
typename _EqualKey, typename _Alloc>
inline bool
operator==(const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x,
const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y)
{ return __x._M_base() == __y._M_base(); }
template<typename _Value, typename _Tp, typename _HashFcn,
typename _EqualKey, typename _Alloc>
inline bool
operator!=(const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x,
const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y)
{ return __x._M_base() != __y._M_base(); }
template<typename _Value, typename _Tp, typename _HashFcn,
typename _EqualKey, typename _Alloc>
inline void
swap(hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x,
hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y)
{ __x.swap(__y); }
} // namespace __gnu_debug_def
#endif
// Debugging hash_multimap implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_HASH_MULTIMAP_H
#define _GLIBCXX_DEBUG_HASH_MULTIMAP_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_iterator.h>
namespace __gnu_debug_def
{
template<typename _Value, typename _Tp,
typename _HashFcn = __gnu_cxx::hash<_Value>,
typename _EqualKey = std::equal_to<_Value>,
typename _Alloc = std::allocator<_Value> >
class hash_multimap
: public __gnu_cxx::hash_multimap<_Value,_Tp,_HashFcn, _EqualKey,_Alloc>,
public __gnu_debug::_Safe_sequence<hash_multimap<_Value, _Tp, _HashFcn,
_EqualKey, _Alloc> >
{
typedef __gnu_cxx::hash_multimap<_Value,_Tp,_HashFcn, _EqualKey,_Alloc>
_Base;
typedef __gnu_debug::_Safe_sequence<hash_multimap> _Safe_base;
public:
typedef typename _Base::key_type key_type;
typedef typename _Base::data_type data_type;
typedef typename _Base::mapped_type mapped_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __gnu_debug::_Safe_iterator<typename _Base::iterator,
hash_multimap> iterator;
typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
hash_multimap> const_iterator;
typedef typename _Base::allocator_type allocator_type;
using _Base::hash_funct;
using _Base::key_eq;
using _Base::get_allocator;
hash_multimap() { }
explicit hash_multimap(size_type __n) : _Base(__n) { }
hash_multimap(size_type __n, const hasher& __hf) : _Base(__n, __hf) { }
hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a) { }
template<typename _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { }
template<typename _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) { }
template<typename _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) { }
template<typename _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf,
__eql, __a) { }
using _Base::size;
using _Base::max_size;
using _Base::empty;
void
swap(hash_multimap& __x)
{
_Base::swap(__x);
this->_M_swap(__x);
}
iterator
begin() { return iterator(_Base::begin(), this); }
iterator
end() { return iterator(_Base::end(), this); }
const_iterator
begin() const
{ return const_iterator(_Base::begin(), this); }
const_iterator
end() const
{ return const_iterator(_Base::end(), this); }
iterator
insert(const value_type& __obj)
{ return iterator(_Base::insert(__obj), this); }
template <typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
__glibcxx_check_valid_range(__first, __last);
_Base::insert(__first.base(), __last.base());
}
iterator
insert_noresize(const value_type& __obj)
{ return iterator(_Base::insert_noresize(__obj), this); }
iterator
find(const key_type& __key)
{ return iterator(_Base::find(__key), this); }
const_iterator
find(const key_type& __key) const
{ return const_iterator(_Base::find(__key), this); }
using _Base::count;
std::pair<iterator, iterator>
equal_range(const key_type& __key)
{
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, _Base_iterator> __res =
_Base::equal_range(__key);
return std::make_pair(iterator(__res.first, this),
iterator(__res.second, this));
}
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const
{
typedef typename _Base::const_iterator _Base_iterator;
std::pair<_Base_iterator, _Base_iterator> __res =
_Base::equal_range(__key);
return std::make_pair(const_iterator(__res.first, this),
const_iterator(__res.second, this));
}
size_type
erase(const key_type& __key)
{
std::pair<iterator, iterator> __victims = this->equal_range(__key);
size_t __num_victims = 0;
while (__victims.first != __victims.second)
{
this->erase(__victims.first++);
++__num_victims;
}
return __num_victims;
}
void
erase(iterator __it)
{
__glibcxx_check_erase(__it);
__it._M_invalidate();
_Base::erase(__it.base());
}
void
erase(iterator __first, iterator __last)
{
__glibcxx_check_erase_range(__first, __last);
for (iterator __tmp = __first; __tmp != __last;)
{
iterator __victim = __tmp++;
__victim._M_invalidate();
}
_Base::erase(__first.base(), __last.base());
}
void
clear()
{
_Base::clear();
this->_M_invalidate_all();
}
using _Base::resize;
using _Base::bucket_count;
using _Base::max_bucket_count;
using _Base::elems_in_bucket;
_Base&
_M_base() { return *this; }
const _Base&
_M_base() const { return *this; }
private:
void
_M_invalidate_all()
{
typedef typename _Base::const_iterator _Base_const_iterator;
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_M_base().end()));
}
};
template<typename _Value, typename _Tp, typename _HashFcn,
typename _EqualKey, typename _Alloc>
inline bool
operator==(const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __x,
const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __y)
{ return __x._M_base() == __y._M_base(); }
template<typename _Value, typename _Tp, typename _HashFcn,
typename _EqualKey, typename _Alloc>
inline bool
operator!=(const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __x,
const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __y)
{ return __x._M_base() != __y._M_base(); }
template<typename _Value, typename _Tp, typename _HashFcn,
typename _EqualKey, typename _Alloc>
inline void
swap(hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x,
hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y)
{ __x.swap(__y); }
} // namespace __gnu_debug_def
#endif
// Debugging hash_multiset implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_HASH_MULTISET_H
#define _GLIBCXX_DEBUG_HASH_MULTISET_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_iterator.h>
namespace __gnu_debug_def
{
template<typename _Value,
typename _HashFcn = __gnu_cxx::hash<_Value>,
typename _EqualKey = std::equal_to<_Value>,
typename _Alloc = std::allocator<_Value> >
class hash_multiset
: public __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>,
public __gnu_debug::_Safe_sequence<hash_multiset<_Value, _HashFcn,
_EqualKey, _Alloc> >
{
typedef __gnu_cxx:: hash_multiset<_Value,_HashFcn, _EqualKey,_Alloc>
_Base;
typedef __gnu_debug::_Safe_sequence<hash_multiset> _Safe_base;
public:
typedef typename _Base::key_type key_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __gnu_debug::_Safe_iterator<typename _Base::iterator,
hash_multiset> iterator;
typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
hash_multiset> const_iterator;
typedef typename _Base::allocator_type allocator_type;
using _Base::hash_funct;
using _Base::key_eq;
using _Base::get_allocator;
hash_multiset() { }
explicit hash_multiset(size_type __n) : _Base(__n) { }
hash_multiset(size_type __n, const hasher& __hf) : _Base(__n, __hf) { }
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a)
{ }
template<typename _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l)
{ }
template<typename _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n)
{ }
template<typename _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf)
{ }
template<typename _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf,
__eql, __a)
{ }
hash_multiset(const _Base& __x) : _Base(__x), _Safe_base() { }
using _Base::size;
using _Base::max_size;
using _Base::empty;
void
swap(hash_multiset& __x)
{
_Base::swap(__x);
this->_M_swap(__x);
}
iterator begin() const { return iterator(_Base::begin(), this); }
iterator end() const { return iterator(_Base::end(), this); }
iterator
insert(const value_type& __obj)
{ return iterator(_Base::insert(__obj), this); }
template <typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
__glibcxx_check_valid_range(__first, __last);
_Base::insert(__first.base(), __last.base());
}
iterator
insert_noresize(const value_type& __obj)
{ return iterator(_Base::insert_noresize(__obj), this); }
iterator
find(const key_type& __key) const
{ return iterator(_Base::find(__key), this); }
using _Base::count;
std::pair<iterator, iterator>
equal_range(const key_type& __key) const
{
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, _Base_iterator> __res =
_Base::equal_range(__key);
return std::make_pair(iterator(__res.first, this),
iterator(__res.second, this));
}
size_type
erase(const key_type& __key)
{
size_type __count = 0;
std::pair<iterator, iterator> __victims = this->equal_range(__key);
while (__victims.first != __victims.second)
{
this->erase(__victims++);
++__count;
}
return __count;
}
void
erase(iterator __it)
{
__glibcxx_check_erase(__it);
__it._M_invalidate();
_Base::erase(__it.base());
}
void
erase(iterator __first, iterator __last)
{
__glibcxx_check_erase_range(__first, __last);
for (iterator __tmp = __first; __tmp != __last;)
{
iterator __victim = __tmp++;
__victim._M_invalidate();
}
_Base::erase(__first.base(), __last.base());
}
void
clear()
{
_Base::clear();
this->_M_invalidate_all();
}
using _Base::resize;
using _Base::bucket_count;
using _Base::max_bucket_count;
using _Base::elems_in_bucket;
_Base& _M_base() { return *this; }
const _Base& _M_base() const { return *this; }
private:
void
_M_invalidate_all()
{
typedef typename _Base::const_iterator _Base_const_iterator;
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_M_base().end()));
}
};
template<typename _Value, typename _HashFcn, typename _EqualKey, typename _Alloc>
inline bool
operator==(const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __x,
const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y)
{ return __x._M_base() == __y._M_base(); }
template<typename _Value, typename _HashFcn, typename _EqualKey, typename _Alloc>
inline bool
operator!=(const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __x,
const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y)
{ return __x._M_base() != __y._M_base(); }
template<typename _Value, typename _HashFcn, typename _EqualKey, typename _Alloc>
inline void
swap(hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __x,
hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y)
{ __x.swap(__y); }
} // namespace __gnu_debug_def
#endif
// Debugging hash_set/hash_multiset implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_HASH_SET
#define _GLIBCXX_DEBUG_HASH_SET 1
#include <hash_set>
#include <debug/dbg_hash_set.h>
#include <debug/dbg_hash_multiset.h>
#endif
// Debugging hash_set implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_HASH_SET_H
#define _GLIBCXX_DEBUG_HASH_SET_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_iterator.h>
namespace __gnu_debug_def
{
template<typename _Value,
typename _HashFcn = __gnu_cxx::hash<_Value>,
typename _EqualKey = std::equal_to<_Value>,
typename _Alloc = std::allocator<_Value> >
class hash_set
: public __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>,
public __gnu_debug::_Safe_sequence<hash_set<_Value, _HashFcn, _EqualKey,
_Alloc> >
{
typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Base;
typedef __gnu_debug::_Safe_sequence<hash_set> _Safe_base;
public:
typedef typename _Base::key_type key_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, hash_set>
iterator;
typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
hash_set>
const_iterator;
typedef typename _Base::allocator_type allocator_type;
using _Base::hash_funct;
using _Base::key_eq;
using _Base::get_allocator;
hash_set() { }
explicit hash_set(size_type __n) : _Base(__n) { }
hash_set(size_type __n, const hasher& __hf) : _Base(__n, __hf) { }
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a) { }
template<typename _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { }
template<typename _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) { }
template<typename _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) { }
template<typename _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf,
__eql, __a) { }
hash_set(const _Base& __x) : _Base(__x), _Safe_base() { }
using _Base::size;
using _Base::max_size;
using _Base::empty;
void
swap(hash_set& __x)
{
_Base::swap(__x);
this->_M_swap(__x);
}
iterator
begin() const { return iterator(_Base::begin(), this); }
iterator
end() const { return iterator(_Base::end(), this); }
std::pair<iterator, bool>
insert(const value_type& __obj)
{
std::pair<typename _Base::iterator, bool> __res =
_Base::insert(__obj);
return std::make_pair(iterator(__res.first, this), __res.second);
}
template <typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
__glibcxx_check_valid_range(__first, __last);
_Base::insert(__first.base(), __last.base());
}
std::pair<iterator, bool>
insert_noresize(const value_type& __obj)
{
std::pair<typename _Base::iterator, bool> __res =
_Base::insert_noresize(__obj);
return std::make_pair(iterator(__res.first, this), __res.second);
}
iterator
find(const key_type& __key) const
{ return iterator(_Base::find(__key), this); }
using _Base::count;
std::pair<iterator, iterator>
equal_range(const key_type& __key) const
{
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, _Base_iterator> __res =
_Base::equal_range(__key);
return std::make_pair(iterator(__res.first, this),
iterator(__res.second, this));
}
size_type
erase(const key_type& __key)
{
iterator __victim(_Base::find(__key), this);
if (__victim != end())
return this->erase(__victim), 1;
else
return 0;
}
void
erase(iterator __it)
{
__glibcxx_check_erase(__it);
__it._M_invalidate();
_Base::erase(__it.base());
}
void
erase(iterator __first, iterator __last)
{
__glibcxx_check_erase_range(__first, __last);
for (iterator __tmp = __first; __tmp != __last;)
{
iterator __victim = __tmp++;
__victim._M_invalidate();
}
_Base::erase(__first.base(), __last.base());
}
void
clear()
{
_Base::clear();
this->_M_invalidate_all();
}
using _Base::resize;
using _Base::bucket_count;
using _Base::max_bucket_count;
using _Base::elems_in_bucket;
_Base&
_M_base() { return *this; }
const _Base&
_M_base() const { return *this; }
private:
void
_M_invalidate_all()
{
typedef typename _Base::const_iterator _Base_const_iterator;
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_M_base().end()));
}
};
template<typename _Value, typename _HashFcn, typename _EqualKey,
typename _Alloc>
inline bool
operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x,
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y)
{ return __x._M_base() == __y._M_base(); }
template<typename _Value, typename _HashFcn, typename _EqualKey,
typename _Alloc>
inline bool
operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x,
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y)
{ return __x._M_base() != __y._M_base(); }
template<typename _Value, typename _HashFcn, typename _EqualKey,
typename _Alloc>
inline void
swap(hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x,
hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y)
{ __x.swap(__y); }
} // namespace __gnu_debug_def
#endif
// Debugging map/multimap implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_MAP
#define _GLIBCXX_DEBUG_MAP 1
#include <map>
#include <debug/map.h>
#include <debug/multimap.h>
#endif
// Safe sequence/iterator base implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_SAFE_BASE_H
#define _GLIBCXX_DEBUG_SAFE_BASE_H 1
namespace __gnu_debug
{
class _Safe_sequence_base;
/** \brief Basic functionality for a "safe" iterator.
*
* The %_Safe_iterator_base base class implements the functionality
* of a safe iterator that is not specific to a particular iterator
* type. It contains a pointer back to the sequence it references
* along with iterator version information and pointers to form a
* doubly-linked list of iterators referenced by the container.
*
* This class must not perform any operations that can throw an
* exception, or the exception guarantees of derived iterators will
* be broken.
*/
class _Safe_iterator_base
{
public:
/** The sequence this iterator references; may be NULL to indicate
a singular iterator. */
_Safe_sequence_base* _M_sequence;
/** The version number of this iterator. The sentinel value 0 is
* used to indicate an invalidated iterator (i.e., one that is
* singular because of an operation on the container). This
* version number must equal the version number in the sequence
* referenced by _M_sequence for the iterator to be
* non-singular.
*/
unsigned int _M_version;
/** Pointer to the previous iterator in the sequence's list of
iterators. Only valid when _M_sequence != NULL. */
_Safe_iterator_base* _M_prior;
/** Pointer to the next iterator in the sequence's list of
iterators. Only valid when _M_sequence != NULL. */
_Safe_iterator_base* _M_next;
protected:
/** Initializes the iterator and makes it singular. */
_Safe_iterator_base()
: _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0)
{ }
/** Initialize the iterator to reference the sequence pointed to
* by @p__seq. @p __constant is true when we are initializing a
* constant iterator, and false if it is a mutable iterator. Note
* that @p __seq may be NULL, in which case the iterator will be
* singular. Otherwise, the iterator will reference @p __seq and
* be nonsingular.
*/
_Safe_iterator_base(const _Safe_sequence_base* __seq, bool __constant)
: _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0)
{ this->_M_attach(const_cast<_Safe_sequence_base*>(__seq), __constant); }
/** Initializes the iterator to reference the same sequence that
@p __x does. @p __constant is true if this is a constant
iterator, and false if it is mutable. */
_Safe_iterator_base(const _Safe_iterator_base& __x, bool __constant)
: _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0)
{ this->_M_attach(__x._M_sequence, __constant); }
~_Safe_iterator_base() { this->_M_detach(); }
public:
/** Attaches this iterator to the given sequence, detaching it
* from whatever sequence it was attached to originally. If the
* new sequence is the NULL pointer, the iterator is left
* unattached.
*/
void _M_attach(_Safe_sequence_base* __seq, bool __constant);
/** Detach the iterator for whatever sequence it is attached to,
* if any.
*/
void _M_detach();
/** Determines if we are attached to the given sequence. */
bool _M_attached_to(const _Safe_sequence_base* __seq) const
{ return _M_sequence == __seq; }
/** Is this iterator singular? */
bool _M_singular() const;
/** Can we compare this iterator to the given iterator @p __x?
Returns true if both iterators are nonsingular and reference
the same sequence. */
bool _M_can_compare(const _Safe_iterator_base& __x) const;
};
/**
* @brief Base class that supports tracking of iterators that
* reference a sequence.
*
* The %_Safe_sequence_base class provides basic support for
* tracking iterators into a sequence. Sequences that track
* iterators must derived from %_Safe_sequence_base publicly, so
* that safe iterators (which inherit _Safe_iterator_base) can
* attach to them. This class contains two linked lists of
* iterators, one for constant iterators and one for mutable
* iterators, and a version number that allows very fast
* invalidation of all iterators that reference the container.
*
* This class must ensure that no operation on it may throw an
* exception, otherwise "safe" sequences may fail to provide the
* exception-safety guarantees required by the C++ standard.
*/
class _Safe_sequence_base
{
public:
/// The list of mutable iterators that reference this container
_Safe_iterator_base* _M_iterators;
/// The list of constant iterators that reference this container
_Safe_iterator_base* _M_const_iterators;
/// The container version number. This number may never be 0.
mutable unsigned int _M_version;
protected:
// Initialize with a version number of 1 and no iterators
_Safe_sequence_base()
: _M_iterators(0), _M_const_iterators(0), _M_version(1)
{ }
/** Notify all iterators that reference this sequence that the
sequence is being destroyed. */
~_Safe_sequence_base()
{ this->_M_detach_all(); }
/** Detach all iterators, leaving them singular. */
void
_M_detach_all();
/** Detach all singular iterators.
* @post for all iterators i attached to this sequence,
* i->_M_version == _M_version.
*/
void
_M_detach_singular();
/** Revalidates all attached singular iterators. This method may
* be used to validate iterators that were invalidated before
* (but for some reasion, such as an exception, need to become
* valid again).
*/
void
_M_revalidate_singular();
/** Swap this sequence with the given sequence. This operation
* also swaps ownership of the iterators, so that when the
* operation is complete all iterators that originally referenced
* one container now reference the other container.
*/
void
_M_swap(_Safe_sequence_base& __x);
public:
/** Invalidates all iterators. */
void
_M_invalidate_all() const
{ if (++_M_version == 0) _M_version = 1; }
};
} // namespace __gnu_debug
#endif
// Debugging iterator implementation (out of line) -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file safe_iterator.tcc
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC
#define _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC 1
namespace __gnu_debug
{
template<typename _Iterator, typename _Sequence>
bool
_Safe_iterator<_Iterator, _Sequence>::
_M_can_advance(const difference_type& __n) const
{
typedef typename _Sequence::const_iterator const_iterator;
if (this->_M_singular())
return false;
if (__n == 0)
return true;
if (__n < 0)
{
const_iterator __begin =
static_cast<const _Sequence*>(_M_sequence)->begin();
pair<difference_type, _Distance_precision> __dist =
this->_M_get_distance(__begin, *this);
bool __ok = (__dist.second == __dp_exact && __dist.first >= -__n
|| __dist.second != __dp_exact && __dist.first > 0);
return __ok;
}
else
{
const_iterator __end =
static_cast<const _Sequence*>(_M_sequence)->end();
pair<difference_type, _Distance_precision> __dist =
this->_M_get_distance(*this, __end);
bool __ok = (__dist.second == __dp_exact && __dist.first >= __n
|| __dist.second != __dp_exact && __dist.first > 0);
return __ok;
}
}
template<typename _Iterator, typename _Sequence>
template<typename _Other>
bool
_Safe_iterator<_Iterator, _Sequence>::
_M_valid_range(const _Safe_iterator<_Other, _Sequence>& __rhs) const
{
if (!_M_can_compare(__rhs))
return false;
/* Determine if we can order the iterators without the help of
the container */
pair<difference_type, _Distance_precision> __dist =
this->_M_get_distance(*this, __rhs);
switch (__dist.second) {
case __dp_equality:
if (__dist.first == 0)
return true;
break;
case __dp_sign:
case __dp_exact:
return __dist.first >= 0;
}
/* We can only test for equality, but check if one of the
iterators is at an extreme. */
if (_M_is_begin() || __rhs._M_is_end())
return true;
else if (_M_is_end() || __rhs._M_is_begin())
return false;
// Assume that this is a valid range; we can't check anything else
return true;
}
template<typename _Iterator, typename _Sequence>
void
_Safe_iterator<_Iterator, _Sequence>::
_M_invalidate()
{
typedef typename _Sequence::iterator iterator;
typedef typename _Sequence::const_iterator const_iterator;
if (!this->_M_singular())
{
for (_Safe_iterator_base* iter = _M_sequence->_M_iterators; iter; )
{
iterator* __victim = static_cast<iterator*>(iter);
iter = iter->_M_next;
if (this->base() == __victim->base())
__victim->_M_version = 0;
}
for (_Safe_iterator_base* iter = _M_sequence->_M_const_iterators;
iter; /* increment in loop */)
{
const_iterator* __victim = static_cast<const_iterator*>(iter);
iter = iter->_M_next;
if (this->base() == __victim->base())
__victim->_M_version = 0;
}
_M_version = 0;
}
}
} // namespace __gnu_debug
#endif
// Safe sequence implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H
#define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1
#include <debug/debug.h>
#include <debug/safe_base.h>
namespace __gnu_debug
{
template<typename _Iterator, typename _Sequence>
class _Safe_iterator;
/** A simple function object that returns true if the passed-in
* value is not equal to the stored value. It saves typing over
* using both bind1st and not_equal.
*/
template<typename _Type>
class _Not_equal_to
{
_Type __value;
public:
explicit _Not_equal_to(const _Type& __v) : __value(__v) { }
bool
operator()(const _Type& __x) const
{ return __value != __x; }
};
/** A function object that returns true when the given random access
iterator is at least @c n steps away from the given iterator. */
template<typename _Iterator>
class _After_nth_from
{
typedef typename std::iterator_traits<_Iterator>::difference_type
difference_type;
_Iterator _M_base;
difference_type _M_n;
public:
_After_nth_from(const difference_type& __n, const _Iterator& __base)
: _M_base(__base), _M_n(__n) { }
bool
operator()(const _Iterator& __x) const
{ return __x - _M_base >= _M_n; }
};
/**
* @brief Base class for constructing a "safe" sequence type that
* tracks iterators that reference it.
*
* The class template %_Safe_sequence simplifies the construction of
* "safe" sequences that track the iterators that reference the
* sequence, so that the iterators are notified of changes in the
* sequence that may affect their operation, e.g., if the container
* invalidates its iterators or is destructed. This class template
* may only be used by deriving from it and passing the name of the
* derived class as its template parameter via the curiously
* recurring template pattern. The derived class must have @c
* iterator and @const_iterator types that are instantiations of
* class template _Safe_iterator for this sequence. Iterators will
* then be tracked automatically.
*/
template<typename _Sequence>
class _Safe_sequence : public _Safe_sequence_base
{
public:
/** Invalidates all iterators @c x that reference this sequence,
are not singular, and for which @c pred(x) returns @c
true. The user of this routine should be careful not to make
copies of the iterators passed to @p pred, as the copies may
interfere with the invalidation. */
template<typename _Predicate>
void
_M_invalidate_if(_Predicate __pred);
/** Transfers all iterators that reference this memory location
to this sequence from whatever sequence they are attached
to. */
template<typename _Iterator>
void
_M_transfer_iter(const _Safe_iterator<_Iterator, _Sequence>& __x);
};
template<typename _Sequence>
template<typename _Predicate>
void
_Safe_sequence<_Sequence>::
_M_invalidate_if(_Predicate __pred)
{
typedef typename _Sequence::iterator iterator;
typedef typename _Sequence::const_iterator const_iterator;
for (_Safe_iterator_base* __iter = _M_iterators; __iter; )
{
iterator* __victim = static_cast<iterator*>(__iter);
__iter = __iter->_M_next;
if (!__victim->_M_singular())
{
if (__pred(__victim->base()))
__victim->_M_invalidate();
}
}
for (_Safe_iterator_base* __iter = _M_const_iterators; __iter; )
{
const_iterator* __victim = static_cast<const_iterator*>(__iter);
__iter = __iter->_M_next;
if (!__victim->_M_singular())
{
if (__pred(__victim->base()))
__victim->_M_invalidate();
}
}
}
template<typename _Sequence>
template<typename _Iterator>
void
_Safe_sequence<_Sequence>::
_M_transfer_iter(const _Safe_iterator<_Iterator, _Sequence>& __x)
{
_Safe_sequence_base* __from = __x._M_sequence;
if (!__from)
return;
typedef typename _Sequence::iterator iterator;
typedef typename _Sequence::const_iterator const_iterator;
for (_Safe_iterator_base* __iter = __from->_M_iterators; __iter; )
{
iterator* __victim = static_cast<iterator*>(__iter);
__iter = __iter->_M_next;
if (!__victim->_M_singular() && __victim->base() == __x.base())
__victim->_M_attach(static_cast<_Sequence*>(this));
}
for (_Safe_iterator_base* __iter = __from->_M_const_iterators; __iter;)
{
const_iterator* __victim = static_cast<const_iterator*>(__iter);
__iter = __iter->_M_next;
if (!__victim->_M_singular() && __victim->base() == __x.base())
__victim->_M_attach(static_cast<_Sequence*>(this));
}
}
} // namespace __gnu_debug
#endif
// Debugging set/multiset implementation -*- C++ -*-
// Copyright (C) 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_DEBUG_SET
#define _GLIBCXX_DEBUG_SET 1
#include <set>
#include <debug/set.h>
#include <debug/multiset.h>
#endif
...@@ -208,6 +208,8 @@ namespace __gnu_cxx ...@@ -208,6 +208,8 @@ namespace __gnu_cxx
typename iterator_traits<_InputIterator1>::value_type>) typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIterator2>::value_type>) typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return __lexicographical_compare_3way(__first1, __last1, __first2, __last2); return __lexicographical_compare_3way(__first1, __last1, __first2, __last2);
} }
...@@ -226,6 +228,8 @@ namespace __gnu_cxx ...@@ -226,6 +228,8 @@ namespace __gnu_cxx
__glibcxx_function_requires(_EqualityComparableConcept< __glibcxx_function_requires(_EqualityComparableConcept<
typename iterator_traits<_InputIterator>::value_type >) typename iterator_traits<_InputIterator>::value_type >)
__glibcxx_function_requires(_EqualityComparableConcept<_Tp>) __glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
__glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
if (*__first == __value) if (*__first == __value)
++__n; ++__n;
...@@ -241,6 +245,8 @@ namespace __gnu_cxx ...@@ -241,6 +245,8 @@ namespace __gnu_cxx
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>) typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
if (__pred(*__first)) if (__pred(*__first))
++__n; ++__n;
...@@ -262,6 +268,7 @@ namespace __gnu_cxx ...@@ -262,6 +268,7 @@ namespace __gnu_cxx
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_ForwardIterator>::value_type>) typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
_Distance __remaining = std::distance(__first, __last); _Distance __remaining = std::distance(__first, __last);
_Distance __m = min(__n, __remaining); _Distance __m = min(__n, __remaining);
...@@ -297,6 +304,7 @@ namespace __gnu_cxx ...@@ -297,6 +304,7 @@ namespace __gnu_cxx
typename iterator_traits<_ForwardIterator>::value_type>) typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_function_requires(_UnaryFunctionConcept< __glibcxx_function_requires(_UnaryFunctionConcept<
_RandomNumberGenerator, _Distance, _Distance>) _RandomNumberGenerator, _Distance, _Distance>)
__glibcxx_requires_valid_range(__first, __last);
_Distance __remaining = std::distance(__first, __last); _Distance __remaining = std::distance(__first, __last);
_Distance __m = min(__n, __remaining); _Distance __m = min(__n, __remaining);
...@@ -378,6 +386,8 @@ namespace __gnu_cxx ...@@ -378,6 +386,8 @@ namespace __gnu_cxx
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_valid_range(__out_first, __out_last);
return __random_sample(__first, __last, return __random_sample(__first, __last,
__out_first, __out_last - __out_first); __out_first, __out_last - __out_first);
...@@ -399,46 +409,14 @@ namespace __gnu_cxx ...@@ -399,46 +409,14 @@ namespace __gnu_cxx
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_valid_range(__out_first, __out_last);
return __random_sample(__first, __last, return __random_sample(__first, __last,
__out_first, __rand, __out_first, __rand,
__out_last - __out_first); __out_last - __out_first);
} }
// is_heap, a predicate testing whether or not a range is
// a heap. This function is an extension, not part of the C++
// standard.
template<typename _RandomAccessIterator, typename _Distance>
bool
__is_heap(_RandomAccessIterator __first, _Distance __n)
{
_Distance __parent = 0;
for (_Distance __child = 1; __child < __n; ++__child) {
if (__first[__parent] < __first[__child])
return false;
if ((__child & 1) == 0)
++__parent;
}
return true;
}
template<typename _RandomAccessIterator, typename _Distance,
typename _StrictWeakOrdering>
bool
__is_heap(_RandomAccessIterator __first, _StrictWeakOrdering __comp,
_Distance __n)
{
_Distance __parent = 0;
for (_Distance __child = 1; __child < __n; ++__child) {
if (__comp(__first[__parent], __first[__child]))
return false;
if ((__child & 1) == 0)
++__parent;
}
return true;
}
/** /**
* This is an SGI extension. * This is an SGI extension.
* @ingroup SGIextensions * @ingroup SGIextensions
...@@ -452,8 +430,9 @@ namespace __gnu_cxx ...@@ -452,8 +430,9 @@ namespace __gnu_cxx
__glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>) __glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>) typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return __is_heap(__first, __last - __first); return std::__is_heap(__first, __last - __first);
} }
/** /**
...@@ -471,8 +450,9 @@ namespace __gnu_cxx ...@@ -471,8 +450,9 @@ namespace __gnu_cxx
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering, __glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
typename iterator_traits<_RandomAccessIterator>::value_type, typename iterator_traits<_RandomAccessIterator>::value_type,
typename iterator_traits<_RandomAccessIterator>::value_type>) typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return __is_heap(__first, __comp, __last - __first); return std::__is_heap(__first, __comp, __last - __first);
} }
// is_sorted, a predicated testing whether a range is sorted in // is_sorted, a predicated testing whether a range is sorted in
...@@ -492,6 +472,7 @@ namespace __gnu_cxx ...@@ -492,6 +472,7 @@ namespace __gnu_cxx
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>) typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last) if (__first == __last)
return true; return true;
...@@ -519,6 +500,7 @@ namespace __gnu_cxx ...@@ -519,6 +500,7 @@ namespace __gnu_cxx
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering, __glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
typename iterator_traits<_ForwardIterator>::value_type, typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>) typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last) if (__first == __last)
return true; return true;
...@@ -531,7 +513,6 @@ namespace __gnu_cxx ...@@ -531,7 +513,6 @@ namespace __gnu_cxx
return true; return true;
} }
} // namespace __gnu_cxx } // namespace __gnu_cxx
#endif /* _EXT_ALGORITHM */ #endif /* _EXT_ALGORITHM */
...@@ -69,7 +69,3 @@ ...@@ -69,7 +69,3 @@
#include <bits/stl_algo.h> #include <bits/stl_algo.h>
#endif /* _GLIBCXX_ALGORITHM */ #endif /* _GLIBCXX_ALGORITHM */
// Local Variables:
// mode:C++
// End:
...@@ -50,21 +50,21 @@ ...@@ -50,21 +50,21 @@
#pragma GCC system_header #pragma GCC system_header
#include <cstddef> // for size_t #include <cstddef> // For size_t
#include <cstring> // for memset #include <cstring> // For memset
#include <limits> // for numeric_limits #include <limits> // For numeric_limits
#include <string> #include <string>
#include <bits/functexcept.h> // for invalid_argument, out_of_range, #include <bits/functexcept.h> // For invalid_argument, out_of_range,
// overflow_error // overflow_error
#include <ostream> // for ostream (operator<<) #include <ostream> // For ostream (operator<<)
#include <istream> // for istream (operator>>) #include <istream> // For istream (operator>>)
#define _GLIBCXX_BITSET_BITS_PER_WORD numeric_limits<unsigned long>::digits #define _GLIBCXX_BITSET_BITS_PER_WORD numeric_limits<unsigned long>::digits
#define _GLIBCXX_BITSET_WORDS(__n) \ #define _GLIBCXX_BITSET_WORDS(__n) \
((__n) < 1 ? 0 : ((__n) + _GLIBCXX_BITSET_BITS_PER_WORD - 1)/_GLIBCXX_BITSET_BITS_PER_WORD) ((__n) < 1 ? 0 : ((__n) + _GLIBCXX_BITSET_BITS_PER_WORD - 1)/_GLIBCXX_BITSET_BITS_PER_WORD)
namespace std namespace __gnu_norm
{ {
/** /**
* @if maint * @if maint
...@@ -646,7 +646,7 @@ namespace std ...@@ -646,7 +646,7 @@ namespace std
~reference() { } ~reference() { }
// for b[i] = __x; // For b[i] = __x;
reference& reference&
operator=(bool __x) operator=(bool __x)
{ {
...@@ -657,7 +657,7 @@ namespace std ...@@ -657,7 +657,7 @@ namespace std
return *this; return *this;
} }
// for b[i] = b[__j]; // For b[i] = b[__j];
reference& reference&
operator=(const reference& __j) operator=(const reference& __j)
{ {
...@@ -668,16 +668,16 @@ namespace std ...@@ -668,16 +668,16 @@ namespace std
return *this; return *this;
} }
// flips the bit // Flips the bit
bool bool
operator~() const operator~() const
{ return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; } { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; }
// for __x = b[i]; // For __x = b[i];
operator bool() const operator bool() const
{ return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; } { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }
// for b[i].flip(); // For b[i].flip();
reference& reference&
flip() flip()
{ {
...@@ -1207,9 +1207,13 @@ namespace std ...@@ -1207,9 +1207,13 @@ namespace std
return __os << __tmp; return __os << __tmp;
} }
//@} //@}
} // namespace std } // namespace __gnu_norm
#undef _GLIBCXX_BITSET_WORDS #undef _GLIBCXX_BITSET_WORDS
#undef _GLIBCXX_BITSET_BITS_PER_WORD #undef _GLIBCXX_BITSET_BITS_PER_WORD
#ifdef _GLIBCXX_DEBUG
# include <debug/bitset>
#endif
#endif /* _GLIBCXX_BITSET */ #endif /* _GLIBCXX_BITSET */
...@@ -74,4 +74,8 @@ ...@@ -74,4 +74,8 @@
# include <bits/deque.tcc> # include <bits/deque.tcc>
#endif #endif
#ifdef _GLIBCXX_DEBUG
# include <debug/deque>
#endif
#endif /* _GLIBCXX_DEQUE */ #endif /* _GLIBCXX_DEQUE */
...@@ -50,13 +50,9 @@ ...@@ -50,13 +50,9 @@
#define _GLIBCXX_FUNCTIONAL 1 #define _GLIBCXX_FUNCTIONAL 1
#pragma GCC system_header #pragma GCC system_header
#include <bits/c++config.h> #include <bits/c++config.h>
#include <cstddef> #include <cstddef>
#include <bits/stl_function.h> #include <bits/stl_function.h>
#endif /* _GLIBCXX_FUNCTIONAL */ #endif /* _GLIBCXX_FUNCTIONAL */
// Local Variables:
// mode:C++
// End:
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#define _GLIBCXX_ITERATOR 1 #define _GLIBCXX_ITERATOR 1
#pragma GCC system_header #pragma GCC system_header
#include <bits/c++config.h> #include <bits/c++config.h>
#include <cstddef> #include <cstddef>
#include <bits/stl_iterator_base_types.h> #include <bits/stl_iterator_base_types.h>
...@@ -73,7 +74,3 @@ ...@@ -73,7 +74,3 @@
#include <bits/streambuf_iterator.h> #include <bits/streambuf_iterator.h>
#endif /* _GLIBCXX_ITERATOR */ #endif /* _GLIBCXX_ITERATOR */
// Local Variables:
// mode:C++
// End:
...@@ -74,5 +74,9 @@ ...@@ -74,5 +74,9 @@
# include <bits/list.tcc> # include <bits/list.tcc>
#endif #endif
#ifdef _GLIBCXX_DEBUG
# include <debug/list>
#endif
#endif /* _GLIBCXX_LIST */ #endif /* _GLIBCXX_LIST */
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
#include <bits/stl_map.h> #include <bits/stl_map.h>
#include <bits/stl_multimap.h> #include <bits/stl_multimap.h>
#endif /* _GLIBCXX_MAP */ #ifdef _GLIBCXX_DEBUG
# include <debug/map>
#endif
// Local Variables: #endif /* _GLIBCXX_MAP */
// mode:C++
// End:
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <bits/stl_iterator_base_types.h> //for iterator_traits #include <bits/stl_iterator_base_types.h> //for iterator_traits
#include <bits/stl_uninitialized.h> #include <bits/stl_uninitialized.h>
#include <bits/stl_raw_storage_iter.h> #include <bits/stl_raw_storage_iter.h>
#include <debug/debug.h>
namespace std namespace std
{ {
...@@ -259,7 +260,11 @@ namespace std ...@@ -259,7 +260,11 @@ namespace std
* what happens when you dereference one of those...) * what happens when you dereference one of those...)
*/ */
element_type& element_type&
operator*() const throw() { return *_M_ptr; } operator*() const throw()
{
_GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
return *_M_ptr;
}
/** /**
* @brief Smart pointer dereferencing. * @brief Smart pointer dereferencing.
...@@ -268,7 +273,11 @@ namespace std ...@@ -268,7 +273,11 @@ namespace std
* automatically cause to be dereferenced. * automatically cause to be dereferenced.
*/ */
element_type* element_type*
operator->() const throw() { return _M_ptr; } operator->() const throw()
{
_GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
return _M_ptr;
}
/** /**
* @brief Bypassing the smart pointer. * @brief Bypassing the smart pointer.
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#define _GLIBCXX_NUMERIC 1 #define _GLIBCXX_NUMERIC 1
#pragma GCC system_header #pragma GCC system_header
#include <bits/c++config.h> #include <bits/c++config.h>
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
...@@ -69,7 +70,3 @@ ...@@ -69,7 +70,3 @@
#include <bits/stl_numeric.h> #include <bits/stl_numeric.h>
#endif /* _GLIBCXX_NUMERIC */ #endif /* _GLIBCXX_NUMERIC */
// Local Variables:
// mode:C++
// End:
...@@ -62,21 +62,17 @@ ...@@ -62,21 +62,17 @@
#define _GLIBCXX_QUEUE 1 #define _GLIBCXX_QUEUE 1
#pragma GCC system_header #pragma GCC system_header
#include <bits/c++config.h> #include <bits/c++config.h>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/stl_algobase.h> #include <bits/stl_algobase.h>
#include <bits/allocator.h> #include <bits/allocator.h>
#include <bits/stl_construct.h> #include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h> #include <bits/stl_uninitialized.h>
#include <bits/stl_vector.h>
#include <bits/stl_heap.h> #include <bits/stl_heap.h>
#include <bits/stl_deque.h>
#include <bits/stl_function.h> #include <bits/stl_function.h>
#include <deque>
#include <vector>
#include <bits/stl_queue.h> #include <bits/stl_queue.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/deque.tcc>
# include <bits/vector.tcc>
#endif
#endif /* _GLIBCXX_QUEUE */ #endif /* _GLIBCXX_QUEUE */
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
#include <bits/stl_set.h> #include <bits/stl_set.h>
#include <bits/stl_multiset.h> #include <bits/stl_multiset.h>
#endif /* _GLIBCXX_SET */ #ifdef _GLIBCXX_DEBUG
# include <debug/set>
#endif
// Local Variables: #endif /* _GLIBCXX_SET */
// mode:C++
// End:
...@@ -67,11 +67,7 @@ ...@@ -67,11 +67,7 @@
#include <bits/allocator.h> #include <bits/allocator.h>
#include <bits/stl_construct.h> #include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h> #include <bits/stl_uninitialized.h>
#include <bits/stl_deque.h> #include <deque>
#include <bits/stl_stack.h> #include <bits/stl_stack.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/deque.tcc>
#endif
#endif /* _GLIBCXX_STACK */ #endif /* _GLIBCXX_STACK */
...@@ -62,12 +62,9 @@ ...@@ -62,12 +62,9 @@
#define _GLIBCXX_UTILITY 1 #define _GLIBCXX_UTILITY 1
#pragma GCC system_header #pragma GCC system_header
#include <bits/c++config.h> #include <bits/c++config.h>
#include <bits/stl_relops.h> #include <bits/stl_relops.h>
#include <bits/stl_pair.h> #include <bits/stl_pair.h>
#endif /* _GLIBCXX_UTILITY */ #endif /* _GLIBCXX_UTILITY */
// Local Variables:
// mode:C++
// End:
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <cstdlib> #include <cstdlib>
#include <numeric> #include <numeric>
#include <algorithm> #include <algorithm>
#include <debug/debug.h>
namespace std namespace std
{ {
...@@ -221,12 +222,18 @@ namespace std ...@@ -221,12 +222,18 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline const _Tp& inline const _Tp&
valarray<_Tp>::operator[](size_t __i) const valarray<_Tp>::operator[](size_t __i) const
{ return _M_data[__i]; } {
__glibcxx_requires_subscript(__i);
return _M_data[__i];
}
template<typename _Tp> template<typename _Tp>
inline _Tp& inline _Tp&
valarray<_Tp>::operator[](size_t __i) valarray<_Tp>::operator[](size_t __i)
{ return _M_data[__i]; } {
__glibcxx_requires_subscript(__i);
return _M_data[__i];
}
} // std:: } // std::
...@@ -260,7 +267,10 @@ namespace std ...@@ -260,7 +267,10 @@ namespace std
inline inline
valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n) valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
: _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{ std::__valarray_copy_construct(__p, __p + __n, _M_data); } {
_GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0);
std::__valarray_copy_construct(__p, __p + __n, _M_data);
}
template<typename _Tp> template<typename _Tp>
inline inline
...@@ -324,6 +334,7 @@ namespace std ...@@ -324,6 +334,7 @@ namespace std
inline valarray<_Tp>& inline valarray<_Tp>&
valarray<_Tp>::operator=(const valarray<_Tp>& __v) valarray<_Tp>::operator=(const valarray<_Tp>& __v)
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size);
std::__valarray_copy(__v._M_data, _M_size, _M_data); std::__valarray_copy(__v._M_data, _M_size, _M_data);
return *this; return *this;
} }
...@@ -340,6 +351,7 @@ namespace std ...@@ -340,6 +351,7 @@ namespace std
inline valarray<_Tp>& inline valarray<_Tp>&
valarray<_Tp>::operator=(const slice_array<_Tp>& __sa) valarray<_Tp>::operator=(const slice_array<_Tp>& __sa)
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size == __sa._M_sz);
std::__valarray_copy(__sa._M_array, __sa._M_sz, std::__valarray_copy(__sa._M_array, __sa._M_sz,
__sa._M_stride, _Array<_Tp>(_M_data)); __sa._M_stride, _Array<_Tp>(_M_data));
return *this; return *this;
...@@ -349,6 +361,7 @@ namespace std ...@@ -349,6 +361,7 @@ namespace std
inline valarray<_Tp>& inline valarray<_Tp>&
valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga) valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga)
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size == __ga._M_index.size());
std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index), std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index),
_Array<_Tp>(_M_data), _M_size); _Array<_Tp>(_M_data), _M_size);
return *this; return *this;
...@@ -358,6 +371,7 @@ namespace std ...@@ -358,6 +371,7 @@ namespace std
inline valarray<_Tp>& inline valarray<_Tp>&
valarray<_Tp>::operator=(const mask_array<_Tp>& __ma) valarray<_Tp>::operator=(const mask_array<_Tp>& __ma)
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size == __ma._M_sz);
std::__valarray_copy(__ma._M_array, __ma._M_mask, std::__valarray_copy(__ma._M_array, __ma._M_mask,
_Array<_Tp>(_M_data), _M_size); _Array<_Tp>(_M_data), _M_size);
return *this; return *this;
...@@ -367,6 +381,7 @@ namespace std ...@@ -367,6 +381,7 @@ namespace std
inline valarray<_Tp>& inline valarray<_Tp>&
valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia) valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia)
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size == __ia._M_sz);
std::__valarray_copy(__ia._M_array, __ia._M_index, std::__valarray_copy(__ia._M_array, __ia._M_index,
_Array<_Tp>(_M_data), _M_size); _Array<_Tp>(_M_data), _M_size);
return *this; return *this;
...@@ -376,6 +391,7 @@ namespace std ...@@ -376,6 +391,7 @@ namespace std
inline valarray<_Tp>& inline valarray<_Tp>&
valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size == __e.size());
std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
return *this; return *this;
} }
...@@ -460,6 +476,7 @@ namespace std ...@@ -460,6 +476,7 @@ namespace std
inline _Tp inline _Tp
valarray<_Tp>::sum() const valarray<_Tp>::sum() const
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size > 0);
return std::__valarray_sum(_M_data, _M_data + _M_size); return std::__valarray_sum(_M_data, _M_data + _M_size);
} }
...@@ -540,6 +557,7 @@ namespace std ...@@ -540,6 +557,7 @@ namespace std
inline _Tp inline _Tp
valarray<_Tp>::min() const valarray<_Tp>::min() const
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size > 0);
return *std::min_element (_M_data, _M_data+_M_size); return *std::min_element (_M_data, _M_data+_M_size);
} }
...@@ -547,6 +565,7 @@ namespace std ...@@ -547,6 +565,7 @@ namespace std
inline _Tp inline _Tp
valarray<_Tp>::max() const valarray<_Tp>::max() const
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size > 0);
return *std::max_element (_M_data, _M_data+_M_size); return *std::max_element (_M_data, _M_data+_M_size);
} }
...@@ -596,6 +615,7 @@ namespace std ...@@ -596,6 +615,7 @@ namespace std
inline valarray<_Tp>& \ inline valarray<_Tp>& \
valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \ valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \
{ \ { \
_GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); \
_Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \ _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \
_Array<_Tp>(__v._M_data)); \ _Array<_Tp>(__v._M_data)); \
return *this; \ return *this; \
...@@ -643,6 +663,7 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right) ...@@ -643,6 +663,7 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
typename __fun<_Name, _Tp>::result_type> \ typename __fun<_Name, _Tp>::result_type> \
operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
{ \ { \
_GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \
typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \ typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
typedef typename __fun<_Name, _Tp>::result_type _Rt; \ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \ return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \
...@@ -690,7 +711,3 @@ _DEFINE_BINARY_OPERATOR(>=, __greater_equal) ...@@ -690,7 +711,3 @@ _DEFINE_BINARY_OPERATOR(>=, __greater_equal)
} // namespace std } // namespace std
#endif /* _GLIBCXX_VALARRAY */ #endif /* _GLIBCXX_VALARRAY */
// Local Variables:
// mode:c++
// End:
...@@ -75,5 +75,9 @@ ...@@ -75,5 +75,9 @@
# include <bits/vector.tcc> # include <bits/vector.tcc>
#endif #endif
#ifdef _GLIBCXX_DEBUG
# include <debug/vector>
#endif
#endif /* _GLIBCXX_VECTOR */ #endif /* _GLIBCXX_VECTOR */
...@@ -94,6 +94,7 @@ sources = \ ...@@ -94,6 +94,7 @@ sources = \
codecvt.cc \ codecvt.cc \
complex_io.cc \ complex_io.cc \
ctype.cc \ ctype.cc \
debug.cc \
demangle.cc \ demangle.cc \
functexcept.cc \ functexcept.cc \
globals_locale.cc \ globals_locale.cc \
......
...@@ -251,6 +251,7 @@ sources = \ ...@@ -251,6 +251,7 @@ sources = \
codecvt.cc \ codecvt.cc \
complex_io.cc \ complex_io.cc \
ctype.cc \ ctype.cc \
debug.cc \
demangle.cc \ demangle.cc \
functexcept.cc \ functexcept.cc \
globals_locale.cc \ globals_locale.cc \
...@@ -360,7 +361,7 @@ am__objects_1 = codecvt_members.lo collate_members.lo ctype_members.lo \ ...@@ -360,7 +361,7 @@ am__objects_1 = codecvt_members.lo collate_members.lo ctype_members.lo \
messages_members.lo monetary_members.lo numeric_members.lo \ messages_members.lo monetary_members.lo numeric_members.lo \
time_members.lo time_members.lo
am__objects_2 = basic_file.lo c++locale.lo am__objects_2 = basic_file.lo c++locale.lo
am__objects_3 = codecvt.lo complex_io.lo ctype.lo demangle.lo \ am__objects_3 = codecvt.lo complex_io.lo ctype.lo debug.lo demangle.lo \
functexcept.lo globals_locale.lo globals_io.lo ios.lo \ functexcept.lo globals_locale.lo globals_io.lo ios.lo \
ios_failure.lo ios_init.lo ios_locale.lo limits.lo locale.lo \ ios_failure.lo ios_init.lo ios_locale.lo limits.lo locale.lo \
locale_init.lo locale_facets.lo localename.lo stdexcept.lo \ locale_init.lo locale_facets.lo localename.lo stdexcept.lo \
......
...@@ -42,6 +42,10 @@ ...@@ -42,6 +42,10 @@
namespace std namespace std
{ {
#ifdef _GLIBCXX_INST_ATOMICITY_LOCK
template volatile int __Atomicity_lock<0>::_S_atomicity_lock;
#endif
// string related to iostreams // string related to iostreams
template template
basic_istream<char>& basic_istream<char>&
...@@ -69,12 +73,8 @@ namespace std ...@@ -69,12 +73,8 @@ namespace std
basic_istream<wchar_t>& basic_istream<wchar_t>&
getline(basic_istream<wchar_t>&, wstring&); getline(basic_istream<wchar_t>&, wstring&);
#endif #endif
#ifdef _GLIBCXX_INST_ATOMICITY_LOCK
template volatile int __Atomicity_lock<0>::_S_atomicity_lock;
#endif
} // namespace std } // namespace std
namespace __gnu_cxx namespace __gnu_cxx
{ {
#ifdef _GLIBCXX_NEED_GENERIC_MUTEX #ifdef _GLIBCXX_NEED_GENERIC_MUTEX
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
# define C char # define C char
#endif #endif
namespace std namespace std
{ {
typedef basic_string<C> S; typedef basic_string<C> S;
...@@ -50,17 +50,7 @@ namespace std ...@@ -50,17 +50,7 @@ namespace std
template S operator+(const C*, const S&); template S operator+(const C*, const S&);
template S operator+(C, const S&); template S operator+(C, const S&);
template S operator+(const S&, const S&); template S operator+(const S&, const S&);
} // namespace std
namespace __gnu_cxx
{
using std::S;
template bool operator==(const S::iterator&, const S::iterator&);
template bool operator==(const S::const_iterator&, const S::const_iterator&);
}
namespace std
{
// Only one template keyword allowed here. // Only one template keyword allowed here.
// See core issue #46 (NAD) // See core issue #46 (NAD)
// http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46 // http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46
...@@ -100,3 +90,10 @@ namespace std ...@@ -100,3 +90,10 @@ namespace std
S::_S_construct(const C*, const C*, const allocator<C>&, S::_S_construct(const C*, const C*, const allocator<C>&,
forward_iterator_tag); forward_iterator_tag);
} // namespace std } // namespace std
namespace __gnu_cxx
{
using std::S;
template bool operator==(const S::iterator&, const S::iterator&);
template bool operator==(const S::const_iterator&, const S::const_iterator&);
} // namespace __gnu_cxx
...@@ -46,5 +46,5 @@ main() ...@@ -46,5 +46,5 @@ main()
test01(); test01();
return 0; return 0;
} }
// { dg-error "candidates" "" { target *-*-* } 216 } // { dg-error "candidates" "" { target *-*-* } 217 }
// { dg-error "std::auto_ptr" "" { target *-*-* } 338 } // { dg-error "std::auto_ptr" "" { target *-*-* } 347 }
// Bitset reference invalidation tests
// Copyright (C) 2003 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.
#include <debug/bitset>
#include <testsuite_hooks.h>
using __gnu_debug::bitset;
bool test = true;
// Disappear
void test01()
{
bitset<32>::reference* i;
{
bitset<32> bs;
bs.flip(7);
i = new bitset<32>::reference(bs[7]);
VERIFY(*i);
}
VERIFY(i->_M_singular());
delete i;
}
int main()
{
test01();
return !test;
}
// Deque iterator invalidation tests
// Copyright (C) 2003 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.
#include <debug/deque>
#include <testsuite_hooks.h>
using __gnu_debug::deque;
bool test = true;
// Assignment
void test01()
{
deque<int> v1;
deque<int> v2;
deque<int>::iterator i = v1.end();
VERIFY(!i._M_dereferenceable() && !i._M_singular());
v1 = v2;
VERIFY(i._M_singular());
i = v1.end();
v1.assign(v2.begin(), v2.end());
VERIFY(i._M_singular());
i = v1.end();
v1.assign(17, 42);
VERIFY(i._M_singular());
}
int main()
{
test01();
return !test;
}
// Deque iterator invalidation tests
// Copyright (C) 2003 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.
#include <debug/deque>
#include <testsuite_hooks.h>
using __gnu_debug::deque;
bool test = true;
// Resize
void test02()
{
deque<int> v(10, 17);
deque<int>::iterator before = v.begin() + 6;
deque<int>::iterator at = before + 1;
deque<int>::iterator after = at + 1;
// Shrink
v.resize(7);
VERIFY(before._M_dereferenceable());
VERIFY(at._M_singular());
VERIFY(after._M_singular());
// Grow
before = v.begin() + 6;
v.resize(17);
VERIFY(before._M_singular());
}
int main()
{
test02();
return !test;
}
// Deque iterator invalidation tests
// Copyright (C) 2003 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.
#include <debug/deque>
#include <testsuite_hooks.h>
using __gnu_debug::deque;
bool test = true;
// Insert
void test03()
{
deque<int> v(10, 17);
// Insert a single element
deque<int>::iterator before = v.begin() + 6;
deque<int>::iterator at = before + 1;
deque<int>::iterator after = at;
at = v.insert(at, 42);
VERIFY(before._M_singular());
VERIFY(at._M_dereferenceable());
VERIFY(after._M_singular());
// Insert multiple copies
before = v.begin() + 6;
at = before + 1;
v.insert(at, 3, 42);
VERIFY(before._M_singular());
VERIFY(at._M_singular());
// Insert iterator range
static int data[] = { 2, 3, 5, 7 };
before = v.begin() + 6;
at = before + 1;
v.insert(at, &data[0], &data[0] + 4);
VERIFY(before._M_singular());
VERIFY(at._M_singular());
}
int main()
{
test03();
return !test;
}
// Deque iterator invalidation tests
// Copyright (C) 2003 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.
#include <debug/deque>
#include <testsuite_hooks.h>
using __gnu_debug::deque;
bool test = true;
// Erase
void test04()
{
deque<int> v(20, 42);
// Single element erase (middle)
deque<int>::iterator before = v.begin();
deque<int>::iterator at = before + 3;
deque<int>::iterator after = at;
at = v.erase(at);
VERIFY(before._M_singular());
VERIFY(at._M_dereferenceable());
VERIFY(after._M_singular());
// Single element erase (end)
before = v.begin();
at = before;
after = at + 1;
at = v.erase(at);
VERIFY(before._M_singular());
VERIFY(at._M_dereferenceable());
VERIFY(after._M_dereferenceable());
// Multiple element erase
before = v.begin();
at = before + 3;
v.erase(at, at + 3);
VERIFY(before._M_singular());
VERIFY(at._M_singular());
// clear()
before = v.begin();
VERIFY(before._M_dereferenceable());
v.clear();
VERIFY(before._M_singular());
}
int main()
{
test04();
return !test;
}
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