summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/include
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2003-07-11 03:42:04 +0000
committerkan <kan@FreeBSD.org>2003-07-11 03:42:04 +0000
commitc7bbbdd036d3dd7ae253fb13c9994215af06f073 (patch)
treece14546aca3a67fa3440aed52f132bafaf68fe70 /contrib/libstdc++/include
parentb2a8872fbe1ec1c49094559ac7b78e6ea4ab7180 (diff)
downloadFreeBSD-src-c7bbbdd036d3dd7ae253fb13c9994215af06f073.zip
FreeBSD-src-c7bbbdd036d3dd7ae253fb13c9994215af06f073.tar.gz
Gcc 3.3.1-pre 2003-07-11 C++ support bits.
Diffstat (limited to 'contrib/libstdc++/include')
-rw-r--r--contrib/libstdc++/include/Makefile.am177
-rw-r--r--contrib/libstdc++/include/Makefile.in199
-rw-r--r--contrib/libstdc++/include/bits/basic_ios.h303
-rw-r--r--contrib/libstdc++/include/bits/basic_ios.tcc43
-rw-r--r--contrib/libstdc++/include/bits/basic_string.h578
-rw-r--r--contrib/libstdc++/include/bits/basic_string.tcc150
-rw-r--r--contrib/libstdc++/include/bits/boost_concept_check.h2
-rw-r--r--contrib/libstdc++/include/bits/c++config25
-rw-r--r--contrib/libstdc++/include/bits/char_traits.h21
-rw-r--r--contrib/libstdc++/include/bits/codecvt.h2
-rw-r--r--contrib/libstdc++/include/bits/concept_check.h3
-rw-r--r--contrib/libstdc++/include/bits/deque.tcc779
-rw-r--r--contrib/libstdc++/include/bits/fpos.h8
-rw-r--r--contrib/libstdc++/include/bits/fstream.tcc200
-rw-r--r--contrib/libstdc++/include/bits/gslice_array.h196
-rw-r--r--contrib/libstdc++/include/bits/indirect_array.h138
-rw-r--r--contrib/libstdc++/include/bits/ios_base.h290
-rw-r--r--contrib/libstdc++/include/bits/istream.tcc140
-rw-r--r--contrib/libstdc++/include/bits/list.tcc368
-rw-r--r--contrib/libstdc++/include/bits/locale_classes.h404
-rw-r--r--contrib/libstdc++/include/bits/locale_facets.h256
-rw-r--r--contrib/libstdc++/include/bits/locale_facets.tcc954
-rw-r--r--contrib/libstdc++/include/bits/localefwd.h333
-rw-r--r--contrib/libstdc++/include/bits/mask_array.h182
-rw-r--r--contrib/libstdc++/include/bits/ostream.tcc98
-rw-r--r--contrib/libstdc++/include/bits/slice_array.h241
-rw-r--r--contrib/libstdc++/include/bits/stl_alloc.h36
-rw-r--r--contrib/libstdc++/include/bits/stl_bvector.h19
-rw-r--r--contrib/libstdc++/include/bits/stl_deque.h2965
-rw-r--r--contrib/libstdc++/include/bits/stl_iterator.h13
-rw-r--r--contrib/libstdc++/include/bits/stl_iterator_base_funcs.h198
-rw-r--r--contrib/libstdc++/include/bits/stl_iterator_base_types.h9
-rw-r--r--contrib/libstdc++/include/bits/stl_list.h1788
-rw-r--r--contrib/libstdc++/include/bits/stl_map.h1004
-rw-r--r--contrib/libstdc++/include/bits/stl_multimap.h963
-rw-r--r--contrib/libstdc++/include/bits/stl_queue.h530
-rw-r--r--contrib/libstdc++/include/bits/stl_stack.h272
-rw-r--r--contrib/libstdc++/include/bits/stl_threads.h20
-rw-r--r--contrib/libstdc++/include/bits/stl_tree.h8
-rw-r--r--contrib/libstdc++/include/bits/stl_vector.h1887
-rw-r--r--contrib/libstdc++/include/bits/streambuf.tcc86
-rw-r--r--contrib/libstdc++/include/bits/streambuf_iterator.h36
-rw-r--r--contrib/libstdc++/include/bits/valarray_array.h20
-rw-r--r--contrib/libstdc++/include/bits/valarray_meta.h1390
-rw-r--r--contrib/libstdc++/include/bits/vector.tcc437
-rw-r--r--contrib/libstdc++/include/c_std/std_cmath.h127
-rw-r--r--contrib/libstdc++/include/c_std/std_cstdio.h15
-rw-r--r--contrib/libstdc++/include/c_std/std_cstdlib.h26
-rw-r--r--contrib/libstdc++/include/c_std/std_cwchar.h16
-rw-r--r--contrib/libstdc++/include/ext/stdio_filebuf.h13
-rw-r--r--contrib/libstdc++/include/ext/stl_hashtable.h7
-rw-r--r--contrib/libstdc++/include/std/std_bitset.h51
-rw-r--r--contrib/libstdc++/include/std/std_complex.h18
-rw-r--r--contrib/libstdc++/include/std/std_deque.h7
-rw-r--r--contrib/libstdc++/include/std/std_fstream.h357
-rw-r--r--contrib/libstdc++/include/std/std_iomanip.h51
-rw-r--r--contrib/libstdc++/include/std/std_iosfwd.h88
-rw-r--r--contrib/libstdc++/include/std/std_iostream.h30
-rw-r--r--contrib/libstdc++/include/std/std_istream.h511
-rw-r--r--contrib/libstdc++/include/std/std_limits.h1311
-rw-r--r--contrib/libstdc++/include/std/std_list.h7
-rw-r--r--contrib/libstdc++/include/std/std_locale.h7
-rw-r--r--contrib/libstdc++/include/std/std_memory.h555
-rw-r--r--contrib/libstdc++/include/std/std_ostream.h290
-rw-r--r--contrib/libstdc++/include/std/std_queue.h9
-rw-r--r--contrib/libstdc++/include/std/std_sstream.h281
-rw-r--r--contrib/libstdc++/include/std/std_stack.h8
-rw-r--r--contrib/libstdc++/include/std/std_streambuf.h531
-rw-r--r--contrib/libstdc++/include/std/std_valarray.h757
-rw-r--r--contrib/libstdc++/include/std/std_vector.h7
70 files changed, 13800 insertions, 9051 deletions
diff --git a/contrib/libstdc++/include/Makefile.am b/contrib/libstdc++/include/Makefile.am
index 5c87bb3..906468d 100644
--- a/contrib/libstdc++/include/Makefile.am
+++ b/contrib/libstdc++/include/Makefile.am
@@ -1,6 +1,6 @@
## Makefile for the include subdirectory of the GNU C++ Standard library.
##
-## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
## Process this file with automake to produce Makefile.in.
@@ -31,6 +31,75 @@ CXX = @glibcpp_CXX@
glibcpp_srcdir=@glibcpp_srcdir@
glibcpp_builddir=@glibcpp_builddir@
+GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
+LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
+INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES)
+
+# Standard C++ includes.
+std_srcdir = ${glibcpp_srcdir}/include/std
+std_builddir = .
+std_headers = \
+ ${std_srcdir}/std_algorithm.h \
+ ${std_srcdir}/std_bitset.h \
+ ${std_srcdir}/std_complex.h \
+ ${std_srcdir}/std_deque.h \
+ ${std_srcdir}/std_fstream.h \
+ ${std_srcdir}/std_functional.h \
+ ${std_srcdir}/std_iomanip.h \
+ ${std_srcdir}/std_ios.h \
+ ${std_srcdir}/std_iosfwd.h \
+ ${std_srcdir}/std_iostream.h \
+ ${std_srcdir}/std_istream.h \
+ ${std_srcdir}/std_iterator.h \
+ ${std_srcdir}/std_limits.h \
+ ${std_srcdir}/std_list.h \
+ ${std_srcdir}/std_locale.h \
+ ${std_srcdir}/std_map.h \
+ ${std_srcdir}/std_memory.h \
+ ${std_srcdir}/std_numeric.h \
+ ${std_srcdir}/std_ostream.h \
+ ${std_srcdir}/std_queue.h \
+ ${std_srcdir}/std_set.h \
+ ${std_srcdir}/std_sstream.h \
+ ${std_srcdir}/std_stack.h \
+ ${std_srcdir}/std_stdexcept.h \
+ ${std_srcdir}/std_streambuf.h \
+ ${std_srcdir}/std_string.h \
+ ${std_srcdir}/std_utility.h \
+ ${std_srcdir}/std_valarray.h \
+ ${std_srcdir}/std_vector.h
+# Renamed at build time.
+std_headers_rename = \
+ algorithm \
+ bitset \
+ complex \
+ deque \
+ fstream \
+ functional \
+ iomanip \
+ ios \
+ iosfwd \
+ iostream \
+ istream \
+ iterator \
+ limits \
+ list \
+ locale \
+ map \
+ memory \
+ numeric \
+ ostream \
+ queue \
+ set \
+ sstream \
+ stack \
+ stdexcept \
+ streambuf \
+ string \
+ utility \
+ valarray \
+ vector
+
bits_srcdir = ${glibcpp_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
@@ -43,15 +112,17 @@ bits_headers = \
${bits_srcdir}/codecvt.h \
${bits_srcdir}/concept_check.h \
${bits_srcdir}/cpp_type_traits.h \
+ ${bits_srcdir}/deque.tcc \
${bits_srcdir}/fpos.h \
${bits_srcdir}/fstream.tcc \
${bits_srcdir}/functexcept.h \
- ${bits_srcdir}/generic_shadow.h \
${bits_srcdir}/gslice.h \
${bits_srcdir}/gslice_array.h \
${bits_srcdir}/indirect_array.h \
${bits_srcdir}/ios_base.h \
${bits_srcdir}/istream.tcc \
+ ${bits_srcdir}/list.tcc \
+ ${bits_srcdir}/locale_classes.h \
${bits_srcdir}/locale_facets.h \
${bits_srcdir}/locale_facets.tcc \
${bits_srcdir}/localefwd.h \
@@ -60,7 +131,6 @@ bits_headers = \
${bits_srcdir}/pthread_allocimpl.h \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
- ${bits_srcdir}/slice.h \
${bits_srcdir}/slice_array.h \
${bits_srcdir}/sstream.tcc \
${bits_srcdir}/stl_algo.h \
@@ -96,7 +166,8 @@ bits_headers = \
${bits_srcdir}/type_traits.h \
${bits_srcdir}/valarray_array.h \
${bits_srcdir}/valarray_array.tcc \
- ${bits_srcdir}/valarray_meta.h
+ ${bits_srcdir}/valarray_meta.h \
+ ${bits_srcdir}/vector.tcc
backward_srcdir = ${glibcpp_srcdir}/include/backward
backward_builddir = ./backward
@@ -135,7 +206,6 @@ backward_headers = \
${backward_srcdir}/tree.h \
${backward_srcdir}/vector.h \
${backward_srcdir}/fstream.h \
- ${backward_srcdir}/strstream.h \
${backward_srcdir}/strstream \
${backward_srcdir}/backward_warning.h
@@ -239,71 +309,6 @@ else
c_compatibility_headers_extra =
endif
-
-std_srcdir = ${glibcpp_srcdir}/include/std
-std_builddir = .
-std_headers = \
- ${std_srcdir}/std_algorithm.h \
- ${std_srcdir}/std_bitset.h \
- ${std_srcdir}/std_complex.h \
- ${std_srcdir}/std_deque.h \
- ${std_srcdir}/std_fstream.h \
- ${std_srcdir}/std_functional.h \
- ${std_srcdir}/std_iomanip.h \
- ${std_srcdir}/std_ios.h \
- ${std_srcdir}/std_iosfwd.h \
- ${std_srcdir}/std_iostream.h \
- ${std_srcdir}/std_istream.h \
- ${std_srcdir}/std_iterator.h \
- ${std_srcdir}/std_limits.h \
- ${std_srcdir}/std_list.h \
- ${std_srcdir}/std_locale.h \
- ${std_srcdir}/std_map.h \
- ${std_srcdir}/std_memory.h \
- ${std_srcdir}/std_numeric.h \
- ${std_srcdir}/std_ostream.h \
- ${std_srcdir}/std_queue.h \
- ${std_srcdir}/std_set.h \
- ${std_srcdir}/std_sstream.h \
- ${std_srcdir}/std_stack.h \
- ${std_srcdir}/std_stdexcept.h \
- ${std_srcdir}/std_streambuf.h \
- ${std_srcdir}/std_string.h \
- ${std_srcdir}/std_utility.h \
- ${std_srcdir}/std_valarray.h \
- ${std_srcdir}/std_vector.h
-# Renamed at build time.
-std_headers_rename = \
- algorithm \
- bitset \
- complex \
- deque \
- fstream \
- functional \
- iomanip \
- ios \
- iosfwd \
- iostream \
- istream \
- iterator \
- limits \
- list \
- locale \
- map \
- memory \
- numeric \
- ostream \
- queue \
- set \
- sstream \
- stack \
- stdexcept \
- streambuf \
- string \
- utility \
- valarray \
- vector
-
target_srcdir = ${glibcpp_srcdir}/@OS_INC_SRCDIR@
target_builddir = ./${target_alias}/bits
target_headers = \
@@ -311,8 +316,12 @@ target_headers = \
${target_srcdir}/ctype_inline.h \
${target_srcdir}/ctype_noninline.h \
${target_srcdir}/os_defines.h \
- ${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h \
- ${glibcpp_srcdir}/@CPU_LIMITS_INC_SRCDIR@/cpu_limits.h
+ ${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
+
+# Non-installed target_header files.
+target_headers_noinst = \
+ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@
+
# These target_headers_extra files are all built with ad hoc naming rules.
target_headers_extra = \
${target_builddir}/basic_file.h \
@@ -333,9 +342,7 @@ thread_target_headers = \
# CLEANFILES and all-local are kept up-to-date.
allstamps = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
- stamp-backward stamp-ext \
- ${target_builddir}/stamp-target
-
+ stamp-backward stamp-ext stamp-target
# Here are the rules for building the headers
all-local: ${target_builddir}/c++config.h ${thread_target_headers} ${allstamps}
@@ -352,6 +359,12 @@ stamp-std: ${std_headers}
done) ;\
echo `date` > stamp-std
+stamp-std-precompile: stamp-std
+ for h in ${std_headers_rename}; do \
+ $(CXX) -Winvalid-pch -x c++-header $(INCLUDES) $${h}; \
+ done; \
+ echo `date` > stamp-std-precompile
+
stamp-bits: ${bits_headers}
@if [ ! -d "${bits_builddir}" ]; then \
mkdir -p ${bits_builddir} ;\
@@ -402,17 +415,19 @@ stamp-${target_alias}:
fi
# Target includes static.
-${target_builddir}/stamp-target: ${target_headers} stamp-${target_alias}
- @cd ${target_builddir} ;\
- if [ ! -f stamp-target ]; then \
+# XXX Missing dependency info for {target_headers_extra}
+stamp-target: ${target_headers} ${target_headers_noinst} stamp-${target_alias}
+ @if [ ! -f stamp-target ]; then \
+ (cd ${target_builddir} ;\
@LN_S@ ${target_headers} . || true ;\
@LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@ . || true ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CTIME_H@ time_members.h || true ;\
- @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true ;\
- echo `date` > stamp-target; \
+ @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true);\
+ echo `date` > stamp-target ; \
fi
# Target includes dynamic.
@@ -495,7 +510,7 @@ install-data-local:
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${target_builddir}; done
# By adding these files here, automake will remove them for 'make clean'
-#CLEANFILES = ${allstamps}
+CLEANFILES = *.pch stamp-std-precompile
# Stop implicit '.o' make rules from ever stomping on extensionless
# headers, in the improbable case where some foolish, crack-addled
diff --git a/contrib/libstdc++/include/Makefile.in b/contrib/libstdc++/include/Makefile.in
index 37a06d4..cc7e3a5 100644
--- a/contrib/libstdc++/include/Makefile.in
+++ b/contrib/libstdc++/include/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
@@ -67,15 +67,24 @@ AR = @AR@
AS = @AS@
ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@
AWK = @AWK@
+BASIC_FILE_CC = @BASIC_FILE_CC@
BASIC_FILE_H = @BASIC_FILE_H@
CC = @CC@
CCODECVT_C = @CCODECVT_C@
+CCODECVT_CC = @CCODECVT_CC@
CCODECVT_H = @CCODECVT_H@
+CCOLLATE_CC = @CCOLLATE_CC@
+CCTYPE_CC = @CCTYPE_CC@
+CLOCALE_CC = @CLOCALE_CC@
CLOCALE_H = @CLOCALE_H@
+CLOCALE_INTERNAL_H = @CLOCALE_INTERNAL_H@
+CMESSAGES_CC = @CMESSAGES_CC@
CMESSAGES_H = @CMESSAGES_H@
+CMONEY_CC = @CMONEY_CC@
+CNUMERIC_CC = @CNUMERIC_CC@
CPP = @CPP@
-CPU_LIMITS_INC_SRCDIR = @CPU_LIMITS_INC_SRCDIR@
CSTDIO_H = @CSTDIO_H@
+CTIME_CC = @CTIME_CC@
CTIME_H = @CTIME_H@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@
@@ -85,12 +94,10 @@ EXEEXT = @EXEEXT@
EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
-GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
GLIBCPP_IS_CROSS_COMPILING = @GLIBCPP_IS_CROSS_COMPILING@
LIBIO_INCLUDES = @LIBIO_INCLUDES@
LIBMATHOBJS = @LIBMATHOBJS@
LIBMATH_INCLUDES = @LIBMATH_INCLUDES@
-LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
LIBSUPCXX_PICFLAGS = @LIBSUPCXX_PICFLAGS@
LIBTOOL = @LIBTOOL@
LIBUNWIND_FLAG = @LIBUNWIND_FLAG@
@@ -107,6 +114,7 @@ RANLIB = @RANLIB@
SECTION_FLAGS = @SECTION_FLAGS@
SECTION_LDFLAGS = @SECTION_LDFLAGS@
STRIP = @STRIP@
+SYMVER_MAP = @SYMVER_MAP@
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
@@ -139,6 +147,77 @@ CXX = @glibcpp_CXX@
glibcpp_srcdir = @glibcpp_srcdir@
glibcpp_builddir = @glibcpp_builddir@
+GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
+LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
+INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES)
+
+# Standard C++ includes.
+std_srcdir = ${glibcpp_srcdir}/include/std
+std_builddir = .
+std_headers = \
+ ${std_srcdir}/std_algorithm.h \
+ ${std_srcdir}/std_bitset.h \
+ ${std_srcdir}/std_complex.h \
+ ${std_srcdir}/std_deque.h \
+ ${std_srcdir}/std_fstream.h \
+ ${std_srcdir}/std_functional.h \
+ ${std_srcdir}/std_iomanip.h \
+ ${std_srcdir}/std_ios.h \
+ ${std_srcdir}/std_iosfwd.h \
+ ${std_srcdir}/std_iostream.h \
+ ${std_srcdir}/std_istream.h \
+ ${std_srcdir}/std_iterator.h \
+ ${std_srcdir}/std_limits.h \
+ ${std_srcdir}/std_list.h \
+ ${std_srcdir}/std_locale.h \
+ ${std_srcdir}/std_map.h \
+ ${std_srcdir}/std_memory.h \
+ ${std_srcdir}/std_numeric.h \
+ ${std_srcdir}/std_ostream.h \
+ ${std_srcdir}/std_queue.h \
+ ${std_srcdir}/std_set.h \
+ ${std_srcdir}/std_sstream.h \
+ ${std_srcdir}/std_stack.h \
+ ${std_srcdir}/std_stdexcept.h \
+ ${std_srcdir}/std_streambuf.h \
+ ${std_srcdir}/std_string.h \
+ ${std_srcdir}/std_utility.h \
+ ${std_srcdir}/std_valarray.h \
+ ${std_srcdir}/std_vector.h
+
+# Renamed at build time.
+std_headers_rename = \
+ algorithm \
+ bitset \
+ complex \
+ deque \
+ fstream \
+ functional \
+ iomanip \
+ ios \
+ iosfwd \
+ iostream \
+ istream \
+ iterator \
+ limits \
+ list \
+ locale \
+ map \
+ memory \
+ numeric \
+ ostream \
+ queue \
+ set \
+ sstream \
+ stack \
+ stdexcept \
+ streambuf \
+ string \
+ utility \
+ valarray \
+ vector
+
+
bits_srcdir = ${glibcpp_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
@@ -151,15 +230,17 @@ bits_headers = \
${bits_srcdir}/codecvt.h \
${bits_srcdir}/concept_check.h \
${bits_srcdir}/cpp_type_traits.h \
+ ${bits_srcdir}/deque.tcc \
${bits_srcdir}/fpos.h \
${bits_srcdir}/fstream.tcc \
${bits_srcdir}/functexcept.h \
- ${bits_srcdir}/generic_shadow.h \
${bits_srcdir}/gslice.h \
${bits_srcdir}/gslice_array.h \
${bits_srcdir}/indirect_array.h \
${bits_srcdir}/ios_base.h \
${bits_srcdir}/istream.tcc \
+ ${bits_srcdir}/list.tcc \
+ ${bits_srcdir}/locale_classes.h \
${bits_srcdir}/locale_facets.h \
${bits_srcdir}/locale_facets.tcc \
${bits_srcdir}/localefwd.h \
@@ -168,7 +249,6 @@ bits_headers = \
${bits_srcdir}/pthread_allocimpl.h \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
- ${bits_srcdir}/slice.h \
${bits_srcdir}/slice_array.h \
${bits_srcdir}/sstream.tcc \
${bits_srcdir}/stl_algo.h \
@@ -204,7 +284,8 @@ bits_headers = \
${bits_srcdir}/type_traits.h \
${bits_srcdir}/valarray_array.h \
${bits_srcdir}/valarray_array.tcc \
- ${bits_srcdir}/valarray_meta.h
+ ${bits_srcdir}/valarray_meta.h \
+ ${bits_srcdir}/vector.tcc
backward_srcdir = ${glibcpp_srcdir}/include/backward
@@ -244,7 +325,6 @@ backward_headers = \
${backward_srcdir}/tree.h \
${backward_srcdir}/vector.h \
${backward_srcdir}/fstream.h \
- ${backward_srcdir}/strstream.h \
${backward_srcdir}/strstream \
${backward_srcdir}/backward_warning.h
@@ -342,72 +422,6 @@ c_compatibility_headers = \
@GLIBCPP_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = @GLIBCPP_C_HEADERS_COMPATIBILITY_TRUE@${c_compatibility_headers}
@GLIBCPP_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
-std_srcdir = ${glibcpp_srcdir}/include/std
-std_builddir = .
-std_headers = \
- ${std_srcdir}/std_algorithm.h \
- ${std_srcdir}/std_bitset.h \
- ${std_srcdir}/std_complex.h \
- ${std_srcdir}/std_deque.h \
- ${std_srcdir}/std_fstream.h \
- ${std_srcdir}/std_functional.h \
- ${std_srcdir}/std_iomanip.h \
- ${std_srcdir}/std_ios.h \
- ${std_srcdir}/std_iosfwd.h \
- ${std_srcdir}/std_iostream.h \
- ${std_srcdir}/std_istream.h \
- ${std_srcdir}/std_iterator.h \
- ${std_srcdir}/std_limits.h \
- ${std_srcdir}/std_list.h \
- ${std_srcdir}/std_locale.h \
- ${std_srcdir}/std_map.h \
- ${std_srcdir}/std_memory.h \
- ${std_srcdir}/std_numeric.h \
- ${std_srcdir}/std_ostream.h \
- ${std_srcdir}/std_queue.h \
- ${std_srcdir}/std_set.h \
- ${std_srcdir}/std_sstream.h \
- ${std_srcdir}/std_stack.h \
- ${std_srcdir}/std_stdexcept.h \
- ${std_srcdir}/std_streambuf.h \
- ${std_srcdir}/std_string.h \
- ${std_srcdir}/std_utility.h \
- ${std_srcdir}/std_valarray.h \
- ${std_srcdir}/std_vector.h
-
-# Renamed at build time.
-std_headers_rename = \
- algorithm \
- bitset \
- complex \
- deque \
- fstream \
- functional \
- iomanip \
- ios \
- iosfwd \
- iostream \
- istream \
- iterator \
- limits \
- list \
- locale \
- map \
- memory \
- numeric \
- ostream \
- queue \
- set \
- sstream \
- stack \
- stdexcept \
- streambuf \
- string \
- utility \
- valarray \
- vector
-
-
target_srcdir = ${glibcpp_srcdir}/@OS_INC_SRCDIR@
target_builddir = ./${target_alias}/bits
target_headers = \
@@ -415,8 +429,13 @@ target_headers = \
${target_srcdir}/ctype_inline.h \
${target_srcdir}/ctype_noninline.h \
${target_srcdir}/os_defines.h \
- ${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h \
- ${glibcpp_srcdir}/@CPU_LIMITS_INC_SRCDIR@/cpu_limits.h
+ ${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
+
+
+# Non-installed target_header files.
+target_headers_noinst = \
+ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@
+
# These target_headers_extra files are all built with ad hoc naming rules.
target_headers_extra = \
@@ -440,8 +459,7 @@ thread_target_headers = \
# CLEANFILES and all-local are kept up-to-date.
allstamps = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
- stamp-backward stamp-ext \
- ${target_builddir}/stamp-target
+ stamp-backward stamp-ext stamp-target
# Target includes for threads
@@ -457,6 +475,9 @@ uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_]
# target_headers_extra are taken out of the build tree staging area;
# the rest are taken from the original source tree.
gxx_include_dir = @gxx_include_dir@
+
+# By adding these files here, automake will remove them for 'make clean'
+CLEANFILES = *.pch stamp-std-precompile
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = Makefile.am Makefile.in
@@ -525,6 +546,7 @@ installdirs:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
@@ -574,6 +596,12 @@ stamp-std: ${std_headers}
done) ;\
echo `date` > stamp-std
+stamp-std-precompile: stamp-std
+ for h in ${std_headers_rename}; do \
+ $(CXX) -Winvalid-pch -x c++-header $(INCLUDES) $${h}; \
+ done; \
+ echo `date` > stamp-std-precompile
+
stamp-bits: ${bits_headers}
@if [ ! -d "${bits_builddir}" ]; then \
mkdir -p ${bits_builddir} ;\
@@ -624,17 +652,19 @@ stamp-${target_alias}:
fi
# Target includes static.
-${target_builddir}/stamp-target: ${target_headers} stamp-${target_alias}
- @cd ${target_builddir} ;\
- if [ ! -f stamp-target ]; then \
+# XXX Missing dependency info for {target_headers_extra}
+stamp-target: ${target_headers} ${target_headers_noinst} stamp-${target_alias}
+ @if [ ! -f stamp-target ]; then \
+ (cd ${target_builddir} ;\
@LN_S@ ${target_headers} . || true ;\
@LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@ . || true ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CTIME_H@ time_members.h || true ;\
- @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true ;\
- echo `date` > stamp-target; \
+ @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true);\
+ echo `date` > stamp-target ; \
fi
# Target includes dynamic.
@@ -702,9 +732,6 @@ install-data-local:
${thread_target_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${target_builddir}; done
-# By adding these files here, automake will remove them for 'make clean'
-#CLEANFILES = ${allstamps}
-
# Stop implicit '.o' make rules from ever stomping on extensionless
# headers, in the improbable case where some foolish, crack-addled
# developer tries to create them via make in the include build
diff --git a/contrib/libstdc++/include/bits/basic_ios.h b/contrib/libstdc++/include/bits/basic_ios.h
index 13ad0f8..fe5e36a 100644
--- a/contrib/libstdc++/include/bits/basic_ios.h
+++ b/contrib/libstdc++/include/bits/basic_ios.h
@@ -1,6 +1,7 @@
// Iostreams base classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 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
@@ -38,120 +39,291 @@
#pragma GCC system_header
#include <bits/streambuf_iterator.h>
+#include <bits/localefwd.h>
+#include <bits/locale_classes.h>
#include <bits/locale_facets.h>
namespace std
{
// 27.4.5 Template class basic_ios
+ /**
+ * @brief Virtual base class for all stream classes.
+ *
+ * Most of the member functions called dispatched on stream objects
+ * (e.g., @c std::cout.foo(bar);) are consolidated in this class.
+ */
template<typename _CharT, typename _Traits>
class basic_ios : public ios_base
{
public:
- // Types:
- typedef _CharT char_type;
- typedef typename _Traits::int_type int_type;
- typedef typename _Traits::pos_type pos_type;
- typedef typename _Traits::off_type off_type;
- typedef _Traits traits_type;
-
- // Non-standard Types:
- typedef ctype<_CharT> __ctype_type;
- typedef ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter;
- typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
- typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
- typedef num_get<_CharT, __istreambuf_iter> __numget_type;
+ //@{
+ /**
+ * These are standard types. They permit a standardized way of
+ * referring to names of (or names dependant on) the template
+ * parameters, which are specific to the implementation.
+ */
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+ //@}
+
+ //@{
+ /**
+ * @if maint
+ * These are non-standard types.
+ * @endif
+ */
+ typedef ctype<_CharT> __ctype_type;
+ typedef ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter;
+ typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
+ typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
+ typedef num_get<_CharT, __istreambuf_iter> __numget_type;
+ //@}
+
+ friend void ios_base::Init::_S_ios_create(bool);
// Data members:
protected:
- basic_ostream<_CharT, _Traits>* _M_tie;
- mutable char_type _M_fill;
- mutable bool _M_fill_init;
- basic_streambuf<_CharT, _Traits>* _M_streambuf;
+ basic_ostream<_CharT, _Traits>* _M_tie;
+ mutable char_type _M_fill;
+ mutable bool _M_fill_init;
+ basic_streambuf<_CharT, _Traits>* _M_streambuf;
// Cached use_facet<ctype>, which is based on the current locale info.
- const __ctype_type* _M_fctype;
+ const __ctype_type* _M_fctype;
// From ostream.
- const __numput_type* _M_fnumput;
+ const __numput_type* _M_fnumput;
// From istream.
- const __numget_type* _M_fnumget;
+ const __numget_type* _M_fnumget;
public:
+ //@{
+ /**
+ * @brief The quick-and-easy status check.
+ *
+ * This allows you to write constructs such as
+ * "if (!a_stream) ..." and "while (a_stream) ..."
+ */
operator void*() const
{ return this->fail() ? 0 : const_cast<basic_ios*>(this); }
bool
operator!() const
{ return this->fail(); }
-
+ //@}
+
+ /**
+ * @brief Returns the error state of the stream buffer.
+ * @return A bit pattern (well, isn't everything?)
+ *
+ * See std::ios_base::iostate for the possible bit values. Most
+ * users will call one of the interpreting wrappers, e.g., good().
+ */
iostate
rdstate() const
{ return _M_streambuf_state; }
+ /**
+ * @brief [Re]sets the error state.
+ * @param state The new state flag(s) to set.
+ *
+ * See std::ios_base::iostate for the possible bit values. Most
+ * users will not need to pass an argument.
+ */
void
clear(iostate __state = goodbit);
+ /**
+ * @brief Sets additional flags in the error state.
+ * @param state The additional state flag(s) to set.
+ *
+ * See std::ios_base::iostate for the possible bit values.
+ */
void
setstate(iostate __state)
{ this->clear(this->rdstate() | __state); }
+ /**
+ * @brief Fast error checking.
+ * @return True if no error flags are set.
+ *
+ * A wrapper around rdstate.
+ */
bool
good() const
{ return this->rdstate() == 0; }
+ /**
+ * @brief Fast error checking.
+ * @return True if the eofbit is set.
+ *
+ * Note that other iostate flags may also be set.
+ */
bool
eof() const
{ return (this->rdstate() & eofbit) != 0; }
+ /**
+ * @brief Fast error checking.
+ * @return True if either the badbit or the failbit is set.
+ *
+ * Checking the badbit in fail() is historical practice.
+ * Note that other iostate flags may also be set.
+ */
bool
fail() const
{ return (this->rdstate() & (badbit | failbit)) != 0; }
+ /**
+ * @brief Fast error checking.
+ * @return True if the badbit is set.
+ *
+ * Note that other iostate flags may also be set.
+ */
bool
bad() const
{ return (this->rdstate() & badbit) != 0; }
+ /**
+ * @brief Throwing exceptions on errors.
+ * @return The current exceptions mask.
+ *
+ * This changes nothing in the stream. See the one-argument version
+ * of exceptions(iostate) for the meaning of the return value.
+ */
iostate
exceptions() const
{ return _M_exception; }
+ /**
+ * @brief Throwing exceptions on errors.
+ * @param except The new exceptions mask.
+ *
+ * By default, error flags are set silently. You can set an
+ * exceptions mask for each stream; if a bit in the mask becomes set
+ * in the error flags, then an exception of type
+ * std::ios_base::failure is thrown.
+ *
+ * If the error flage is already set when the exceptions mask is
+ * added, the exception is immediately thrown. Try running the
+ * following under GCC 3.1 or later:
+ * @code
+ * #include <iostream>
+ * #include <fstream>
+ * #include <exception>
+ *
+ * int main()
+ * {
+ * std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
+ *
+ * std::ifstream f ("/etc/motd");
+ *
+ * std::cerr << "Setting badbit\n";
+ * f.setstate (std::ios_base::badbit);
+ *
+ * std::cerr << "Setting exception mask\n";
+ * f.exceptions (std::ios_base::badbit);
+ * }
+ * @endcode
+ */
void
exceptions(iostate __except)
{
- _M_exception = __except;
- this->clear(_M_streambuf_state);
+ _M_exception = __except;
+ this->clear(_M_streambuf_state);
}
// Constructor/destructor:
+ /**
+ * @brief Constructor performs initialization.
+ *
+ * The parameter is passed by derived streams.
+ */
explicit
basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base()
{ this->init(__sb); }
+ /**
+ * @brief Empty.
+ *
+ * The destructor does nothing. More specifically, it does not
+ * destroy the streambuf held by rdbuf().
+ */
virtual
~basic_ios() { }
// Members:
+ /**
+ * @brief Fetches the current @e tied stream.
+ * @return A pointer to the tied stream, or NULL if the stream is
+ * not tied.
+ *
+ * A stream may be @e tied (or synchronized) to a second output
+ * stream. When this stream performs any I/O, the tied stream is
+ * first flushed. For example, @c std::cin is tied to @c std::cout.
+ */
basic_ostream<_CharT, _Traits>*
tie() const
{ return _M_tie; }
+ /**
+ * @brief Ties this stream to an output stream.
+ * @param tiestr The output stream.
+ * @return The previously tied output stream, or NULL if the stream
+ * was not tied.
+ *
+ * This sets up a new tie; see tie() for more.
+ */
basic_ostream<_CharT, _Traits>*
tie(basic_ostream<_CharT, _Traits>* __tiestr)
{
- basic_ostream<_CharT, _Traits>* __old = _M_tie;
- _M_tie = __tiestr;
- return __old;
+ basic_ostream<_CharT, _Traits>* __old = _M_tie;
+ _M_tie = __tiestr;
+ return __old;
}
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current stream buffer.
+ *
+ * This does not change the state of the stream.
+ */
basic_streambuf<_CharT, _Traits>*
rdbuf() const
{ return _M_streambuf; }
+ /**
+ * @brief Changing the underlying buffer.
+ * @param sb The new stream buffer.
+ * @return The previous stream buffer.
+ *
+ * Associates a new buffer with the current stream, and clears the
+ * error state.
+ *
+ * Due to historical accidents which the LWG refuses to correct, the
+ * I/O library suffers from a design error: this function is hidden
+ * in derived classes by overrides of the zero-argument @c rdbuf(),
+ * which is non-virtual for hysterical raisins. As a result, you
+ * must use explicit qualifications to access this function via any
+ * derived class.
+ */
basic_streambuf<_CharT, _Traits>*
rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
+ /**
+ * @doctodo
+ */
basic_ios&
copyfmt(const basic_ios& __rhs);
+ /**
+ * @brief Retreives the "empty" character.
+ * @return The current fill character.
+ *
+ * It defaults to a space (' ') in the current locale.
+ */
char_type
fill() const
{
@@ -163,6 +335,15 @@ namespace std
return _M_fill;
}
+ /**
+ * @brief Sets a new "empty" character.
+ * @param ch The new character.
+ * @return The previous fill character.
+ *
+ * The fill character is used to fill out space when P+ characters
+ * have been requested (e.g., via setw), Q characters are actually
+ * used, and Q<P. It defaults to a space (' ') in the current locale.
+ */
char_type
fill(char_type __ch)
{
@@ -172,20 +353,77 @@ namespace std
}
// Locales:
+ /**
+ * @brief Moves to a new locale.
+ * @param loc The new locale.
+ * @return The previous locale.
+ *
+ * Calls @c ios_base::imbue(loc), and if a stream buffer is associated
+ * with this stream, calls that buffer's @c pubimbue(loc).
+ *
+ * Additional l10n notes are at
+ * http://gcc.gnu.org/onlinedocs/libstdc++/22_locale/howto.html
+ */
locale
imbue(const locale& __loc);
+ /**
+ * @brief Squeezes characters.
+ * @param c The character to narrow.
+ * @param dfault The character to narrow.
+ * @return The narrowed character.
+ *
+ * Maps a character of @c char_type to a character of @c char,
+ * if possible.
+ *
+ * Returns the result of
+ * @code
+ * std::use_facet< ctype<char_type> >(getloc()).narrow(c,dfault)
+ * @endcode
+ *
+ * Additional l10n notes are at
+ * http://gcc.gnu.org/onlinedocs/libstdc++/22_locale/howto.html
+ */
char
narrow(char_type __c, char __dfault) const;
+ /**
+ * @brief Widens characters.
+ * @param c The character to widen.
+ * @return The widened character.
+ *
+ * Maps a character of @c char to a character of @c char_type.
+ *
+ * Returns the result of
+ * @code
+ * std::use_facet< ctype<char_type> >(getloc()).widen(c)
+ * @endcode
+ *
+ * Additional l10n notes are at
+ * http://gcc.gnu.org/onlinedocs/libstdc++/22_locale/howto.html
+ */
char_type
widen(char __c) const;
protected:
// 27.4.5.1 basic_ios constructors
+ /**
+ * @brief Empty.
+ *
+ * The default constructor does nothing and is not normally
+ * accessible to users.
+ */
basic_ios() : ios_base()
{ }
+ /**
+ * @brief All setup is performed here.
+ *
+ * This is called from the public constructor. It is not virtual and
+ * cannot be redefined. The second argument, __cache, is used
+ * to initialize the standard streams without allocating
+ * memory.
+ */
void
init(basic_streambuf<_CharT, _Traits>* __sb);
@@ -198,7 +436,18 @@ namespace std
}
void
+ _M_cache_locale(const locale& __loc);
+
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
+ void
_M_cache_facets(const locale& __loc);
+#endif
+
+ // Internal state setter that won't throw, only set the state bits.
+ // Used to guarantee we don't throw when setting badbit.
+ void
+ _M_setstate(iostate __state) { _M_streambuf_state |= __state; }
};
} // namespace std
diff --git a/contrib/libstdc++/include/bits/basic_ios.tcc b/contrib/libstdc++/include/bits/basic_ios.tcc
index 7ee8015..1c9cd3b 100644
--- a/contrib/libstdc++/include/bits/basic_ios.tcc
+++ b/contrib/libstdc++/include/bits/basic_ios.tcc
@@ -1,6 +1,6 @@
// basic_ios locale and locale-related member functions -*- C++ -*-
-// Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2001, 2002, 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
@@ -95,10 +95,17 @@ namespace std
this->precision(__rhs.precision());
this->tie(__rhs.tie());
this->fill(__rhs.fill());
+ _M_ios_locale = __rhs.getloc();
+
+ // This removes the link to __rhs locale cache
+ _M_call_callbacks(copyfmt_event);
+
+ _M_cache_locale(_M_ios_locale);
+
+
// The next is required to be the last assignment.
this->exceptions(__rhs.exceptions());
- _M_call_callbacks(copyfmt_event);
return *this;
}
@@ -129,7 +136,7 @@ namespace std
{
locale __old(this->getloc());
ios_base::imbue(__loc);
- _M_cache_facets(__loc);
+ _M_cache_locale(__loc);
if (this->rdbuf() != 0)
this->rdbuf()->pubimbue(__loc);
return __old;
@@ -141,7 +148,7 @@ namespace std
{
// NB: This may be called more than once on the same object.
ios_base::_M_init();
- _M_cache_facets(_M_ios_locale);
+ _M_cache_locale(_M_ios_locale);
_M_tie = 0;
// NB: The 27.4.4.1 Postconditions Table specifies requirements
@@ -166,31 +173,47 @@ namespace std
template<typename _CharT, typename _Traits>
void
- basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
+ basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc)
{
- if (has_facet<__ctype_type>(__loc))
+ if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
_M_fctype = &use_facet<__ctype_type>(__loc);
else
_M_fctype = 0;
- // Should be filled in by ostream and istream, respectively.
- if (has_facet<__numput_type>(__loc))
+ if (__builtin_expect(has_facet<__numput_type>(__loc), true))
_M_fnumput = &use_facet<__numput_type>(__loc);
else
_M_fnumput = 0;
- if (has_facet<__numget_type>(__loc))
- _M_fnumget = &use_facet<__numget_type>(__loc);
+ if (__builtin_expect(has_facet<__numget_type>(__loc), true))
+ _M_fnumget = &use_facet<__numget_type>(__loc);
else
_M_fnumget = 0;
}
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
+ template<typename _CharT, typename _Traits>
+ void
+ basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
+ {
+ if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
+ _M_fctype = &use_facet<__ctype_type>(__loc);
+ if (__builtin_expect(has_facet<__numput_type>(__loc), true))
+ _M_fnumput = &use_facet<__numput_type>(__loc);
+ if (__builtin_expect(has_facet<__numget_type>(__loc), true))
+ _M_fnumget = &use_facet<__numget_type>(__loc);
+ }
+#endif
+
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_ios<char>;
#ifdef _GLIBCPP_USE_WCHAR_T
extern template class basic_ios<wchar_t>;
#endif
+#endif
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/basic_string.h b/contrib/libstdc++/include/bits/basic_string.h
index a9c02ce..e92009d 100644
--- a/contrib/libstdc++/include/bits/basic_string.h
+++ b/contrib/libstdc++/include/bits/basic_string.h
@@ -38,7 +38,7 @@
*/
#ifndef _CPP_BITS_STRING_H
-#define _CPP_BITS_STRING_H 1
+#define _CPP_BITS_STRING_H 1
#pragma GCC system_header
@@ -46,44 +46,64 @@
namespace std
{
- // Documentation? What's that?
- // Nathan Myers <ncm@cantrip.org>.
- //
- // A string looks like this:
- //
- // [_Rep]
- // _M_length
- // [basic_string<char_type>] _M_capacity
- // _M_dataplus _M_state
- // _M_p ----------------> unnamed array of char_type
-
- // Where the _M_p points to the first character in the string, and
- // you cast it to a pointer-to-_Rep and subtract 1 to get a
- // pointer to the header.
-
- // This approach has the enormous advantage that a string object
- // requires only one allocation. All the ugliness is confined
- // within a single pair of inline functions, which each compile to
- // a single "add" instruction: _Rep::_M_data(), and
- // string::_M_rep(); and the allocation function which gets a
- // block of raw bytes and with room enough and constructs a _Rep
- // object at the front.
-
- // The reason you want _M_data pointing to the character array and
- // not the _Rep is so that the debugger can see the string
- // contents. (Probably we should add a non-inline member to get
- // the _Rep for the debugger to use, so users can check the actual
- // string length.)
-
- // Note that the _Rep object is a POD so that you can have a
- // static "empty string" _Rep object already "constructed" before
- // static constructors have run. The reference-count encoding is
- // chosen so that a 0 indicates one reference, so you never try to
- // destroy the empty-string _Rep object.
-
- // All but the last paragraph is considered pretty conventional
- // for a C++ string implementation.
-
+ /**
+ * @class basic_string basic_string.h <string>
+ * @brief Managing sequences of characters and character-like objects.
+ *
+ * @ingroup Containers
+ * @ingroup Sequences
+ *
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
+ * <a href="tables.html#66">reversible container</a>, and a
+ * <a href="tables.html#67">sequence</a>. Of the
+ * <a href="tables.html#68">optional sequence requirements</a>, only
+ * @c push_back, @c at, and array access are supported.
+ *
+ * @doctodo
+ *
+ *
+ * @if maint
+ * Documentation? What's that?
+ * Nathan Myers <ncm@cantrip.org>.
+ *
+ * A string looks like this:
+ *
+ * @code
+ * [_Rep]
+ * _M_length
+ * [basic_string<char_type>] _M_capacity
+ * _M_dataplus _M_state
+ * _M_p ----------------> unnamed array of char_type
+ * @endcode
+ *
+ * Where the _M_p points to the first character in the string, and
+ * you cast it to a pointer-to-_Rep and subtract 1 to get a
+ * pointer to the header.
+ *
+ * This approach has the enormous advantage that a string object
+ * requires only one allocation. All the ugliness is confined
+ * within a single pair of inline functions, which each compile to
+ * a single "add" instruction: _Rep::_M_data(), and
+ * string::_M_rep(); and the allocation function which gets a
+ * block of raw bytes and with room enough and constructs a _Rep
+ * object at the front.
+ *
+ * The reason you want _M_data pointing to the character array and
+ * not the _Rep is so that the debugger can see the string
+ * contents. (Probably we should add a non-inline member to get
+ * the _Rep for the debugger to use, so users can check the actual
+ * string length.)
+ *
+ * Note that the _Rep object is a POD so that you can have a
+ * static "empty string" _Rep object already "constructed" before
+ * static constructors have run. The reference-count encoding is
+ * chosen so that a 0 indicates one reference, so you never try to
+ * destroy the empty-string _Rep object.
+ *
+ * All but the last paragraph is considered pretty conventional
+ * for a C++ string implementation.
+ * @endif
+ */
// 21.3 Template class basic_string
template<typename _CharT, typename _Traits, typename _Alloc>
class basic_string
@@ -102,9 +122,9 @@ namespace std
typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
const_iterator;
- typedef reverse_iterator<const_iterator> const_reverse_iterator;
- typedef reverse_iterator<iterator> reverse_iterator;
-
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+
private:
// _Rep: string representation
// Invariants:
@@ -125,7 +145,7 @@ namespace std
// Types:
typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
- // (Public) Data members:
+ // (Public) Data members:
// The maximum number of individual char_type elements of an
// individual string is determined by _S_max_size. This is the
@@ -133,10 +153,10 @@ namespace std
// is the maximum number of bytes the allocator can allocate.)
// If one was to divvy up the theoretical largest size string,
// with a terminating character and m _CharT elements, it'd
- // look like this:
+ // look like this:
// npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT)
// Solving for m:
- // m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1
+ // m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1
// In addition, this implementation quarters this ammount.
static const size_type _S_max_size;
static const _CharT _S_terminal;
@@ -144,7 +164,7 @@ namespace std
size_type _M_length;
size_type _M_capacity;
_Atomic_word _M_references;
-
+
bool
_M_is_leaked() const
{ return _M_references < 0; }
@@ -154,50 +174,50 @@ namespace std
{ return _M_references > 0; }
void
- _M_set_leaked()
+ _M_set_leaked()
{ _M_references = -1; }
void
- _M_set_sharable()
+ _M_set_sharable()
{ _M_references = 0; }
- _CharT*
+ _CharT*
_M_refdata() throw()
{ return reinterpret_cast<_CharT*>(this + 1); }
- _CharT&
+ _CharT&
operator[](size_t __s) throw()
{ return _M_refdata() [__s]; }
- _CharT*
+ _CharT*
_M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2)
- {
- return (!_M_is_leaked() && __alloc1 == __alloc2)
- ? _M_refcopy() : _M_clone(__alloc1);
+ {
+ return (!_M_is_leaked() && __alloc1 == __alloc2)
+ ? _M_refcopy() : _M_clone(__alloc1);
}
// Create & Destroy
- static _Rep*
+ static _Rep*
_S_create(size_t, const _Alloc&);
- void
+ void
_M_dispose(const _Alloc& __a)
- {
- if (__exchange_and_add(&_M_references, -1) <= 0)
- _M_destroy(__a);
+ {
+ if (__exchange_and_add(&_M_references, -1) <= 0)
+ _M_destroy(__a);
} // XXX MT
- void
+ void
_M_destroy(const _Alloc&) throw();
- _CharT*
+ _CharT*
_M_refcopy() throw()
- {
- __atomic_add(&_M_references, 1);
- return _M_refdata();
+ {
+ __atomic_add(&_M_references, 1);
+ return _M_refdata();
} // XXX MT
- _CharT*
+ _CharT*
_M_clone(const _Alloc&, size_type __res = 0);
};
@@ -224,45 +244,45 @@ namespace std
// (carefully) in an empty string with one reference.
static size_type _S_empty_rep_storage[(sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)];
- _CharT*
- _M_data() const
+ _CharT*
+ _M_data() const
{ return _M_dataplus._M_p; }
- _CharT*
- _M_data(_CharT* __p)
+ _CharT*
+ _M_data(_CharT* __p)
{ return (_M_dataplus._M_p = __p); }
- _Rep*
+ _Rep*
_M_rep() const
{ return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); }
// For the internal use we have functions similar to `begin'/`end'
// but they do not call _M_leak.
- iterator
+ iterator
_M_ibegin() const { return iterator(_M_data()); }
- iterator
+ iterator
_M_iend() const { return iterator(_M_data() + this->size()); }
- void
+ void
_M_leak() // for use in begin() & non-const op[]
- {
- if (!_M_rep()->_M_is_leaked())
- _M_leak_hard();
+ {
+ if (!_M_rep()->_M_is_leaked())
+ _M_leak_hard();
}
- iterator
+ iterator
_M_check(size_type __pos) const
- {
+ {
if (__pos > this->size())
- __throw_out_of_range("basic_string::_M_check");
- return _M_ibegin() + __pos;
+ __throw_out_of_range("basic_string::_M_check");
+ return _M_ibegin() + __pos;
}
// NB: _M_fold doesn't check for a bad __pos1 value.
- iterator
+ iterator
_M_fold(size_type __pos, size_type __off) const
- {
+ {
bool __testoff = __off < this->size() - __pos;
size_type __newoff = __testoff ? __off : this->size() - __pos;
return (_M_ibegin() + __pos + __newoff);
@@ -273,8 +293,8 @@ namespace std
template<class _Iterator>
static void
_S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
- {
- for (; __k1 != __k2; ++__k1, ++__p)
+ {
+ for (; __k1 != __k2; ++__k1, ++__p)
traits_type::assign(*__p, *__k1); // These types are off.
}
@@ -285,7 +305,7 @@ namespace std
static void
_S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
{ _S_copy_chars(__p, __k1.base(), __k2.base()); }
-
+
static void
_S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
{ traits_type::copy(__p, __k1, __k2 - __k1); }
@@ -294,13 +314,13 @@ namespace std
_S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
{ traits_type::copy(__p, __k1, __k2 - __k1); }
- void
+ void
_M_mutate(size_type __pos, size_type __len1, size_type __len2);
- void
+ void
_M_leak_hard();
- static _Rep&
+ static _Rep&
_S_empty_rep()
{ return *reinterpret_cast<_Rep*>(&_S_empty_rep_storage); }
@@ -309,10 +329,10 @@ namespace std
// NB: We overload ctors in some cases instead of using default
// arguments, per 17.4.4.4 para. 2 item 2.
- inline
+ inline
basic_string();
- explicit
+ explicit
basic_string(const _Alloc& __a);
// NB: per LWG issue 42, semantics different from IS:
@@ -331,200 +351,173 @@ namespace std
basic_string(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a = _Alloc());
- ~basic_string()
+ ~basic_string()
{ _M_rep()->_M_dispose(this->get_allocator()); }
- basic_string&
+ basic_string&
operator=(const basic_string& __str) { return this->assign(__str); }
- basic_string&
+ basic_string&
operator=(const _CharT* __s) { return this->assign(__s); }
- basic_string&
+ basic_string&
operator=(_CharT __c) { return this->assign(1, __c); }
// Iterators:
- iterator
- begin()
- {
- _M_leak();
+ iterator
+ begin()
+ {
+ _M_leak();
return iterator(_M_data());
}
- const_iterator
- begin() const
+ const_iterator
+ begin() const
{ return const_iterator(_M_data()); }
- iterator
+ iterator
end()
{
_M_leak();
return iterator(_M_data() + this->size());
}
- const_iterator
+ const_iterator
end() const
{ return const_iterator(_M_data() + this->size()); }
- reverse_iterator
- rbegin()
+ reverse_iterator
+ rbegin()
{ return reverse_iterator(this->end()); }
- const_reverse_iterator
- rbegin() const
+ const_reverse_iterator
+ rbegin() const
{ return const_reverse_iterator(this->end()); }
- reverse_iterator
- rend()
+ reverse_iterator
+ rend()
{ return reverse_iterator(this->begin()); }
- const_reverse_iterator
- rend() const
+ const_reverse_iterator
+ rend() const
{ return const_reverse_iterator(this->begin()); }
public:
// Capacity:
- size_type
+ size_type
size() const { return _M_rep()->_M_length; }
- size_type
+ size_type
length() const { return _M_rep()->_M_length; }
- size_type
+ size_type
max_size() const { return _Rep::_S_max_size; }
- void
+ void
resize(size_type __n, _CharT __c);
- void
+ void
resize(size_type __n) { this->resize(__n, _CharT()); }
- size_type
+ size_type
capacity() const { return _M_rep()->_M_capacity; }
- void
+ void
reserve(size_type __res_arg = 0);
- void
+ void
clear() { _M_mutate(0, this->size(), 0); }
- bool
+ bool
empty() const { return this->size() == 0; }
// Element access:
- const_reference
- operator[] (size_type __pos) const
+ const_reference
+ operator[] (size_type __pos) const
{ return _M_data()[__pos]; }
- reference
- operator[](size_type __pos)
- {
- _M_leak();
- return _M_data()[__pos];
+ reference
+ operator[](size_type __pos)
+ {
+ _M_leak();
+ return _M_data()[__pos];
}
- const_reference
+ const_reference
at(size_type __n) const
{
if (__n >= this->size())
__throw_out_of_range("basic_string::at");
- return _M_data()[__n];
+ return _M_data()[__n];
}
- reference
+ reference
at(size_type __n)
{
if (__n >= size())
__throw_out_of_range("basic_string::at");
- _M_leak();
- return _M_data()[__n];
+ _M_leak();
+ return _M_data()[__n];
}
// Modifiers:
- basic_string&
+ basic_string&
operator+=(const basic_string& __str) { return this->append(__str); }
- basic_string&
+ basic_string&
operator+=(const _CharT* __s) { return this->append(__s); }
- basic_string&
+ basic_string&
operator+=(_CharT __c) { return this->append(size_type(1), __c); }
- basic_string&
+ basic_string&
append(const basic_string& __str);
- basic_string&
+ basic_string&
append(const basic_string& __str, size_type __pos, size_type __n);
- basic_string&
+ basic_string&
append(const _CharT* __s, size_type __n);
- basic_string&
+ basic_string&
append(const _CharT* __s)
{ return this->append(__s, traits_type::length(__s)); }
- basic_string&
+ basic_string&
append(size_type __n, _CharT __c);
template<class _InputIterator>
- basic_string&
+ basic_string&
append(_InputIterator __first, _InputIterator __last)
{ return this->replace(_M_iend(), _M_iend(), __first, __last); }
- void
+ void
push_back(_CharT __c)
{ this->replace(_M_iend(), _M_iend(), 1, __c); }
- basic_string&
+ basic_string&
assign(const basic_string& __str);
- basic_string&
- assign(const basic_string& __str, size_type __pos, size_type __n)
- {
- const size_type __strsize = __str.size();
- if (__pos > __strsize)
- __throw_out_of_range("basic_string::assign");
- const bool __testn = __n < __strsize - __pos;
- const size_type __newsize = __testn ? __n : __strsize - __pos;
- return this->assign(__str._M_data() + __pos, __newsize);
- }
+ basic_string&
+ assign(const basic_string& __str, size_type __pos, size_type __n);
- basic_string&
- assign(const _CharT* __s, size_type __n)
- {
- if (__n > this->max_size())
- __throw_length_error("basic_string::assign");
- if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
- || less<const _CharT*>()(_M_data() + this->size(), __s))
- return _M_replace_safe(_M_ibegin(), _M_iend(), __s, __s + __n);
- else
- {
- // Work in-place
- const size_type __pos = __s - _M_data();
- if (__pos >= __n)
- traits_type::copy(_M_data(), __s, __n);
- else if (__pos)
- traits_type::move(_M_data(), __s, __n);
- _M_rep()->_M_length = __n;
- _M_data()[__n] = _Rep::_S_terminal;
- return *this;
- }
- }
+ basic_string&
+ assign(const _CharT* __s, size_type __n);
- basic_string&
+ basic_string&
assign(const _CharT* __s)
{ return this->assign(__s, traits_type::length(__s)); }
- basic_string&
+ basic_string&
assign(size_type __n, _CharT __c)
{ return this->replace(_M_ibegin(), _M_iend(), __n, __c); }
template<class _InputIterator>
- basic_string&
+ basic_string&
assign(_InputIterator __first, _InputIterator __last)
{ return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
- void
+ void
insert(iterator __p, size_type __n, _CharT __c)
{ this->replace(__p, __p, __n, __c); }
@@ -532,93 +525,54 @@ namespace std
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
{ this->replace(__p, __p, __beg, __end); }
- basic_string&
+ basic_string&
insert(size_type __pos1, const basic_string& __str)
{ return this->insert(__pos1, __str, 0, __str.size()); }
- basic_string&
+ basic_string&
insert(size_type __pos1, const basic_string& __str,
- size_type __pos2, size_type __n)
- {
- const size_type __strsize = __str.size();
- if (__pos2 > __strsize)
- __throw_out_of_range("basic_string::insert");
- const bool __testn = __n < __strsize - __pos2;
- const size_type __newsize = __testn ? __n : __strsize - __pos2;
- return this->insert(__pos1, __str._M_data() + __pos2, __newsize);
- }
+ size_type __pos2, size_type __n);
- basic_string&
- insert(size_type __pos, const _CharT* __s, size_type __n)
- {
- const size_type __size = this->size();
- if (__pos > __size)
- __throw_out_of_range("basic_string::insert");
- if (__size > this->max_size() - __n)
- __throw_length_error("basic_string::insert");
- if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
- || less<const _CharT*>()(_M_data() + __size, __s))
- return _M_replace_safe(_M_ibegin() + __pos, _M_ibegin() + __pos,
- __s, __s + __n);
- else
- {
- // Work in-place. If _M_mutate reallocates the string, __s
- // does not point anymore to valid data, therefore we save its
- // offset, then we restore it.
- const size_type __off = __s - _M_data();
- _M_mutate(__pos, 0, __n);
- __s = _M_data() + __off;
- _CharT* __p = _M_data() + __pos;
- if (__s + __n <= __p)
- traits_type::copy(__p, __s, __n);
- else if (__s >= __p)
- traits_type::copy(__p, __s + __n, __n);
- else
- {
- traits_type::copy(__p, __s, __p - __s);
- traits_type::copy(__p + (__p - __s), __p + __n, __n - (__p - __s));
- }
- return *this;
- }
- }
-
- basic_string&
+ basic_string&
+ insert(size_type __pos, const _CharT* __s, size_type __n);
+
+ basic_string&
insert(size_type __pos, const _CharT* __s)
{ return this->insert(__pos, __s, traits_type::length(__s)); }
- basic_string&
+ basic_string&
insert(size_type __pos, size_type __n, _CharT __c)
- {
- this->insert(_M_check(__pos), __n, __c);
- return *this;
+ {
+ this->insert(_M_check(__pos), __n, __c);
+ return *this;
}
- iterator
+ iterator
insert(iterator __p, _CharT __c = _CharT())
{
size_type __pos = __p - _M_ibegin();
this->insert(_M_check(__pos), size_type(1), __c);
- _M_rep()->_M_set_leaked();
- return this->_M_ibegin() + __pos;
+ _M_rep()->_M_set_leaked();
+ return this->_M_ibegin() + __pos;
}
- basic_string&
+ basic_string&
erase(size_type __pos = 0, size_type __n = npos)
- {
+ {
return this->replace(_M_check(__pos), _M_fold(__pos, __n),
- _M_data(), _M_data());
+ _M_data(), _M_data());
}
- iterator
+ iterator
erase(iterator __position)
{
size_type __i = __position - _M_ibegin();
this->replace(__position, __position + 1, _M_data(), _M_data());
- _M_rep()->_M_set_leaked();
+ _M_rep()->_M_set_leaked();
return _M_ibegin() + __i;
}
- iterator
+ iterator
erase(iterator __first, iterator __last)
{
size_type __i = __first - _M_ibegin();
@@ -627,62 +581,44 @@ namespace std
return _M_ibegin() + __i;
}
- basic_string&
+ basic_string&
replace(size_type __pos, size_type __n, const basic_string& __str)
{ return this->replace(__pos, __n, __str._M_data(), __str.size()); }
- basic_string&
+ basic_string&
replace(size_type __pos1, size_type __n1, const basic_string& __str,
size_type __pos2, size_type __n2);
- basic_string&
+ basic_string&
replace(size_type __pos, size_type __n1, const _CharT* __s,
- size_type __n2)
- {
- const size_type __size = this->size();
- if (__pos > __size)
- __throw_out_of_range("basic_string::replace");
- const bool __testn1 = __n1 < __size - __pos;
- const size_type __foldn1 = __testn1 ? __n1 : __size - __pos;
- if (__size - __foldn1 > this->max_size() - __n2)
- __throw_length_error("basic_string::replace");
- if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
- || less<const _CharT*>()(_M_data() + __size, __s))
- return _M_replace_safe(_M_ibegin() + __pos,
- _M_ibegin() + __pos + __foldn1, __s, __s + __n2);
- // Todo: optimized in-place replace.
- else return
- _M_replace(_M_ibegin() + __pos, _M_ibegin() + __pos + __foldn1,
- __s, __s + __n2,
- typename iterator_traits<const _CharT*>::iterator_category());
- }
+ size_type __n2);
- basic_string&
+ basic_string&
replace(size_type __pos, size_type __n1, const _CharT* __s)
{ return this->replace(__pos, __n1, __s, traits_type::length(__s)); }
- basic_string&
+ basic_string&
replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
{ return this->replace(_M_check(__pos), _M_fold(__pos, __n1), __n2, __c); }
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2, const basic_string& __str)
{ return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
{ return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n); }
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2, const _CharT* __s)
{ return this->replace(__i1, __i2, __s, traits_type::length(__s)); }
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c);
template<class _InputIterator>
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2,
_InputIterator __k1, _InputIterator __k2)
{ return _M_replace(__i1, __i2, __k1, __k2,
@@ -690,23 +626,23 @@ namespace std
// Specializations for the common case of pointer and iterator:
// useful to avoid the overhead of temporary buffering in _M_replace.
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
{ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1, __k2 - __k1); }
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2)
{ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1, __k2 - __k1); }
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
{ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1.base(), __k2 - __k1);
}
- basic_string&
+ basic_string&
replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2)
{ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1.base(), __k2 - __k1);
@@ -714,13 +650,13 @@ namespace std
private:
template<class _InputIterator>
- basic_string&
- _M_replace(iterator __i1, iterator __i2, _InputIterator __k1,
+ basic_string&
+ _M_replace(iterator __i1, iterator __i2, _InputIterator __k1,
_InputIterator __k2, input_iterator_tag);
template<class _ForwardIterator>
- basic_string&
- _M_replace_safe(iterator __i1, iterator __i2, _ForwardIterator __k1,
+ basic_string&
+ _M_replace_safe(iterator __i1, iterator __i2, _ForwardIterator __k1,
_ForwardIterator __k2);
// _S_construct_aux is used to implement the 21.3.1 para 15 which
@@ -733,7 +669,7 @@ namespace std
typedef typename iterator_traits<_InIter>::iterator_category _Tag;
return _S_construct(__beg, __end, __a, _Tag());
}
-
+
template<class _InIter>
static _CharT*
_S_construct_aux(_InIter __beg, _InIter __end, const _Alloc& __a,
@@ -742,7 +678,7 @@ namespace std
return _S_construct(static_cast<size_type>(__beg),
static_cast<value_type>(__end), __a);
}
-
+
template<class _InIter>
static _CharT*
_S_construct(_InIter __beg, _InIter __end, const _Alloc& __a)
@@ -756,7 +692,7 @@ namespace std
static _CharT*
_S_construct(_InIter __beg, _InIter __end, const _Alloc& __a,
input_iterator_tag);
-
+
// For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc.
template<class _FwdIter>
@@ -764,19 +700,19 @@ namespace std
_S_construct(_FwdIter __beg, _FwdIter __end, const _Alloc& __a,
forward_iterator_tag);
- static _CharT*
+ static _CharT*
_S_construct(size_type __req, _CharT __c, const _Alloc& __a);
public:
- size_type
+ size_type
copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
- void
+ void
swap(basic_string<_CharT, _Traits, _Alloc>& __s);
// String operations:
- const _CharT*
+ const _CharT*
c_str() const
{
// MT: This assumes concurrent writes are OK.
@@ -785,137 +721,137 @@ namespace std
return _M_data();
}
- const _CharT*
+ const _CharT*
data() const { return _M_data(); }
- allocator_type
+ allocator_type
get_allocator() const { return _M_dataplus; }
- size_type
+ size_type
find(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
+ size_type
find(const basic_string& __str, size_type __pos = 0) const
{ return this->find(__str.data(), __pos, __str.size()); }
- size_type
+ size_type
find(const _CharT* __s, size_type __pos = 0) const
{ return this->find(__s, __pos, traits_type::length(__s)); }
- size_type
+ size_type
find(_CharT __c, size_type __pos = 0) const;
- size_type
+ size_type
rfind(const basic_string& __str, size_type __pos = npos) const
{ return this->rfind(__str.data(), __pos, __str.size()); }
- size_type
+ size_type
rfind(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
+ size_type
rfind(const _CharT* __s, size_type __pos = npos) const
{ return this->rfind(__s, __pos, traits_type::length(__s)); }
- size_type
+ size_type
rfind(_CharT __c, size_type __pos = npos) const;
- size_type
+ size_type
find_first_of(const basic_string& __str, size_type __pos = 0) const
{ return this->find_first_of(__str.data(), __pos, __str.size()); }
- size_type
+ size_type
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
+ size_type
find_first_of(const _CharT* __s, size_type __pos = 0) const
{ return this->find_first_of(__s, __pos, traits_type::length(__s)); }
- size_type
+ size_type
find_first_of(_CharT __c, size_type __pos = 0) const
{ return this->find(__c, __pos); }
- size_type
+ size_type
find_last_of(const basic_string& __str, size_type __pos = npos) const
{ return this->find_last_of(__str.data(), __pos, __str.size()); }
- size_type
+ size_type
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
+ size_type
find_last_of(const _CharT* __s, size_type __pos = npos) const
{ return this->find_last_of(__s, __pos, traits_type::length(__s)); }
- size_type
+ size_type
find_last_of(_CharT __c, size_type __pos = npos) const
{ return this->rfind(__c, __pos); }
- size_type
+ size_type
find_first_not_of(const basic_string& __str, size_type __pos = 0) const
{ return this->find_first_not_of(__str.data(), __pos, __str.size()); }
- size_type
- find_first_not_of(const _CharT* __s, size_type __pos,
+ size_type
+ find_first_not_of(const _CharT* __s, size_type __pos,
size_type __n) const;
- size_type
+ size_type
find_first_not_of(const _CharT* __s, size_type __pos = 0) const
{ return this->find_first_not_of(__s, __pos, traits_type::length(__s)); }
- size_type
+ size_type
find_first_not_of(_CharT __c, size_type __pos = 0) const;
- size_type
+ size_type
find_last_not_of(const basic_string& __str, size_type __pos = npos) const
{ return this->find_last_not_of(__str.data(), __pos, __str.size()); }
- size_type
- find_last_not_of(const _CharT* __s, size_type __pos,
+ size_type
+ find_last_not_of(const _CharT* __s, size_type __pos,
size_type __n) const;
- size_type
+ size_type
find_last_not_of(const _CharT* __s, size_type __pos = npos) const
{ return this->find_last_not_of(__s, __pos, traits_type::length(__s)); }
- size_type
+ size_type
find_last_not_of(_CharT __c, size_type __pos = npos) const;
- basic_string
+ basic_string
substr(size_type __pos = 0, size_type __n = npos) const
- {
+ {
if (__pos > this->size())
__throw_out_of_range("basic_string::substr");
- return basic_string(*this, __pos, __n);
+ return basic_string(*this, __pos, __n);
}
- int
+ int
compare(const basic_string& __str) const
{
size_type __size = this->size();
size_type __osize = __str.size();
- size_type __len = min(__size, __osize);
-
+ size_type __len = std::min(__size, __osize);
+
int __r = traits_type::compare(_M_data(), __str.data(), __len);
if (!__r)
__r = __size - __osize;
return __r;
}
- int
+ int
compare(size_type __pos, size_type __n, const basic_string& __str) const;
- int
+ int
compare(size_type __pos1, size_type __n1, const basic_string& __str,
size_type __pos2, size_type __n2) const;
- int
+ int
compare(const _CharT* __s) const;
// _GLIBCPP_RESOLVE_LIB_DEFECTS
- // 5. String::compare specification questionable
- int
+ // 5 String::compare specification questionable
+ int
compare(size_type __pos, size_type __n1, const _CharT* __s) const;
- int
- compare(size_type __pos, size_type __n1, const _CharT* __s,
+ int
+ compare(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2) const;
};
diff --git a/contrib/libstdc++/include/bits/basic_string.tcc b/contrib/libstdc++/include/bits/basic_string.tcc
index 4a22d89..d3f1e8e 100644
--- a/contrib/libstdc++/include/bits/basic_string.tcc
+++ b/contrib/libstdc++/include/bits/basic_string.tcc
@@ -1,6 +1,6 @@
// Components for manipulating sequences of characters -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -137,14 +137,14 @@ namespace std
_S_construct(_InIter __beg, _InIter __end, const _Alloc& __a,
forward_iterator_tag)
{
- size_type __dnew = static_cast<size_type>(distance(__beg, __end));
-
if (__beg == __end && __a == _Alloc())
return _S_empty_rep()._M_refcopy();
// NB: Not required, but considered best practice.
if (__builtin_expect(__beg == _InIter(), 0))
__throw_logic_error("attempt to create string with null pointer");
+
+ size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__dnew, __a);
@@ -254,6 +254,117 @@ namespace std
}
return *this;
}
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ assign(const basic_string& __str, size_type __pos, size_type __n)
+ {
+ const size_type __strsize = __str.size();
+ if (__pos > __strsize)
+ __throw_out_of_range("basic_string::assign");
+ const bool __testn = __n < __strsize - __pos;
+ const size_type __newsize = __testn ? __n : __strsize - __pos;
+ return this->assign(__str._M_data() + __pos, __newsize);
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ assign(const _CharT* __s, size_type __n)
+ {
+ if (__n > this->max_size())
+ __throw_length_error("basic_string::assign");
+ if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
+ || less<const _CharT*>()(_M_data() + this->size(), __s))
+ return _M_replace_safe(_M_ibegin(), _M_iend(), __s, __s + __n);
+ else
+ {
+ // Work in-place
+ const size_type __pos = __s - _M_data();
+ if (__pos >= __n)
+ traits_type::copy(_M_data(), __s, __n);
+ else if (__pos)
+ traits_type::move(_M_data(), __s, __n);
+ _M_rep()->_M_length = __n;
+ _M_data()[__n] = _Rep::_S_terminal; // grr.
+ return *this;
+ }
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ insert(size_type __pos1, const basic_string& __str,
+ size_type __pos2, size_type __n)
+ {
+ const size_type __strsize = __str.size();
+ if (__pos2 > __strsize)
+ __throw_out_of_range("basic_string::insert");
+ const bool __testn = __n < __strsize - __pos2;
+ const size_type __newsize = __testn ? __n : __strsize - __pos2;
+ return this->insert(__pos1, __str._M_data() + __pos2, __newsize);
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ insert(size_type __pos, const _CharT* __s, size_type __n)
+ {
+ const size_type __size = this->size();
+ if (__pos > __size)
+ __throw_out_of_range("basic_string::insert");
+ if (__size > this->max_size() - __n)
+ __throw_length_error("basic_string::insert");
+ if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
+ || less<const _CharT*>()(_M_data() + __size, __s))
+ return _M_replace_safe(_M_ibegin() + __pos, _M_ibegin() + __pos,
+ __s, __s + __n);
+ else
+ {
+ // Work in-place. If _M_mutate reallocates the string, __s
+ // does not point anymore to valid data, therefore we save its
+ // offset, then we restore it.
+ const size_type __off = __s - _M_data();
+ _M_mutate(__pos, 0, __n);
+ __s = _M_data() + __off;
+ _CharT* __p = _M_data() + __pos;
+ if (__s + __n <= __p)
+ traits_type::copy(__p, __s, __n);
+ else if (__s >= __p)
+ traits_type::copy(__p, __s + __n, __n);
+ else
+ {
+ traits_type::copy(__p, __s, __p - __s);
+ traits_type::copy(__p + (__p-__s), __p + __n, __n - (__p-__s));
+ }
+ return *this;
+ }
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ replace(size_type __pos, size_type __n1, const _CharT* __s,
+ size_type __n2)
+ {
+ const size_type __size = this->size();
+ if (__pos > __size)
+ __throw_out_of_range("basic_string::replace");
+ const bool __testn1 = __n1 < __size - __pos;
+ const size_type __foldn1 = __testn1 ? __n1 : __size - __pos;
+ if (__size - __foldn1 > this->max_size() - __n2)
+ __throw_length_error("basic_string::replace");
+ if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
+ || less<const _CharT*>()(_M_data() + __size, __s))
+ return _M_replace_safe(_M_ibegin() + __pos,
+ _M_ibegin() + __pos + __foldn1, __s, __s + __n2);
+ // Todo: optimized in-place replace.
+ else
+ return _M_replace(_M_ibegin() + __pos, _M_ibegin() + __pos + __foldn1,
+ __s, __s + __n2,
+ typename iterator_traits<const _CharT*>::iterator_category());
+ }
template<typename _CharT, typename _Traits, typename _Alloc>
void
@@ -523,7 +634,7 @@ namespace std
_M_replace_safe(iterator __i1, iterator __i2, _ForwardIter __k1,
_ForwardIter __k2)
{
- size_type __dnew = static_cast<size_type>(distance(__k1, __k2));
+ size_type __dnew = static_cast<size_type>(std::distance(__k1, __k2));
size_type __dold = __i2 - __i1;
size_type __dmax = this->max_size();
@@ -578,7 +689,8 @@ namespace std
// Iff appending itself, string needs to pre-reserve the
// correct size so that _M_mutate does not clobber the
// iterators formed here.
- size_type __len = min(__str.size() - __pos, __n) + this->size();
+ size_type __len = std::min(size_type(__str.size() - __pos),
+ __n) + this->size();
if (__len > this->capacity())
this->reserve(__len);
return _M_replace_safe(_M_iend(), _M_iend(), __str._M_check(__pos),
@@ -709,7 +821,7 @@ namespace std
size_type __size = this->size();
if (__n <= __size)
{
- __pos = std::min(__size - __n, __pos);
+ __pos = std::min(size_type(__size - __n), __pos);
const _CharT* __data = _M_data();
do
{
@@ -848,8 +960,8 @@ namespace std
if (__pos > __size)
__throw_out_of_range("basic_string::compare");
- size_type __rsize= min(__size - __pos, __n);
- size_type __len = min(__rsize, __osize);
+ size_type __rsize= std::min(size_type(__size - __pos), __n);
+ size_type __len = std::min(__rsize, __osize);
int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
if (!__r)
__r = __rsize - __osize;
@@ -867,9 +979,9 @@ namespace std
if (__pos1 > __size || __pos2 > __osize)
__throw_out_of_range("basic_string::compare");
- size_type __rsize = min(__size - __pos1, __n1);
- size_type __rosize = min(__osize - __pos2, __n2);
- size_type __len = min(__rsize, __rosize);
+ size_type __rsize = std::min(size_type(__size - __pos1), __n1);
+ size_type __rosize = std::min(size_type(__osize - __pos2), __n2);
+ size_type __len = std::min(__rsize, __rosize);
int __r = traits_type::compare(_M_data() + __pos1,
__str.data() + __pos2, __len);
if (!__r)
@@ -885,7 +997,7 @@ namespace std
{
size_type __size = this->size();
size_type __osize = traits_type::length(__s);
- size_type __len = min(__size, __osize);
+ size_type __len = std::min(__size, __osize);
int __r = traits_type::compare(_M_data(), __s, __len);
if (!__r)
__r = __size - __osize;
@@ -903,8 +1015,8 @@ namespace std
__throw_out_of_range("basic_string::compare");
size_type __osize = traits_type::length(__s);
- size_type __rsize = min(__size - __pos, __n1);
- size_type __len = min(__rsize, __osize);
+ size_type __rsize = std::min(size_type(__size - __pos), __n1);
+ size_type __len = std::min(__rsize, __osize);
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
if (!__r)
__r = __rsize - __osize;
@@ -921,9 +1033,9 @@ namespace std
if (__pos > __size)
__throw_out_of_range("basic_string::compare");
- size_type __osize = min(traits_type::length(__s), __n2);
- size_type __rsize = min(__size - __pos, __n1);
- size_type __len = min(__rsize, __osize);
+ size_type __osize = std::min(traits_type::length(__s), __n2);
+ size_type __rsize = std::min(size_type(__size - __pos), __n1);
+ size_type __len = std::min(__rsize, __osize);
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
if (!__r)
__r = __rsize - __osize;
@@ -937,7 +1049,7 @@ namespace std
{
typedef typename _Alloc::size_type size_type;
size_type __strsize = __str.size();
- size_type __bytes = min(__strsize, __bufsiz - 1);
+ size_type __bytes = std::min(__strsize, __bufsiz - 1);
_Traits::copy(__buf, __str.data(), __bytes);
__buf[__bytes] = _CharT();
}
@@ -945,6 +1057,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_string<char>;
extern template
basic_istream<char>&
@@ -974,6 +1087,7 @@ namespace std
basic_istream<wchar_t>&
getline(basic_istream<wchar_t>&, wstring&);
#endif
+#endif
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/boost_concept_check.h b/contrib/libstdc++/include/bits/boost_concept_check.h
index 29ca61b..d91c2e8 100644
--- a/contrib/libstdc++/include/bits/boost_concept_check.h
+++ b/contrib/libstdc++/include/bits/boost_concept_check.h
@@ -149,6 +149,8 @@ struct _Aux_require_same<_Tp,_Tp> { typedef _Tp _Type; };
__a = __b; // const required for argument to assignment
}
_Tp __a;
+ // possibly should be "Tp* a;" and then dereference "a" in constraint
+ // functions? present way would require a default ctor, i think...
};
template <class _Tp>
diff --git a/contrib/libstdc++/include/bits/c++config b/contrib/libstdc++/include/bits/c++config
index cda776c..1716e25 100644
--- a/contrib/libstdc++/include/bits/c++config
+++ b/contrib/libstdc++/include/bits/c++config
@@ -1,6 +1,7 @@
// Predefined symbols and macros -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 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
@@ -34,10 +35,9 @@
#include <bits/os_defines.h>
// The current version of the C++ library in compressed ISO date format.
-#define __GLIBCPP__ 20030205
+#define __GLIBCPP__ 20030711
-// This is necessary until GCC supports separate template
-// compilation.
+// This is necessary until GCC supports separate template compilation.
#define _GLIBCPP_NO_TEMPLATE_EXPORT 1
// This is a hack around not having either pre-compiled headers or
@@ -49,6 +49,16 @@
// by the compiler, but instead instantiated into the library binary.
#define _GLIBCPP_FULLY_COMPLIANT_HEADERS 1
+// Allow use of the GNU syntax extension, "extern template." This
+// extension is fully documented in the g++ manual, but in a nutshell,
+// it inhibits all implicit instantiations and is used throughout the
+// library to avoid multiple weak definitions for required types that
+// are already explicitly instantiated in the library binary. This
+// substantially reduces the binary size of resulting executables.
+#ifndef _GLIBCPP_EXTERN_TEMPLATE
+#define _GLIBCPP_EXTERN_TEMPLATE 1
+#endif
+
// To enable older, ARM-style iostreams and other anachronisms use this.
//#define _GLIBCPP_DEPRECATED 1
@@ -77,6 +87,13 @@
#error __USE_MALLOC should never be defined. Read the release notes.
#endif
+// Create a boolean flag to be used to determine if --fast-math is set.
+#ifdef __FAST_MATH__
+#define _GLIBCPP_FAST_MATH 1
+#else
+#define _GLIBCPP_FAST_MATH 0
+#endif
+
// The remainder of the prewritten config is mostly automatic; all the
// user hooks are listed above.
diff --git a/contrib/libstdc++/include/bits/char_traits.h b/contrib/libstdc++/include/bits/char_traits.h
index 41f943d..2b733cd 100644
--- a/contrib/libstdc++/include/bits/char_traits.h
+++ b/contrib/libstdc++/include/bits/char_traits.h
@@ -42,14 +42,22 @@
#pragma GCC system_header
-#include <cstring> // For memmove, memset, memchr
-#include <bits/fpos.h> // For streampos
+#include <cstring> // For memmove, memset, memchr
+#include <bits/fpos.h> // For streampos
namespace std
{
- /// 21.1.2 Basis for explicit _Traits specialization
- /// NB: That for any given actual character type this definition is
- /// probably wrong.
+ // 21.1
+ /**
+ * @brief Basis for explicit traits specializations.
+ *
+ * @note For any given actual character type, this definition is
+ * probably wrong.
+ *
+ * See http://gcc.gnu.org/onlinedocs/libstdc++/21_strings/howto.html#5
+ * for advice on how to make use of this class for "unusual" character
+ * types.
+ */
template<class _CharT>
struct char_traits
{
@@ -104,7 +112,7 @@ namespace std
};
- /// 21.1.4 char_traits specializations
+ /// 21.1.3.1 char_traits specializations
template<>
struct char_traits<char>
{
@@ -174,6 +182,7 @@ namespace std
#ifdef _GLIBCPP_USE_WCHAR_T
+ /// 21.1.3.2 char_traits specializations
template<>
struct char_traits<wchar_t>
{
diff --git a/contrib/libstdc++/include/bits/codecvt.h b/contrib/libstdc++/include/bits/codecvt.h
index 3666e98..9ab9f94 100644
--- a/contrib/libstdc++/include/bits/codecvt.h
+++ b/contrib/libstdc++/include/bits/codecvt.h
@@ -1,6 +1,6 @@
// Locale support (codecvt) -*- C++ -*-
-// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2002, 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
diff --git a/contrib/libstdc++/include/bits/concept_check.h b/contrib/libstdc++/include/bits/concept_check.h
index 92ceefb..88877eb 100644
--- a/contrib/libstdc++/include/bits/concept_check.h
+++ b/contrib/libstdc++/include/bits/concept_check.h
@@ -61,8 +61,7 @@
// Note that the obvious and elegant approach of
//
-//#define glibcpp_function_requires(C) \
-// boost::function_requires< boost::C >()
+//#define glibcpp_function_requires(C) boost::function_requires< boost::C >()
//
// won't work due to concept templates with more than one parameter, e.g.,
// BinaryPredicateConcept. The preprocessor tries to split things up on
diff --git a/contrib/libstdc++/include/bits/deque.tcc b/contrib/libstdc++/include/bits/deque.tcc
new file mode 100644
index 0000000..a8d43d0
--- /dev/null
+++ b/contrib/libstdc++/include/bits/deque.tcc
@@ -0,0 +1,779 @@
+// Deque implementation (out of line) -*- C++ -*-
+
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file deque.tcc
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+#ifndef __GLIBCPP_INTERNAL_DEQUE_TCC
+#define __GLIBCPP_INTERNAL_DEQUE_TCC
+
+namespace std
+{
+ template <typename _Tp, typename _Alloc>
+ deque<_Tp,_Alloc>&
+ deque<_Tp,_Alloc>::
+ operator=(const deque& __x)
+ {
+ const size_type __len = size();
+ if (&__x != this)
+ {
+ if (__len >= __x.size())
+ erase(copy(__x.begin(), __x.end(), _M_start), _M_finish);
+ else
+ {
+ const_iterator __mid = __x.begin() + difference_type(__len);
+ copy(__x.begin(), __mid, _M_start);
+ insert(_M_finish, __mid, __x.end());
+ }
+ }
+ return *this;
+ }
+
+ template <typename _Tp, typename _Alloc>
+ typename deque<_Tp,_Alloc>::iterator
+ deque<_Tp,_Alloc>::
+ insert(iterator position, const value_type& __x)
+ {
+ if (position._M_cur == _M_start._M_cur)
+ {
+ push_front(__x);
+ return _M_start;
+ }
+ else if (position._M_cur == _M_finish._M_cur)
+ {
+ push_back(__x);
+ iterator __tmp = _M_finish;
+ --__tmp;
+ return __tmp;
+ }
+ else
+ return _M_insert_aux(position, __x);
+ }
+
+ template <typename _Tp, typename _Alloc>
+ typename deque<_Tp,_Alloc>::iterator
+ deque<_Tp,_Alloc>::
+ erase(iterator __position)
+ {
+ iterator __next = __position;
+ ++__next;
+ size_type __index = __position - _M_start;
+ if (__index < (size() >> 1))
+ {
+ copy_backward(_M_start, __position, __next);
+ pop_front();
+ }
+ else
+ {
+ copy(__next, _M_finish, __position);
+ pop_back();
+ }
+ return _M_start + __index;
+ }
+
+ template <typename _Tp, typename _Alloc>
+ typename deque<_Tp,_Alloc>::iterator
+ deque<_Tp,_Alloc>::
+ erase(iterator __first, iterator __last)
+ {
+ if (__first == _M_start && __last == _M_finish)
+ {
+ clear();
+ return _M_finish;
+ }
+ else
+ {
+ difference_type __n = __last - __first;
+ difference_type __elems_before = __first - _M_start;
+ if (static_cast<size_type>(__elems_before) < (size() - __n) / 2)
+ {
+ copy_backward(_M_start, __first, __last);
+ iterator __new_start = _M_start + __n;
+ _Destroy(_M_start, __new_start);
+ _M_destroy_nodes(_M_start._M_node, __new_start._M_node);
+ _M_start = __new_start;
+ }
+ else
+ {
+ copy(__last, _M_finish, __first);
+ iterator __new_finish = _M_finish - __n;
+ _Destroy(__new_finish, _M_finish);
+ _M_destroy_nodes(__new_finish._M_node + 1, _M_finish._M_node + 1);
+ _M_finish = __new_finish;
+ }
+ return _M_start + __elems_before;
+ }
+ }
+
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ clear()
+ {
+ for (_Map_pointer __node = _M_start._M_node + 1;
+ __node < _M_finish._M_node;
+ ++__node)
+ {
+ _Destroy(*__node, *__node + _S_buffer_size());
+ _M_deallocate_node(*__node);
+ }
+
+ if (_M_start._M_node != _M_finish._M_node)
+ {
+ _Destroy(_M_start._M_cur, _M_start._M_last);
+ _Destroy(_M_finish._M_first, _M_finish._M_cur);
+ _M_deallocate_node(_M_finish._M_first);
+ }
+ else
+ _Destroy(_M_start._M_cur, _M_finish._M_cur);
+
+ _M_finish = _M_start;
+ }
+
+ template <typename _Tp, class _Alloc>
+ template <typename _InputIter>
+ void
+ deque<_Tp,_Alloc>
+ ::_M_assign_aux(_InputIter __first, _InputIter __last, input_iterator_tag)
+ {
+ iterator __cur = begin();
+ for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
+ *__cur = *__first;
+ if (__first == __last)
+ erase(__cur, end());
+ else
+ insert(end(), __first, __last);
+ }
+
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
+ {
+ if (__pos._M_cur == _M_start._M_cur)
+ {
+ iterator __new_start = _M_reserve_elements_at_front(__n);
+ try
+ {
+ uninitialized_fill(__new_start, _M_start, __x);
+ _M_start = __new_start;
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+ __throw_exception_again;
+ }
+ }
+ else if (__pos._M_cur == _M_finish._M_cur)
+ {
+ iterator __new_finish = _M_reserve_elements_at_back(__n);
+ try
+ {
+ uninitialized_fill(_M_finish, __new_finish, __x);
+ _M_finish = __new_finish;
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
+ __throw_exception_again;
+ }
+ }
+ else
+ _M_insert_aux(__pos, __n, __x);
+ }
+
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_fill_initialize(const value_type& __value)
+ {
+ _Map_pointer __cur;
+ try
+ {
+ for (__cur = _M_start._M_node; __cur < _M_finish._M_node; ++__cur)
+ uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value);
+ uninitialized_fill(_M_finish._M_first, _M_finish._M_cur, __value);
+ }
+ catch(...)
+ {
+ _Destroy(_M_start, iterator(*__cur, __cur));
+ __throw_exception_again;
+ }
+ }
+
+ template <typename _Tp, typename _Alloc>
+ template <typename _InputIterator>
+ void
+ deque<_Tp,_Alloc>::
+ _M_range_initialize(_InputIterator __first, _InputIterator __last,
+ input_iterator_tag)
+ {
+ _M_initialize_map(0);
+ try
+ {
+ for ( ; __first != __last; ++__first)
+ push_back(*__first);
+ }
+ catch(...)
+ {
+ clear();
+ __throw_exception_again;
+ }
+ }
+
+ template <typename _Tp, typename _Alloc>
+ template <typename _ForwardIterator>
+ void
+ deque<_Tp,_Alloc>::
+ _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
+ forward_iterator_tag)
+ {
+ size_type __n = distance(__first, __last);
+ _M_initialize_map(__n);
+
+ _Map_pointer __cur_node;
+ try
+ {
+ for (__cur_node = _M_start._M_node;
+ __cur_node < _M_finish._M_node;
+ ++__cur_node)
+ {
+ _ForwardIterator __mid = __first;
+ advance(__mid, _S_buffer_size());
+ uninitialized_copy(__first, __mid, *__cur_node);
+ __first = __mid;
+ }
+ uninitialized_copy(__first, __last, _M_finish._M_first);
+ }
+ catch(...)
+ {
+ _Destroy(_M_start, iterator(*__cur_node, __cur_node));
+ __throw_exception_again;
+ }
+ }
+
+ // Called only if _M_finish._M_cur == _M_finish._M_last - 1.
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_push_back_aux(const value_type& __t)
+ {
+ value_type __t_copy = __t;
+ _M_reserve_map_at_back();
+ *(_M_finish._M_node + 1) = _M_allocate_node();
+ try
+ {
+ _Construct(_M_finish._M_cur, __t_copy);
+ _M_finish._M_set_node(_M_finish._M_node + 1);
+ _M_finish._M_cur = _M_finish._M_first;
+ }
+ catch(...)
+ {
+ _M_deallocate_node(*(_M_finish._M_node + 1));
+ __throw_exception_again;
+ }
+ }
+
+ #ifdef _GLIBCPP_DEPRECATED
+ // Called only if _M_finish._M_cur == _M_finish._M_last - 1.
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_push_back_aux()
+ {
+ _M_reserve_map_at_back();
+ *(_M_finish._M_node + 1) = _M_allocate_node();
+ try
+ {
+ _Construct(_M_finish._M_cur);
+ _M_finish._M_set_node(_M_finish._M_node + 1);
+ _M_finish._M_cur = _M_finish._M_first;
+ }
+ catch(...)
+ {
+ _M_deallocate_node(*(_M_finish._M_node + 1));
+ __throw_exception_again;
+ }
+ }
+ #endif
+
+ // Called only if _M_start._M_cur == _M_start._M_first.
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_push_front_aux(const value_type& __t)
+ {
+ value_type __t_copy = __t;
+ _M_reserve_map_at_front();
+ *(_M_start._M_node - 1) = _M_allocate_node();
+ try
+ {
+ _M_start._M_set_node(_M_start._M_node - 1);
+ _M_start._M_cur = _M_start._M_last - 1;
+ _Construct(_M_start._M_cur, __t_copy);
+ }
+ catch(...)
+ {
+ ++_M_start;
+ _M_deallocate_node(*(_M_start._M_node - 1));
+ __throw_exception_again;
+ }
+ }
+
+ #ifdef _GLIBCPP_DEPRECATED
+ // Called only if _M_start._M_cur == _M_start._M_first.
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_push_front_aux()
+ {
+ _M_reserve_map_at_front();
+ *(_M_start._M_node - 1) = _M_allocate_node();
+ try
+ {
+ _M_start._M_set_node(_M_start._M_node - 1);
+ _M_start._M_cur = _M_start._M_last - 1;
+ _Construct(_M_start._M_cur);
+ }
+ catch(...)
+ {
+ ++_M_start;
+ _M_deallocate_node(*(_M_start._M_node - 1));
+ __throw_exception_again;
+ }
+ }
+ #endif
+
+ // Called only if _M_finish._M_cur == _M_finish._M_first.
+ template <typename _Tp, typename _Alloc>
+ void deque<_Tp,_Alloc>::
+ _M_pop_back_aux()
+ {
+ _M_deallocate_node(_M_finish._M_first);
+ _M_finish._M_set_node(_M_finish._M_node - 1);
+ _M_finish._M_cur = _M_finish._M_last - 1;
+ _Destroy(_M_finish._M_cur);
+ }
+
+ // Called only if _M_start._M_cur == _M_start._M_last - 1. Note that
+ // if the deque has at least one element (a precondition for this member
+ // function), and if _M_start._M_cur == _M_start._M_last, then the deque
+ // must have at least two nodes.
+ template <typename _Tp, typename _Alloc>
+ void deque<_Tp,_Alloc>::
+ _M_pop_front_aux()
+ {
+ _Destroy(_M_start._M_cur);
+ _M_deallocate_node(_M_start._M_first);
+ _M_start._M_set_node(_M_start._M_node + 1);
+ _M_start._M_cur = _M_start._M_first;
+ }
+
+ template <typename _Tp, typename _Alloc>
+ template <typename _InputIterator>
+ void
+ deque<_Tp,_Alloc>::
+ _M_range_insert_aux(iterator __pos,
+ _InputIterator __first, _InputIterator __last,
+ input_iterator_tag)
+ {
+ copy(__first, __last, inserter(*this, __pos));
+ }
+
+ template <typename _Tp, typename _Alloc>
+ template <typename _ForwardIterator>
+ void
+ deque<_Tp,_Alloc>::
+ _M_range_insert_aux(iterator __pos,
+ _ForwardIterator __first, _ForwardIterator __last,
+ forward_iterator_tag)
+ {
+ size_type __n = distance(__first, __last);
+ if (__pos._M_cur == _M_start._M_cur)
+ {
+ iterator __new_start = _M_reserve_elements_at_front(__n);
+ try
+ {
+ uninitialized_copy(__first, __last, __new_start);
+ _M_start = __new_start;
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+ __throw_exception_again;
+ }
+ }
+ else if (__pos._M_cur == _M_finish._M_cur)
+ {
+ iterator __new_finish = _M_reserve_elements_at_back(__n);
+ try
+ {
+ uninitialized_copy(__first, __last, _M_finish);
+ _M_finish = __new_finish;
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
+ __throw_exception_again;
+ }
+ }
+ else
+ _M_insert_aux(__pos, __first, __last, __n);
+ }
+
+ template <typename _Tp, typename _Alloc>
+ typename deque<_Tp, _Alloc>::iterator
+ deque<_Tp,_Alloc>::
+ _M_insert_aux(iterator __pos, const value_type& __x)
+ {
+ difference_type __index = __pos - _M_start;
+ value_type __x_copy = __x; // XXX copy
+ if (static_cast<size_type>(__index) < size() / 2)
+ {
+ push_front(front());
+ iterator __front1 = _M_start;
+ ++__front1;
+ iterator __front2 = __front1;
+ ++__front2;
+ __pos = _M_start + __index;
+ iterator __pos1 = __pos;
+ ++__pos1;
+ copy(__front2, __pos1, __front1);
+ }
+ else
+ {
+ push_back(back());
+ iterator __back1 = _M_finish;
+ --__back1;
+ iterator __back2 = __back1;
+ --__back2;
+ __pos = _M_start + __index;
+ copy_backward(__pos, __back2, __back1);
+ }
+ *__pos = __x_copy;
+ return __pos;
+ }
+
+ #ifdef _GLIBCPP_DEPRECATED
+ // Nothing seems to actually use this. According to the pattern followed by
+ // the rest of the SGI code, it would be called by the deprecated insert(pos)
+ // function, but that has been replaced. We'll take our time removing this
+ // anyhow; mark for 3.4. -pme
+ template <typename _Tp, typename _Alloc>
+ typename deque<_Tp,_Alloc>::iterator
+ deque<_Tp,_Alloc>::
+ _M_insert_aux(iterator __pos)
+ {
+ difference_type __index = __pos - _M_start;
+ if (static_cast<size_type>(__index) < size() / 2)
+ {
+ push_front(front());
+ iterator __front1 = _M_start;
+ ++__front1;
+ iterator __front2 = __front1;
+ ++__front2;
+ __pos = _M_start + __index;
+ iterator __pos1 = __pos;
+ ++__pos1;
+ copy(__front2, __pos1, __front1);
+ }
+ else
+ {
+ push_back(back());
+ iterator __back1 = _M_finish;
+ --__back1;
+ iterator __back2 = __back1;
+ --__back2;
+ __pos = _M_start + __index;
+ copy_backward(__pos, __back2, __back1);
+ }
+ *__pos = value_type();
+ return __pos;
+ }
+ #endif
+
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_insert_aux(iterator __pos, size_type __n, const value_type& __x)
+ {
+ const difference_type __elems_before = __pos - _M_start;
+ size_type __length = this->size();
+ value_type __x_copy = __x;
+ if (__elems_before < difference_type(__length / 2))
+ {
+ iterator __new_start = _M_reserve_elements_at_front(__n);
+ iterator __old_start = _M_start;
+ __pos = _M_start + __elems_before;
+ try
+ {
+ if (__elems_before >= difference_type(__n))
+ {
+ iterator __start_n = _M_start + difference_type(__n);
+ uninitialized_copy(_M_start, __start_n, __new_start);
+ _M_start = __new_start;
+ copy(__start_n, __pos, __old_start);
+ fill(__pos - difference_type(__n), __pos, __x_copy);
+ }
+ else
+ {
+ __uninitialized_copy_fill(_M_start, __pos, __new_start,
+ _M_start, __x_copy);
+ _M_start = __new_start;
+ fill(__old_start, __pos, __x_copy);
+ }
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+ __throw_exception_again;
+ }
+ }
+ else
+ {
+ iterator __new_finish = _M_reserve_elements_at_back(__n);
+ iterator __old_finish = _M_finish;
+ const difference_type __elems_after =
+ difference_type(__length) - __elems_before;
+ __pos = _M_finish - __elems_after;
+ try
+ {
+ if (__elems_after > difference_type(__n))
+ {
+ iterator __finish_n = _M_finish - difference_type(__n);
+ uninitialized_copy(__finish_n, _M_finish, _M_finish);
+ _M_finish = __new_finish;
+ copy_backward(__pos, __finish_n, __old_finish);
+ fill(__pos, __pos + difference_type(__n), __x_copy);
+ }
+ else
+ {
+ __uninitialized_fill_copy(_M_finish, __pos + difference_type(__n),
+ __x_copy, __pos, _M_finish);
+ _M_finish = __new_finish;
+ fill(__pos, __old_finish, __x_copy);
+ }
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
+ __throw_exception_again;
+ }
+ }
+ }
+
+ template <typename _Tp, typename _Alloc>
+ template <typename _ForwardIterator>
+ void
+ deque<_Tp,_Alloc>::
+ _M_insert_aux(iterator __pos,
+ _ForwardIterator __first, _ForwardIterator __last,
+ size_type __n)
+ {
+ const difference_type __elemsbefore = __pos - _M_start;
+ size_type __length = size();
+ if (static_cast<size_type>(__elemsbefore) < __length / 2)
+ {
+ iterator __new_start = _M_reserve_elements_at_front(__n);
+ iterator __old_start = _M_start;
+ __pos = _M_start + __elemsbefore;
+ try
+ {
+ if (__elemsbefore >= difference_type(__n))
+ {
+ iterator __start_n = _M_start + difference_type(__n);
+ uninitialized_copy(_M_start, __start_n, __new_start);
+ _M_start = __new_start;
+ copy(__start_n, __pos, __old_start);
+ copy(__first, __last, __pos - difference_type(__n));
+ }
+ else
+ {
+ _ForwardIterator __mid = __first;
+ advance(__mid, difference_type(__n) - __elemsbefore);
+ __uninitialized_copy_copy(_M_start, __pos, __first, __mid,
+ __new_start);
+ _M_start = __new_start;
+ copy(__mid, __last, __old_start);
+ }
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+ __throw_exception_again;
+ }
+ }
+ else
+ {
+ iterator __new_finish = _M_reserve_elements_at_back(__n);
+ iterator __old_finish = _M_finish;
+ const difference_type __elemsafter =
+ difference_type(__length) - __elemsbefore;
+ __pos = _M_finish - __elemsafter;
+ try
+ {
+ if (__elemsafter > difference_type(__n))
+ {
+ iterator __finish_n = _M_finish - difference_type(__n);
+ uninitialized_copy(__finish_n, _M_finish, _M_finish);
+ _M_finish = __new_finish;
+ copy_backward(__pos, __finish_n, __old_finish);
+ copy(__first, __last, __pos);
+ }
+ else
+ {
+ _ForwardIterator __mid = __first;
+ advance(__mid, __elemsafter);
+ __uninitialized_copy_copy(__mid, __last, __pos,
+ _M_finish, _M_finish);
+ _M_finish = __new_finish;
+ copy(__first, __mid, __pos);
+ }
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
+ __throw_exception_again;
+ }
+ }
+ }
+
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_new_elements_at_front(size_type __new_elems)
+ {
+ size_type __new_nodes
+ = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
+ _M_reserve_map_at_front(__new_nodes);
+ size_type __i;
+ try
+ {
+ for (__i = 1; __i <= __new_nodes; ++__i)
+ *(_M_start._M_node - __i) = _M_allocate_node();
+ }
+ catch(...)
+ {
+ for (size_type __j = 1; __j < __i; ++__j)
+ _M_deallocate_node(*(_M_start._M_node - __j));
+ __throw_exception_again;
+ }
+ }
+
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_new_elements_at_back(size_type __new_elems)
+ {
+ size_type __new_nodes
+ = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
+ _M_reserve_map_at_back(__new_nodes);
+ size_type __i;
+ try
+ {
+ for (__i = 1; __i <= __new_nodes; ++__i)
+ *(_M_finish._M_node + __i) = _M_allocate_node();
+ }
+ catch(...)
+ {
+ for (size_type __j = 1; __j < __i; ++__j)
+ _M_deallocate_node(*(_M_finish._M_node + __j));
+ __throw_exception_again;
+ }
+ }
+
+ template <typename _Tp, typename _Alloc>
+ void
+ deque<_Tp,_Alloc>::
+ _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
+ {
+ size_type __old_num_nodes = _M_finish._M_node - _M_start._M_node + 1;
+ size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
+
+ _Map_pointer __new_nstart;
+ if (_M_map_size > 2 * __new_num_nodes)
+ {
+ __new_nstart = _M_map + (_M_map_size - __new_num_nodes) / 2
+ + (__add_at_front ? __nodes_to_add : 0);
+ if (__new_nstart < _M_start._M_node)
+ copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);
+ else
+ copy_backward(_M_start._M_node, _M_finish._M_node + 1,
+ __new_nstart + __old_num_nodes);
+ }
+ else
+ {
+ size_type __new_map_size =
+ _M_map_size + max(_M_map_size, __nodes_to_add) + 2;
+
+ _Map_pointer __new_map = _M_allocate_map(__new_map_size);
+ __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
+ + (__add_at_front ? __nodes_to_add : 0);
+ copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);
+ _M_deallocate_map(_M_map, _M_map_size);
+
+ _M_map = __new_map;
+ _M_map_size = __new_map_size;
+ }
+
+ _M_start._M_set_node(__new_nstart);
+ _M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
+ }
+} // namespace std
+
+#endif /* __GLIBCPP_INTERNAL_DEQUE_TCC */
+
diff --git a/contrib/libstdc++/include/bits/fpos.h b/contrib/libstdc++/include/bits/fpos.h
index 279e0ab..5432527 100644
--- a/contrib/libstdc++/include/bits/fpos.h
+++ b/contrib/libstdc++/include/bits/fpos.h
@@ -48,7 +48,10 @@ namespace std
{
// 27.4.1 Types
- // 27.4.3 Template class fpos
+ // [27.4.3] template class fpos
+ /**
+ * @doctodo
+ */
template<typename _StateT>
class fpos
{
@@ -113,9 +116,10 @@ namespace std
_M_position(streamoff __off) { _M_off = __off; }
};
- // 27.2, paragraph 10 about fpos/char_traits circularity
+ /// 27.2, paragraph 10 about fpos/char_traits circularity
typedef fpos<mbstate_t> streampos;
# ifdef _GLIBCPP_USE_WCHAR_T
+ /// 27.2, paragraph 10 about fpos/char_traits circularity
typedef fpos<mbstate_t> wstreampos;
# endif
} // namespace std
diff --git a/contrib/libstdc++/include/bits/fstream.tcc b/contrib/libstdc++/include/bits/fstream.tcc
index 0b3bec1..c69ac9c 100644
--- a/contrib/libstdc++/include/bits/fstream.tcc
+++ b/contrib/libstdc++/include/bits/fstream.tcc
@@ -58,7 +58,7 @@ namespace std
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
- _M_destroy_internal_buffer()
+ _M_destroy_internal_buffer() throw()
{
if (_M_buf_allocated)
{
@@ -90,11 +90,18 @@ namespace std
{
_M_allocate_internal_buffer();
_M_mode = __mode;
+
+ // Setup initial position of buffer.
_M_set_indeterminate();
if ((__mode & ios_base::ate)
&& this->seekoff(0, ios_base::end, __mode) < 0)
- this->close();
+ {
+ // 27.8.1.3,4
+ this->close();
+ return __ret;
+ }
+
__ret = this;
}
}
@@ -104,35 +111,46 @@ namespace std
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>::
- close()
+ close() throw()
{
- __filebuf_type *__ret = NULL;
+ __filebuf_type* __ret = NULL;
if (this->is_open())
{
- const int_type __eof = traits_type::eof();
- bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
- if (__testput
- && traits_type::eq_int_type(_M_really_overflow(__eof), __eof))
- return __ret;
+ bool __testfail = false;
+ try
+ {
+ const int_type __eof = traits_type::eof();
+ bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
+ if (__testput
+ && traits_type::eq_int_type(_M_really_overflow(__eof),
+ __eof))
+ __testfail = true;
+
+#if 0
+ // XXX not done
+ if (_M_last_overflowed)
+ {
+ _M_output_unshift();
+ _M_really_overflow(__eof);
+ }
+#endif
+ }
+ catch(...)
+ {
+ __testfail = true;
+ }
// NB: Do this here so that re-opened filebufs will be cool...
- _M_mode = ios_base::openmode(0);
+ this->_M_mode = ios_base::openmode(0);
_M_destroy_internal_buffer();
_M_pback_destroy();
-
-#if 0
- // XXX not done
- if (_M_last_overflowed)
- {
- _M_output_unshift();
- _M_really_overflow(__eof);
- }
-#endif
- if (_M_file.close())
+ if (!_M_file.close())
+ __testfail = true;
+
+ if (!__testfail)
__ret = this;
}
-
_M_last_overflowed = false;
return __ret;
}
@@ -144,9 +162,16 @@ namespace std
{
streamsize __ret = -1;
bool __testin = _M_mode & ios_base::in;
+ const locale __loc = this->getloc();
+ const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc);
if (__testin && this->is_open())
- __ret = _M_in_end - _M_in_cur;
+ {
+ __ret = _M_in_end - _M_in_cur;
+ if (__cvt.always_noconv())
+ __ret += _M_file.showmanyc_helper();
+ }
+
_M_last_overflowed = false;
return __ret;
}
@@ -198,21 +223,26 @@ namespace std
}
else
{
- // At the beginning of the buffer, need to make a
- // putback position available.
- this->seekoff(-1, ios_base::cur);
- this->underflow();
- if (!__testeof)
+ // At the beginning of the buffer, need to make a
+ // putback position available.
+ // But the seek may fail (f.i., at the beginning of
+ // a file, see libstdc++/9439) and in that case
+ // we return traits_type::eof()
+ if (this->seekoff(-1, ios_base::cur) >= 0)
{
- if (!traits_type::eq(__c, *_M_in_cur))
- {
- _M_pback_create();
- *_M_in_cur = __c;
- }
- __ret = __i;
+ this->underflow();
+ if (!__testeof)
+ {
+ if (!traits_type::eq(__c, *_M_in_cur))
+ {
+ _M_pback_create();
+ *_M_in_cur = __c;
+ }
+ __ret = __i;
+ }
+ else
+ __ret = traits_type::not_eof(__i);
}
- else
- __ret = traits_type::not_eof(__i);
}
}
_M_last_overflowed = false;
@@ -230,7 +260,9 @@ namespace std
if (__testout)
{
- if (__testput)
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ __ret = traits_type::not_eof(__c);
+ else if (__testput)
{
*_M_out_cur = traits_type::to_char_type(__c);
_M_out_cur_move(1);
@@ -268,14 +300,23 @@ namespace std
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
char* __bend;
const char_type* __iend;
- __res_type __r = __cvt.out(_M_state_cur, __ibuf, __ibuf + __ilen,
- __iend, __buf, __buf + __blen, __bend);
- // Result == ok, partial, noconv
- if (__r != codecvt_base::error)
+ codecvt_base::result __r;
+ __r = __cvt.out(_M_state_cur, __ibuf, __ibuf + __ilen,
+ __iend, __buf, __buf + __blen, __bend);
+
+ if (__r == codecvt_base::ok || __r == codecvt_base::partial)
__blen = __bend - __buf;
- // Result == error
- else
- __blen = 0;
+ else if (__r == codecvt_base::noconv)
+ {
+ // Same as the always_noconv case above.
+ __buf = reinterpret_cast<char*>(__ibuf);
+ __blen = __ilen;
+ }
+ else
+ {
+ // Result == error
+ __blen = 0;
+ }
if (__blen)
{
@@ -291,11 +332,8 @@ namespace std
__r = __cvt.out(_M_state_cur, __iresume, __iresume + __rlen,
__iend, __buf, __buf + __blen, __bend);
if (__r != codecvt_base::error)
- __rlen = __bend - __buf;
- else
- __rlen = 0;
- if (__rlen)
{
+ __rlen = __bend - __buf;
__elen += _M_file.xsputn(__buf, __rlen);
__plen += __rlen;
}
@@ -310,7 +348,7 @@ namespace std
{
int_type __ret = traits_type::eof();
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
- bool __testunbuffered = _M_file.is_open() && !_M_buf_size_opt;
+ bool __testunbuffered = _M_file.is_open() && !_M_buf_size;
if (__testput || __testunbuffered)
{
@@ -333,26 +371,32 @@ namespace std
_M_convert_to_external(_M_out_beg, _M_out_end - _M_out_beg,
__elen, __plen);
- // Convert pending sequence to external representation, output.
- // If eof, then just attempt sync.
- if (!traits_type::eq_int_type(__c, traits_type::eof()))
- {
- char_type __pending = traits_type::to_char_type(__c);
- _M_convert_to_external(&__pending, 1, __elen, __plen);
-
- // User code must flush when switching modes (thus don't sync).
- if (__elen == __plen)
+ // Checks for codecvt.out failures and _M_file.xsputn failures,
+ // respectively, inside _M_convert_to_external.
+ if (__testunbuffered || (__elen && __elen == __plen))
+ {
+ // Convert pending sequence to external representation, output.
+ // If eof, then just attempt sync.
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
- _M_set_indeterminate();
- __ret = traits_type::not_eof(__c);
+ char_type __pending = traits_type::to_char_type(__c);
+ _M_convert_to_external(&__pending, 1, __elen, __plen);
+
+ // User code must flush when switching modes (thus
+ // don't sync).
+ if (__elen == __plen && __elen)
+ {
+ _M_set_indeterminate();
+ __ret = traits_type::not_eof(__c);
+ }
}
- }
- else if (!_M_file.sync())
- {
- _M_set_indeterminate();
- __ret = traits_type::not_eof(__c);
- }
- }
+ else if (!_M_file.sync())
+ {
+ _M_set_indeterminate();
+ __ret = traits_type::not_eof(__c);
+ }
+ }
+ }
_M_last_overflowed = true;
return __ret;
}
@@ -391,12 +435,13 @@ namespace std
bool __testin = (ios_base::in & _M_mode & __mode) != 0;
bool __testout = (ios_base::out & _M_mode & __mode) != 0;
- // Should probably do has_facet checks here.
- int __width = use_facet<__codecvt_type>(_M_buf_locale).encoding();
+ int __width = 0;
+ if (has_facet<__codecvt_type>(this->_M_buf_locale))
+ __width = use_facet<__codecvt_type>(this->_M_buf_locale).encoding();
if (__width < 0)
__width = 0;
- bool __testfail = __off != 0 && __width <= 0;
-
+
+ bool __testfail = __off != 0 && __width <= 0;
if (this->is_open() && !__testfail && (__testin || __testout))
{
// Ditch any pback buffers to avoid confusion.
@@ -420,7 +465,8 @@ namespace std
//in
else if (__testget && __way == ios_base::cur)
__computed_off += _M_in_cur - _M_filepos;
-
+
+ // Return pos_type(off_type(-1)) in case of failure.
__ret = _M_file.seekoff(__computed_off, __way, __mode);
_M_set_indeterminate();
}
@@ -428,8 +474,14 @@ namespace std
// state, ie _M_file._offset == -1
else
{
- __ret = _M_file.seekoff(__off, ios_base::cur, __mode);
- __ret += max(_M_out_cur, _M_in_cur) - _M_filepos;
+ pos_type __tmp =
+ _M_file.seekoff(__off, ios_base::cur, __mode);
+ if (__tmp >= 0)
+ {
+ // Seek successful.
+ __ret = __tmp;
+ __ret += max(_M_out_cur, _M_in_cur) - _M_filepos;
+ }
}
}
_M_last_overflowed = false;
@@ -473,6 +525,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_filebuf<char>;
extern template class basic_ifstream<char>;
extern template class basic_ofstream<char>;
@@ -484,6 +537,7 @@ namespace std
extern template class basic_ofstream<wchar_t>;
extern template class basic_fstream<wchar_t>;
#endif
+#endif
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/gslice_array.h b/contrib/libstdc++/include/bits/gslice_array.h
index 8989ac5..1116e9c 100644
--- a/contrib/libstdc++/include/bits/gslice_array.h
+++ b/contrib/libstdc++/include/bits/gslice_array.h
@@ -41,129 +41,131 @@
namespace std {
- template<typename _Tp> class gslice_array
+ template<typename _Tp>
+ class gslice_array
{
public:
- typedef _Tp value_type;
-
- void operator= (const valarray<_Tp>&) const;
- void operator*= (const valarray<_Tp>&) const;
- void operator/= (const valarray<_Tp>&) const;
- void operator%= (const valarray<_Tp>&) const;
- void operator+= (const valarray<_Tp>&) const;
- void operator-= (const valarray<_Tp>&) const;
- void operator^= (const valarray<_Tp>&) const;
- void operator&= (const valarray<_Tp>&) const;
- void operator|= (const valarray<_Tp>&) const;
- void operator<<=(const valarray<_Tp>&) const;
- void operator>>=(const valarray<_Tp>&) const;
- void operator=(const _Tp&);
-
- template<class _Dom>
- void operator= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator*= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator/= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator%= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator+= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator-= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator^= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator&= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator|= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator<<= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator>>= (const _Expr<_Dom,_Tp>&) const;
+ typedef _Tp value_type;
+
+ void operator=(const valarray<_Tp>&) const;
+ void operator*=(const valarray<_Tp>&) const;
+ void operator/=(const valarray<_Tp>&) const;
+ void operator%=(const valarray<_Tp>&) const;
+ void operator+=(const valarray<_Tp>&) const;
+ void operator-=(const valarray<_Tp>&) const;
+ void operator^=(const valarray<_Tp>&) const;
+ void operator&=(const valarray<_Tp>&) const;
+ void operator|=(const valarray<_Tp>&) const;
+ void operator<<=(const valarray<_Tp>&) const;
+ void operator>>=(const valarray<_Tp>&) const;
+ void operator=(const _Tp&) const;
+
+ template<class _Dom>
+ void operator=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator*=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator/=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator%=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator+=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator-=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator^=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator&=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator|=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator<<=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator>>=(const _Expr<_Dom,_Tp>&) const;
private:
- _Array<_Tp> _M_array;
- const valarray<size_t>& _M_index;
+ _Array<_Tp> _M_array;
+ const valarray<size_t>& _M_index;
- friend class valarray<_Tp>;
-
- gslice_array (_Array<_Tp>, const valarray<size_t>&);
+ friend class valarray<_Tp>;
+
+ gslice_array(_Array<_Tp>, const valarray<size_t>&);
- // this constructor needs to be implemented.
- gslice_array (const gslice_array&);
+ // this constructor needs to be implemented.
+ gslice_array(const gslice_array&);
- // not implemented
- gslice_array();
- gslice_array& operator= (const gslice_array&);
+ // not implemented
+ gslice_array();
+ gslice_array& operator= (const gslice_array&);
};
- template<typename _Tp>
+ template<typename _Tp>
inline
- gslice_array<_Tp>::gslice_array (_Array<_Tp> __a,
- const valarray<size_t>& __i)
- : _M_array (__a), _M_index (__i) {}
+ gslice_array<_Tp>::gslice_array(_Array<_Tp> __a,
+ const valarray<size_t>& __i)
+ : _M_array(__a), _M_index(__i) {}
- template<typename _Tp>
+ template<typename _Tp>
inline
- gslice_array<_Tp>::gslice_array (const gslice_array<_Tp>& __a)
- : _M_array (__a._M_array), _M_index (__a._M_index) {}
+ gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a)
+ : _M_array(__a._M_array), _M_index(__a._M_index) {}
- template<typename _Tp>
+ template<typename _Tp>
inline void
- gslice_array<_Tp>::operator= (const _Tp& __t)
+ gslice_array<_Tp>::operator=(const _Tp& __t) const
{
- __valarray_fill (_M_array, _Array<size_t>(_M_index),
- _M_index.size(), __t);
+ __valarray_fill(_M_array, _Array<size_t>(_M_index),
+ _M_index.size(), __t);
}
- template<typename _Tp>
+ template<typename _Tp>
inline void
- gslice_array<_Tp>::operator= (const valarray<_Tp>& __v) const
+ gslice_array<_Tp>::operator=(const valarray<_Tp>& __v) const
{
- __valarray_copy (_Array<_Tp> (__v), __v.size (),
- _M_array, _Array<size_t>(_M_index));
+ __valarray_copy(_Array<_Tp>(__v), __v.size(),
+ _M_array, _Array<size_t>(_M_index));
}
- template<typename _Tp>
- template<class E>
- inline void
- gslice_array<_Tp>::operator= (const _Expr<E, _Tp>& __e) const
- {
- __valarray_copy (__e, _M_index.size(), _M_array,
- _Array<size_t>(_M_index));
- }
+ template<typename _Tp>
+ template<class _Dom>
+ inline void
+ gslice_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const
+ {
+ __valarray_copy (__e, _M_index.size(), _M_array,
+ _Array<size_t>(_M_index));
+ }
#undef _DEFINE_VALARRAY_OPERATOR
-#define _DEFINE_VALARRAY_OPERATOR(op, name) \
-template<typename _Tp> \
-inline void \
-gslice_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \
-{ \
- _Array_augmented_##name (_M_array, _Array<size_t>(_M_index), \
- _Array<_Tp> (__v), __v.size ()); \
-} \
+#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline void \
+ gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
+ { \
+ _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), \
+ _Array<_Tp>(__v), __v.size()); \
+ } \
\
-template<typename _Tp> template<class E> \
-inline void \
-gslice_array<_Tp>::operator op##= (const _Expr<E, _Tp>& __e) const \
-{ \
- _Array_augmented_##name (_M_array, _Array<size_t>(_M_index), __e, \
- _M_index.size()); \
-}
-
-_DEFINE_VALARRAY_OPERATOR(*, multiplies)
-_DEFINE_VALARRAY_OPERATOR(/, divides)
-_DEFINE_VALARRAY_OPERATOR(%, modulus)
-_DEFINE_VALARRAY_OPERATOR(+, plus)
-_DEFINE_VALARRAY_OPERATOR(-, minus)
-_DEFINE_VALARRAY_OPERATOR(^, xor)
-_DEFINE_VALARRAY_OPERATOR(&, and)
-_DEFINE_VALARRAY_OPERATOR(|, or)
-_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
-_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+ template<typename _Tp> \
+ template<class _Dom> \
+ inline void \
+ gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\
+ { \
+ _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), __e,\
+ _M_index.size()); \
+ }
+
+_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, __divides)
+_DEFINE_VALARRAY_OPERATOR(%, __modulus)
+_DEFINE_VALARRAY_OPERATOR(+, __plus)
+_DEFINE_VALARRAY_OPERATOR(-, __minus)
+_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
+_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
+_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
+_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
#undef _DEFINE_VALARRAY_OPERATOR
diff --git a/contrib/libstdc++/include/bits/indirect_array.h b/contrib/libstdc++/include/bits/indirect_array.h
index a5737e9..9fc973e 100644
--- a/contrib/libstdc++/include/bits/indirect_array.h
+++ b/contrib/libstdc++/include/bits/indirect_array.h
@@ -1,6 +1,7 @@
// The template and inlines for the -*- C++ -*- indirect_array class.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -48,70 +49,70 @@ namespace std
typedef _Tp value_type;
// XXX: This is a proposed resolution for DR-253.
- indirect_array& operator= (const indirect_array&);
-
- void operator= (const valarray<_Tp>&) const;
- void operator*= (const valarray<_Tp>&) const;
- void operator/= (const valarray<_Tp>&) const;
- void operator%= (const valarray<_Tp>&) const;
- void operator+= (const valarray<_Tp>&) const;
- void operator-= (const valarray<_Tp>&) const;
- void operator^= (const valarray<_Tp>&) const;
- void operator&= (const valarray<_Tp>&) const;
- void operator|= (const valarray<_Tp>&) const;
- void operator<<= (const valarray<_Tp>&) const;
- void operator>>= (const valarray<_Tp>&) const;
- void operator= (const _Tp&);
+ indirect_array& operator=(const indirect_array&);
+
+ void operator=(const valarray<_Tp>&) const;
+ void operator*=(const valarray<_Tp>&) const;
+ void operator/=(const valarray<_Tp>&) const;
+ void operator%=(const valarray<_Tp>&) const;
+ void operator+=(const valarray<_Tp>&) const;
+ void operator-=(const valarray<_Tp>&) const;
+ void operator^=(const valarray<_Tp>&) const;
+ void operator&=(const valarray<_Tp>&) const;
+ void operator|=(const valarray<_Tp>&) const;
+ void operator<<=(const valarray<_Tp>&) const;
+ void operator>>=(const valarray<_Tp>&) const;
+ void operator= (const _Tp&) const;
// ~indirect_array();
-
+
template<class _Dom>
- void operator= (const _Expr<_Dom, _Tp>&) const;
+ void operator=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator*= (const _Expr<_Dom, _Tp>&) const;
+ void operator*=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator/= (const _Expr<_Dom, _Tp>&) const;
+ void operator/=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator%= (const _Expr<_Dom, _Tp>&) const;
+ void operator%=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator+= (const _Expr<_Dom, _Tp>&) const;
+ void operator+=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator-= (const _Expr<_Dom, _Tp>&) const;
+ void operator-=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator^= (const _Expr<_Dom, _Tp>&) const;
+ void operator^=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator&= (const _Expr<_Dom, _Tp>&) const;
+ void operator&=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator|= (const _Expr<_Dom, _Tp>&) const;
+ void operator|=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator<<= (const _Expr<_Dom, _Tp>&) const;
+ void operator<<=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
- void operator>>= (const _Expr<_Dom, _Tp>&) const;
+ void operator>>=(const _Expr<_Dom, _Tp>&) const;
private:
- indirect_array (const indirect_array&);
- indirect_array (_Array<_Tp>, size_t, _Array<size_t>);
+ indirect_array(const indirect_array&);
+ indirect_array(_Array<_Tp>, size_t, _Array<size_t>);
friend class valarray<_Tp>;
friend class gslice_array<_Tp>;
-
+
const size_t _M_sz;
const _Array<size_t> _M_index;
const _Array<_Tp> _M_array;
-
+
// not implemented
- indirect_array ();
+ indirect_array();
};
template<typename _Tp>
- inline indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a)
- : _M_sz (__a._M_sz), _M_index (__a._M_index),
- _M_array (__a._M_array) {}
+ inline
+ indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a)
+ : _M_sz(__a._M_sz), _M_index(__a._M_index), _M_array(__a._M_array) {}
template<typename _Tp>
inline
- indirect_array<_Tp>::indirect_array (_Array<_Tp> __a, size_t __s,
- _Array<size_t> __i)
- : _M_sz (__s), _M_index (__i), _M_array (__a) {}
+ indirect_array<_Tp>::indirect_array(_Array<_Tp> __a, size_t __s,
+ _Array<size_t> __i)
+ : _M_sz(__s), _M_index(__i), _M_array(__a) {}
template<typename _Tp>
inline indirect_array<_Tp>&
@@ -124,46 +125,47 @@ namespace std
template<typename _Tp>
inline void
- indirect_array<_Tp>::operator= (const _Tp& __t)
+ indirect_array<_Tp>::operator=(const _Tp& __t) const
{ __valarray_fill(_M_array, _M_index, _M_sz, __t); }
template<typename _Tp>
inline void
- indirect_array<_Tp>::operator= (const valarray<_Tp>& __v) const
- { __valarray_copy (_Array<_Tp> (__v), _M_sz, _M_array, _M_index); }
+ indirect_array<_Tp>::operator=(const valarray<_Tp>& __v) const
+ { __valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); }
template<typename _Tp>
template<class _Dom>
- inline void
- indirect_array<_Tp>::operator= (const _Expr<_Dom,_Tp>& __e) const
- { __valarray_copy (__e, _M_sz, _M_array, _M_index); }
+ inline void
+ indirect_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const
+ { __valarray_copy(__e, _M_sz, _M_array, _M_index); }
#undef _DEFINE_VALARRAY_OPERATOR
-#define _DEFINE_VALARRAY_OPERATOR(op, name) \
-template<typename _Tp> \
-inline void \
-indirect_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \
-{ \
- _Array_augmented_##name (_M_array, _M_index, _Array<_Tp> (__v), _M_sz); \
-} \
+#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline void \
+ indirect_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const\
+ { \
+ _Array_augmented_##_Name(_M_array, _M_index, _Array<_Tp>(__v), _M_sz); \
+ } \
\
-template<typename _Tp> template<class _Dom> \
-inline void \
-indirect_array<_Tp>::operator op##= (const _Expr<_Dom,_Tp>& __e) const \
-{ \
- _Array_augmented_##name (_M_array, _M_index, __e, _M_sz); \
-}
-
-_DEFINE_VALARRAY_OPERATOR(*, multiplies)
-_DEFINE_VALARRAY_OPERATOR(/, divides)
-_DEFINE_VALARRAY_OPERATOR(%, modulus)
-_DEFINE_VALARRAY_OPERATOR(+, plus)
-_DEFINE_VALARRAY_OPERATOR(-, minus)
-_DEFINE_VALARRAY_OPERATOR(^, xor)
-_DEFINE_VALARRAY_OPERATOR(&, and)
-_DEFINE_VALARRAY_OPERATOR(|, or)
-_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
-_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+ template<typename _Tp> \
+ template<class _Dom> \
+ inline void \
+ indirect_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\
+ { \
+ _Array_augmented_##_Name(_M_array, _M_index, __e, _M_sz); \
+ }
+
+_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, __divides)
+_DEFINE_VALARRAY_OPERATOR(%, __modulus)
+_DEFINE_VALARRAY_OPERATOR(+, __plus)
+_DEFINE_VALARRAY_OPERATOR(-, __minus)
+_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
+_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
+_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
+_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
#undef _DEFINE_VALARRAY_OPERATOR
diff --git a/contrib/libstdc++/include/bits/ios_base.h b/contrib/libstdc++/include/bits/ios_base.h
index a56475c..3437f84 100644
--- a/contrib/libstdc++/include/bits/ios_base.h
+++ b/contrib/libstdc++/include/bits/ios_base.h
@@ -1,6 +1,6 @@
// Iostreams base classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -43,6 +43,8 @@
#pragma GCC system_header
#include <bits/atomicity.h>
+#include <bits/localefwd.h>
+#include <bits/locale_classes.h>
namespace std
{
@@ -145,11 +147,20 @@ namespace std
enum _Ios_Seekdir { _M_ios_seekdir_end = 1L << 16 };
// 27.4.2 Class ios_base
+ /**
+ * @brief The very top of the I/O class hierarchy.
+ *
+ * This class defines everything that can be defined about I/O that does
+ * not depend on the type of characters being input or output. Most
+ * people will only see @c ios_base when they need to specify the full
+ * name of the various I/O flags (e.g., the openmodes).
+ */
class ios_base
{
public:
// 27.4.2.1.1 Class ios_base::failure
+ /// These are thrown to indicate problems. Doc me.
class failure : public exception
{
public:
@@ -173,50 +184,152 @@ namespace std
};
// 27.4.2.1.2 Type ios_base::fmtflags
+ /**
+ * @brief This is a bitmask type.
+ *
+ * @c "_Ios_Fmtflags" is implementation-defined, but it is valid to
+ * perform bitwise operations on these values and expect the Right
+ * Thing to happen. Defined objects of type fmtflags are:
+ * - boolalpha
+ * - dec
+ * - fixed
+ * - hex
+ * - internal
+ * - left
+ * - oct
+ * - right
+ * - scientific
+ * - showbase
+ * - showpoint
+ * - showpos
+ * - skipws
+ * - unitbuf
+ * - uppercase
+ * - adjustfield
+ * - basefield
+ * - floatfield
+ */
typedef _Ios_Fmtflags fmtflags;
- // 27.4.2.1.2 Type fmtflags
+ /// Insert/extract @c bool in alphabetic rather than numeric format.
static const fmtflags boolalpha = fmtflags(__ios_flags::_S_boolalpha);
+ /// Converts integer input or generates integer output in decimal base.
static const fmtflags dec = fmtflags(__ios_flags::_S_dec);
+ /// Generate floating-point output in fixed-point notation.
static const fmtflags fixed = fmtflags(__ios_flags::_S_fixed);
+ /// Converts integer input or generates integer output in hexadecimal base.
static const fmtflags hex = fmtflags(__ios_flags::_S_hex);
+ /// Adds fill characters at a designated internal point in certain
+ /// generated output, or identical to @c right if no such point is
+ /// designated.
static const fmtflags internal = fmtflags(__ios_flags::_S_internal);
+ /// Adds fill characters on the right (final positions) of certain
+ /// generated output. (I.e., the thing you print is flush left.)
static const fmtflags left = fmtflags(__ios_flags::_S_left);
+ /// Converts integer input or generates integer output in octal base.
static const fmtflags oct = fmtflags(__ios_flags::_S_oct);
+ /// Adds fill characters on the left (initial positions) of certain
+ /// generated output. (I.e., the thing you print is flush right.)
static const fmtflags right = fmtflags(__ios_flags::_S_right);
+ /// Generates floating-point output in scientific notation.
static const fmtflags scientific = fmtflags(__ios_flags::_S_scientific);
+ /// Generates a prefix indicating the numeric base of generated integer
+ /// output.
static const fmtflags showbase = fmtflags(__ios_flags::_S_showbase);
+ /// Generates a decimal-point character unconditionally in generated
+ /// floating-point output.
static const fmtflags showpoint = fmtflags(__ios_flags::_S_showpoint);
+ /// Generates a + sign in non-negative generated numeric output.
static const fmtflags showpos = fmtflags(__ios_flags::_S_showpos);
+ /// Skips leading white space before certain input operations.
static const fmtflags skipws = fmtflags(__ios_flags::_S_skipws);
+ /// Flushes output after each output operation.
static const fmtflags unitbuf = fmtflags(__ios_flags::_S_unitbuf);
+ /// Replaces certain lowercase letters with their uppercase equivalents
+ /// in generated output.
static const fmtflags uppercase = fmtflags(__ios_flags::_S_uppercase);
+ /// A mask of left|right|internal. Useful for the 2-arg form of @c setf.
static const fmtflags adjustfield = fmtflags(__ios_flags::_S_adjustfield);
+ /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf.
static const fmtflags basefield = fmtflags(__ios_flags::_S_basefield);
+ /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf.
static const fmtflags floatfield = fmtflags(__ios_flags::_S_floatfield);
// 27.4.2.1.3 Type ios_base::iostate
+ /**
+ * @brief This is a bitmask type.
+ *
+ * @c "_Ios_Iostate" is implementation-defined, but it is valid to
+ * perform bitwise operations on these values and expect the Right
+ * Thing to happen. Defined objects of type iostate are:
+ * - badbit
+ * - eofbit
+ * - failbit
+ * - goodbit
+ */
typedef _Ios_Iostate iostate;
+ /// Indicates a loss of integrity in an input or output sequence (such
+ /// as an irrecoverable read error from a file).
static const iostate badbit = iostate(__ios_flags::_S_badbit);
+ /// Indicates that an input operation reached the end of an input sequence.
static const iostate eofbit = iostate(__ios_flags::_S_eofbit);
+ /// Indicates that an input operation failed to read the expected
+ /// characters, or that an output operation failed to generate the
+ /// desired characters.
static const iostate failbit = iostate(__ios_flags::_S_failbit);
+ /// Indicates all is well.
static const iostate goodbit = iostate(0);
- // 27.4.2.1.4 Type openmode
+ // 27.4.2.1.4 Type ios_base::openmode
+ /**
+ * @brief This is a bitmask type.
+ *
+ * @c "_Ios_Openmode" is implementation-defined, but it is valid to
+ * perform bitwise operations on these values and expect the Right
+ * Thing to happen. Defined objects of type openmode are:
+ * - app
+ * - ate
+ * - binary
+ * - in
+ * - out
+ * - trunc
+ */
typedef _Ios_Openmode openmode;
+ /// Seek to end before each write.
static const openmode app = openmode(__ios_flags::_S_app);
+ /// Open and seek to end immediately after opening.
static const openmode ate = openmode(__ios_flags::_S_ate);
+ /// Perform input and output in binary mode (as opposed to text mode).
+ /// This is probably not what you think it is; see
+ /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#3 and
+ /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#7 for more.
static const openmode binary = openmode(__ios_flags::_S_bin);
+ /// Open for input. Default for @c ifstream and fstream.
static const openmode in = openmode(__ios_flags::_S_in);
+ /// Open for output. Default for @c ofstream and fstream.
static const openmode out = openmode(__ios_flags::_S_out);
+ /// Open for input. Default for @c ofstream.
static const openmode trunc = openmode(__ios_flags::_S_trunc);
- // 27.4.2.1.5 Type seekdir
+ // 27.4.2.1.5 Type ios_base::seekdir
+ /**
+ * @brief This is an enumerated type.
+ *
+ * @c "_Ios_Seekdir" is implementation-defined. Defined values
+ * of type seekdir are:
+ * - beg
+ * - cur, equivalent to @c SEEK_CUR in the C standard library.
+ * - end, equivalent to @c SEEK_END in the C standard library.
+ */
typedef _Ios_Seekdir seekdir;
+ /// Request a seek relative to the beginning of the stream.
static const seekdir beg = seekdir(0);
+ /// Request a seek relative to the current position within the sequence.
static const seekdir cur = seekdir(SEEK_CUR);
+ /// Request a seek relative to the current end of the sequence.
static const seekdir end = seekdir(SEEK_END);
#ifdef _GLIBCPP_DEPRECATED
+ // Annex D.6
typedef int io_state;
typedef int open_mode;
typedef int seek_dir;
@@ -226,6 +339,9 @@ namespace std
#endif
// Callbacks;
+ /**
+ * @doctodo
+ */
enum event
{
erase_event,
@@ -233,18 +349,30 @@ namespace std
copyfmt_event
};
+ /**
+ * @doctodo
+ */
typedef void (*event_callback) (event, ios_base&, int);
+ /**
+ * @doctodo
+ */
void
register_callback(event_callback __fn, int __index);
protected:
- // Data Members
+ //@{
+ /**
+ * @if maint
+ * ios_base data members (doc me)
+ * @endif
+ */
streamsize _M_precision;
streamsize _M_width;
fmtflags _M_flags;
iostate _M_exception;
iostate _M_streambuf_state;
+ //@}
// 27.4.2.6 Members for callbacks
// 27.4.2.6 ios_base callbacks
@@ -288,6 +416,7 @@ namespace std
_Words _M_word_zero;
// Guaranteed storage.
+ // The first 5 iword and pword slots are reserved for internal use.
static const int _S_local_word_size = 8;
_Words _M_local_word[_S_local_word_size];
@@ -323,15 +452,32 @@ namespace std
static void
_S_ios_destroy();
+ // NB: Allows debugger applications use of the standard streams
+ // from operator new. _S_ios_base_init must be incremented in
+ // _S_ios_create _after_ initialization is completed.
+ static bool
+ _S_initialized() { return _S_ios_base_init; }
+
private:
static int _S_ios_base_init;
static bool _S_synced_with_stdio;
};
- // Fmtflags state:
+ // [27.4.2.2] fmtflags state functions
+ /**
+ * @brief Access to format flags.
+ * @return The format control flags for both input and output.
+ */
inline fmtflags
flags() const { return _M_flags; }
+ /**
+ * @brief Setting new format flags all at once.
+ * @param fmtfl The new flags to set.
+ * @return The previous format control flags.
+ *
+ * This function overwrites all the format flags with @a fmtfl.
+ */
inline fmtflags
flags(fmtflags __fmtfl)
{
@@ -340,6 +486,14 @@ namespace std
return __old;
}
+ /**
+ * @brief Setting new format flags.
+ * @param fmtfl Additional flags to set.
+ * @return The previous format control flags.
+ *
+ * This function sets additional flags in format control. Flags that
+ * were previously set remain set.
+ */
inline fmtflags
setf(fmtflags __fmtfl)
{
@@ -348,6 +502,15 @@ namespace std
return __old;
}
+ /**
+ * @brief Setting new format flags.
+ * @param fmtfl Additional flags to set.
+ * @param mask The flags mask for @a fmtfl.
+ * @return The previous format control flags.
+ *
+ * This function clears @a mask in the format flags, then sets
+ * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield.
+ */
inline fmtflags
setf(fmtflags __fmtfl, fmtflags __mask)
{
@@ -357,12 +520,32 @@ namespace std
return __old;
}
+ /**
+ * @brief Clearing format flags.
+ * @param mask The flags to unset.
+ *
+ * This function clears @a mask in the format flags.
+ */
inline void
unsetf(fmtflags __mask) { _M_flags &= ~__mask; }
+ /**
+ * @brief Flags access.
+ * @return The precision to generate on certain output operations.
+ *
+ * @if maint
+ * Be careful if you try to give a definition of "precision" here; see
+ * DR 189.
+ * @endif
+ */
inline streamsize
precision() const { return _M_precision; }
+ /**
+ * @brief Changing flags.
+ * @param prec The new precision value.
+ * @return The previous value of precision().
+ */
inline streamsize
precision(streamsize __prec)
{
@@ -371,9 +554,20 @@ namespace std
return __old;
}
+ /**
+ * @brief Flags access.
+ * @return The minimum field width to generate on output operations.
+ *
+ * "Minimum field width" refers to the number of characters.
+ */
inline streamsize
width() const { return _M_width; }
+ /**
+ * @brief Changing flags.
+ * @param wide The new width value.
+ * @return The previous value of width().
+ */
inline streamsize
width(streamsize __wide)
{
@@ -382,20 +576,63 @@ namespace std
return __old;
}
+ // [27.4.2.4] ios_base static members
+ /**
+ * @brief Interaction with the standard C I/O objects.
+ * @param sync Whether to synchronize or not.
+ * @return True if the standard streams were previously synchronized.
+ *
+ * The synchronization referred to is @e only that between the standard
+ * C facilities (e.g., stdout) and the standard C++ objects (e.g.,
+ * cout). User-declared streams are unaffected. See
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#8 for more.
+ */
static bool
sync_with_stdio(bool __sync = true);
- // Locales:
+ // [27.4.2.3] ios_base locale functions
+ /**
+ * @brief Setting a new locale.
+ * @param loc The new locale.
+ * @return The previous locale.
+ *
+ * Sets the new locale for this stream, and
+ * [XXX does something with callbacks].
+ */
locale
imbue(const locale& __loc);
+ /**
+ * @brief Locale access
+ * @return A copy of the current locale.
+ *
+ * If @c imbue(loc) has previously been called, then this function
+ * returns @c loc. Otherwise, it returns a copy of @c std::locale(),
+ * the global C++ locale.
+ */
inline locale
getloc() const { return _M_ios_locale; }
- // Storage:
+ /**
+ * @brief Locale access
+ * @return A reference to the current locale.
+ *
+ * Like getloc above, but returns a reference instead of
+ * generating a copy.
+ */
+ inline const locale&
+ _M_getloc() const { return _M_ios_locale; }
+
+ // [27.4.2.5] ios_base storage functions
+ /**
+ * @doctodo
+ */
static int
xalloc() throw();
+ /**
+ * @doctodo
+ */
inline long&
iword(int __ix)
{
@@ -404,6 +641,9 @@ namespace std
return __word._M_iword;
}
+ /**
+ * @doctodo
+ */
inline void*&
pword(int __ix)
{
@@ -413,6 +653,10 @@ namespace std
}
// Destructor
+ /**
+ * Destroys local storage and
+ * [XXX does something with callbacks].
+ */
~ios_base();
protected:
@@ -428,7 +672,8 @@ namespace std
#endif
};
- // 27.4.5.1 fmtflags manipulators:
+ // [27.4.5.1] fmtflags manipulators
+ /// Calls base.setf(ios_base::boolalpha).
inline ios_base&
boolalpha(ios_base& __base)
{
@@ -436,6 +681,7 @@ namespace std
return __base;
}
+ /// Calls base.unsetf(ios_base::boolalpha).
inline ios_base&
noboolalpha(ios_base& __base)
{
@@ -443,6 +689,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::showbase).
inline ios_base&
showbase(ios_base& __base)
{
@@ -450,6 +697,7 @@ namespace std
return __base;
}
+ /// Calls base.unsetf(ios_base::showbase).
inline ios_base&
noshowbase(ios_base& __base)
{
@@ -457,6 +705,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::showpoint).
inline ios_base&
showpoint(ios_base& __base)
{
@@ -464,6 +713,7 @@ namespace std
return __base;
}
+ /// Calls base.unsetf(ios_base::showpoint).
inline ios_base&
noshowpoint(ios_base& __base)
{
@@ -471,6 +721,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::showpos).
inline ios_base&
showpos(ios_base& __base)
{
@@ -478,6 +729,7 @@ namespace std
return __base;
}
+ /// Calls base.unsetf(ios_base::showpos).
inline ios_base&
noshowpos(ios_base& __base)
{
@@ -485,6 +737,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::skipws).
inline ios_base&
skipws(ios_base& __base)
{
@@ -492,6 +745,7 @@ namespace std
return __base;
}
+ /// Calls base.unsetf(ios_base::skipws).
inline ios_base&
noskipws(ios_base& __base)
{
@@ -499,6 +753,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::uppercase).
inline ios_base&
uppercase(ios_base& __base)
{
@@ -506,6 +761,7 @@ namespace std
return __base;
}
+ /// Calls base.unsetf(ios_base::uppercase).
inline ios_base&
nouppercase(ios_base& __base)
{
@@ -513,6 +769,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::unitbuf).
inline ios_base&
unitbuf(ios_base& __base)
{
@@ -520,6 +777,7 @@ namespace std
return __base;
}
+ /// Calls base.unsetf(ios_base::unitbuf).
inline ios_base&
nounitbuf(ios_base& __base)
{
@@ -527,7 +785,8 @@ namespace std
return __base;
}
- // 27.4.5.2 adjustfield anipulators:
+ // [27.4.5.2] adjustfield anipulators
+ /// Calls base.setf(ios_base::internal, ios_base::adjustfield).
inline ios_base&
internal(ios_base& __base)
{
@@ -535,6 +794,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::left, ios_base::adjustfield).
inline ios_base&
left(ios_base& __base)
{
@@ -542,6 +802,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::right, ios_base::adjustfield).
inline ios_base&
right(ios_base& __base)
{
@@ -549,7 +810,8 @@ namespace std
return __base;
}
- // 27.4.5.3 basefield anipulators:
+ // [27.4.5.3] basefield anipulators
+ /// Calls base.setf(ios_base::dec, ios_base::basefield).
inline ios_base&
dec(ios_base& __base)
{
@@ -557,6 +819,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::hex, ios_base::basefield).
inline ios_base&
hex(ios_base& __base)
{
@@ -564,6 +827,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::oct, ios_base::basefield).
inline ios_base&
oct(ios_base& __base)
{
@@ -571,7 +835,8 @@ namespace std
return __base;
}
- // 27.4.5.4 floatfield anipulators:
+ // [27.4.5.4] floatfield anipulators
+ /// Calls base.setf(ios_base::fixed, ios_base::floatfield).
inline ios_base&
fixed(ios_base& __base)
{
@@ -579,6 +844,7 @@ namespace std
return __base;
}
+ /// Calls base.setf(ios_base::scientific, ios_base::floatfield).
inline ios_base&
scientific(ios_base& __base)
{
diff --git a/contrib/libstdc++/include/bits/istream.tcc b/contrib/libstdc++/include/bits/istream.tcc
index a6e49a9..7ba6735 100644
--- a/contrib/libstdc++/include/bits/istream.tcc
+++ b/contrib/libstdc++/include/bits/istream.tcc
@@ -1,6 +1,6 @@
// istream classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -118,11 +118,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -155,11 +155,11 @@ namespace std
#endif
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -182,11 +182,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -219,11 +219,11 @@ namespace std
#endif
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -246,11 +246,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -273,11 +273,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -300,11 +300,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -328,11 +328,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -355,11 +355,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -383,11 +383,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -410,11 +410,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -437,11 +437,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -464,11 +464,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -495,11 +495,11 @@ namespace std
if (!__sbout || !__xtrct)
this->setstate(ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -527,11 +527,11 @@ namespace std
else
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -561,11 +561,11 @@ namespace std
else
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -600,11 +600,11 @@ namespace std
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -643,11 +643,11 @@ namespace std
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -694,11 +694,11 @@ namespace std
this->setstate(ios_base::failbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -735,11 +735,11 @@ namespace std
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -759,11 +759,11 @@ namespace std
{
try
{ __c = this->rdbuf()->sgetc(); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -786,11 +786,11 @@ namespace std
if (_M_gcount != __n)
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -822,11 +822,11 @@ namespace std
else
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -841,6 +841,10 @@ namespace std
basic_istream<_CharT, _Traits>::
putback(char_type __c)
{
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+// 60. What is a formatted input function?
+ _M_gcount = 0;
+#endif
sentry __cerb(*this, true);
if (__cerb)
{
@@ -852,11 +856,11 @@ namespace std
|| traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -871,7 +875,10 @@ namespace std
basic_istream<_CharT, _Traits>::
unget(void)
{
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+// 60. What is a formatted input function?
_M_gcount = 0;
+#endif
sentry __cerb(*this, true);
if (__cerb)
{
@@ -883,11 +890,11 @@ namespace std
|| traits_type::eq_int_type(__sb->sungetc(), __eof))
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -902,8 +909,8 @@ namespace std
basic_istream<_CharT, _Traits>::
sync(void)
{
+ // DR60. Do not change _M_gcount.
int __ret = -1;
- _M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb)
{
@@ -918,11 +925,11 @@ namespace std
__ret = 0;
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -935,6 +942,7 @@ namespace std
basic_istream<_CharT, _Traits>::
tellg(void)
{
+ // DR60. Do not change _M_gcount.
pos_type __ret = pos_type(-1);
if (!this->fail())
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
@@ -947,7 +955,7 @@ namespace std
basic_istream<_CharT, _Traits>::
seekg(pos_type __pos)
{
- _M_gcount = 0;
+ // DR60. Do not change _M_gcount.
if (!this->fail())
{
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
@@ -967,7 +975,7 @@ namespace std
basic_istream<_CharT, _Traits>::
seekg(off_type __off, ios_base::seekdir __dir)
{
- _M_gcount = 0;
+ // DR60. Do not change _M_gcount.
if (!this->fail())
{
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
@@ -994,11 +1002,11 @@ namespace std
{
try
{ __in.get(__c); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __in.setstate(ios_base::badbit);
+ __in._M_setstate(ios_base::badbit);
if ((__in.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -1026,7 +1034,7 @@ namespace std
{
// Figure out how many characters to extract.
streamsize __num = __in.width();
- if (__num == 0)
+ if (__num <= 0)
__num = numeric_limits<streamsize>::max();
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
@@ -1036,9 +1044,9 @@ namespace std
while (__extracted < __num - 1
&& !_Traits::eq_int_type(__c, __eof)
- && !__ctype.is(ctype_base::space, __c))
+ && !__ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
{
- *__s++ = __c;
+ *__s++ = _Traits::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
@@ -1051,11 +1059,11 @@ namespace std
#endif
__in.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __in.setstate(ios_base::badbit);
+ __in._M_setstate(ios_base::badbit);
if ((__in.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -1081,7 +1089,7 @@ namespace std
__int_type __c = __sb->sgetc();
while (!_Traits::eq_int_type(__c, __eof)
- && __ctype.is(ctype_base::space, __c))
+ && __ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
__c = __sb->snextc();
if (_Traits::eq_int_type(__c, __eof))
@@ -1119,7 +1127,7 @@ namespace std
while (__extracted < __n
&& !_Traits::eq_int_type(__c, __eof)
- && !__ctype.is(ctype_base::space, __c))
+ && !__ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
{
__str += _Traits::to_char_type(__c);
++__extracted;
@@ -1189,6 +1197,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_istream<char>;
extern template istream& ws(istream&);
extern template istream& operator>>(istream&, char&);
@@ -1204,4 +1213,5 @@ namespace std
extern template wistream& operator>>(wistream&, wchar_t&);
extern template wistream& operator>>(wistream&, wchar_t*);
#endif
+#endif
} // namespace std
diff --git a/contrib/libstdc++/include/bits/list.tcc b/contrib/libstdc++/include/bits/list.tcc
new file mode 100644
index 0000000..898a502
--- /dev/null
+++ b/contrib/libstdc++/include/bits/list.tcc
@@ -0,0 +1,368 @@
+// List implementation (out of line) -*- C++ -*-
+
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file list.tcc
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+#ifndef __GLIBCPP_INTERNAL_LIST_TCC
+#define __GLIBCPP_INTERNAL_LIST_TCC
+
+namespace std
+{
+ template<typename _Tp, typename _Alloc>
+ void
+ _List_base<_Tp,_Alloc>::
+ __clear()
+ {
+ typedef _List_node<_Tp> _Node;
+ _Node* __cur = static_cast<_Node*>(_M_node->_M_next);
+ while (__cur != _M_node)
+ {
+ _Node* __tmp = __cur;
+ __cur = static_cast<_Node*>(__cur->_M_next);
+ _Destroy(&__tmp->_M_data);
+ _M_put_node(__tmp);
+ }
+ _M_node->_M_next = _M_node;
+ _M_node->_M_prev = _M_node;
+ }
+
+ template<typename _Tp, typename _Alloc>
+ typename list<_Tp,_Alloc>::iterator
+ list<_Tp,_Alloc>::
+ insert(iterator __position, const value_type& __x)
+ {
+ _Node* __tmp = _M_create_node(__x);
+ __tmp->_M_next = __position._M_node;
+ __tmp->_M_prev = __position._M_node->_M_prev;
+ __position._M_node->_M_prev->_M_next = __tmp;
+ __position._M_node->_M_prev = __tmp;
+ return __tmp;
+ }
+
+ template<typename _Tp, typename _Alloc>
+ typename list<_Tp,_Alloc>::iterator
+ list<_Tp,_Alloc>::
+ erase(iterator __position)
+ {
+ _List_node_base* __next_node = __position._M_node->_M_next;
+ _List_node_base* __prev_node = __position._M_node->_M_prev;
+ _Node* __n = static_cast<_Node*>(__position._M_node);
+ __prev_node->_M_next = __next_node;
+ __next_node->_M_prev = __prev_node;
+ _Destroy(&__n->_M_data);
+ _M_put_node(__n);
+ return iterator(static_cast<_Node*>(__next_node));
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ list<_Tp,_Alloc>::
+ resize(size_type __new_size, const value_type& __x)
+ {
+ iterator __i = begin();
+ size_type __len = 0;
+ for ( ; __i != end() && __len < __new_size; ++__i, ++__len)
+ ;
+ if (__len == __new_size)
+ erase(__i, end());
+ else // __i == end()
+ insert(end(), __new_size - __len, __x);
+ }
+
+ template<typename _Tp, typename _Alloc>
+ list<_Tp,_Alloc>&
+ list<_Tp,_Alloc>::
+ operator=(const list& __x)
+ {
+ if (this != &__x)
+ {
+ iterator __first1 = begin();
+ iterator __last1 = end();
+ const_iterator __first2 = __x.begin();
+ const_iterator __last2 = __x.end();
+ while (__first1 != __last1 && __first2 != __last2)
+ *__first1++ = *__first2++;
+ if (__first2 == __last2)
+ erase(__first1, __last1);
+ else
+ insert(__last1, __first2, __last2);
+ }
+ return *this;
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ list<_Tp,_Alloc>::
+ _M_fill_assign(size_type __n, const value_type& __val)
+ {
+ iterator __i = begin();
+ for ( ; __i != end() && __n > 0; ++__i, --__n)
+ *__i = __val;
+ if (__n > 0)
+ insert(end(), __n, __val);
+ else
+ erase(__i, end());
+ }
+
+ template<typename _Tp, typename _Alloc>
+ template <typename _InputIter>
+ void
+ list<_Tp,_Alloc>::
+ _M_assign_dispatch(_InputIter __first2, _InputIter __last2, __false_type)
+ {
+ iterator __first1 = begin();
+ iterator __last1 = end();
+ for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
+ *__first1 = *__first2;
+ if (__first2 == __last2)
+ erase(__first1, __last1);
+ else
+ insert(__last1, __first2, __last2);
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ list<_Tp,_Alloc>::
+ remove(const value_type& __value)
+ {
+ iterator __first = begin();
+ iterator __last = end();
+ while (__first != __last)
+ {
+ iterator __next = __first;
+ ++__next;
+ if (*__first == __value)
+ erase(__first);
+ __first = __next;
+ }
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ list<_Tp,_Alloc>::
+ unique()
+ {
+ iterator __first = begin();
+ iterator __last = end();
+ if (__first == __last) return;
+ iterator __next = __first;
+ while (++__next != __last)
+ {
+ if (*__first == *__next)
+ erase(__next);
+ else
+ __first = __next;
+ __next = __first;
+ }
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ list<_Tp,_Alloc>::
+ merge(list& __x)
+ {
+ iterator __first1 = begin();
+ iterator __last1 = end();
+ iterator __first2 = __x.begin();
+ iterator __last2 = __x.end();
+ while (__first1 != __last1 && __first2 != __last2)
+ if (*__first2 < *__first1)
+ {
+ iterator __next = __first2;
+ _M_transfer(__first1, __first2, ++__next);
+ __first2 = __next;
+ }
+ else
+ ++__first1;
+ if (__first2 != __last2)
+ _M_transfer(__last1, __first2, __last2);
+ }
+
+ // FIXME put this somewhere else
+ inline void
+ __List_base_reverse(_List_node_base* __p)
+ {
+ _List_node_base* __tmp = __p;
+ do {
+ std::swap(__tmp->_M_next, __tmp->_M_prev);
+ __tmp = __tmp->_M_prev; // Old next node is now prev.
+ } while (__tmp != __p);
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ list<_Tp,_Alloc>::
+ sort()
+ {
+ // Do nothing if the list has length 0 or 1.
+ if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node)
+ {
+ list __carry;
+ list __counter[64];
+ int __fill = 0;
+ while (!empty())
+ {
+ __carry.splice(__carry.begin(), *this, begin());
+ int __i = 0;
+ while(__i < __fill && !__counter[__i].empty())
+ {
+ __counter[__i].merge(__carry);
+ __carry.swap(__counter[__i++]);
+ }
+ __carry.swap(__counter[__i]);
+ if (__i == __fill) ++__fill;
+ }
+
+ for (int __i = 1; __i < __fill; ++__i)
+ __counter[__i].merge(__counter[__i-1]);
+ swap(__counter[__fill-1]);
+ }
+ }
+
+ template<typename _Tp, typename _Alloc>
+ template <typename _Predicate>
+ void
+ list<_Tp,_Alloc>::
+ remove_if(_Predicate __pred)
+ {
+ iterator __first = begin();
+ iterator __last = end();
+ while (__first != __last)
+ {
+ iterator __next = __first;
+ ++__next;
+ if (__pred(*__first)) erase(__first);
+ __first = __next;
+ }
+ }
+
+ template<typename _Tp, typename _Alloc>
+ template <typename _BinaryPredicate>
+ void
+ list<_Tp,_Alloc>::
+ unique(_BinaryPredicate __binary_pred)
+ {
+ iterator __first = begin();
+ iterator __last = end();
+ if (__first == __last) return;
+ iterator __next = __first;
+ while (++__next != __last)
+ {
+ if (__binary_pred(*__first, *__next))
+ erase(__next);
+ else
+ __first = __next;
+ __next = __first;
+ }
+ }
+
+ template<typename _Tp, typename _Alloc>
+ template <typename _StrictWeakOrdering>
+ void
+ list<_Tp,_Alloc>::
+ merge(list& __x, _StrictWeakOrdering __comp)
+ {
+ iterator __first1 = begin();
+ iterator __last1 = end();
+ iterator __first2 = __x.begin();
+ iterator __last2 = __x.end();
+ while (__first1 != __last1 && __first2 != __last2)
+ if (__comp(*__first2, *__first1))
+ {
+ iterator __next = __first2;
+ _M_transfer(__first1, __first2, ++__next);
+ __first2 = __next;
+ }
+ else
+ ++__first1;
+ if (__first2 != __last2) _M_transfer(__last1, __first2, __last2);
+ }
+
+ template<typename _Tp, typename _Alloc>
+ template <typename _StrictWeakOrdering>
+ void
+ list<_Tp,_Alloc>::
+ sort(_StrictWeakOrdering __comp)
+ {
+ // Do nothing if the list has length 0 or 1.
+ if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node)
+ {
+ list __carry;
+ list __counter[64];
+ int __fill = 0;
+ while (!empty())
+ {
+ __carry.splice(__carry.begin(), *this, begin());
+ int __i = 0;
+ while(__i < __fill && !__counter[__i].empty())
+ {
+ __counter[__i].merge(__carry, __comp);
+ __carry.swap(__counter[__i++]);
+ }
+ __carry.swap(__counter[__i]);
+ if (__i == __fill) ++__fill;
+ }
+
+ for (int __i = 1; __i < __fill; ++__i)
+ __counter[__i].merge(__counter[__i-1], __comp);
+ swap(__counter[__fill-1]);
+ }
+ }
+} // namespace std
+
+#endif /* __GLIBCPP_INTERNAL_LIST_TCC */
diff --git a/contrib/libstdc++/include/bits/locale_classes.h b/contrib/libstdc++/include/bits/locale_classes.h
new file mode 100644
index 0000000..ddd23fb
--- /dev/null
+++ b/contrib/libstdc++/include/bits/locale_classes.h
@@ -0,0 +1,404 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 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.
+
+//
+// ISO C++ 14882: 22.1 Locales
+//
+
+/** @file localefwd.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+#ifndef _CPP_BITS_LOCALE_CLASSES_H
+#define _CPP_BITS_LOCALE_CLASSES_H 1
+
+#pragma GCC system_header
+
+#include <bits/localefwd.h>
+#include <cstring> // For strcmp.
+#include <string>
+#include <bits/atomicity.h>
+
+namespace std
+{
+ class __locale_cache_base;
+ template<typename _Facet> class __locale_cache;
+
+ // 22.1.1 Class locale
+ class locale
+ {
+ public:
+ // Types:
+ typedef unsigned int category;
+
+ // Forward decls and friends:
+ class facet;
+ class id;
+ class _Impl;
+
+ friend class facet;
+ friend class _Impl;
+
+ template<typename _Facet>
+ friend const _Facet&
+ use_facet(const locale&);
+
+ template<typename _Facet>
+ friend bool
+ has_facet(const locale&) throw();
+
+ template<typename _Facet>
+ friend const __locale_cache<_Facet>&
+ __use_cache(const locale&);
+
+ // Category values:
+ // NB: Order must match _S_facet_categories definition in locale.cc
+ static const category none = 0;
+ static const category ctype = 1L << 0;
+ static const category numeric = 1L << 1;
+ static const category collate = 1L << 2;
+ static const category time = 1L << 3;
+ static const category monetary = 1L << 4;
+ static const category messages = 1L << 5;
+ static const category all = (ctype | numeric | collate |
+ time | monetary | messages);
+
+ // Construct/copy/destroy:
+ locale() throw();
+
+ locale(const locale& __other) throw();
+
+ explicit
+ locale(const char* __s);
+
+ locale(const locale& __base, const char* __s, category __cat);
+
+ locale(const locale& __base, const locale& __add, category __cat);
+
+ template<typename _Facet>
+ locale(const locale& __other, _Facet* __f);
+
+ ~locale() throw();
+
+ const locale&
+ operator=(const locale& __other) throw();
+
+ template<typename _Facet>
+ locale
+ combine(const locale& __other) const;
+
+ // Locale operations:
+ string
+ name() const;
+
+ bool
+ operator==(const locale& __other) const throw ();
+
+ inline bool
+ operator!=(const locale& __other) const throw ()
+ { return !(this->operator==(__other)); }
+
+ template<typename _Char, typename _Traits, typename _Alloc>
+ bool
+ operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
+ const basic_string<_Char, _Traits, _Alloc>& __s2) const;
+
+ // Global locale objects:
+ static locale
+ global(const locale&);
+
+ static const locale&
+ classic();
+
+ private:
+ // The (shared) implementation
+ _Impl* _M_impl;
+
+ // The "C" reference locale
+ static _Impl* _S_classic;
+
+ // Current global locale
+ static _Impl* _S_global;
+
+ // Number of standard categories. For C++, these categories are
+ // collate, ctype, monetary, numeric, time, and messages. These
+ // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
+ // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
+ // 1003.1-2001) specifies LC_MESSAGES.
+ static const size_t _S_categories_size = 6;
+
+ // In addition to the standard categories, the underlying
+ // operating system is allowed to define extra LC_*
+ // macros. For GNU systems, the following are also valid:
+ // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
+ // and LC_IDENTIFICATION.
+ static const size_t _S_extra_categories_size = _GLIBCPP_NUM_CATEGORIES;
+
+ // Names of underlying locale categories.
+ // NB: locale::global() has to know how to modify all the
+ // underlying categories, not just the ones required by the C++
+ // standard.
+ static const char* _S_categories[_S_categories_size
+ + _S_extra_categories_size];
+
+ explicit
+ locale(_Impl*) throw();
+
+ static inline void
+ _S_initialize()
+ {
+ if (!_S_classic)
+ classic();
+ }
+
+ static category
+ _S_normalize_category(category);
+
+ void
+ _M_coalesce(const locale& __base, const locale& __add, category __cat);
+ };
+
+
+ // Implementation object for locale
+ class locale::_Impl
+ {
+ public:
+ // Friends.
+ friend class locale;
+ friend class locale::facet;
+
+ template<typename _Facet>
+ friend const _Facet&
+ use_facet(const locale&);
+
+ template<typename _Facet>
+ friend bool
+ has_facet(const locale&) throw();
+
+ template<typename _Facet>
+ friend const __locale_cache<_Facet>&
+ __use_cache(const locale&);
+
+ private:
+ // Data Members.
+ _Atomic_word _M_references;
+ facet** _M_facets;
+ size_t _M_facets_size;
+
+ char* _M_names[_S_categories_size
+ + _S_extra_categories_size];
+ static const locale::id* const _S_id_ctype[];
+ static const locale::id* const _S_id_numeric[];
+ static const locale::id* const _S_id_collate[];
+ static const locale::id* const _S_id_time[];
+ static const locale::id* const _S_id_monetary[];
+ static const locale::id* const _S_id_messages[];
+ static const locale::id* const* const _S_facet_categories[];
+
+ inline void
+ _M_add_reference() throw()
+ { __atomic_add(&_M_references, 1); }
+
+ inline void
+ _M_remove_reference() throw()
+ {
+ if (__exchange_and_add(&_M_references, -1) == 1)
+ {
+ try
+ { delete this; }
+ catch(...)
+ { }
+ }
+ }
+
+ _Impl(const _Impl&, size_t);
+ _Impl(const char*, size_t);
+ _Impl(facet**, size_t, bool);
+
+ ~_Impl() throw();
+
+ _Impl(const _Impl&); // Not defined.
+
+ void
+ operator=(const _Impl&); // Not defined.
+
+ inline bool
+ _M_check_same_name()
+ {
+ bool __ret = true;
+ for (size_t __i = 0;
+ __ret && __i < _S_categories_size + _S_extra_categories_size - 1;
+ ++__i)
+ __ret &= (strcmp(_M_names[__i], _M_names[__i + 1]) == 0);
+ return __ret;
+ }
+
+ void
+ _M_replace_categories(const _Impl*, category);
+
+ void
+ _M_replace_category(const _Impl*, const locale::id* const*);
+
+ void
+ _M_replace_facet(const _Impl*, const locale::id*);
+
+ void
+ _M_install_facet(const locale::id*, facet*);
+
+ template<typename _Facet>
+ inline void
+ _M_init_facet(_Facet* __facet)
+ { _M_install_facet(&_Facet::id, __facet); }
+
+ // Retrieve the cache at __index. 0 is returned if the cache is
+ // missing. Cache is actually located at __index +
+ // _M_facets_size. __index must be < _M_facets_size.
+ inline __locale_cache_base*
+ _M_get_cache(size_t __index)
+ {
+ return (__locale_cache_base*)_M_facets[__index + _M_facets_size];
+ }
+
+ // Save the supplied cache at __id. Assumes _M_get_cache has been
+ // called.
+ void
+ _M_install_cache(__locale_cache_base* __cache, int __id)
+ {
+ _M_facets[__id + _M_facets_size] =
+ reinterpret_cast<locale::facet*>(__cache);
+ }
+
+ };
+
+ template<typename _Facet>
+ locale::locale(const locale& __other, _Facet* __f)
+ {
+ _M_impl = new _Impl(*__other._M_impl, 1);
+ _M_impl->_M_install_facet(&_Facet::id, __f);
+ for (size_t __i = 0;
+ __i < _S_categories_size + _S_extra_categories_size; ++__i)
+ {
+ delete [] _M_impl->_M_names[__i];
+ char* __new = new char[2];
+ strcpy(__new, "*");
+ _M_impl->_M_names[__i] = __new;
+ }
+ }
+
+
+ // 22.1.1.1.2 Class locale::facet
+ class locale::facet
+ {
+ private:
+ friend class locale;
+ friend class locale::_Impl;
+
+ _Atomic_word _M_references;
+
+ protected:
+ // Contains data from the underlying "C" library for the classic locale.
+ static __c_locale _S_c_locale;
+
+ // String literal for the name of the classic locale.
+ static char _S_c_name[2];
+
+ explicit
+ facet(size_t __refs = 0) throw();
+
+ virtual
+ ~facet();
+
+ static void
+ _S_create_c_locale(__c_locale& __cloc, const char* __s,
+ __c_locale __old = 0);
+
+ static __c_locale
+ _S_clone_c_locale(__c_locale& __cloc);
+
+ static void
+ _S_destroy_c_locale(__c_locale& __cloc);
+
+ private:
+ void
+ _M_add_reference() throw();
+
+ void
+ _M_remove_reference() throw();
+
+ facet(const facet&); // Not defined.
+
+ void
+ operator=(const facet&); // Not defined.
+ };
+
+
+ // 22.1.1.1.3 Class locale::id
+ class locale::id
+ {
+ private:
+ friend class locale;
+ friend class locale::_Impl;
+ template<typename _Facet>
+ friend const _Facet&
+ use_facet(const locale&);
+ template<typename _Facet>
+ friend bool
+ has_facet(const locale&) throw ();
+
+ // NB: There is no accessor for _M_index because it may be used
+ // before the constructor is run; the effect of calling a member
+ // function (even an inline) would be undefined.
+ mutable size_t _M_index;
+
+ // Last id number assigned.
+ static _Atomic_word _S_highwater;
+
+ void
+ operator=(const id&); // Not defined.
+
+ id(const id&); // Not defined.
+
+ public:
+ // NB: This class is always a static data member, and thus can be
+ // counted on to be zero-initialized.
+ id();
+
+ inline size_t
+ _M_id() const
+ {
+ if (!_M_index)
+ _M_index = 1 + __exchange_and_add(&_S_highwater, 1);
+ return _M_index - 1;
+ }
+ };
+} // namespace std
+
+#endif
diff --git a/contrib/libstdc++/include/bits/locale_facets.h b/contrib/libstdc++/include/bits/locale_facets.h
index 6e42b3b..37f6875 100644
--- a/contrib/libstdc++/include/bits/locale_facets.h
+++ b/contrib/libstdc++/include/bits/locale_facets.h
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -44,7 +44,9 @@
#include <ctime> // For struct tm
#include <cwctype> // For wctype_t
-#include <ios> // For ios_base
+#include <iosfwd>
+#include <bits/ios_base.h> // For ios_base, ios_base::iostate
+#include <streambuf>
namespace std
{
@@ -55,8 +57,109 @@ namespace std
# define _GLIBCPP_NUM_FACETS 14
#endif
+ // Convert string to numeric value of type _Tv and store results.
+ // NB: This is specialized for all required types, there is no
+ // generic definition.
+ template<typename _Tv>
+ void
+ __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
+ const __c_locale& __cloc, int __base = 10);
+
+ // Explicit specializations for required types.
+ template<>
+ void
+ __convert_to_v(const char*, long&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, unsigned long&, ios_base::iostate&,
+ const __c_locale&, int);
+
+#ifdef _GLIBCPP_USE_LONG_LONG
+ template<>
+ void
+ __convert_to_v(const char*, long long&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, unsigned long long&, ios_base::iostate&,
+ const __c_locale&, int);
+#endif
+
+ template<>
+ void
+ __convert_to_v(const char*, float&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, double&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, long double&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ // NB: __pad is a struct, rather than a function, so it can be
+ // partially-specialized.
template<typename _CharT, typename _Traits>
- struct __pad;
+ struct __pad
+ {
+ static void
+ _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
+ const _CharT* __olds, const streamsize __newlen,
+ const streamsize __oldlen, const bool __num);
+ };
+
+ // Used by both numeric and monetary facets.
+ // Check to make sure that the __grouping_tmp string constructed in
+ // money_get or num_get matches the canonical grouping for a given
+ // locale.
+ // __grouping_tmp is parsed L to R
+ // 1,222,444 == __grouping_tmp of "\1\3\3"
+ // __grouping is parsed R to L
+ // 1,222,444 == __grouping of "\3" == "\3\3\3"
+ template<typename _CharT>
+ bool
+ __verify_grouping(const basic_string<_CharT>& __grouping,
+ basic_string<_CharT>& __grouping_tmp);
+
+ // Used by both numeric and monetary facets.
+ // Inserts "group separator" characters into an array of characters.
+ // It's recursive, one iteration per group. It moves the characters
+ // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
+ // only with __gbeg != __gend.
+ template<typename _CharT>
+ _CharT*
+ __add_grouping(_CharT* __s, _CharT __sep,
+ const char* __gbeg, const char* __gend,
+ const _CharT* __first, const _CharT* __last);
+
+ // This template permits specializing facet output code for
+ // ostreambuf_iterator. For ostreambuf_iterator, sputn is
+ // significantly more efficient than incrementing iterators.
+ template<typename _CharT>
+ inline
+ ostreambuf_iterator<_CharT>
+ __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
+ {
+ __s._M_put(__ws, __len);
+ return __s;
+ }
+
+ // This is the unspecialized form of the template.
+ template<typename _CharT, typename _OutIter>
+ inline
+ _OutIter
+ __write(_OutIter __s, const _CharT* __ws, int __len)
+ {
+ for (int __j = 0; __j < __len; __j++, ++__s)
+ *__s = __ws[__j];
+ return __s;
+ }
// 22.2.1.1 Template class ctype
// Include host and configuration specific ctype enums for ctype_base.
@@ -424,14 +527,38 @@ namespace std
// 22.2.1.5 Template class codecvt
#include <bits/codecvt.h>
-
// 22.2.2 The numeric category.
class __num_base
{
+ public:
+ // NB: Code depends on the order of _S_atoms_out elements.
+ // Below are the indices into _S_atoms_out.
+ enum
+ {
+ _S_minus,
+ _S_plus,
+ _S_x,
+ _S_X,
+ _S_digits,
+ _S_digits_end = _S_digits + 16,
+ _S_udigits = _S_digits_end,
+ _S_udigits_end = _S_udigits + 16,
+ _S_e = _S_digits + 14, // For scientific notation, 'e'
+ _S_E = _S_udigits + 14, // For scientific notation, 'E'
+ _S_end = _S_udigits_end
+ };
+
+ // A list of valid numeric literals for output. This array
+ // contains chars that will be passed through the current locale's
+ // ctype<_CharT>.widen() and then used to render numbers.
+ // For the standard "C" locale, this is
+ // "-+xX0123456789abcdef0123456789ABCDEF".
+ static const char* _S_atoms_out;
+
protected:
// String literal of acceptable (narrow) input, for num_get.
// "0123456789eEabcdfABCDF"
- static const char _S_atoms[];
+ static const char* _S_atoms_in;
enum
{
@@ -443,7 +570,7 @@ namespace std
// num_put
// Construct and return valid scanf format for floating point types.
- static bool
+ static void
_S_format_float(const ios_base& __io, char* __fptr, char __mod,
streamsize __prec);
@@ -454,6 +581,9 @@ namespace std
template<typename _CharT>
+ class __locale_cache;
+
+ template<typename _CharT>
class numpunct : public locale::facet
{
public:
@@ -461,6 +591,8 @@ namespace std
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
+ friend class __locale_cache<numpunct<_CharT> >;
+
static locale::id id;
private:
@@ -725,7 +857,6 @@ namespace std
// Types:
typedef _CharT char_type;
typedef _OutIter iter_type;
-
static locale::id id;
explicit
@@ -775,6 +906,27 @@ namespace std
_M_convert_float(iter_type, ios_base& __io, char_type __fill,
char __mod, _ValueT __v) const;
+ void
+ _M_group_float(const string& __grouping, char_type __sep,
+ const char_type* __p, char_type* __new, char_type* __cs,
+ int& __len) const;
+
+ template<typename _ValueT>
+ iter_type
+ _M_convert_int(iter_type, ios_base& __io, char_type __fill,
+ _ValueT __v) const;
+
+ void
+ _M_group_int(const string& __grouping, char_type __sep,
+ ios_base& __io, char_type* __new, char_type* __cs,
+ int& __len) const;
+
+ void
+ _M_pad(char_type __fill, streamsize __w, ios_base& __io,
+ char_type* __new, const char_type* __cs, int& __len) const;
+
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
template<typename _ValueT>
iter_type
_M_convert_int(iter_type, ios_base& __io, char_type __fill,
@@ -791,8 +943,9 @@ namespace std
iter_type
_M_insert(iter_type, ios_base& __io, char_type __fill,
const char_type* __ws, int __len) const;
+#endif
- virtual
+ virtual
~num_put() { };
virtual iter_type
@@ -1805,6 +1958,93 @@ namespace std
inline _CharT
tolower(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
+
+ /**
+ * @if maint
+ * __locale_cache objects hold information extracted from facets in
+ * a form optimized for parsing and formatting. They are stored in
+ * a locale's facet array and accessed via __use_cache<_Facet>.
+ *
+ * The intent twofold: to avoid the costs of creating a locale
+ * object and to avoid calling the virtual functions in a locale's
+ * facet to look up data.
+ * @endif
+ */
+ class __locale_cache_base
+ {
+ friend class std::locale::_Impl;
+ friend class locale;
+
+ public:
+ virtual
+ ~__locale_cache_base() { }
+
+ };
+
+ // This template doesn't really get used for anything except a
+ // placeholder for specializations
+ template<typename _Facet>
+ class __locale_cache : public __locale_cache_base
+ {
+ // ctor
+ __locale_cache(const locale&) {}
+ };
+
+ template<typename _CharT>
+ class __locale_cache<numpunct<_CharT> > : public __locale_cache_base
+ {
+ // Types:
+ typedef _CharT char_type;
+ typedef char_traits<_CharT> traits_type;
+ typedef basic_string<_CharT> string_type;
+
+ public:
+ // Data Members:
+
+ // The sign used to separate decimal values: for standard US
+ // locales, this would usually be: "." Abstracted from
+ // numpunct::decimal_point().
+ _CharT _M_decimal_point;
+
+ // The sign used to separate groups of digits into smaller
+ // strings that the eye can parse with less difficulty: for
+ // standard US locales, this would usually be: "," Abstracted
+ // from numpunct::thousands_sep().
+ _CharT _M_thousands_sep;
+
+ // However the US's "false" and "true" are translated. From
+ // numpunct::truename() and numpunct::falsename(), respectively.
+ const _CharT* _M_truename;
+ const _CharT* _M_falsename;
+
+ // If we are checking groupings. This should be equivalent to
+ // numpunct::groupings().size() != 0
+ bool _M_use_grouping;
+
+ // If we are using numpunct's groupings, this is the current
+ // grouping string in effect (from numpunct::grouping()).
+ const char* _M_grouping;
+
+ // A list of valid numeric literals: for the standard "C"
+ // locale, this is "-+xX0123456789abcdef0123456789ABCDEF". This
+ // array contains the chars after having been passed through the
+ // current locale's ctype<_CharT>.widen().
+
+ // Copied here from __locale_cache<ctype> to save multiple cache
+ // access in num_put functions.
+ _CharT _M_atoms_out[__num_base::_S_end];
+
+ // ctor
+ __locale_cache(const locale& __loc);
+ __locale_cache(const locale& __loc, bool);
+
+ ~__locale_cache()
+ {
+ delete [] _M_truename;
+ delete [] _M_falsename;
+ delete [] _M_grouping;
+ }
+ };
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/locale_facets.tcc b/contrib/libstdc++/include/bits/locale_facets.tcc
index 1bf3d7c..b8b9918 100644
--- a/contrib/libstdc++/include/bits/locale_facets.tcc
+++ b/contrib/libstdc++/include/bits/locale_facets.tcc
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -36,13 +36,13 @@
#pragma GCC system_header
#include <cerrno>
-#include <clocale> // For localeconv
-#include <cstdlib> // For strof, strtold
-#include <cmath> // For ceil
-#include <cctype> // For isspace
-#include <limits> // For numeric_limits
+#include <clocale> // For localeconv
+#include <cstdlib> // For strof, strtold
+#include <cmath> // For ceil
+#include <cctype> // For isspace
+#include <limits> // For numeric_limits
+#include <typeinfo> // For bad_cast.
#include <bits/streambuf_iterator.h>
-#include <typeinfo> // For bad_cast.
namespace std
{
@@ -86,6 +86,23 @@ namespace std
return (__i < __loc._M_impl->_M_facets_size && __facets[__i]);
}
+ // Routine to access a cache for the locale. If the cache didn't
+ // exist before, it gets constructed on the fly.
+ template<typename _Facet>
+ inline const __locale_cache<_Facet>&
+ __use_cache(const locale& __loc)
+ {
+ size_t __i = _Facet::id._M_id();
+ if (__builtin_expect(__i >= __loc._M_impl->_M_facets_size,false))
+ __throw_bad_cast();
+ __locale_cache_base* __cache = __loc._M_impl->_M_get_cache(__i);
+ if (__builtin_expect(!__cache, false))
+ {
+ __cache = new __locale_cache<_Facet>(__loc);
+ __loc._M_impl->_M_install_cache(__cache, __i);
+ }
+ return static_cast<const __locale_cache<_Facet>&>(*__cache);
+ }
// Stage 1: Determine a conversion specifier.
template<typename _CharT, typename _InIter>
@@ -113,7 +130,7 @@ namespace std
}
// Next, strip leading zeros.
- const char_type __zero = __ctype.widen(_S_atoms[_M_zero]);
+ const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
bool __found_zero = false;
while (__traits_type::eq(__c, __zero) && __beg != __end)
{
@@ -122,14 +139,14 @@ namespace std
}
if (__found_zero)
{
- __xtrc += _S_atoms[_M_zero];
+ __xtrc += _S_atoms_in[_M_zero];
++__pos;
}
// Only need acceptable digits for floating point numbers.
const size_t __len = _M_E - _M_zero + 1;
char_type __watoms[__len];
- __ctype.widen(_S_atoms, _S_atoms + __len, __watoms);
+ __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
bool __found_dec = false;
bool __found_sci = false;
const char_type __dec = __np.decimal_point();
@@ -150,7 +167,7 @@ namespace std
{
// Try first for acceptable digit; record it if found.
++__pos;
- __xtrc += _S_atoms[__p - __watoms];
+ __xtrc += _S_atoms_in[__p - __watoms];
++__sep_pos;
__c = *(++__beg);
}
@@ -261,7 +278,7 @@ namespace std
}
// Next, strip leading zeros and check required digits for base formats.
- const char_type __zero = __ctype.widen(_S_atoms[_M_zero]);
+ const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
const char_type __x = __ctype.widen('x');
const char_type __X = __ctype.widen('X');
if (__base == 10)
@@ -274,7 +291,7 @@ namespace std
}
if (__found_zero)
{
- __xtrc += _S_atoms[_M_zero];
+ __xtrc += _S_atoms_in[_M_zero];
++__pos;
if (__basefield == 0)
{
@@ -296,7 +313,7 @@ namespace std
{
if (__traits_type::eq(__c, __zero) && __beg != __end)
{
- __xtrc += _S_atoms[_M_zero];
+ __xtrc += _S_atoms_in[_M_zero];
++__pos;
__c = *(++__beg);
if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X))
@@ -319,7 +336,7 @@ namespace std
// Extract.
char_type __watoms[_M_size];
- __ctype.widen(_S_atoms, _S_atoms + __len, __watoms);
+ __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
string __found_grouping;
const string __grouping = __np.grouping();
bool __check_grouping = __grouping.size();
@@ -333,7 +350,7 @@ namespace std
if (__p && !__traits_type::eq(__c, char_type()))
{
// Try first for acceptable digit; record it if found.
- __xtrc += _S_atoms[__p - __watoms];
+ __xtrc += _S_atoms_in[__p - __watoms];
++__pos;
++__sep_pos;
__c = *(++__beg);
@@ -606,14 +623,251 @@ namespace std
return __beg;
}
- // The following code uses snprintf (or sprintf(), when _GLIBCPP_USE_C99
- // is not defined) to convert floating point values for insertion into a
- // stream. An optimization would be to replace them with code that works
- // directly on a wide buffer and then use __pad to do the padding.
- // It would be good to replace them anyway to gain back the efficiency
- // that C++ provides by knowing up front the type of the values to insert.
- // Also, sprintf is dangerous since may lead to accidental buffer overruns.
- // This implementation follows the C++ standard fairly directly as
+ // For use by integer and floating-point types after they have been
+ // converted into a char_type string.
+ template<typename _CharT, typename _OutIter>
+ void
+ num_put<_CharT, _OutIter>::
+ _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
+ _CharT* __new, const _CharT* __cs, int& __len) const
+ {
+ // [22.2.2.2.2] Stage 3.
+ // If necessary, pad.
+ __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
+ __w, __len, true);
+ __len = static_cast<int>(__w);
+ }
+
+ // Forwarding functions to peel signed from unsigned integer types.
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ {
+ unsigned long __ul = static_cast<unsigned long>(__v);
+ bool __neg = false;
+ if (__v < 0)
+ {
+ __ul = -__ul;
+ __neg = true;
+ }
+ return __int_to_char(__out, __size, __ul, __lit, __flags, __neg);
+ }
+
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, unsigned long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ { return __int_to_char(__out, __size, __v, __lit, __flags, false); }
+
+#ifdef _GLIBCPP_USE_LONG_LONG
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, long long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ {
+ unsigned long long __ull = static_cast<unsigned long long>(__v);
+ bool __neg = false;
+ if (__v < 0)
+ {
+ __ull = -__ull;
+ __neg = true;
+ }
+ return __int_to_char(__out, __size, __ull, __lit, __flags, __neg);
+ }
+
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, unsigned long long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ { return __int_to_char(__out, __size, __v, __lit, __flags, false); }
+#endif
+
+ template<typename _CharT, typename _ValueT>
+ int
+ __int_to_char(_CharT* __out, const int __size, _ValueT __v,
+ const _CharT* __lit, ios_base::fmtflags __flags, bool __neg)
+ {
+ // Don't write base if already 0.
+ const bool __showbase = (__flags & ios_base::showbase) && __v;
+ const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
+ _CharT* __buf = __out + __size - 1;
+ _CharT* __bufend = __out + __size;
+
+ if (__builtin_expect(__basefield != ios_base::oct &&
+ __basefield != ios_base::hex, true))
+ {
+ // Decimal.
+ do
+ {
+ *__buf-- = __lit[(__v % 10) + __num_base::_S_digits];
+ __v /= 10;
+ }
+ while (__v != 0);
+ if (__neg)
+ *__buf-- = __lit[__num_base::_S_minus];
+ else if (__flags & ios_base::showpos)
+ *__buf-- = __lit[__num_base::_S_plus];
+ }
+ else if (__basefield == ios_base::oct)
+ {
+ // Octal.
+ do
+ {
+ *__buf-- = __lit[(__v & 0x7) + __num_base::_S_digits];
+ __v >>= 3;
+ }
+ while (__v != 0);
+ if (__showbase)
+ *__buf-- = __lit[__num_base::_S_digits];
+ }
+ else
+ {
+ // Hex.
+ const bool __uppercase = __flags & ios_base::uppercase;
+ int __case_offset = __uppercase
+ ? __num_base::_S_udigits : __num_base::_S_digits;
+ do
+ {
+ *__buf-- = __lit[(__v & 0xf) + __case_offset];
+ __v >>= 4;
+ }
+ while (__v != 0);
+ if (__showbase)
+ {
+ // 'x' or 'X'
+ *__buf-- = __lit[__num_base::_S_x + __uppercase];
+ // '0'
+ *__buf-- = __lit[__num_base::_S_digits];
+ }
+ }
+ int __ret = __bufend - __buf - 1;
+ return __ret;
+ }
+
+ template<typename _CharT, typename _OutIter>
+ void
+ num_put<_CharT, _OutIter>::
+ _M_group_int(const string& __grouping, _CharT __sep, ios_base& __io,
+ _CharT* __new, _CharT* __cs, int& __len) const
+ {
+ // By itself __add_grouping cannot deal correctly with __ws when
+ // ios::showbase is set and ios_base::oct || ios_base::hex.
+ // Therefore we take care "by hand" of the initial 0, 0x or 0X.
+ // However, remember that the latter do not occur if the number
+ // printed is '0' (__len == 1).
+ streamsize __off = 0;
+ const ios_base::fmtflags __basefield = __io.flags()
+ & ios_base::basefield;
+ if ((__io.flags() & ios_base::showbase) && __len > 1)
+ if (__basefield == ios_base::oct)
+ {
+ __off = 1;
+ *__new = *__cs;
+ }
+ else if (__basefield == ios_base::hex)
+ {
+ __off = 2;
+ *__new = *__cs;
+ *(__new + 1) = *(__cs + 1);
+ }
+ _CharT* __p;
+ __p = __add_grouping(__new + __off, __sep,
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __cs + __off, __cs + __len);
+ __len = __p - __new;
+ }
+
+ template<typename _CharT, typename _OutIter>
+ template<typename _ValueT>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill,
+ _ValueT __v) const
+ {
+ typedef numpunct<_CharT> __facet_type;
+ typedef __locale_cache<numpunct<_CharT> > __cache_type;
+ const locale& __loc = __io._M_getloc();
+ const __cache_type& __lc = __use_cache<__facet_type>(__loc);
+ const _CharT* __lit = __lc._M_atoms_out;
+
+ // Long enough to hold hex, dec, and octal representations.
+ int __ilen = 4 * sizeof(_ValueT);
+ _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __ilen));
+ // [22.2.2.2.2] Stage 1, numeric conversion to character.
+ // Result is returned right-justified in the buffer.
+ int __len;
+ __len = __int_to_char(&__cs[0], __ilen, __v, __lit, __io.flags());
+ __cs = __cs + __ilen - __len;
+
+ // Add grouping, if necessary.
+ _CharT* __cs2;
+ if (__lc._M_use_grouping)
+ {
+ // Grouping can add (almost) as many separators as the
+ // number of digits, but no more.
+ __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ _M_group_int(__lc._M_grouping, __lc._M_thousands_sep, __io,
+ __cs2, __cs, __len);
+ __cs = __cs2;
+ }
+
+ // Pad.
+ _CharT* __cs3;
+ streamsize __w = __io.width();
+ if (__w > static_cast<streamsize>(__len))
+ {
+ __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __w));
+ _M_pad(__fill, __w, __io, __cs3, __cs, __len);
+ __cs = __cs3;
+ }
+ __io.width(0);
+
+ // [22.2.2.2.2] Stage 4.
+ // Write resulting, fully-formatted string to output iterator.
+ return __write(__s, __cs, __len);
+ }
+
+ template<typename _CharT, typename _OutIter>
+ void
+ num_put<_CharT, _OutIter>::
+ _M_group_float(const string& __grouping, _CharT __sep, const _CharT* __p,
+ _CharT* __new, _CharT* __cs, int& __len) const
+ {
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+ //282. What types does numpunct grouping refer to?
+ // Add grouping, if necessary.
+ _CharT* __p2;
+ int __declen = __p ? __p - __cs : __len;
+ __p2 = __add_grouping(__new, __sep,
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __cs, __cs + __declen);
+
+ // Tack on decimal part.
+ int __newlen = __p2 - __new;
+ if (__p)
+ {
+ char_traits<_CharT>::copy(__p2, __p, __len - __declen);
+ __newlen += __len - __declen;
+ }
+ __len = __newlen;
+#endif
+ }
+
+ // The following code uses snprintf (or sprintf(), when
+ // _GLIBCPP_USE_C99 is not defined) to convert floating point values
+ // for insertion into a stream. An optimization would be to replace
+ // them with code that works directly on a wide buffer and then use
+ // __pad to do the padding. It would be good to replace them anyway
+ // to gain back the efficiency that C++ provides by knowing up front
+ // the type of the values to insert. Also, sprintf is dangerous
+ // since may lead to accidental buffer overruns. This
+ // implementation follows the C++ standard fairly directly as
// outlined in 22.2.2.2 [lib.locale.num.put]
template<typename _CharT, typename _OutIter>
template<typename _ValueT>
@@ -622,53 +876,55 @@ namespace std
_M_convert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
_ValueT __v) const
{
- // Note: digits10 is rounded down: we need to add 1 to ensure
- // we get the full available precision.
- // Then, in general, one more 1 needs to be added since, when the
- // %{g,G} conversion specifiers are chosen inside _S_format_float, the
- // precision field is "the maximum number of significant digits", *not*
- // the "number of digits to appear after the decimal point", as happens
- // for %{e,E,f,F} (C99, 7.19.6.1,4).
+ // Note: digits10 is rounded down: add 1 to ensure the maximum
+ // available precision. Then, in general, one more 1 needs to
+ // be added since, when the %{g,G} conversion specifiers are
+ // chosen inside _S_format_float, the precision field is "the
+ // maximum number of significant digits", *not* the "number of
+ // digits to appear after the decimal point", as happens for
+ // %{e,E,f,F} (C99, 7.19.6.1,4).
const int __max_digits = numeric_limits<_ValueT>::digits10 + 2;
- streamsize __prec = __io.precision();
+ // Use default precision if out of range.
+ streamsize __prec = __io.precision();
if (__prec > static_cast<streamsize>(__max_digits))
__prec = static_cast<streamsize>(__max_digits);
+ else if (__prec < static_cast<streamsize>(0))
+ __prec = static_cast<streamsize>(6);
- // Long enough for the max format spec.
- char __fbuf[16];
+ typedef numpunct<_CharT> __facet_type;
+ typedef __locale_cache<numpunct<_CharT> > __cache_type;
+ const locale __loc = __io._M_getloc();
+ const __cache_type& __lc = __use_cache<__facet_type>(__loc);
// [22.2.2.2.2] Stage 1, numeric conversion to character.
int __len;
+ // Long enough for the max format spec.
+ char __fbuf[16];
+
#ifdef _GLIBCPP_USE_C99
- // First try a buffer perhaps big enough (for sure sufficient for
- // non-ios_base::fixed outputs)
+ // First try a buffer perhaps big enough (for sure sufficient
+ // for non-ios_base::fixed outputs)
int __cs_size = __max_digits * 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- const bool __fp = _S_format_float(__io, __fbuf, __mod, __prec);
- if (__fp)
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale, __prec);
- else
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v, _S_c_locale);
+ _S_format_float(__io, __fbuf, __mod, __prec);
+ __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale, __prec);
// If the buffer was not large enough, try again with the correct size.
if (__len >= __cs_size)
{
__cs_size = __len + 1;
__cs = static_cast<char*>(__builtin_alloca(__cs_size));
- if (__fp)
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale, __prec);
- else
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale);
+ __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale, __prec);
}
#else
// Consider the possibility of long ios_base::fixed outputs
const bool __fixed = __io.flags() & ios_base::fixed;
const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
+
// ios_base::fixed outputs may need up to __max_exp+1 chars
// for the integer part + up to __max_digits chars for the
// fractional part + 3 chars for sign, decimal point, '\0'. On
@@ -678,187 +934,53 @@ namespace std
: __max_digits * 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- if (_S_format_float(__io, __fbuf, __mod, __prec))
- __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale, __prec);
- else
- __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale);
+ _S_format_float(__io, __fbuf, __mod, __prec);
+ __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale, __prec);
#endif
- return _M_widen_float(__s, __io, __fill, __cs, __len);
- }
- template<typename _CharT, typename _OutIter>
- template<typename _ValueT>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
- char __modl, _ValueT __v) const
- {
- // [22.2.2.2.2] Stage 1, numeric conversion to character.
-
- // Long enough for the max format spec.
- char __fbuf[16];
- _S_format_int(__io, __fbuf, __mod, __modl);
-#ifdef _GLIBCPP_USE_C99
- // First try a buffer perhaps big enough.
- int __cs_size = 64;
- char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- int __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale);
- // If the buffer was not large enough, try again with the correct size.
- if (__len >= __cs_size)
- {
- __cs_size = __len + 1;
- __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale);
- }
-#else
- // Leave room for "+/-," "0x," and commas. This size is
- // arbitrary, but should be largely sufficient.
- char __cs[128];
- int __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale);
-#endif
- return _M_widen_int(__s, __io, __fill, __cs, __len);
- }
-
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
- int __len) const
- {
- typedef char_traits<_CharT> __traits_type;
// [22.2.2.2.2] Stage 2, convert to char_type, using correct
// numpunct.decimal_point() values for '.' and adding grouping.
- const locale __loc = __io.getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len));
- // Grouping can add (almost) as many separators as the number of
- // digits, but no more.
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len * 2));
__ctype.widen(__cs, __cs + __len, __ws);
// Replace decimal point.
+ const _CharT __cdec = __ctype.widen('.');
+ const _CharT __dec = __lc._M_decimal_point;
const _CharT* __p;
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
- if (__p = __traits_type::find(__ws, __len, __ctype.widen('.')))
- __ws[__p - __ws] = __np.decimal_point();
+ if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
+ __ws[__p - __ws] = __dec;
-#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
-//282. What types does numpunct grouping refer to?
// Add grouping, if necessary.
- const string __grouping = __np.grouping();
- ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
- if (__grouping.size())
+ _CharT* __ws2;
+ if (__lc._M_use_grouping)
{
- _CharT* __p2;
- int __declen = __p ? __p - __ws : __len;
- __p2 = __add_grouping(__ws2, __np.thousands_sep(),
- __grouping.c_str(),
- __grouping.c_str() + __grouping.size(),
- __ws, __ws + __declen);
- int __newlen = __p2 - __ws2;
-
- // Tack on decimal part.
- if (__p)
- {
- __traits_type::copy(__p2, __p, __len - __declen);
- __newlen += __len - __declen;
- }
-
- // Switch strings, establish correct new length.
- __ws = __ws2;
- __len = __newlen;
+ // Grouping can add (almost) as many separators as the
+ // number of digits, but no more.
+ __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ _M_group_float(__lc._M_grouping, __lc._M_thousands_sep, __p,
+ __ws2, __ws, __len);
+ __ws = __ws2;
}
-#endif
- return _M_insert(__s, __io, __fill, __ws, __len);
- }
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_widen_int(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
- int __len) const
- {
- // [22.2.2.2.2] Stage 2, convert to char_type, using correct
- // numpunct.decimal_point() values for '.' and adding grouping.
- const locale __loc = __io.getloc();
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
- _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len));
- // Grouping can add (almost) as many separators as the number of
- // digits, but no more.
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len * 2));
- __ctype.widen(__cs, __cs + __len, __ws);
-
- // Add grouping, if necessary.
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
- const string __grouping = __np.grouping();
- const ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
- if (__grouping.size())
- {
- // By itself __add_grouping cannot deal correctly with __ws when
- // ios::showbase is set and ios_base::oct || ios_base::hex.
- // Therefore we take care "by hand" of the initial 0, 0x or 0X.
- // However, remember that the latter do not occur if the number
- // printed is '0' (__len == 1).
- streamsize __off = 0;
- if ((__io.flags() & ios_base::showbase) && __len > 1)
- if (__basefield == ios_base::oct)
- {
- __off = 1;
- *__ws2 = *__ws;
- }
- else if (__basefield == ios_base::hex)
- {
- __off = 2;
- *__ws2 = *__ws;
- *(__ws2 + 1) = *(__ws + 1);
- }
- _CharT* __p;
- __p = __add_grouping(__ws2 + __off, __np.thousands_sep(),
- __grouping.c_str(),
- __grouping.c_str() + __grouping.size(),
- __ws + __off, __ws + __len);
- __len = __p - __ws2;
- // Switch strings.
- __ws = __ws2;
- }
- return _M_insert(__s, __io, __fill, __ws, __len);
- }
-
- // For use by integer and floating-point types after they have been
- // converted into a char_type string.
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws,
- int __len) const
- {
- typedef char_traits<_CharT> __traits_type;
- // [22.2.2.2.2] Stage 3.
+ // Pad.
+ _CharT* __ws3;
streamsize __w = __io.width();
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __w));
if (__w > static_cast<streamsize>(__len))
{
- __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws,
- __w, __len, true);
- __len = static_cast<int>(__w);
- // Switch strings.
- __ws = __ws2;
+ __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
+ _M_pad(__fill, __w, __io, __ws3, __ws, __len);
+ __ws = __ws3;
}
__io.width(0);
-
+
// [22.2.2.2.2] Stage 4.
// Write resulting, fully-formatted string to output iterator.
- for (int __j = 0; __j < __len; ++__j, ++__s)
- *__s = __ws[__j];
- return __s;
- }
+ return __write(__s, __ws, __len);
+ }
template<typename _CharT, typename _OutIter>
_OutIter
@@ -869,19 +991,35 @@ namespace std
if ((__flags & ios_base::boolalpha) == 0)
{
unsigned long __uv = __v;
- __s = _M_convert_int(__s, __io, __fill, 'u', char(), __uv);
+ __s = _M_convert_int(__s, __io, __fill, __uv);
}
else
{
- typedef basic_string<_CharT> __string_type;
- locale __loc = __io.getloc();
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ typedef numpunct<_CharT> __facet_type;
+ typedef __locale_cache<numpunct<_CharT> > __cache_type;
+ const locale __loc = __io._M_getloc();
+ const __cache_type& __lc = __use_cache<__facet_type>(__loc);
+
+ typedef basic_string<_CharT> __string_type;
__string_type __name;
if (__v)
- __name = __np.truename();
+ __name = __lc._M_truename;
else
- __name = __np.falsename();
- __s = _M_insert(__s, __io, __fill, __name.c_str(), __name.size());
+ __name = __lc._M_falsename;
+
+ const _CharT* __cs = __name.c_str();
+ int __len = __name.size();
+ _CharT* __cs3;
+ streamsize __w = __io.width();
+ if (__w > static_cast<streamsize>(__len))
+ {
+ __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __w));
+ _M_pad(__fill, __w, __io, __cs3, __cs, __len);
+ __cs = __cs3;
+ }
+ __io.width(0);
+ __s = __write(__s, __cs, __len);
}
return __s;
}
@@ -890,28 +1028,28 @@ namespace std
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
- { return _M_convert_int(__s, __io, __fill, 'd', char(), __v); }
+ { return _M_convert_int(__s, __io, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long __v) const
- { return _M_convert_int(__s, __io, __fill, 'u', char(), __v); }
+ { return _M_convert_int(__s, __io, __fill, __v); }
#ifdef _GLIBCPP_USE_LONG_LONG
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
- { return _M_convert_int(__s, __b, __fill, 'd', 'l', __v); }
+ { return _M_convert_int(__s, __b, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long long __v) const
- { return _M_convert_int(__s, __io, __fill, 'u', 'l', __v); }
+ { return _M_convert_int(__s, __io, __fill, __v); }
#endif
template<typename _CharT, typename _OutIter>
@@ -939,7 +1077,7 @@ namespace std
__io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
try
{
- __s = _M_convert_int(__s, __io, __fill, 'u', char(),
+ __s = _M_convert_int(__s, __io, __fill,
reinterpret_cast<unsigned long>(__v));
__io.flags(__flags);
}
@@ -1196,7 +1334,8 @@ namespace std
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
int __len = __convert_from_v(__cs, 0, "%.01Lf", __units, _S_c_locale);
#endif
- _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __cs_size));
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __cs_size));
__ctype.widen(__cs, __cs + __len, __ws);
string_type __digits(__ws);
return this->do_put(__s, __intl, __io, __fill, __digits);
@@ -1290,7 +1429,7 @@ namespace std
const char* __gend = __gbeg + __grouping.size();
const int __n = (__end - __beg) * 2;
_CharT* __ws2 =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
+ static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
_CharT* __ws_end = __add_grouping(__ws2, __sep, __gbeg,
__gend, __beg, __end);
__value.insert(0, __ws2, __ws_end - __ws2);
@@ -1359,8 +1498,7 @@ namespace std
}
// Write resulting, fully-formatted string to output iterator.
- for (size_type __j = 0; __j < __len; ++__j, ++__s)
- *__s = __res[__j];
+ __s = __write(__s, __res.c_str(), __len);
}
__io.width(0);
return __s;
@@ -1616,7 +1754,8 @@ namespace std
ios_base::iostate& __err) const
{
typedef char_traits<_CharT> __traits_type;
- int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int) * __indexlen));
+ int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
+ * __indexlen));
size_t __nmatches = 0;
size_t __pos = 0;
bool __testvalid = true;
@@ -1628,7 +1767,7 @@ namespace std
if (__c == __names[__i1][0])
__matches[__nmatches++] = __i1;
- while(__nmatches > 1)
+ while (__nmatches > 1)
{
// Find smallest matching string.
size_t __minlen = 10;
@@ -1853,8 +1992,7 @@ namespace std
}
else
__format = __c;
- __s = this->do_put(__s, __io, char_type(), __tm, __format,
- __mod);
+ __s = this->do_put(__s, __io, _CharT(), __tm, __format, __mod);
}
else
{
@@ -1878,8 +2016,7 @@ namespace std
// NB: This size is arbitrary. Should this be a data member,
// initialized at construction?
const size_t __maxlen = 64;
- char_type* __res =
- static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
+ char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
// NB: In IEE 1003.1-200x, and perhaps other locale models, it
// is possible that the format character will be longer than one
@@ -1903,10 +2040,7 @@ namespace std
__tp._M_put(__res, __maxlen, __fmt, __tm);
// Write resulting, fully-formatted string to output iterator.
- size_t __len = char_traits<char_type>::length(__res);
- for (size_t __i = 0; __i < __len; ++__i, ++__s)
- *__s = __res[__i];
- return __s;
+ return __write(__s, __res, char_traits<char_type>::length(__res));
}
@@ -1928,9 +2062,37 @@ namespace std
do_compare(const _CharT* __lo1, const _CharT* __hi1,
const _CharT* __lo2, const _CharT* __hi2) const
{
+ // strcoll assumes zero-terminated strings so we make a copy
+ // and then put a zero at the end.
const string_type __one(__lo1, __hi1);
const string_type __two(__lo2, __hi2);
- return _M_compare(__one.c_str(), __two.c_str());
+
+ const _CharT* __p = __one.c_str();
+ const _CharT* __pend = __one.c_str() + __one.length();
+ const _CharT* __q = __two.c_str();
+ const _CharT* __qend = __two.c_str() + __two.length();
+
+ // strcoll stops when it sees a nul character so we break
+ // the strings into zero-terminated substrings and pass those
+ // to strcoll.
+ for (;;)
+ {
+ int __res = _M_compare(__p, __q);
+ if (__res)
+ return __res;
+
+ __p += char_traits<_CharT>::length(__p);
+ __q += char_traits<_CharT>::length(__q);
+ if (__p == __pend && __q == __qend)
+ return 0;
+ else if (__p == __pend)
+ return -1;
+ else if (__q == __qend)
+ return 1;
+
+ __p++;
+ __q++;
+ }
}
template<typename _CharT>
@@ -1938,19 +2100,43 @@ namespace std
collate<_CharT>::
do_transform(const _CharT* __lo, const _CharT* __hi) const
{
+ // strxfrm assumes zero-terminated strings so we make a copy
+ string_type __str(__lo, __hi);
+
+ const _CharT* __p = __str.c_str();
+ const _CharT* __pend = __str.c_str() + __str.length();
+
size_t __len = (__hi - __lo) * 2;
- // First try a buffer perhaps big enough.
- _CharT* __c =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
- size_t __res = _M_transform(__c, __lo, __len);
- // If the buffer was not large enough, try again with the correct size.
- if (__res >= __len)
+
+ string_type __ret;
+
+ // strxfrm stops when it sees a nul character so we break
+ // the string into zero-terminated substrings and pass those
+ // to strxfrm.
+ for (;;)
{
- __c =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__res + 1)));
- _M_transform(__c, __lo, __res + 1);
+ // First try a buffer perhaps big enough.
+ _CharT* __c =
+ static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
+ size_t __res = _M_transform(__c, __p, __len);
+ // If the buffer was not large enough, try again with the
+ // correct size.
+ if (__res >= __len)
+ {
+ __len = __res + 1;
+ __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len));
+ __res = _M_transform(__c, __p, __res + 1);
+ }
+
+ __ret.append(__c, __res);
+ __p += char_traits<_CharT>::length(__p);
+ if (__p == __pend)
+ return __ret;
+
+ __p++;
+ __ret.push_back(_CharT());
}
- return string_type(__c);
}
template<typename _CharT>
@@ -1965,22 +2151,6 @@ namespace std
return static_cast<long>(__val);
}
- // Convert string to numeric value of type _Tv and store results.
- // NB: This is specialized for all required types, there is no
- // generic definition.
- template<typename _Tv>
- void
- __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
- const __c_locale& __cloc, int __base = 10);
-
- // Convert numeric value of type _Tv to string and return length of string.
- // If snprintf is available use it, otherwise fall back to the unsafe sprintf
- // which, in general, can be dangerous and should be avoided.
- template<typename _Tv>
- int
- __convert_from_v(char* __out, const int __size, const char* __fmt,
- _Tv __v, const __c_locale&, int __prec = -1);
-
// Construct correctly padded string, as per 22.2.2.2.2
// Assumes
// __newlen > __oldlen
@@ -1993,15 +2163,6 @@ namespace std
// NB: Of the two parameters, _CharT can be deduced from the
// function arguments. The other (_Traits) has to be explicitly specified.
template<typename _CharT, typename _Traits>
- struct __pad
- {
- static void
- _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
- const _CharT* __olds, const streamsize __newlen,
- const streamsize __oldlen, const bool __num);
- };
-
- template<typename _CharT, typename _Traits>
void
__pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
_CharT* __news, const _CharT* __olds,
@@ -2009,7 +2170,8 @@ namespace std
const streamsize __oldlen, const bool __num)
{
size_t __plen = static_cast<size_t>(__newlen - __oldlen);
- _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __plen));
+ _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __plen));
_Traits::assign(__pads, __plen, __fill);
_CharT* __beg;
@@ -2079,14 +2241,6 @@ namespace std
__newlen - __beglen - __mod);
}
- // Used by both numeric and monetary facets.
- // Check to make sure that the __grouping_tmp string constructed in
- // money_get or num_get matches the canonical grouping for a given
- // locale.
- // __grouping_tmp is parsed L to R
- // 1,222,444 == __grouping_tmp of "/1/3/3"
- // __grouping is parsed R to L
- // 1,222,444 == __grouping of "/3" == "/3/3/3"
template<typename _CharT>
bool
__verify_grouping(const basic_string<_CharT>& __grouping,
@@ -2111,11 +2265,6 @@ namespace std
return __test;
}
- // Used by both numeric and monetary facets.
- // Inserts "group separator" characters into an array of characters.
- // It's recursive, one iteration per group. It moves the characters
- // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
- // only with __gbeg != __gend.
template<typename _CharT>
_CharT*
__add_grouping(_CharT* __s, _CharT __sep,
@@ -2136,9 +2285,249 @@ namespace std
return __s;
}
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
+ template<typename _CharT, typename _OutIter>
+ template<typename _ValueT>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
+ char __modl, _ValueT __v) const
+ {
+ // [22.2.2.2.2] Stage 1, numeric conversion to character.
+
+ // Long enough for the max format spec.
+ char __fbuf[16];
+ _S_format_int(__io, __fbuf, __mod, __modl);
+#ifdef _GLIBCPP_USE_C99
+ // First try a buffer perhaps big enough.
+ int __cs_size = 64;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+ int __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale);
+ // If the buffer was not large enough, try again with the correct size.
+ if (__len >= __cs_size)
+ {
+ __cs_size = __len + 1;
+ __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+ __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale);
+ }
+#else
+ // Leave room for "+/-," "0x," and commas. This size is
+ // arbitrary, but should be largely sufficient.
+ char __cs[128];
+ int __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale);
+#endif
+ return _M_widen_int(__s, __io, __fill, __cs, __len);
+ }
+
+ template<typename _CharT, typename _OutIter>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
+ int __len) const
+ {
+ typedef char_traits<_CharT> __traits_type;
+ // [22.2.2.2.2] Stage 2, convert to char_type, using correct
+ // numpunct.decimal_point() values for '.' and adding grouping.
+ const locale __loc = __io.getloc();
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len));
+ // Grouping can add (almost) as many separators as the number of
+ // digits, but no more.
+ _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ __ctype.widen(__cs, __cs + __len, __ws);
+
+ // Replace decimal point.
+ const _CharT* __p;
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ if (__p = __traits_type::find(__ws, __len, __ctype.widen('.')))
+ __ws[__p - __ws] = __np.decimal_point();
+
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+//282. What types does numpunct grouping refer to?
+ // Add grouping, if necessary.
+ const string __grouping = __np.grouping();
+ if (__grouping.size())
+ {
+ _CharT* __p2;
+ int __declen = __p ? __p - __ws : __len;
+ __p2 = __add_grouping(__ws2, __np.thousands_sep(),
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __ws, __ws + __declen);
+ int __newlen = __p2 - __ws2;
+
+ // Tack on decimal part.
+ if (__p)
+ {
+ __traits_type::copy(__p2, __p, __len - __declen);
+ __newlen += __len - __declen;
+ }
+
+ // Switch strings, establish correct new length.
+ __ws = __ws2;
+ __len = __newlen;
+ }
+#endif
+ return _M_insert(__s, __io, __fill, __ws, __len);
+ }
+
+ template<typename _CharT, typename _OutIter>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_widen_int(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
+ int __len) const
+ {
+ // [22.2.2.2.2] Stage 2, convert to char_type, using correct
+ // numpunct.decimal_point() values for '.' and adding grouping.
+ const locale __loc = __io.getloc();
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len));
+ // Grouping can add (almost) as many separators as the number of
+ // digits, but no more.
+ _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ __ctype.widen(__cs, __cs + __len, __ws);
+
+ // Add grouping, if necessary.
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ const string __grouping = __np.grouping();
+ if (__grouping.size())
+ {
+ // By itself __add_grouping cannot deal correctly with __ws when
+ // ios::showbase is set and ios_base::oct || ios_base::hex.
+ // Therefore we take care "by hand" of the initial 0, 0x or 0X.
+ // However, remember that the latter do not occur if the number
+ // printed is '0' (__len == 1).
+ streamsize __off = 0;
+ const ios_base::fmtflags __basefield = __io.flags()
+ & ios_base::basefield;
+ if ((__io.flags() & ios_base::showbase) && __len > 1)
+ if (__basefield == ios_base::oct)
+ {
+ __off = 1;
+ *__ws2 = *__ws;
+ }
+ else if (__basefield == ios_base::hex)
+ {
+ __off = 2;
+ *__ws2 = *__ws;
+ *(__ws2 + 1) = *(__ws + 1);
+ }
+ _CharT* __p;
+ __p = __add_grouping(__ws2 + __off, __np.thousands_sep(),
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __ws + __off, __ws + __len);
+ __len = __p - __ws2;
+ // Switch strings.
+ __ws = __ws2;
+ }
+ return _M_insert(__s, __io, __fill, __ws, __len);
+ }
+
+ // For use by integer and floating-point types after they have been
+ // converted into a char_type string.
+ template<typename _CharT, typename _OutIter>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws,
+ int __len) const
+ {
+ typedef char_traits<_CharT> __traits_type;
+ // [22.2.2.2.2] Stage 3.
+ // If necessary, pad.
+ streamsize __w = __io.width();
+ _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __w));
+ if (__w > static_cast<streamsize>(__len))
+ {
+ __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws,
+ __w, __len, true);
+ __len = static_cast<int>(__w);
+ // Switch strings.
+ __ws = __ws2;
+ }
+ __io.width(0);
+
+ // [22.2.2.2.2] Stage 4.
+ // Write resulting, fully-formatted string to output iterator.
+ return __write(__s, __ws, __len);
+ }
+#endif
+
+ template<typename _CharT>
+ __locale_cache<numpunct<_CharT> >::__locale_cache(const locale& __loc)
+ : _M_truename(0), _M_falsename(0), _M_use_grouping(false),
+ _M_grouping(0)
+ {
+ if (has_facet<numpunct<_CharT> >(__loc))
+ {
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ _M_decimal_point = __np.decimal_point();
+ _M_thousands_sep = __np.thousands_sep();
+
+ string_type __false = __np.falsename();
+ _CharT* __falsename = new _CharT[__false.length() + 1];
+ __false.copy(__falsename, __false.length());
+ __falsename[__false.length()] = _CharT();
+ _M_falsename = __falsename;
+
+ string_type __true = __np.truename();
+ _CharT* __truename = new _CharT[__true.length() + 1];
+ __true.copy(__truename, __true.length());
+ __truename[__true.length()] = _CharT();
+ _M_truename = __truename;
+
+ string __grouping = __np.grouping();
+ char* __group = new char[__grouping.length() + 1];
+ __grouping.copy(__group, __grouping.length());
+ __group[__grouping.length()] = 0;
+ _M_grouping = __group;
+
+ _M_use_grouping = __grouping.length() != 0
+ && __grouping.data()[0] != 0;
+ }
+
+ if (has_facet<ctype<_CharT> >(__loc))
+ {
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
+ __ct.widen(__num_base::_S_atoms_out,
+ __num_base::_S_atoms_out + __num_base::_S_end,
+ _M_atoms_out);
+ }
+ }
+
+ // Static locale cache initialization. Only instantiated with char
+ // and wchar_t, so no need to check has_facet.
+ template<typename _CharT>
+ __locale_cache<numpunct<_CharT> >::
+ __locale_cache(const locale& __loc, bool)
+ {
+ // Grab pointers to numpunct static strings
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ _M_thousands_sep = __np._M_thousands_sep;
+ _M_decimal_point = __np._M_decimal_point;
+ _M_falsename = __np._M_falsename;
+ _M_truename = __np._M_truename;
+ _M_grouping = __np._M_grouping;
+ _M_use_grouping = false;
+
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
+ __ct.widen(__num_base::_S_atoms_out,
+ __num_base::_S_atoms_out + __num_base::_S_end,
+ _M_atoms_out);
+ }
+
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class moneypunct<char, false>;
extern template class moneypunct<char, true>;
extern template class moneypunct_byname<char, false>;
@@ -2392,6 +2781,7 @@ namespace std
bool
has_facet<messages<wchar_t> >(const locale&);
#endif
+#endif
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/localefwd.h b/contrib/libstdc++/include/bits/localefwd.h
index dedc764..ac9e1a9 100644
--- a/contrib/libstdc++/include/bits/localefwd.h
+++ b/contrib/libstdc++/include/bits/localefwd.h
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -37,18 +37,15 @@
* You should not attempt to use it directly.
*/
-#ifndef _CPP_BITS_LOCCORE_H
-#define _CPP_BITS_LOCCORE_H 1
+#ifndef _CPP_BITS_LOCALE_FWD_H
+#define _CPP_BITS_LOCALE_FWD_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/c++locale.h> // Defines __c_locale, config-specific includes
-#include <climits> // For CHAR_BIT
-#include <cctype> // For isspace, etc.
-#include <string> // For string.
+#include <iosfwd> // For ostreambuf_iterator, istreambuf_iterator
#include <bits/functexcept.h>
-#include <bits/atomicity.h>
namespace std
{
@@ -108,7 +105,6 @@ namespace std
inline _CharT
tolower(_CharT, const locale&);
-
// 22.2.1 and 22.2.1.3 ctype
class ctype_base;
template<typename _CharT>
@@ -175,327 +171,6 @@ namespace std
template<typename _CharT>
class messages_byname;
- // 22.1.1 Class locale
- class locale
- {
- public:
- // Types:
- typedef unsigned int category;
-
- // Forward decls and friends:
- class facet;
- class id;
- class _Impl;
-
- friend class facet;
- friend class _Impl;
-
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
-
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw();
-
- // Category values:
- // NB: Order must match _S_facet_categories definition in locale.cc
- static const category none = 0;
- static const category ctype = 1L << 0;
- static const category numeric = 1L << 1;
- static const category collate = 1L << 2;
- static const category time = 1L << 3;
- static const category monetary = 1L << 4;
- static const category messages = 1L << 5;
- static const category all = (ctype | numeric | collate |
- time | monetary | messages);
-
- // Construct/copy/destroy:
- locale() throw();
-
- locale(const locale& __other) throw();
-
- explicit
- locale(const char* __s);
-
- locale(const locale& __base, const char* __s, category __cat);
-
- locale(const locale& __base, const locale& __add, category __cat);
-
- template<typename _Facet>
- locale(const locale& __other, _Facet* __f);
-
- ~locale() throw();
-
- const locale&
- operator=(const locale& __other) throw();
-
- template<typename _Facet>
- locale
- combine(const locale& __other) const;
-
- // Locale operations:
- string
- name() const;
-
- bool
- operator==(const locale& __other) const throw ();
-
- inline bool
- operator!=(const locale& __other) const throw ()
- { return !(this->operator==(__other)); }
-
- template<typename _Char, typename _Traits, typename _Alloc>
- bool
- operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
- const basic_string<_Char, _Traits, _Alloc>& __s2) const;
-
- // Global locale objects:
- static locale
- global(const locale&);
-
- static const locale&
- classic();
-
- private:
- // The (shared) implementation
- _Impl* _M_impl;
-
- // The "C" reference locale
- static _Impl* _S_classic;
-
- // Current global locale
- static _Impl* _S_global;
-
- // Number of standard categories. For C++, these categories are
- // collate, ctype, monetary, numeric, time, and messages. These
- // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
- // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
- // 1003.1-2001) specifies LC_MESSAGES.
- static const size_t _S_categories_size = 6;
-
- // In addition to the standard categories, the underlying
- // operating system is allowed to define extra LC_*
- // macros. For GNU systems, the following are also valid:
- // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
- // and LC_IDENTIFICATION.
- static const size_t _S_extra_categories_size = _GLIBCPP_NUM_CATEGORIES;
-
- // Names of underlying locale categories.
- // NB: locale::global() has to know how to modify all the
- // underlying categories, not just the ones required by the C++
- // standard.
- static const char* _S_categories[_S_categories_size
- + _S_extra_categories_size];
-
- explicit
- locale(_Impl*) throw();
-
- static inline void
- _S_initialize()
- {
- if (!_S_classic)
- classic();
- }
-
- static category
- _S_normalize_category(category);
-
- void
- _M_coalesce(const locale& __base, const locale& __add, category __cat);
- };
-
-
- // Implementation object for locale
- class locale::_Impl
- {
- public:
- // Friends.
- friend class locale;
- friend class locale::facet;
-
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
-
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw();
-
- private:
- // Data Members.
- _Atomic_word _M_references;
- facet** _M_facets;
- size_t _M_facets_size;
-
- char* _M_names[_S_categories_size
- + _S_extra_categories_size];
- static const locale::id* const _S_id_ctype[];
- static const locale::id* const _S_id_numeric[];
- static const locale::id* const _S_id_collate[];
- static const locale::id* const _S_id_time[];
- static const locale::id* const _S_id_monetary[];
- static const locale::id* const _S_id_messages[];
- static const locale::id* const* const _S_facet_categories[];
-
- inline void
- _M_add_reference() throw()
- { __atomic_add(&_M_references, 1); }
-
- inline void
- _M_remove_reference() throw()
- {
- if (__exchange_and_add(&_M_references, -1) == 1)
- {
- try
- { delete this; }
- catch(...)
- { }
- }
- }
-
- _Impl(const _Impl&, size_t);
- _Impl(const char*, size_t);
- _Impl(facet**, size_t, bool);
-
- ~_Impl() throw();
-
- _Impl(const _Impl&); // Not defined.
-
- void
- operator=(const _Impl&); // Not defined.
-
- inline bool
- _M_check_same_name()
- {
- bool __ret = true;
- for (size_t __i = 0;
- __ret && __i < _S_categories_size + _S_extra_categories_size - 1;
- ++__i)
- __ret &= (strcmp(_M_names[__i], _M_names[__i + 1]) == 0);
- return __ret;
- }
-
- void
- _M_replace_categories(const _Impl*, category);
-
- void
- _M_replace_category(const _Impl*, const locale::id* const*);
-
- void
- _M_replace_facet(const _Impl*, const locale::id*);
-
- void
- _M_install_facet(const locale::id*, facet*);
-
- template<typename _Facet>
- inline void
- _M_init_facet(_Facet* __facet)
- { _M_install_facet(&_Facet::id, __facet); }
- };
-
- template<typename _Facet>
- locale::locale(const locale& __other, _Facet* __f)
- {
- _M_impl = new _Impl(*__other._M_impl, 1);
- _M_impl->_M_install_facet(&_Facet::id, __f);
- for (size_t __i = 0;
- __i < _S_categories_size + _S_extra_categories_size; ++__i)
- {
- delete [] _M_impl->_M_names[__i];
- char* __new = new char[2];
- strcpy(__new, "*");
- _M_impl->_M_names[__i] = __new;
- }
- }
-
- // 22.1.1.1.2 Class locale::facet
- class locale::facet
- {
- private:
- friend class locale;
- friend class locale::_Impl;
-
- _Atomic_word _M_references;
-
- protected:
- // Contains data from the underlying "C" library for for the
- // classic locale.
- static __c_locale _S_c_locale;
-
- // String literal for the name of the classic locale.
- static char _S_c_name[2];
-
- explicit
- facet(size_t __refs = 0) throw();
-
- virtual
- ~facet();
-
- static void
- _S_create_c_locale(__c_locale& __cloc, const char* __s,
- __c_locale __old = 0);
-
- static __c_locale
- _S_clone_c_locale(__c_locale& __cloc);
-
- static void
- _S_destroy_c_locale(__c_locale& __cloc);
-
- private:
- void
- _M_add_reference() throw();
-
- void
- _M_remove_reference() throw();
-
- facet(const facet&); // Not defined.
-
- void
- operator=(const facet&); // Not defined.
- };
-
-
- // 22.1.1.1.3 Class locale::id
- class locale::id
- {
- private:
- friend class locale;
- friend class locale::_Impl;
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw ();
-
- // NB: There is no accessor for _M_index because it may be used
- // before the constructor is run; the effect of calling a member
- // function (even an inline) would be undefined.
- mutable size_t _M_index;
-
- // Last id number assigned.
- static _Atomic_word _S_highwater;
-
- void
- operator=(const id&); // Not defined.
-
- id(const id&); // Not defined.
-
- public:
- // NB: This class is always a static data member, and thus can be
- // counted on to be zero-initialized.
- id();
-
- inline size_t
- _M_id() const
- {
- if (!_M_index)
- _M_index = 1 + __exchange_and_add(&_S_highwater, 1);
- return _M_index - 1;
- }
- };
-
template<typename _Facet>
const _Facet&
use_facet(const locale& __loc);
diff --git a/contrib/libstdc++/include/bits/mask_array.h b/contrib/libstdc++/include/bits/mask_array.h
index 13c01d3..df23a46 100644
--- a/contrib/libstdc++/include/bits/mask_array.h
+++ b/contrib/libstdc++/include/bits/mask_array.h
@@ -1,6 +1,7 @@
// The template and inlines for the -*- C++ -*- mask_array class.
-// Copyright (C) 1997-2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -41,120 +42,119 @@
namespace std {
- template <class _Tp> class mask_array
+ template <class _Tp>
+ class mask_array
{
public:
- typedef _Tp value_type;
+ typedef _Tp value_type;
- void operator= (const valarray<_Tp>&) const;
- void operator*= (const valarray<_Tp>&) const;
- void operator/= (const valarray<_Tp>&) const;
- void operator%= (const valarray<_Tp>&) const;
- void operator+= (const valarray<_Tp>&) const;
- void operator-= (const valarray<_Tp>&) const;
- void operator^= (const valarray<_Tp>&) const;
- void operator&= (const valarray<_Tp>&) const;
- void operator|= (const valarray<_Tp>&) const;
- void operator<<=(const valarray<_Tp>&) const;
- void operator>>=(const valarray<_Tp>&) const;
- void operator= (const _Tp&);
+ void operator=(const valarray<_Tp>&) const;
+ void operator*=(const valarray<_Tp>&) const;
+ void operator/=(const valarray<_Tp>&) const;
+ void operator%=(const valarray<_Tp>&) const;
+ void operator+=(const valarray<_Tp>&) const;
+ void operator-=(const valarray<_Tp>&) const;
+ void operator^=(const valarray<_Tp>&) const;
+ void operator&=(const valarray<_Tp>&) const;
+ void operator|=(const valarray<_Tp>&) const;
+ void operator<<=(const valarray<_Tp>&) const;
+ void operator>>=(const valarray<_Tp>&) const;
+ void operator=(const _Tp&) const;
// ~mask_array ();
- template<class _Dom>
- void operator= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator*= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator/= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator%= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator+= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator-= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator^= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator&= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator|= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
+ template<class _Dom>
+ void operator=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator*=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator/=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator%=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator+=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator-=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator^=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator&=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator|=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
void operator<<=(const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
+ template<class _Dom>
void operator>>=(const _Expr<_Dom,_Tp>&) const;
private:
- mask_array (_Array<_Tp>, size_t, _Array<bool>);
- friend class valarray<_Tp>;
+ mask_array(_Array<_Tp>, size_t, _Array<bool>);
+ friend class valarray<_Tp>;
- const size_t _M_sz;
- const _Array<bool> _M_mask;
- const _Array<_Tp> _M_array;
-
- mask_array (const mask_array&);
-
- // not implemented
- mask_array ();
- mask_array& operator= (const mask_array&);
+ const size_t _M_sz;
+ const _Array<bool> _M_mask;
+ const _Array<_Tp> _M_array;
+
+ mask_array (const mask_array&);
+
+ // not implemented
+ mask_array();
+ mask_array& operator=(const mask_array&);
};
- template<typename _Tp>
- inline mask_array<_Tp>::mask_array (const mask_array<_Tp>& a)
- : _M_sz (a._M_sz), _M_mask (a._M_mask), _M_array (a._M_array) {}
+ template<typename _Tp>
+ inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& a)
+ : _M_sz(a._M_sz), _M_mask(a._M_mask), _M_array(a._M_array) {}
- template<typename _Tp>
+ template<typename _Tp>
inline
- mask_array<_Tp>::mask_array (_Array<_Tp> __a, size_t __s, _Array<bool> __m)
- : _M_sz (__s), _M_mask (__m), _M_array (__a) {}
+ mask_array<_Tp>::mask_array(_Array<_Tp> __a, size_t __s, _Array<bool> __m)
+ : _M_sz(__s), _M_mask(__m), _M_array(__a) {}
- // template<typename _Tp>
- // inline mask_array<_Tp>::~mask_array () {}
-
- template<typename _Tp>
+ template<typename _Tp>
inline void
- mask_array<_Tp>::operator= (const _Tp& __t)
- { __valarray_fill (_M_array, _M_sz, _M_mask, __t); }
+ mask_array<_Tp>::operator=(const _Tp& __t) const
+ { __valarray_fill(_M_array, _M_sz, _M_mask, __t); }
- template<typename _Tp>
+ template<typename _Tp>
inline void
- mask_array<_Tp>::operator= (const valarray<_Tp>& __v) const
- { __valarray_copy (_Array<_Tp> (__v), __v.size (), _M_array, _M_mask); }
+ mask_array<_Tp>::operator=(const valarray<_Tp>& __v) const
+ { __valarray_copy(_Array<_Tp>(__v), __v.size(), _M_array, _M_mask); }
- template<typename _Tp>
- template<class E>
- inline void
- mask_array<_Tp>::operator= (const _Expr<E, _Tp>& __e) const
- { __valarray_copy (__e, __e.size (), _M_array, _M_mask); }
+ template<typename _Tp>
+ template<class _Ex>
+ inline void
+ mask_array<_Tp>::operator=(const _Expr<_Ex, _Tp>& __e) const
+ { __valarray_copy(__e, __e.size(), _M_array, _M_mask); }
#undef _DEFINE_VALARRAY_OPERATOR
-#define _DEFINE_VALARRAY_OPERATOR(op, name) \
-template<typename _Tp> \
-inline void \
-mask_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \
-{ \
- _Array_augmented_##name (_M_array, _M_mask, \
- _Array<_Tp> (__v), __v.size ()); \
-} \
+#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline void \
+ mask_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
+ { \
+ _Array_augmented_##_Name(_M_array, _M_mask, \
+ _Array<_Tp>(__v), __v.size()); \
+ } \
\
-template<typename _Tp> template<class E> \
-inline void \
-mask_array<_Tp>::operator op##= (const _Expr<E, _Tp>& __e) const \
-{ \
- _Array_augmented_##name (_M_array, _M_mask, __e, __e.size ()); \
-}
-
-_DEFINE_VALARRAY_OPERATOR(*, multiplies)
-_DEFINE_VALARRAY_OPERATOR(/, divides)
-_DEFINE_VALARRAY_OPERATOR(%, modulus)
-_DEFINE_VALARRAY_OPERATOR(+, plus)
-_DEFINE_VALARRAY_OPERATOR(-, minus)
-_DEFINE_VALARRAY_OPERATOR(^, xor)
-_DEFINE_VALARRAY_OPERATOR(&, and)
-_DEFINE_VALARRAY_OPERATOR(|, or)
-_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
-_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+ template<typename _Tp> \
+ template<class _Dom> \
+ inline void \
+ mask_array<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) const\
+ { \
+ _Array_augmented_##_Name(_M_array, _M_mask, __e, __e.size()); \
+ }
+
+_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, __divides)
+_DEFINE_VALARRAY_OPERATOR(%, __modulus)
+_DEFINE_VALARRAY_OPERATOR(+, __plus)
+_DEFINE_VALARRAY_OPERATOR(-, __minus)
+_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
+_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
+_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
+_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
#undef _DEFINE_VALARRAY_OPERATOR
diff --git a/contrib/libstdc++/include/bits/ostream.tcc b/contrib/libstdc++/include/bits/ostream.tcc
index e42eca2..ab15ae8 100644
--- a/contrib/libstdc++/include/bits/ostream.tcc
+++ b/contrib/libstdc++/include/bits/ostream.tcc
@@ -41,11 +41,19 @@ namespace std
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>::sentry::
sentry(basic_ostream<_CharT,_Traits>& __os)
- : _M_ok(__os.good()), _M_os(__os)
+ : _M_os(__os)
{
- // XXX MT
- if (_M_ok && __os.tie())
- __os.tie()->flush();
+ // XXX MT
+ if (__os.tie() && __os.good())
+ __os.tie()->flush();
+
+ if (__os.good())
+ _M_ok = true;
+ else
+ {
+ _M_ok = false;
+ __os.setstate(ios_base::failbit);
+ }
}
template<typename _CharT, typename _Traits>
@@ -58,11 +66,11 @@ namespace std
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -80,11 +88,11 @@ namespace std
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -102,11 +110,11 @@ namespace std
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -126,11 +134,11 @@ namespace std
if (!__copy_streambufs(*this, __sbin, this->rdbuf()))
this->setstate(ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -153,11 +161,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -190,11 +198,11 @@ namespace std
this->setstate(ios_base::badbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -215,11 +223,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -254,11 +262,11 @@ namespace std
this->setstate(ios_base::badbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -279,11 +287,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -305,11 +313,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -330,11 +338,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -355,11 +363,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -468,7 +476,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__w + 1)));
__pads[0] = __c;
streamsize __len = 1;
@@ -481,11 +489,11 @@ namespace std
__out.write(__pads, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -504,7 +512,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
char* __pads = static_cast<char*>(__builtin_alloca(__w + 1));
__pads[0] = __c;
streamsize __len = 1;
@@ -517,11 +525,11 @@ namespace std
__out.write(__pads, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -539,7 +547,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
if (__w > __len)
@@ -552,11 +560,11 @@ namespace std
__out.write(__s, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -588,7 +596,7 @@ namespace std
try
{
streamsize __len = static_cast<streamsize>(__clen);
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
if (__w > __len)
@@ -601,11 +609,11 @@ namespace std
__out.write(__str, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -626,7 +634,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
char* __pads = static_cast<char*>(__builtin_alloca(__w));
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
@@ -640,11 +648,11 @@ namespace std
__out.write(__s, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -665,7 +673,7 @@ namespace std
if (__cerb)
{
const _CharT* __s = __str.data();
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
streamsize __len = static_cast<streamsize>(__str.size());
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
@@ -689,6 +697,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);
@@ -710,4 +719,5 @@ namespace std
extern template wostream& operator<<(wostream&, const wchar_t*);
extern template wostream& operator<<(wostream&, const char*);
#endif
+#endif
} // namespace std
diff --git a/contrib/libstdc++/include/bits/slice_array.h b/contrib/libstdc++/include/bits/slice_array.h
index cca3e63..2502ef4 100644
--- a/contrib/libstdc++/include/bits/slice_array.h
+++ b/contrib/libstdc++/include/bits/slice_array.h
@@ -1,6 +1,6 @@
// The template and inlines for the -*- C++ -*- slice_array class.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -41,134 +41,171 @@
namespace std
{
+ class slice
+ {
+ public:
+ slice();
+ slice(size_t, size_t, size_t);
+
+ size_t start() const;
+ size_t size() const;
+ size_t stride() const;
- template<typename _Tp>
+ private:
+ size_t _M_off; // offset
+ size_t _M_sz; // size
+ size_t _M_st; // stride unit
+ };
+
+ // The default constructor constructor is not required to initialize
+ // data members with any meaningful values, so we choose to do nothing.
+ inline
+ slice::slice() {}
+
+ inline
+ slice::slice(size_t __o, size_t __d, size_t __s)
+ : _M_off(__o), _M_sz(__d), _M_st(__s) {}
+
+ inline size_t
+ slice::start() const
+ { return _M_off; }
+
+ inline size_t
+ slice::size() const
+ { return _M_sz; }
+
+ inline size_t
+ slice::stride() const
+ { return _M_st; }
+
+ template<typename _Tp>
class slice_array
{
public:
- typedef _Tp value_type;
+ typedef _Tp value_type;
// This constructor is implemented since we need to return a value.
- slice_array (const slice_array&);
+ slice_array(const slice_array&);
// This operator must be public. See DR-253.
- slice_array& operator= (const slice_array&);
-
- void operator= (const valarray<_Tp>&) const;
- void operator*= (const valarray<_Tp>&) const;
- void operator/= (const valarray<_Tp>&) const;
- void operator%= (const valarray<_Tp>&) const;
- void operator+= (const valarray<_Tp>&) const;
- void operator-= (const valarray<_Tp>&) const;
- void operator^= (const valarray<_Tp>&) const;
- void operator&= (const valarray<_Tp>&) const;
- void operator|= (const valarray<_Tp>&) const;
- void operator<<= (const valarray<_Tp>&) const;
- void operator>>= (const valarray<_Tp>&) const;
- void operator= (const _Tp &);
- // ~slice_array ();
-
- template<class _Dom>
- void operator= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator*= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator/= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator%= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator+= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator-= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator^= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator&= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator|= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator<<= (const _Expr<_Dom,_Tp>&) const;
- template<class _Dom>
- void operator>>= (const _Expr<_Dom,_Tp>&) const;
-
+ slice_array& operator=(const slice_array&);
+
+ void operator=(const valarray<_Tp>&) const;
+ void operator*=(const valarray<_Tp>&) const;
+ void operator/=(const valarray<_Tp>&) const;
+ void operator%=(const valarray<_Tp>&) const;
+ void operator+=(const valarray<_Tp>&) const;
+ void operator-=(const valarray<_Tp>&) const;
+ void operator^=(const valarray<_Tp>&) const;
+ void operator&=(const valarray<_Tp>&) const;
+ void operator|=(const valarray<_Tp>&) const;
+ void operator<<=(const valarray<_Tp>&) const;
+ void operator>>=(const valarray<_Tp>&) const;
+ void operator=(const _Tp &) const;
+ // ~slice_array ();
+
+ template<class _Dom>
+ void operator=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator*=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator/=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator%=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator+=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator-=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator^=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator&=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator|=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator<<=(const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator>>=(const _Expr<_Dom,_Tp>&) const;
+
private:
- friend class valarray<_Tp>;
- slice_array(_Array<_Tp>, const slice&);
-
- const size_t _M_sz;
- const size_t _M_stride;
- const _Array<_Tp> _M_array;
+ friend class valarray<_Tp>;
+ slice_array(_Array<_Tp>, const slice&);
+
+ const size_t _M_sz;
+ const size_t _M_stride;
+ const _Array<_Tp> _M_array;
- // not implemented
- slice_array ();
+ // not implemented
+ slice_array();
};
- template<typename _Tp>
- inline slice_array<_Tp>::slice_array (_Array<_Tp> __a, const slice& __s)
- : _M_sz (__s.size ()), _M_stride (__s.stride ()),
- _M_array (__a.begin () + __s.start ()) {}
+ template<typename _Tp>
+ inline
+ slice_array<_Tp>::slice_array(_Array<_Tp> __a, const slice& __s)
+ : _M_sz(__s.size()), _M_stride(__s.stride()),
+ _M_array(__a.begin() + __s.start()) {}
+ template<typename _Tp>
+ inline
+ slice_array<_Tp>::slice_array(const slice_array<_Tp>& a)
+ : _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {}
- template<typename _Tp>
- inline slice_array<_Tp>::slice_array(const slice_array<_Tp>& a)
- : _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {}
-
- // template<typename _Tp>
- // inline slice_array<_Tp>::~slice_array () {}
+ // template<typename _Tp>
+ // inline slice_array<_Tp>::~slice_array () {}
template<typename _Tp>
- inline slice_array<_Tp>&
- slice_array<_Tp>::operator=(const slice_array<_Tp>& __a)
- {
- __valarray_copy(__a._M_array, __a._M_sz, __a._M_stride,
- _M_array, _M_stride);
- return *this;
- }
-
+ inline slice_array<_Tp>&
+ slice_array<_Tp>::operator=(const slice_array<_Tp>& __a)
+ {
+ __valarray_copy(__a._M_array, __a._M_sz, __a._M_stride,
+ _M_array, _M_stride);
+ return *this;
+ }
- template<typename _Tp>
+ template<typename _Tp>
inline void
- slice_array<_Tp>::operator= (const _Tp& __t)
- { __valarray_fill (_M_array, _M_sz, _M_stride, __t); }
+ slice_array<_Tp>::operator=(const _Tp& __t) const
+ { __valarray_fill(_M_array, _M_sz, _M_stride, __t); }
- template<typename _Tp>
+ template<typename _Tp>
inline void
- slice_array<_Tp>::operator= (const valarray<_Tp>& __v) const
- { __valarray_copy (_Array<_Tp> (__v), _M_array, _M_sz, _M_stride); }
+ slice_array<_Tp>::operator=(const valarray<_Tp>& __v) const
+ { __valarray_copy(_Array<_Tp>(__v), _M_array, _M_sz, _M_stride); }
- template<typename _Tp>
- template<class _Dom>
+ template<typename _Tp>
+ template<class _Dom>
inline void
- slice_array<_Tp>::operator= (const _Expr<_Dom,_Tp>& __e) const
- { __valarray_copy (__e, _M_sz, _M_array, _M_stride); }
+ slice_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const
+ { __valarray_copy(__e, _M_sz, _M_array, _M_stride); }
#undef _DEFINE_VALARRAY_OPERATOR
-#define _DEFINE_VALARRAY_OPERATOR(op, name) \
-template<typename _Tp> \
-inline void \
-slice_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \
-{ \
- _Array_augmented_##name (_M_array, _M_sz, _M_stride, _Array<_Tp> (__v));\
-} \
+#define _DEFINE_VALARRAY_OPERATOR(_Op,_Name) \
+ template<typename _Tp> \
+ inline void \
+ slice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
+ { \
+ _Array_augmented_##_Name(_M_array, _M_sz, _M_stride, _Array<_Tp>(__v));\
+ } \
\
-template<typename _Tp> template<class _Dom> \
-inline void \
-slice_array<_Tp>::operator op##= (const _Expr<_Dom,_Tp>& __e) const \
-{ \
- _Array_augmented_##name (_M_array, _M_stride, __e, _M_sz); \
-}
+ template<typename _Tp> \
+ template<class _Dom> \
+ inline void \
+ slice_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\
+ { \
+ _Array_augmented_##_Name(_M_array, _M_stride, __e, _M_sz); \
+ }
-_DEFINE_VALARRAY_OPERATOR(*, multiplies)
-_DEFINE_VALARRAY_OPERATOR(/, divides)
-_DEFINE_VALARRAY_OPERATOR(%, modulus)
-_DEFINE_VALARRAY_OPERATOR(+, plus)
-_DEFINE_VALARRAY_OPERATOR(-, minus)
-_DEFINE_VALARRAY_OPERATOR(^, xor)
-_DEFINE_VALARRAY_OPERATOR(&, and)
-_DEFINE_VALARRAY_OPERATOR(|, or)
-_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
-_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, __divides)
+_DEFINE_VALARRAY_OPERATOR(%, __modulus)
+_DEFINE_VALARRAY_OPERATOR(+, __plus)
+_DEFINE_VALARRAY_OPERATOR(-, __minus)
+_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
+_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
+_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
+_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
#undef _DEFINE_VALARRAY_OPERATOR
diff --git a/contrib/libstdc++/include/bits/stl_alloc.h b/contrib/libstdc++/include/bits/stl_alloc.h
index 238986d..9677c3e 100644
--- a/contrib/libstdc++/include/bits/stl_alloc.h
+++ b/contrib/libstdc++/include/bits/stl_alloc.h
@@ -1,6 +1,6 @@
// Allocators -*- C++ -*-
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 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
@@ -85,7 +85,6 @@
#include <cstddef>
#include <cstdlib>
#include <cstring>
-#include <cassert>
#include <bits/functexcept.h> // For __throw_bad_alloc
#include <bits/stl_threads.h>
@@ -129,10 +128,7 @@ namespace std
{
private:
static void* _S_oom_malloc(size_t);
-
- // _GLIBCPP_DEPRECATED
static void* _S_oom_realloc(void*, size_t);
-
static void (* __malloc_alloc_oom_handler)();
public:
@@ -149,7 +145,6 @@ namespace std
deallocate(void* __p, size_t /* __n */)
{ free(__p); }
- // _GLIBCPP_DEPRECATED
static void*
reallocate(void* __p, size_t /* old_sz */, size_t __new_sz)
{
@@ -191,7 +186,6 @@ namespace std
}
}
- // _GLIBCPP_DEPRECATED
template<int __inst>
void*
__malloc_alloc_template<__inst>::
@@ -256,10 +250,7 @@ namespace std
/**
* @if maint
* An adaptor for an underlying allocator (_Alloc) to check the size
- * arguments for debugging. Errors are reported using assert; these
- * checks can be disabled via NDEBUG, but the space penalty is still
- * paid, therefore it is far better to just use the underlying allocator
- * by itelf when no checking is desired.
+ * arguments for debugging.
*
* "There is some evidence that this can confuse Purify." - SGI comment
*
@@ -288,16 +279,17 @@ namespace std
deallocate(void* __p, size_t __n)
{
char* __real_p = (char*)__p - (int) _S_extra;
- assert(*(size_t*)__real_p == __n);
+ if (*(size_t*)__real_p != __n)
+ abort();
_Alloc::deallocate(__real_p, __n + (int) _S_extra);
}
- // _GLIBCPP_DEPRECATED
static void*
reallocate(void* __p, size_t __old_sz, size_t __new_sz)
{
char* __real_p = (char*)__p - (int) _S_extra;
- assert(*(size_t*)__real_p == __old_sz);
+ if (*(size_t*)__real_p != __old_sz)
+ abort();
char* __result = (char*) _Alloc::reallocate(__real_p,
__old_sz + (int) _S_extra,
__new_sz + (int) _S_extra);
@@ -405,8 +397,6 @@ namespace std
__atomic_add(&_S_force_new, 1);
else
__atomic_add(&_S_force_new, -1);
- // Trust but verify...
- assert(_S_force_new != 0);
}
if ((__n > (size_t) _MAX_BYTES) || (_S_force_new > 0))
@@ -454,7 +444,6 @@ namespace std
}
}
- // _GLIBCPP_DEPRECATED
static void*
reallocate(void* __p, size_t __old_sz, size_t __new_sz);
};
@@ -511,8 +500,8 @@ namespace std
_Obj* volatile* __my_free_list =
_S_free_list + _S_freelist_index(__bytes_left);
- ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
- *__my_free_list = (_Obj*)_S_start_free;
+ ((_Obj*)(void*)_S_start_free) -> _M_free_list_link = *__my_free_list;
+ *__my_free_list = (_Obj*)(void*)_S_start_free;
}
_S_start_free = (char*) __new_alloc::allocate(__bytes_to_get);
if (_S_start_free == 0)
@@ -570,12 +559,12 @@ namespace std
__my_free_list = _S_free_list + _S_freelist_index(__n);
// Build free list in chunk.
- __result = (_Obj*)__chunk;
- *__my_free_list = __next_obj = (_Obj*)(__chunk + __n);
+ __result = (_Obj*)(void*)__chunk;
+ *__my_free_list = __next_obj = (_Obj*)(void*)(__chunk + __n);
for (__i = 1; ; __i++)
{
__current_obj = __next_obj;
- __next_obj = (_Obj*)((char*)__next_obj + __n);
+ __next_obj = (_Obj*)(void*)((char*)__next_obj + __n);
if (__nobjs - 1 == __i)
{
__current_obj -> _M_free_list_link = 0;
@@ -588,7 +577,6 @@ namespace std
}
- // _GLIBCPP_DEPRECATED
template<bool threads, int inst>
void*
__default_alloc_template<threads, inst>::
@@ -976,9 +964,11 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class allocator<char>;
extern template class allocator<wchar_t>;
extern template class __default_alloc_template<true,0>;
+#endif
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/stl_bvector.h b/contrib/libstdc++/include/bits/stl_bvector.h
index ce6df71..2c97d47 100644
--- a/contrib/libstdc++/include/bits/stl_bvector.h
+++ b/contrib/libstdc++/include/bits/stl_bvector.h
@@ -91,13 +91,6 @@ public:
void flip() { *_M_p ^= _M_mask; }
};
-inline void swap(_Bit_reference __x, _Bit_reference __y)
-{
- bool __tmp = __x;
- __x = __y;
- __y = __tmp;
-}
-
struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool>
{
_Bit_type * _M_p;
@@ -363,8 +356,8 @@ template <typename _Alloc>
typedef _Bit_iterator iterator;
typedef _Bit_const_iterator const_iterator;
- typedef reverse_iterator<const_iterator> const_reverse_iterator;
- typedef reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
typedef typename _Bvector_base<_Alloc>::allocator_type allocator_type;
allocator_type get_allocator() const {
@@ -637,6 +630,14 @@ template <typename _Alloc>
std::swap(_M_finish, __x._M_finish);
std::swap(_M_end_of_storage, __x._M_end_of_storage);
}
+
+ // [23.2.5]/1, third-to-last entry in synopsis listing
+ static void swap(reference __x, reference __y) {
+ bool __tmp = __x;
+ __x = __y;
+ __y = __tmp;
+ }
+
iterator insert(iterator __position, bool __x = bool()) {
difference_type __n = __position - begin();
if (_M_finish._M_p != _M_end_of_storage && __position == end())
diff --git a/contrib/libstdc++/include/bits/stl_deque.h b/contrib/libstdc++/include/bits/stl_deque.h
index cbe8779..454fed3 100644
--- a/contrib/libstdc++/include/bits/stl_deque.h
+++ b/contrib/libstdc++/include/bits/stl_deque.h
@@ -1,4 +1,4 @@
-// deque implementation -*- C++ -*-
+// Deque implementation -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
//
@@ -58,1625 +58,1546 @@
* You should not attempt to use it directly.
*/
-#include <bits/concept_check.h>
-#include <bits/stl_iterator_base_types.h>
-#include <bits/stl_iterator_base_funcs.h>
-
#ifndef __GLIBCPP_INTERNAL_DEQUE_H
#define __GLIBCPP_INTERNAL_DEQUE_H
+#include <bits/concept_check.h>
+#include <bits/stl_iterator_base_types.h>
+#include <bits/stl_iterator_base_funcs.h>
-// Since this entire file is within namespace std, there's no reason to
-// waste two spaces along the left column. Thus the leading indentation is
-// slightly violated from here on.
namespace std
{
-
-/**
- * @if maint
- * @brief This function controls the size of memory nodes.
- * @param size The size of an element.
- * @return The number (not bytesize) of elements per node.
- *
- * This function started off as a compiler kludge from SGI, but seems to
- * be a useful wrapper around a repeated constant expression.
- * @endif
-*/
-inline size_t
-__deque_buf_size(size_t __size)
-{ return __size < 512 ? size_t(512 / __size) : size_t(1); }
-
-
-/// A deque::iterator.
-/**
- * Quite a bit of intelligence here. Much of the functionality of deque is
- * actually passed off to this class. A deque holds two of these internally,
- * marking its valid range. Access to elements is done as offsets of either
- * of those two, relying on operator overloading in this class.
- *
- * @if maint
- * All the functions are op overloads except for _M_set_node.
- * @endif
-*/
-template <class _Tp, class _Ref, class _Ptr>
-struct _Deque_iterator
-{
- typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
- typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
- static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }
-
- typedef random_access_iterator_tag iterator_category;
- typedef _Tp value_type;
- typedef _Ptr pointer;
- typedef _Ref reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Tp** _Map_pointer;
- typedef _Deque_iterator _Self;
-
- _Tp* _M_cur;
- _Tp* _M_first;
- _Tp* _M_last;
- _Map_pointer _M_node;
-
- _Deque_iterator(_Tp* __x, _Map_pointer __y)
- : _M_cur(__x), _M_first(*__y),
- _M_last(*__y + _S_buffer_size()), _M_node(__y) {}
- _Deque_iterator() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {}
- _Deque_iterator(const iterator& __x)
- : _M_cur(__x._M_cur), _M_first(__x._M_first),
- _M_last(__x._M_last), _M_node(__x._M_node) {}
-
- reference operator*() const { return *_M_cur; }
- pointer operator->() const { return _M_cur; }
-
- _Self& operator++() {
- ++_M_cur;
- if (_M_cur == _M_last) {
- _M_set_node(_M_node + 1);
- _M_cur = _M_first;
+ /**
+ * @if maint
+ * @brief This function controls the size of memory nodes.
+ * @param size The size of an element.
+ * @return The number (not byte size) of elements per node.
+ *
+ * This function started off as a compiler kludge from SGI, but seems to
+ * be a useful wrapper around a repeated constant expression. The '512' is
+ * tuneable (and no other code needs to change), but no investigation has
+ * been done since inheriting the SGI code.
+ * @endif
+ */
+ inline size_t
+ __deque_buf_size(size_t __size)
+ { return __size < 512 ? size_t(512 / __size) : size_t(1); }
+
+
+ /**
+ * @brief A deque::iterator.
+ *
+ * Quite a bit of intelligence here. Much of the functionality of deque is
+ * actually passed off to this class. A deque holds two of these internally,
+ * marking its valid range. Access to elements is done as offsets of either
+ * of those two, relying on operator overloading in this class.
+ *
+ * @if maint
+ * All the functions are op overloads except for _M_set_node.
+ * @endif
+ */
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ struct _Deque_iterator
+ {
+ typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
+ typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
+ static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }
+
+ typedef random_access_iterator_tag iterator_category;
+ typedef _Tp value_type;
+ typedef _Ptr pointer;
+ typedef _Ref reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp** _Map_pointer;
+ typedef _Deque_iterator _Self;
+
+ _Tp* _M_cur;
+ _Tp* _M_first;
+ _Tp* _M_last;
+ _Map_pointer _M_node;
+
+ _Deque_iterator(_Tp* __x, _Map_pointer __y)
+ : _M_cur(__x), _M_first(*__y),
+ _M_last(*__y + _S_buffer_size()), _M_node(__y) {}
+ _Deque_iterator() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {}
+ _Deque_iterator(const iterator& __x)
+ : _M_cur(__x._M_cur), _M_first(__x._M_first),
+ _M_last(__x._M_last), _M_node(__x._M_node) {}
+
+ reference operator*() const { return *_M_cur; }
+ pointer operator->() const { return _M_cur; }
+
+ _Self& operator++() {
+ ++_M_cur;
+ if (_M_cur == _M_last) {
+ _M_set_node(_M_node + 1);
+ _M_cur = _M_first;
+ }
+ return *this;
+ }
+ _Self operator++(int) {
+ _Self __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _Self& operator--() {
+ if (_M_cur == _M_first) {
+ _M_set_node(_M_node - 1);
+ _M_cur = _M_last;
+ }
+ --_M_cur;
+ return *this;
+ }
+ _Self operator--(int) {
+ _Self __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _Self& operator+=(difference_type __n)
+ {
+ difference_type __offset = __n + (_M_cur - _M_first);
+ if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
+ _M_cur += __n;
+ else {
+ difference_type __node_offset =
+ __offset > 0 ? __offset / difference_type(_S_buffer_size())
+ : -difference_type((-__offset - 1) / _S_buffer_size()) - 1;
+ _M_set_node(_M_node + __node_offset);
+ _M_cur = _M_first +
+ (__offset - __node_offset * difference_type(_S_buffer_size()));
+ }
+ return *this;
+ }
+
+ _Self operator+(difference_type __n) const
+ {
+ _Self __tmp = *this;
+ return __tmp += __n;
+ }
+
+ _Self& operator-=(difference_type __n) { return *this += -__n; }
+
+ _Self operator-(difference_type __n) const {
+ _Self __tmp = *this;
+ return __tmp -= __n;
+ }
+
+ reference operator[](difference_type __n) const { return *(*this + __n); }
+
+ /** @if maint
+ * Prepares to traverse new_node. Sets everything except _M_cur, which
+ * should therefore be set by the caller immediately afterwards, based on
+ * _M_first and _M_last.
+ * @endif
+ */
+ void
+ _M_set_node(_Map_pointer __new_node)
+ {
+ _M_node = __new_node;
+ _M_first = *__new_node;
+ _M_last = _M_first + difference_type(_S_buffer_size());
}
- return *this;
+ };
+
+ // Note: we also provide overloads whose operands are of the same type in
+ // order to avoid ambiguous overload resolution when std::rel_ops operators
+ // are in scope (for additional details, see libstdc++/3628)
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ inline bool
+ operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
+ const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
+ {
+ return __x._M_cur == __y._M_cur;
}
- _Self operator++(int) {
- _Self __tmp = *this;
- ++*this;
- return __tmp;
+
+ template <typename _Tp, typename _RefL, typename _PtrL,
+ typename _RefR, typename _PtrR>
+ inline bool
+ operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
+ const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
+ {
+ return __x._M_cur == __y._M_cur;
}
-
- _Self& operator--() {
- if (_M_cur == _M_first) {
- _M_set_node(_M_node - 1);
- _M_cur = _M_last;
- }
- --_M_cur;
- return *this;
+
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ inline bool
+ operator!=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
+ const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
+ {
+ return !(__x == __y);
}
- _Self operator--(int) {
- _Self __tmp = *this;
- --*this;
- return __tmp;
+
+ template <typename _Tp, typename _RefL, typename _PtrL,
+ typename _RefR, typename _PtrR>
+ inline bool
+ operator!=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
+ const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
+ {
+ return !(__x == __y);
}
-
- _Self& operator+=(difference_type __n)
+
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ inline bool
+ operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
+ const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
{
- difference_type __offset = __n + (_M_cur - _M_first);
- if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
- _M_cur += __n;
- else {
- difference_type __node_offset =
- __offset > 0 ? __offset / difference_type(_S_buffer_size())
- : -difference_type((-__offset - 1) / _S_buffer_size()) - 1;
- _M_set_node(_M_node + __node_offset);
- _M_cur = _M_first +
- (__offset - __node_offset * difference_type(_S_buffer_size()));
- }
- return *this;
+ return (__x._M_node == __y._M_node) ?
+ (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
}
-
- _Self operator+(difference_type __n) const
+
+ template <typename _Tp, typename _RefL, typename _PtrL,
+ typename _RefR, typename _PtrR>
+ inline bool
+ operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
+ const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
{
- _Self __tmp = *this;
- return __tmp += __n;
+ return (__x._M_node == __y._M_node) ?
+ (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
}
-
- _Self& operator-=(difference_type __n) { return *this += -__n; }
-
- _Self operator-(difference_type __n) const {
- _Self __tmp = *this;
- return __tmp -= __n;
+
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ inline bool
+ operator>(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
+ const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
+ {
+ return __y < __x;
}
-
- reference operator[](difference_type __n) const { return *(*this + __n); }
-
- /** @if maint
- * Prepares to traverse new_node. Sets everything except _M_cur, which
- * should therefore be set by the caller immediately afterwards, based on
- * _M_first and _M_last.
- * @endif
- */
- void _M_set_node(_Map_pointer __new_node) {
- _M_node = __new_node;
- _M_first = *__new_node;
- _M_last = _M_first + difference_type(_S_buffer_size());
+
+ template <typename _Tp, typename _RefL, typename _PtrL,
+ typename _RefR, typename _PtrR>
+ inline bool
+ operator>(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
+ const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
+ {
+ return __y < __x;
}
-};
-
-// Note: we also provide overloads whose operands are of the same type in
-// order to avoid ambiguos overload resolution when std::rel_ops operators
-// are in scope (for additional details, see libstdc++/3628)
-template <class _Tp, class _Ref, class _Ptr>
-inline bool
-operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
-{
- return __x._M_cur == __y._M_cur;
-}
-
-template <class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR>
-inline bool
-operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
-{
- return __x._M_cur == __y._M_cur;
-}
-
-template <class _Tp, class _Ref, class _Ptr>
-inline bool
-operator!=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
-{
- return !(__x == __y);
-}
-
-template <class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR>
-inline bool
-operator!=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
-{
- return !(__x == __y);
-}
-
-template <class _Tp, class _Ref, class _Ptr>
-inline bool
-operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
-{
- return (__x._M_node == __y._M_node) ?
- (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
-}
-
-template <class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR>
-inline bool
-operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
-{
- return (__x._M_node == __y._M_node) ?
- (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
-}
-
-template <class _Tp, class _Ref, class _Ptr>
-inline bool
-operator>(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
-{
- return __y < __x;
-}
-
-template <class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR>
-inline bool
-operator>(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
-{
- return __y < __x;
-}
-
-template <class _Tp, class _Ref, class _Ptr>
-inline bool
-operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
-{
- return !(__y < __x);
-}
-
-template <class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR>
-inline bool
-operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
-{
- return !(__y < __x);
-}
-
-template <class _Tp, class _Ref, class _Ptr>
-inline bool
-operator>=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
-{
- return !(__x < __y);
-}
-
-template <class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR>
-inline bool
-operator>=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
-{
- return !(__x < __y);
-}
-
-// _GLIBCPP_RESOLVE_LIB_DEFECTS
-// According to the resolution of DR179 not only the various comparison
-// operators but also operator- must accept mixed iterator/const_iterator
-// parameters.
-template <typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
-inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
-operator-(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
-{
- return _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
- (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size()) *
- (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) +
- (__y._M_last - __y._M_cur);
-}
-
-template <class _Tp, class _Ref, class _Ptr>
-inline _Deque_iterator<_Tp, _Ref, _Ptr>
-operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
-{
- return __x + __n;
-}
-
-
-/// @if maint Primary default version. @endif
-/**
- * @if maint
- * Deque base class. It has two purposes. First, its constructor
- * and destructor allocate (but don't initialize) storage. This makes
- * exception safety easier. Second, the base class encapsulates all of
- * the differences between SGI-style allocators and standard-conforming
- * allocators. There are two versions: this ordinary one, and the
- * space-saving specialization for instanceless allocators.
- * @endif
-*/
-template <class _Tp, class _Alloc, bool __is_static>
-class _Deque_alloc_base
-{
-public:
- typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;
- allocator_type get_allocator() const { return _M_node_allocator; }
-
- _Deque_alloc_base(const allocator_type& __a)
- : _M_node_allocator(__a), _M_map_allocator(__a),
- _M_map(0), _M_map_size(0)
- {}
-
-protected:
- typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type
- _Map_allocator_type;
-
- allocator_type _M_node_allocator;
- _Map_allocator_type _M_map_allocator;
-
- _Tp* _M_allocate_node() {
- return _M_node_allocator.allocate(__deque_buf_size(sizeof(_Tp)));
+
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ inline bool
+ operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
+ const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
+ {
+ return !(__y < __x);
}
- void _M_deallocate_node(_Tp* __p) {
- _M_node_allocator.deallocate(__p, __deque_buf_size(sizeof(_Tp)));
+
+ template <typename _Tp, typename _RefL, typename _PtrL,
+ typename _RefR, typename _PtrR>
+ inline bool
+ operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
+ const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
+ {
+ return !(__y < __x);
}
- _Tp** _M_allocate_map(size_t __n)
- { return _M_map_allocator.allocate(__n); }
- void _M_deallocate_map(_Tp** __p, size_t __n)
- { _M_map_allocator.deallocate(__p, __n); }
-
- _Tp** _M_map;
- size_t _M_map_size;
-};
-
-/// @if maint Specialization for instanceless allocators. @endif
-template <class _Tp, class _Alloc>
-class _Deque_alloc_base<_Tp, _Alloc, true>
-{
-public:
- typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;
- allocator_type get_allocator() const { return allocator_type(); }
-
- _Deque_alloc_base(const allocator_type&) : _M_map(0), _M_map_size(0) {}
-protected:
- typedef typename _Alloc_traits<_Tp, _Alloc>::_Alloc_type _Node_alloc_type;
- typedef typename _Alloc_traits<_Tp*, _Alloc>::_Alloc_type _Map_alloc_type;
-
- _Tp* _M_allocate_node() {
- return _Node_alloc_type::allocate(__deque_buf_size(sizeof(_Tp)));
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ inline bool
+ operator>=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
+ const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
+ {
+ return !(__x < __y);
}
- void _M_deallocate_node(_Tp* __p) {
- _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp)));
+
+ template <typename _Tp, typename _RefL, typename _PtrL,
+ typename _RefR, typename _PtrR>
+ inline bool
+ operator>=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
+ const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
+ {
+ return !(__x < __y);
}
- _Tp** _M_allocate_map(size_t __n)
- { return _Map_alloc_type::allocate(__n); }
- void _M_deallocate_map(_Tp** __p, size_t __n)
- { _Map_alloc_type::deallocate(__p, __n); }
-
- _Tp** _M_map;
- size_t _M_map_size;
-};
-
-
-/**
- * @if maint
- * Deque base class. Using _Alloc_traits in the instantiation of the parent
- * class provides the compile-time dispatching mentioned in the parent's docs.
- * This class provides the unified face for deque's allocation.
- *
- * Nothing in this class ever constructs or destroys an actual Tp element.
- * (Deque handles that itself.) Only/All memory management is performed here.
- * @endif
-*/
-template <class _Tp, class _Alloc>
-class _Deque_base
- : public _Deque_alloc_base<_Tp,_Alloc,
- _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
-{
-public:
- typedef _Deque_alloc_base<_Tp,_Alloc,
- _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
- _Base;
- typedef typename _Base::allocator_type allocator_type;
- typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator;
- typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
-
- _Deque_base(const allocator_type& __a, size_t __num_elements)
- : _Base(__a), _M_start(), _M_finish()
- { _M_initialize_map(__num_elements); }
- _Deque_base(const allocator_type& __a)
- : _Base(__a), _M_start(), _M_finish() {}
- ~_Deque_base();
-
-protected:
- void _M_initialize_map(size_t);
- void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
- void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
- enum { _S_initial_map_size = 8 };
-
-protected:
- iterator _M_start;
- iterator _M_finish;
-};
-
-
-template <class _Tp, class _Alloc>
-_Deque_base<_Tp,_Alloc>::~_Deque_base()
-{
- if (_M_map) {
- _M_destroy_nodes(_M_start._M_node, _M_finish._M_node + 1);
- _M_deallocate_map(_M_map, _M_map_size);
+
+ // _GLIBCPP_RESOLVE_LIB_DEFECTS
+ // According to the resolution of DR179 not only the various comparison
+ // operators but also operator- must accept mixed iterator/const_iterator
+ // parameters.
+ template <typename _Tp, typename _RefL, typename _PtrL,
+ typename _RefR, typename _PtrR>
+ inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
+ operator-(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
+ const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
+ {
+ return _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
+ (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size()) *
+ (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) +
+ (__y._M_last - __y._M_cur);
}
-}
-
-/**
- * @if maint
- * @brief Layout storage.
- * @param num_elements The count of T's for which to allocate space at first.
- * @return Nothing.
- *
- * The initial underlying memory layout is a bit complicated...
- * @endif
-*/
-template <class _Tp, class _Alloc>
-void
-_Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements)
-{
- size_t __num_nodes =
- __num_elements / __deque_buf_size(sizeof(_Tp)) + 1;
-
- _M_map_size = max((size_t) _S_initial_map_size, __num_nodes + 2);
- _M_map = _M_allocate_map(_M_map_size);
-
- _Tp** __nstart = _M_map + (_M_map_size - __num_nodes) / 2;
- _Tp** __nfinish = __nstart + __num_nodes;
-
- try
- { _M_create_nodes(__nstart, __nfinish); }
- catch(...)
- {
- _M_deallocate_map(_M_map, _M_map_size);
- _M_map = 0;
- _M_map_size = 0;
- __throw_exception_again;
- }
- _M_start._M_set_node(__nstart);
- _M_finish._M_set_node(__nfinish - 1);
- _M_start._M_cur = _M_start._M_first;
- _M_finish._M_cur = _M_finish._M_first +
- __num_elements % __deque_buf_size(sizeof(_Tp));
-}
-
-template <class _Tp, class _Alloc>
-void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish)
-{
- _Tp** __cur;
- try {
- for (__cur = __nstart; __cur < __nfinish; ++__cur)
- *__cur = _M_allocate_node();
+ template <typename _Tp, typename _Ref, typename _Ptr>
+ inline _Deque_iterator<_Tp, _Ref, _Ptr>
+ operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
+ {
+ return __x + __n;
}
- catch(...)
- {
- _M_destroy_nodes(__nstart, __cur);
- __throw_exception_again;
- }
-}
-
-template <class _Tp, class _Alloc>
-void
-_Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)
-{
- for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
- _M_deallocate_node(*__n);
-}
-
-
-/**
- * @ingroup Containers
- * @ingroup Sequences
- *
- * Meets the requirements of a <a href="tables.html#65">container</a>, a
- * <a href="tables.html#66">reversible container</a>, and a
- * <a href="tables.html#67">sequence</a>, including the
- * <a href="tables.html#68">optional sequence requirements</a>.
- *
- * Placeholder: see http://www.sgi.com/tech/stl/Deque.html for now.
- *
- * In previous HP/SGI versions of deque, there was an extra template parameter
- * so users could control the node size. This extension turned out to violate
- * the C++ standard (it can be detected using template template parameters),
- * and it was removed.
- *
- * @if maint
- * Here's how a deque<Tp> manages memory. Each deque has 4 members:
- *
- * - Tp** _M_map
- * - size_t _M_map_size
- * - iterator _M_start, _M_finish
- *
- * map_size is at least 8. %map is an array of map_size pointers-to-"nodes".
- * (The name has nothing to do with the std::map class.)
- *
- * A "node" has no specific type name as such, but it is referred to as
- * "node" in this file. It is a simple array-of-Tp. If Tp is very large,
- * there will be one Tp element per node (i.e., an "array" of one).
- * For non-huge Tp's, node size is inversely related to Tp size: the
- * larger the Tp, the fewer Tp's will fit in a node. The goal here is to
- * keep the total size of a node relatively small and constant over different
- * Tp's, to improve allocator efficiency.
- *
- * **** As I write this, the nodes are /not/ allocated using the high-speed
- * memory pool. There are 20 hours left in the year; perhaps I can fix
- * this before 2002.
- *
- * Not every pointer in the %map array will point to a node. If the initial
- * number of elements in the deque is small, the /middle/ %map pointers will
- * be valid, and the ones at the edges will be unused. This same situation
- * will arise as the %map grows: available %map pointers, if any, will be on
- * the ends. As new nodes are created, only a subset of the %map's pointers
- * need to be copied "outward".
- *
- * Class invariants:
- * - For any nonsingular iterator i:
- * - i.node points to a member of the %map array. (Yes, you read that
- * correctly: i.node does not actually point to a node.) The member of
- * the %map array is what actually points to the node.
- * - i.first == *(i.node) (This points to the node (first Tp element).)
- * - i.last == i.first + node_size
- * - i.cur is a pointer in the range [i.first, i.last). NOTE:
- * the implication of this is that i.cur is always a dereferenceable
- * pointer, even if i is a past-the-end iterator.
- * - Start and Finish are always nonsingular iterators. NOTE: this means that
- * an empty deque must have one node, a deque with <N elements (where N is
- * the node buffer size) must have one node, a deque with N through (2N-1)
- * elements must have two nodes, etc.
- * - For every node other than start.node and finish.node, every element in the
- * node is an initialized object. If start.node == finish.node, then
- * [start.cur, finish.cur) are initialized objects, and the elements outside
- * that range are uninitialized storage. Otherwise, [start.cur, start.last)
- * and [finish.first, finish.cur) are initialized objects, and [start.first,
- * start.cur) and [finish.cur, finish.last) are uninitialized storage.
- * - [%map, %map + map_size) is a valid, non-empty range.
- * - [start.node, finish.node] is a valid range contained within
- * [%map, %map + map_size).
- * - A pointer in the range [%map, %map + map_size) points to an allocated node
- * if and only if the pointer is in the range [start.node, finish.node].
- *
- * Here's the magic: nothing in deque is "aware" of the discontiguous storage!
- *
- * The memory setup and layout occurs in the parent, _Base, and the iterator
- * class is entirely responsible for "leaping" from one node to the next. All
- * the implementation routines for deque itself work only through the start
- * and finish iterators. This keeps the routines simple and sane, and we can
- * use other standard algorithms as well.
- * @endif
-*/
-template <class _Tp, class _Alloc = allocator<_Tp> >
-class deque : protected _Deque_base<_Tp, _Alloc>
-{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
-
- typedef _Deque_base<_Tp, _Alloc> _Base;
-
-public:
- typedef _Tp value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
-
- typedef typename _Base::allocator_type allocator_type;
- allocator_type get_allocator() const { return _Base::get_allocator(); }
-
- typedef typename _Base::iterator iterator;
- typedef typename _Base::const_iterator const_iterator;
- typedef reverse_iterator<const_iterator> const_reverse_iterator;
- typedef reverse_iterator<iterator> reverse_iterator;
-
-protected:
- typedef pointer* _Map_pointer;
- static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }
-
- // Functions controlling memory layout, and nothing else.
- using _Base::_M_initialize_map;
- using _Base::_M_create_nodes;
- using _Base::_M_destroy_nodes;
- using _Base::_M_allocate_node;
- using _Base::_M_deallocate_node;
- using _Base::_M_allocate_map;
- using _Base::_M_deallocate_map;
-
- /** @if maint
- * A total of four data members accumulated down the heirarchy. If the
- * _Alloc type requires separate instances, then two of them will also be
- * included in each deque.
+
+
+ /// @if maint Primary default version. @endif
+ /**
+ * @if maint
+ * Deque base class. It has two purposes. First, its constructor
+ * and destructor allocate (but don't initialize) storage. This makes
+ * %exception safety easier. Second, the base class encapsulates all of
+ * the differences between SGI-style allocators and standard-conforming
+ * allocators. (See stl_alloc.h for more on this topic.) There are two
+ * versions: this ordinary one, and the space-saving specialization for
+ * instanceless allocators.
* @endif
*/
- using _Base::_M_map;
- using _Base::_M_map_size;
- using _Base::_M_start;
- using _Base::_M_finish;
-
-public: // Basic accessors
- iterator begin() { return _M_start; }
- iterator end() { return _M_finish; }
- const_iterator begin() const { return _M_start; }
- const_iterator end() const { return _M_finish; }
-
- reverse_iterator rbegin() { return reverse_iterator(_M_finish); }
- reverse_iterator rend() { return reverse_iterator(_M_start); }
- const_reverse_iterator rbegin() const
- { return const_reverse_iterator(_M_finish); }
- const_reverse_iterator rend() const
- { return const_reverse_iterator(_M_start); }
-
- reference operator[](size_type __n)
- { return _M_start[difference_type(__n)]; }
- const_reference operator[](size_type __n) const
- { return _M_start[difference_type(__n)]; }
-
- void _M_range_check(size_type __n) const {
- if (__n >= this->size())
- __throw_out_of_range("deque");
- }
-
- reference at(size_type __n)
- { _M_range_check(__n); return (*this)[__n]; }
- const_reference at(size_type __n) const
- { _M_range_check(__n); return (*this)[__n]; }
-
- reference front() { return *_M_start; }
- reference back() {
- iterator __tmp = _M_finish;
- --__tmp;
- return *__tmp;
- }
- const_reference front() const { return *_M_start; }
- const_reference back() const {
- const_iterator __tmp = _M_finish;
- --__tmp;
- return *__tmp;
- }
-
- size_type size() const { return _M_finish - _M_start; }
- size_type max_size() const { return size_type(-1); }
- bool empty() const { return _M_finish == _M_start; }
-
-public: // Constructor, destructor.
- explicit deque(const allocator_type& __a = allocator_type())
- : _Base(__a, 0) {}
- deque(const deque& __x) : _Base(__x.get_allocator(), __x.size())
- { uninitialized_copy(__x.begin(), __x.end(), _M_start); }
- deque(size_type __n, const value_type& __value,
- const allocator_type& __a = allocator_type()) : _Base(__a, __n)
- { _M_fill_initialize(__value); }
-
- explicit
- deque(size_type __n)
- : _Base(allocator_type(), __n)
- { _M_fill_initialize(value_type()); }
-
- // Check whether it's an integral type. If so, it's not an iterator.
- template<class _InputIterator>
- deque(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type())
- : _Base(__a)
+ template <typename _Tp, typename _Alloc, bool __is_static>
+ class _Deque_alloc_base
+ {
+ public:
+ typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;
+ allocator_type get_allocator() const { return _M_node_allocator; }
+
+ _Deque_alloc_base(const allocator_type& __a)
+ : _M_node_allocator(__a), _M_map_allocator(__a),
+ _M_map(0), _M_map_size(0)
+ {}
+
+ protected:
+ typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type
+ _Map_allocator_type;
+
+ _Tp*
+ _M_allocate_node()
{
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_initialize_dispatch(__first, __last, _Integral());
+ return _M_node_allocator.allocate(__deque_buf_size(sizeof(_Tp)));
}
-
- template<class _Integer>
+
void
- _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
+ _M_deallocate_node(_Tp* __p)
{
- _M_initialize_map(__n);
- _M_fill_initialize(__x);
+ _M_node_allocator.deallocate(__p, __deque_buf_size(sizeof(_Tp)));
}
-
- template<class _InputIter>
+
+ _Tp**
+ _M_allocate_map(size_t __n)
+ { return _M_map_allocator.allocate(__n); }
+
void
- _M_initialize_dispatch(_InputIter __first, _InputIter __last, __false_type)
+ _M_deallocate_map(_Tp** __p, size_t __n)
+ { _M_map_allocator.deallocate(__p, __n); }
+
+ allocator_type _M_node_allocator;
+ _Map_allocator_type _M_map_allocator;
+ _Tp** _M_map;
+ size_t _M_map_size;
+ };
+
+ /// @if maint Specialization for instanceless allocators. @endif
+ template <typename _Tp, typename _Alloc>
+ class _Deque_alloc_base<_Tp, _Alloc, true>
+ {
+ public:
+ typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;
+ allocator_type get_allocator() const { return allocator_type(); }
+
+ _Deque_alloc_base(const allocator_type&)
+ : _M_map(0), _M_map_size(0)
+ {}
+
+ protected:
+ typedef typename _Alloc_traits<_Tp,_Alloc>::_Alloc_type _Node_alloc_type;
+ typedef typename _Alloc_traits<_Tp*,_Alloc>::_Alloc_type _Map_alloc_type;
+
+ _Tp*
+ _M_allocate_node()
{
- typedef typename iterator_traits<_InputIter>::iterator_category _IterCategory;
- _M_range_initialize(__first, __last, _IterCategory());
- }
-
- ~deque()
- { _Destroy(_M_start, _M_finish); }
-
- deque& operator= (const deque& __x) {
- const size_type __len = size();
- if (&__x != this) {
- if (__len >= __x.size())
- erase(copy(__x.begin(), __x.end(), _M_start), _M_finish);
- else {
- const_iterator __mid = __x.begin() + difference_type(__len);
- copy(__x.begin(), __mid, _M_start);
- insert(_M_finish, __mid, __x.end());
- }
- }
- return *this;
- }
-
- void swap(deque& __x) {
- std::swap(_M_start, __x._M_start);
- std::swap(_M_finish, __x._M_finish);
- std::swap(_M_map, __x._M_map);
- std::swap(_M_map_size, __x._M_map_size);
- }
-
-public:
- // assign(), a generalized assignment member function. Two
- // versions: one that takes a count, and one that takes a range.
- // The range version is a member template, so we dispatch on whether
- // or not the type is an integer.
-
- void _M_fill_assign(size_type __n, const _Tp& __val) {
- if (__n > size()) {
- fill(begin(), end(), __val);
- insert(end(), __n - size(), __val);
- }
- else {
- erase(begin() + __n, end());
- fill(begin(), end(), __val);
+ return _Node_alloc_type::allocate(__deque_buf_size(sizeof(_Tp)));
}
- }
-
- void
- assign(size_type __n, const _Tp& __val)
- { _M_fill_assign(__n, __val); }
-
- template<class _InputIterator>
+
void
- assign(_InputIterator __first, _InputIterator __last)
+ _M_deallocate_node(_Tp* __p)
{
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_assign_dispatch(__first, __last, _Integral());
+ _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp)));
}
-
-private: // helper functions for assign()
-
- template<class _Integer>
- void
- _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
- { _M_fill_assign(static_cast<size_type>(__n), static_cast<_Tp>(__val)); }
-
- template<class _InputIterator>
+
+ _Tp**
+ _M_allocate_map(size_t __n)
+ { return _Map_alloc_type::allocate(__n); }
+
void
- _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type)
- {
- typedef typename iterator_traits<_InputIterator>::iterator_category _IterCategory;
- _M_assign_aux(__first, __last, _IterCategory());
- }
-
- template <class _InputIterator>
- void _M_assign_aux(_InputIterator __first, _InputIterator __last,
- input_iterator_tag);
-
- template <class _ForwardIterator>
- void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
- forward_iterator_tag) {
- size_type __len = distance(__first, __last);
- if (__len > size()) {
- _ForwardIterator __mid = __first;
- advance(__mid, size());
- copy(__first, __mid, begin());
- insert(end(), __mid, __last);
- }
- else
- erase(copy(__first, __last, begin()), end());
- }
-
-public: // push_* and pop_*
+ _M_deallocate_map(_Tp** __p, size_t __n)
+ { _Map_alloc_type::deallocate(__p, __n); }
- void
- push_back(const value_type& __t)
- {
- if (_M_finish._M_cur != _M_finish._M_last - 1) {
- _Construct(_M_finish._M_cur, __t);
- ++_M_finish._M_cur;
- }
- else
- _M_push_back_aux(__t);
- }
-
- void
- push_back()
+ _Tp** _M_map;
+ size_t _M_map_size;
+ };
+
+
+ /**
+ * @if maint
+ * Deque base class. Using _Alloc_traits in the instantiation of the parent
+ * class provides the compile-time dispatching mentioned in the parent's
+ * docs. This class provides the unified face for %deque's allocation.
+ *
+ * Nothing in this class ever constructs or destroys an actual Tp element.
+ * (Deque handles that itself.) Only/All memory management is performed
+ * here.
+ * @endif
+ */
+ template <typename _Tp, typename _Alloc>
+ class _Deque_base
+ : public _Deque_alloc_base<_Tp,_Alloc,
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
{
- if (_M_finish._M_cur != _M_finish._M_last - 1) {
- _Construct(_M_finish._M_cur);
- ++_M_finish._M_cur;
- }
- else
- _M_push_back_aux();
- }
-
- void
- push_front(const value_type& __t)
+ public:
+ typedef _Deque_alloc_base<_Tp,_Alloc,
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
+ _Base;
+ typedef typename _Base::allocator_type allocator_type;
+ typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator;
+ typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
+
+ _Deque_base(const allocator_type& __a, size_t __num_elements)
+ : _Base(__a), _M_start(), _M_finish()
+ { _M_initialize_map(__num_elements); }
+ _Deque_base(const allocator_type& __a)
+ : _Base(__a), _M_start(), _M_finish() {}
+ ~_Deque_base();
+
+ protected:
+ void _M_initialize_map(size_t);
+ void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
+ void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
+ enum { _S_initial_map_size = 8 };
+
+ iterator _M_start;
+ iterator _M_finish;
+ };
+
+
+ template <typename _Tp, typename _Alloc>
+ _Deque_base<_Tp,_Alloc>::~_Deque_base()
{
- if (_M_start._M_cur != _M_start._M_first) {
- _Construct(_M_start._M_cur - 1, __t);
- --_M_start._M_cur;
+ if (_M_map)
+ {
+ _M_destroy_nodes(_M_start._M_node, _M_finish._M_node + 1);
+ _M_deallocate_map(_M_map, _M_map_size);
}
- else
- _M_push_front_aux(__t);
}
-
+
+ /**
+ * @if maint
+ * @brief Layout storage.
+ * @param num_elements The count of T's for which to allocate space
+ * at first.
+ * @return Nothing.
+ *
+ * The initial underlying memory layout is a bit complicated...
+ * @endif
+ */
+ template <typename _Tp, typename _Alloc>
void
- push_front()
+ _Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements)
{
- if (_M_start._M_cur != _M_start._M_first) {
- _Construct(_M_start._M_cur - 1);
- --_M_start._M_cur;
- }
- else
- _M_push_front_aux();
+ size_t __num_nodes =
+ __num_elements / __deque_buf_size(sizeof(_Tp)) + 1;
+
+ _M_map_size = max((size_t) _S_initial_map_size, __num_nodes + 2);
+ _M_map = _M_allocate_map(_M_map_size);
+
+ // For "small" maps (needing less than _M_map_size nodes), allocation
+ // starts in the middle elements and grows outwards. So nstart may be the
+ // beginning of _M_map, but for small maps it may be as far in as _M_map+3.
+
+ _Tp** __nstart = _M_map + (_M_map_size - __num_nodes) / 2;
+ _Tp** __nfinish = __nstart + __num_nodes;
+
+ try
+ { _M_create_nodes(__nstart, __nfinish); }
+ catch(...)
+ {
+ _M_deallocate_map(_M_map, _M_map_size);
+ _M_map = 0;
+ _M_map_size = 0;
+ __throw_exception_again;
+ }
+
+ _M_start._M_set_node(__nstart);
+ _M_finish._M_set_node(__nfinish - 1);
+ _M_start._M_cur = _M_start._M_first;
+ _M_finish._M_cur = _M_finish._M_first +
+ __num_elements % __deque_buf_size(sizeof(_Tp));
}
-
-
- void
- pop_back()
+
+ template <typename _Tp, typename _Alloc>
+ void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish)
{
- if (_M_finish._M_cur != _M_finish._M_first) {
- --_M_finish._M_cur;
- _Destroy(_M_finish._M_cur);
- }
- else
- _M_pop_back_aux();
+ _Tp** __cur;
+ try
+ {
+ for (__cur = __nstart; __cur < __nfinish; ++__cur)
+ *__cur = _M_allocate_node();
+ }
+ catch(...)
+ {
+ _M_destroy_nodes(__nstart, __cur);
+ __throw_exception_again;
+ }
}
-
+
+ template <typename _Tp, typename _Alloc>
void
- pop_front()
+ _Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)
{
- if (_M_start._M_cur != _M_start._M_last - 1) {
- _Destroy(_M_start._M_cur);
- ++_M_start._M_cur;
- }
- else
- _M_pop_front_aux();
+ for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
+ _M_deallocate_node(*__n);
}
-
-public: // Insert
-
- iterator
- insert(iterator position, const value_type& __x)
+
+
+ /**
+ * @brief A standard container using fixed-size memory allocation and
+ * constant-time manipulation of elements at either end.
+ *
+ * @ingroup Containers
+ * @ingroup Sequences
+ *
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
+ * <a href="tables.html#66">reversible container</a>, and a
+ * <a href="tables.html#67">sequence</a>, including the
+ * <a href="tables.html#68">optional sequence requirements</a>.
+ *
+ * In previous HP/SGI versions of deque, there was an extra template
+ * parameter so users could control the node size. This extension turned
+ * out to violate the C++ standard (it can be detected using template
+ * template parameters), and it was removed.
+ *
+ * @if maint
+ * Here's how a deque<Tp> manages memory. Each deque has 4 members:
+ *
+ * - Tp** _M_map
+ * - size_t _M_map_size
+ * - iterator _M_start, _M_finish
+ *
+ * map_size is at least 8. %map is an array of map_size pointers-to-"nodes".
+ * (The name %map has nothing to do with the std::map class, and "nodes"
+ * should not be confused with std::list's usage of "node".)
+ *
+ * A "node" has no specific type name as such, but it is referred to as
+ * "node" in this file. It is a simple array-of-Tp. If Tp is very large,
+ * there will be one Tp element per node (i.e., an "array" of one).
+ * For non-huge Tp's, node size is inversely related to Tp size: the
+ * larger the Tp, the fewer Tp's will fit in a node. The goal here is to
+ * keep the total size of a node relatively small and constant over different
+ * Tp's, to improve allocator efficiency.
+ *
+ * **** As I write this, the nodes are /not/ allocated using the high-speed
+ * memory pool. There are 20 hours left in the year; perhaps I can fix
+ * this before 2002.
+ *
+ * Not every pointer in the %map array will point to a node. If the initial
+ * number of elements in the deque is small, the /middle/ %map pointers will
+ * be valid, and the ones at the edges will be unused. This same situation
+ * will arise as the %map grows: available %map pointers, if any, will be on
+ * the ends. As new nodes are created, only a subset of the %map's pointers
+ * need to be copied "outward".
+ *
+ * Class invariants:
+ * - For any nonsingular iterator i:
+ * - i.node points to a member of the %map array. (Yes, you read that
+ * correctly: i.node does not actually point to a node.) The member of
+ * the %map array is what actually points to the node.
+ * - i.first == *(i.node) (This points to the node (first Tp element).)
+ * - i.last == i.first + node_size
+ * - i.cur is a pointer in the range [i.first, i.last). NOTE:
+ * the implication of this is that i.cur is always a dereferenceable
+ * pointer, even if i is a past-the-end iterator.
+ * - Start and Finish are always nonsingular iterators. NOTE: this means that
+ * an empty deque must have one node, a deque with <N elements (where N is
+ * the node buffer size) must have one node, a deque with N through (2N-1)
+ * elements must have two nodes, etc.
+ * - For every node other than start.node and finish.node, every element in
+ * the node is an initialized object. If start.node == finish.node, then
+ * [start.cur, finish.cur) are initialized objects, and the elements outside
+ * that range are uninitialized storage. Otherwise, [start.cur, start.last)
+ * and [finish.first, finish.cur) are initialized objects, and [start.first,
+ * start.cur) and [finish.cur, finish.last) are uninitialized storage.
+ * - [%map, %map + map_size) is a valid, non-empty range.
+ * - [start.node, finish.node] is a valid range contained within
+ * [%map, %map + map_size).
+ * - A pointer in the range [%map, %map + map_size) points to an allocated
+ * node if and only if the pointer is in the range
+ * [start.node, finish.node].
+ *
+ * Here's the magic: nothing in deque is "aware" of the discontiguous
+ * storage!
+ *
+ * The memory setup and layout occurs in the parent, _Base, and the iterator
+ * class is entirely responsible for "leaping" from one node to the next.
+ * All the implementation routines for deque itself work only through the
+ * start and finish iterators. This keeps the routines simple and sane,
+ * and we can use other standard algorithms as well.
+ * @endif
+ */
+ template <typename _Tp, typename _Alloc = allocator<_Tp> >
+ class deque : protected _Deque_base<_Tp, _Alloc>
{
- if (position._M_cur == _M_start._M_cur) {
- push_front(__x);
- return _M_start;
- }
- else if (position._M_cur == _M_finish._M_cur) {
- push_back(__x);
- iterator __tmp = _M_finish;
- --__tmp;
- return __tmp;
- }
- else {
- return _M_insert_aux(position, __x);
- }
- }
-
- iterator
- insert(iterator __position)
- { return insert(__position, value_type()); }
-
- void
- insert(iterator __pos, size_type __n, const value_type& __x)
- { _M_fill_insert(__pos, __n, __x); }
-
- void
- _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
-
- // Check whether it's an integral type. If so, it's not an iterator.
- template<class _InputIterator>
+ // concept requirements
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+
+ typedef _Deque_base<_Tp, _Alloc> _Base;
+
+ public:
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef typename _Base::iterator iterator;
+ typedef typename _Base::const_iterator const_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef typename _Base::allocator_type allocator_type;
+
+ protected:
+ typedef pointer* _Map_pointer;
+ static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }
+
+ // Functions controlling memory layout, and nothing else.
+ using _Base::_M_initialize_map;
+ using _Base::_M_create_nodes;
+ using _Base::_M_destroy_nodes;
+ using _Base::_M_allocate_node;
+ using _Base::_M_deallocate_node;
+ using _Base::_M_allocate_map;
+ using _Base::_M_deallocate_map;
+
+ /** @if maint
+ * A total of four data members accumulated down the heirarchy. If the
+ * _Alloc type requires separate instances, then two of them will also be
+ * included in each deque.
+ * @endif
+ */
+ using _Base::_M_map;
+ using _Base::_M_map_size;
+ using _Base::_M_start;
+ using _Base::_M_finish;
+
+ public:
+ // [23.2.1.1] construct/copy/destroy
+ // (assign() and get_allocator() are also listed in this section)
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ deque(const allocator_type& __a = allocator_type())
+ : _Base(__a, 0) {}
+
+ /**
+ * @brief Create a %deque with copies of an exemplar element.
+ * @param n The number of elements to initially create.
+ * @param value An element to copy.
+ *
+ * This constructor fills the %deque with @a n copies of @a value.
+ */
+ deque(size_type __n, const value_type& __value,
+ const allocator_type& __a = allocator_type())
+ : _Base(__a, __n)
+ { _M_fill_initialize(__value); }
+
+ /**
+ * @brief Create a %deque with default elements.
+ * @param n The number of elements to initially create.
+ *
+ * This constructor fills the %deque with @a n copies of a
+ * default-constructed element.
+ */
+ explicit
+ deque(size_type __n)
+ : _Base(allocator_type(), __n)
+ { _M_fill_initialize(value_type()); }
+
+ /**
+ * @brief %Deque copy constructor.
+ * @param x A %deque of identical element and allocator types.
+ *
+ * The newly-created %deque uses a copy of the allocation object used
+ * by @a x.
+ */
+ deque(const deque& __x)
+ : _Base(__x.get_allocator(), __x.size())
+ { uninitialized_copy(__x.begin(), __x.end(), _M_start); }
+
+ /**
+ * @brief Builds a %deque from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * Create a %deque consisting of copies of the elements from [first,last).
+ *
+ * If the iterators are forward, bidirectional, or random-access, then
+ * this will call the elements' copy constructor N times (where N is
+ * distance(first,last)) and do no memory reallocation. But if only
+ * input iterators are used, then this will do at most 2N calls to the
+ * copy constructor, and logN memory reallocations.
+ */
+ template<typename _InputIterator>
+ deque(_InputIterator __first, _InputIterator __last,
+ const allocator_type& __a = allocator_type())
+ : _Base(__a)
+ {
+ // Check whether it's an integral type. If so, it's not an iterator.
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_initialize_dispatch(__first, __last, _Integral());
+ }
+
+ /**
+ * The dtor only erases the elements, and note that if the elements
+ * themselves are pointers, the pointed-to memory is not touched in any
+ * way. Managing the pointer is the user's responsibilty.
+ */
+ ~deque() { _Destroy(_M_start, _M_finish); }
+
+ /**
+ * @brief %Deque assignment operator.
+ * @param x A %deque of identical element and allocator types.
+ *
+ * All the elements of @a x are copied, but unlike the copy constructor,
+ * the allocator object is not copied.
+ */
+ deque&
+ operator=(const deque& __x);
+
+ /**
+ * @brief Assigns a given value to a %deque.
+ * @param n Number of elements to be assigned.
+ * @param val Value to be assigned.
+ *
+ * This function fills a %deque with @a n copies of the given value.
+ * Note that the assignment completely changes the %deque and that the
+ * resulting %deque's size is the same as the number of elements assigned.
+ * Old data may be lost.
+ */
+ void
+ assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); }
+
+ /**
+ * @brief Assigns a range to a %deque.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * This function fills a %deque with copies of the elements in the
+ * range [first,last).
+ *
+ * Note that the assignment completely changes the %deque and that the
+ * resulting %deque's size is the same as the number of elements assigned.
+ * Old data may be lost.
+ */
+ template<typename _InputIterator>
+ void
+ assign(_InputIterator __first, _InputIterator __last)
+ {
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_assign_dispatch(__first, __last, _Integral());
+ }
+
+ /// Get a copy of the memory allocation object.
+ allocator_type
+ get_allocator() const { return _Base::get_allocator(); }
+
+ // iterators
+ /**
+ * Returns a read/write iterator that points to the first element in the
+ * %deque. Iteration is done in ordinary element order.
+ */
+ iterator
+ begin() { return _M_start; }
+
+ /**
+ * Returns a read-only (constant) iterator that points to the first element
+ * in the %deque. Iteration is done in ordinary element order.
+ */
+ const_iterator
+ begin() const { return _M_start; }
+
+ /**
+ * Returns a read/write iterator that points one past the last element in
+ * the %deque. Iteration is done in ordinary element order.
+ */
+ iterator
+ end() { return _M_finish; }
+
+ /**
+ * Returns a read-only (constant) iterator that points one past the last
+ * element in the %deque. Iteration is done in ordinary element order.
+ */
+ const_iterator
+ end() const { return _M_finish; }
+
+ /**
+ * Returns a read/write reverse iterator that points to the last element in
+ * the %deque. Iteration is done in reverse element order.
+ */
+ reverse_iterator
+ rbegin() { return reverse_iterator(_M_finish); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to the last
+ * element in the %deque. Iteration is done in reverse element order.
+ */
+ const_reverse_iterator
+ rbegin() const { return const_reverse_iterator(_M_finish); }
+
+ /**
+ * Returns a read/write reverse iterator that points to one before the
+ * first element in the %deque. Iteration is done in reverse element
+ * order.
+ */
+ reverse_iterator
+ rend() { return reverse_iterator(_M_start); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to one
+ * before the first element in the %deque. Iteration is done in reverse
+ * element order.
+ */
+ const_reverse_iterator
+ rend() const { return const_reverse_iterator(_M_start); }
+
+ // [23.2.1.2] capacity
+ /** Returns the number of elements in the %deque. */
+ size_type
+ size() const { return _M_finish - _M_start; }
+
+ /** Returns the size() of the largest possible %deque. */
+ size_type
+ max_size() const { return size_type(-1); }
+
+ /**
+ * @brief Resizes the %deque to the specified number of elements.
+ * @param new_size Number of elements the %deque should contain.
+ * @param x Data with which new elements should be populated.
+ *
+ * This function will %resize the %deque to the specified number of
+ * elements. If the number is smaller than the %deque's current size the
+ * %deque is truncated, otherwise the %deque is extended and new elements
+ * are populated with given data.
+ */
void
- insert(iterator __pos, _InputIterator __first, _InputIterator __last)
+ resize(size_type __new_size, const value_type& __x)
{
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_insert_dispatch(__pos, __first, __last, _Integral());
+ const size_type __len = size();
+ if (__new_size < __len)
+ erase(_M_start + __new_size, _M_finish);
+ else
+ insert(_M_finish, __new_size - __len, __x);
}
-
- template<class _Integer>
+
+ /**
+ * @brief Resizes the %deque to the specified number of elements.
+ * @param new_size Number of elements the %deque should contain.
+ *
+ * This function will resize the %deque to the specified number of
+ * elements. If the number is smaller than the %deque's current size the
+ * %deque is truncated, otherwise the %deque is extended and new elements
+ * are default-constructed.
+ */
void
- _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, __true_type)
- { _M_fill_insert(__pos, static_cast<size_type>(__n), static_cast<value_type>(__x)); }
-
- template<class _InputIterator>
+ resize(size_type new_size) { resize(new_size, value_type()); }
+
+ /**
+ * Returns true if the %deque is empty. (Thus begin() would equal end().)
+ */
+ bool empty() const { return _M_finish == _M_start; }
+
+ // element access
+ /**
+ * @brief Subscript access to the data contained in the %deque.
+ * @param n The index of the element for which data should be accessed.
+ * @return Read/write reference to data.
+ *
+ * This operator allows for easy, array-style, data access.
+ * Note that data access with this operator is unchecked and out_of_range
+ * lookups are not defined. (For checked lookups see at().)
+ */
+ reference
+ operator[](size_type __n) { return _M_start[difference_type(__n)]; }
+
+ /**
+ * @brief Subscript access to the data contained in the %deque.
+ * @param n The index of the element for which data should be accessed.
+ * @return Read-only (constant) reference to data.
+ *
+ * This operator allows for easy, array-style, data access.
+ * Note that data access with this operator is unchecked and out_of_range
+ * lookups are not defined. (For checked lookups see at().)
+ */
+ const_reference
+ operator[](size_type __n) const { return _M_start[difference_type(__n)]; }
+
+ protected:
+ /// @if maint Safety check used only from at(). @endif
void
- _M_insert_dispatch(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- __false_type)
+ _M_range_check(size_type __n) const
{
- typedef typename iterator_traits<_InputIterator>::iterator_category _IterCategory;
- insert(__pos, __first, __last, _IterCategory());
- }
-
- void resize(size_type __new_size, const value_type& __x) {
- const size_type __len = size();
- if (__new_size < __len)
- erase(_M_start + __new_size, _M_finish);
- else
- insert(_M_finish, __new_size - __len, __x);
- }
-
- void resize(size_type new_size) { resize(new_size, value_type()); }
-
-public: // Erase
- iterator erase(iterator __pos) {
- iterator __next = __pos;
- ++__next;
- size_type __index = __pos - _M_start;
- if (__index < (size() >> 1)) {
- copy_backward(_M_start, __pos, __next);
- pop_front();
- }
- else {
- copy(__next, _M_finish, __pos);
- pop_back();
- }
- return _M_start + __index;
- }
-
- iterator erase(iterator __first, iterator __last);
- void clear();
-
-protected: // Internal construction/destruction
-
- void _M_fill_initialize(const value_type& __value);
-
- template <class _InputIterator>
- void _M_range_initialize(_InputIterator __first, _InputIterator __last,
- input_iterator_tag);
-
- template <class _ForwardIterator>
- void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
- forward_iterator_tag);
-
-protected: // Internal push_* and pop_*
-
- void _M_push_back_aux(const value_type&);
- void _M_push_back_aux();
- void _M_push_front_aux(const value_type&);
- void _M_push_front_aux();
- void _M_pop_back_aux();
- void _M_pop_front_aux();
-
-protected: // Internal insert functions
-
- template <class _InputIterator>
- void insert(iterator __pos, _InputIterator __first, _InputIterator __last,
- input_iterator_tag);
-
- template <class _ForwardIterator>
- void insert(iterator __pos,
- _ForwardIterator __first, _ForwardIterator __last,
- forward_iterator_tag);
-
- iterator _M_insert_aux(iterator __pos, const value_type& __x);
- iterator _M_insert_aux(iterator __pos);
- void _M_insert_aux(iterator __pos, size_type __n, const value_type& __x);
-
- template <class _ForwardIterator>
- void _M_insert_aux(iterator __pos,
- _ForwardIterator __first, _ForwardIterator __last,
- size_type __n);
-
- iterator _M_reserve_elements_at_front(size_type __n) {
- size_type __vacancies = _M_start._M_cur - _M_start._M_first;
- if (__n > __vacancies)
- _M_new_elements_at_front(__n - __vacancies);
- return _M_start - difference_type(__n);
- }
-
- iterator _M_reserve_elements_at_back(size_type __n) {
- size_type __vacancies = (_M_finish._M_last - _M_finish._M_cur) - 1;
- if (__n > __vacancies)
- _M_new_elements_at_back(__n - __vacancies);
- return _M_finish + difference_type(__n);
- }
-
- void _M_new_elements_at_front(size_type __new_elements);
- void _M_new_elements_at_back(size_type __new_elements);
-
-protected: // Allocation of _M_map and nodes
-
- // Makes sure the _M_map has space for new nodes. Does not actually
- // add the nodes. Can invalidate _M_map pointers. (And consequently,
- // deque iterators.)
-
- void _M_reserve_map_at_back (size_type __nodes_to_add = 1) {
- if (__nodes_to_add + 1 > _M_map_size - (_M_finish._M_node - _M_map))
- _M_reallocate_map(__nodes_to_add, false);
- }
-
- void _M_reserve_map_at_front (size_type __nodes_to_add = 1) {
- if (__nodes_to_add > size_type(_M_start._M_node - _M_map))
- _M_reallocate_map(__nodes_to_add, true);
- }
-
- void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
-};
-
-// Non-inline member functions
-
-template <class _Tp, class _Alloc>
-template <class _InputIter>
-void deque<_Tp, _Alloc>
- ::_M_assign_aux(_InputIter __first, _InputIter __last, input_iterator_tag)
-{
- iterator __cur = begin();
- for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
- *__cur = *__first;
- if (__first == __last)
- erase(__cur, end());
- else
- insert(end(), __first, __last);
-}
-
-template <class _Tp, class _Alloc>
-void deque<_Tp, _Alloc>::_M_fill_insert(iterator __pos,
- size_type __n, const value_type& __x)
-{
- if (__pos._M_cur == _M_start._M_cur) {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- try {
- uninitialized_fill(__new_start, _M_start, __x);
- _M_start = __new_start;
- }
- catch(...)
- {
- _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
- __throw_exception_again;
- }
- }
- else if (__pos._M_cur == _M_finish._M_cur) {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- try {
- uninitialized_fill(_M_finish, __new_finish, __x);
- _M_finish = __new_finish;
- }
- catch(...)
- {
- _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
- __throw_exception_again;
- }
- }
- else
- _M_insert_aux(__pos, __n, __x);
-}
-
-template <class _Tp, class _Alloc>
-typename deque<_Tp,_Alloc>::iterator
-deque<_Tp,_Alloc>::erase(iterator __first, iterator __last)
-{
- if (__first == _M_start && __last == _M_finish) {
- clear();
- return _M_finish;
- }
- else {
- difference_type __n = __last - __first;
- difference_type __elems_before = __first - _M_start;
- if (static_cast<size_type>(__elems_before) < (size() - __n) / 2) {
- copy_backward(_M_start, __first, __last);
- iterator __new_start = _M_start + __n;
- _Destroy(_M_start, __new_start);
- _M_destroy_nodes(_M_start._M_node, __new_start._M_node);
- _M_start = __new_start;
- }
- else {
- copy(__last, _M_finish, __first);
- iterator __new_finish = _M_finish - __n;
- _Destroy(__new_finish, _M_finish);
- _M_destroy_nodes(__new_finish._M_node + 1, _M_finish._M_node + 1);
- _M_finish = __new_finish;
+ if (__n >= this->size())
+ __throw_out_of_range("deque [] access out of range");
}
- return _M_start + __elems_before;
- }
-}
-
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::clear()
-{
- for (_Map_pointer __node = _M_start._M_node + 1;
- __node < _M_finish._M_node;
- ++__node) {
- _Destroy(*__node, *__node + _S_buffer_size());
- _M_deallocate_node(*__node);
- }
-
- if (_M_start._M_node != _M_finish._M_node) {
- _Destroy(_M_start._M_cur, _M_start._M_last);
- _Destroy(_M_finish._M_first, _M_finish._M_cur);
- _M_deallocate_node(_M_finish._M_first);
- }
- else
- _Destroy(_M_start._M_cur, _M_finish._M_cur);
-
- _M_finish = _M_start;
-}
-
-/**
- * @if maint
- * @brief Fills the deque with copies of value.
- * @param value Initial value.
- * @return Nothing.
- * @pre _M_start and _M_finish have already been initialized, but none of the
- * deque's elements have yet been constructed.
- *
- * This function is called only when the user provides an explicit size (with
- * or without an explicit exemplar value).
- * @endif
-*/
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __value)
-{
- _Map_pointer __cur;
- try {
- for (__cur = _M_start._M_node; __cur < _M_finish._M_node; ++__cur)
- uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value);
- uninitialized_fill(_M_finish._M_first, _M_finish._M_cur, __value);
- }
- catch(...)
+
+ public:
+ /**
+ * @brief Provides access to the data contained in the %deque.
+ * @param n The index of the element for which data should be accessed.
+ * @return Read/write reference to data.
+ * @throw std::out_of_range If @a n is an invalid index.
+ *
+ * This function provides for safer data access. The parameter is first
+ * checked that it is in the range of the deque. The function throws
+ * out_of_range if the check fails.
+ */
+ reference
+ at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
+
+ /**
+ * @brief Provides access to the data contained in the %deque.
+ * @param n The index of the element for which data should be accessed.
+ * @return Read-only (constant) reference to data.
+ * @throw std::out_of_range If @a n is an invalid index.
+ *
+ * This function provides for safer data access. The parameter is first
+ * checked that it is in the range of the deque. The function throws
+ * out_of_range if the check fails.
+ */
+ const_reference
+ at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
+
+ /**
+ * Returns a read/write reference to the data at the first element of the
+ * %deque.
+ */
+ reference
+ front() { return *_M_start; }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the first
+ * element of the %deque.
+ */
+ const_reference
+ front() const { return *_M_start; }
+
+ /**
+ * Returns a read/write reference to the data at the last element of the
+ * %deque.
+ */
+ reference
+ back()
{
- _Destroy(_M_start, iterator(*__cur, __cur));
- __throw_exception_again;
+ iterator __tmp = _M_finish;
+ --__tmp;
+ return *__tmp;
}
-}
-
-/** @{
- * @if maint
- * @brief Fills the deque with whatever is in [first,last).
- * @param first An input iterator.
- * @param last An input iterator.
- * @return Nothing.
- *
- * If the iterators are actually forward iterators (or better), then the
- * memory layout can be done all at once. Else we move forward using
- * push_back on each value from the iterator.
- * @endif
-*/
-template <class _Tp, class _Alloc> template <class _InputIterator>
-void deque<_Tp,_Alloc>::_M_range_initialize(_InputIterator __first,
- _InputIterator __last,
- input_iterator_tag)
-{
- _M_initialize_map(0);
- try {
- for ( ; __first != __last; ++__first)
- push_back(*__first);
- }
- catch(...)
+
+ /**
+ * Returns a read-only (constant) reference to the data at the last
+ * element of the %deque.
+ */
+ const_reference
+ back() const
{
- clear();
- __throw_exception_again;
- }
-}
-
-template <class _Tp, class _Alloc> template <class _ForwardIterator>
-void deque<_Tp,_Alloc>::_M_range_initialize(_ForwardIterator __first,
- _ForwardIterator __last,
- forward_iterator_tag)
-{
- size_type __n = distance(__first, __last);
- _M_initialize_map(__n);
-
- _Map_pointer __cur_node;
- try {
- for (__cur_node = _M_start._M_node;
- __cur_node < _M_finish._M_node;
- ++__cur_node) {
- _ForwardIterator __mid = __first;
- advance(__mid, _S_buffer_size());
- uninitialized_copy(__first, __mid, *__cur_node);
- __first = __mid;
+ const_iterator __tmp = _M_finish;
+ --__tmp;
+ return *__tmp;
}
- uninitialized_copy(__first, __last, _M_finish._M_first);
- }
- catch(...)
+
+ // [23.2.1.2] modifiers
+ /**
+ * @brief Add data to the front of the %deque.
+ * @param x Data to be added.
+ *
+ * This is a typical stack operation. The function creates an element at
+ * the front of the %deque and assigns the given data to it. Due to the
+ * nature of a %deque this operation can be done in constant time.
+ */
+ void
+ push_front(const value_type& __x)
{
- _Destroy(_M_start, iterator(*__cur_node, __cur_node));
- __throw_exception_again;
+ if (_M_start._M_cur != _M_start._M_first) {
+ _Construct(_M_start._M_cur - 1, __x);
+ --_M_start._M_cur;
+ }
+ else
+ _M_push_front_aux(__x);
}
-}
-/** @} */
-
-// Called only if _M_finish._M_cur == _M_finish._M_last - 1.
-template <class _Tp, class _Alloc>
-void
-deque<_Tp,_Alloc>::_M_push_back_aux(const value_type& __t)
-{
- value_type __t_copy = __t;
- _M_reserve_map_at_back();
- *(_M_finish._M_node + 1) = _M_allocate_node();
- try {
- _Construct(_M_finish._M_cur, __t_copy);
- _M_finish._M_set_node(_M_finish._M_node + 1);
- _M_finish._M_cur = _M_finish._M_first;
- }
- catch(...)
+
+ #ifdef _GLIBCPP_DEPRECATED
+ /**
+ * @brief Add data to the front of the %deque.
+ *
+ * This is a typical stack operation. The function creates a
+ * default-constructed element at the front of the %deque. Due to the
+ * nature of a %deque this operation can be done in constant time. You
+ * should consider using push_front(value_type()) instead.
+ *
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
+ * c++config.h.
+ */
+ void
+ push_front()
{
- _M_deallocate_node(*(_M_finish._M_node + 1));
- __throw_exception_again;
+ if (_M_start._M_cur != _M_start._M_first) {
+ _Construct(_M_start._M_cur - 1);
+ --_M_start._M_cur;
+ }
+ else
+ _M_push_front_aux();
}
-}
-
-// Called only if _M_finish._M_cur == _M_finish._M_last - 1.
-template <class _Tp, class _Alloc>
-void
-deque<_Tp,_Alloc>::_M_push_back_aux()
-{
- _M_reserve_map_at_back();
- *(_M_finish._M_node + 1) = _M_allocate_node();
- try {
- _Construct(_M_finish._M_cur);
- _M_finish._M_set_node(_M_finish._M_node + 1);
- _M_finish._M_cur = _M_finish._M_first;
- }
- catch(...)
+ #endif
+
+ /**
+ * @brief Add data to the end of the %deque.
+ * @param x Data to be added.
+ *
+ * This is a typical stack operation. The function creates an element at
+ * the end of the %deque and assigns the given data to it. Due to the
+ * nature of a %deque this operation can be done in constant time.
+ */
+ void
+ push_back(const value_type& __x)
{
- _M_deallocate_node(*(_M_finish._M_node + 1));
- __throw_exception_again;
+ if (_M_finish._M_cur != _M_finish._M_last - 1) {
+ _Construct(_M_finish._M_cur, __x);
+ ++_M_finish._M_cur;
+ }
+ else
+ _M_push_back_aux(__x);
}
-}
-
-// Called only if _M_start._M_cur == _M_start._M_first.
-template <class _Tp, class _Alloc>
-void
-deque<_Tp,_Alloc>::_M_push_front_aux(const value_type& __t)
-{
- value_type __t_copy = __t;
- _M_reserve_map_at_front();
- *(_M_start._M_node - 1) = _M_allocate_node();
- try {
- _M_start._M_set_node(_M_start._M_node - 1);
- _M_start._M_cur = _M_start._M_last - 1;
- _Construct(_M_start._M_cur, __t_copy);
- }
- catch(...)
+
+ #ifdef _GLIBCPP_DEPRECATED
+ /**
+ * @brief Add data to the end of the %deque.
+ *
+ * This is a typical stack operation. The function creates a
+ * default-constructed element at the end of the %deque. Due to the nature
+ * of a %deque this operation can be done in constant time. You should
+ * consider using push_back(value_type()) instead.
+ *
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
+ * c++config.h.
+ */
+ void
+ push_back()
{
- ++_M_start;
- _M_deallocate_node(*(_M_start._M_node - 1));
- __throw_exception_again;
+ if (_M_finish._M_cur != _M_finish._M_last - 1) {
+ _Construct(_M_finish._M_cur);
+ ++_M_finish._M_cur;
+ }
+ else
+ _M_push_back_aux();
}
-}
-
-// Called only if _M_start._M_cur == _M_start._M_first.
-template <class _Tp, class _Alloc>
-void
-deque<_Tp,_Alloc>::_M_push_front_aux()
-{
- _M_reserve_map_at_front();
- *(_M_start._M_node - 1) = _M_allocate_node();
- try {
- _M_start._M_set_node(_M_start._M_node - 1);
- _M_start._M_cur = _M_start._M_last - 1;
- _Construct(_M_start._M_cur);
- }
- catch(...)
+ #endif
+
+ /**
+ * @brief Removes first element.
+ *
+ * This is a typical stack operation. It shrinks the %deque by one.
+ *
+ * Note that no data is returned, and if the first element's data is
+ * needed, it should be retrieved before pop_front() is called.
+ */
+ void
+ pop_front()
{
- ++_M_start;
- _M_deallocate_node(*(_M_start._M_node - 1));
- __throw_exception_again;
+ if (_M_start._M_cur != _M_start._M_last - 1) {
+ _Destroy(_M_start._M_cur);
+ ++_M_start._M_cur;
+ }
+ else
+ _M_pop_front_aux();
}
-}
-
-// Called only if _M_finish._M_cur == _M_finish._M_first.
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::_M_pop_back_aux()
-{
- _M_deallocate_node(_M_finish._M_first);
- _M_finish._M_set_node(_M_finish._M_node - 1);
- _M_finish._M_cur = _M_finish._M_last - 1;
- _Destroy(_M_finish._M_cur);
-}
-
-// Called only if _M_start._M_cur == _M_start._M_last - 1. Note that
-// if the deque has at least one element (a precondition for this member
-// function), and if _M_start._M_cur == _M_start._M_last, then the deque
-// must have at least two nodes.
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::_M_pop_front_aux()
-{
- _Destroy(_M_start._M_cur);
- _M_deallocate_node(_M_start._M_first);
- _M_start._M_set_node(_M_start._M_node + 1);
- _M_start._M_cur = _M_start._M_first;
-}
-
-template <class _Tp, class _Alloc> template <class _InputIterator>
-void deque<_Tp,_Alloc>::insert(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- input_iterator_tag)
-{
- copy(__first, __last, inserter(*this, __pos));
-}
-
-template <class _Tp, class _Alloc> template <class _ForwardIterator>
-void
-deque<_Tp,_Alloc>::insert(iterator __pos,
- _ForwardIterator __first, _ForwardIterator __last,
- forward_iterator_tag) {
- size_type __n = distance(__first, __last);
- if (__pos._M_cur == _M_start._M_cur) {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- try {
- uninitialized_copy(__first, __last, __new_start);
- _M_start = __new_start;
+
+ /**
+ * @brief Removes last element.
+ *
+ * This is a typical stack operation. It shrinks the %deque by one.
+ *
+ * Note that no data is returned, and if the last element's data is
+ * needed, it should be retrieved before pop_back() is called.
+ */
+ void
+ pop_back()
+ {
+ if (_M_finish._M_cur != _M_finish._M_first) {
+ --_M_finish._M_cur;
+ _Destroy(_M_finish._M_cur);
+ }
+ else
+ _M_pop_back_aux();
}
- catch(...)
+
+ /**
+ * @brief Inserts given value into %deque before specified iterator.
+ * @param position An iterator into the %deque.
+ * @param x Data to be inserted.
+ * @return An iterator that points to the inserted data.
+ *
+ * This function will insert a copy of the given value before the specified
+ * location.
+ */
+ iterator
+ insert(iterator position, const value_type& __x);
+
+ #ifdef _GLIBCPP_DEPRECATED
+ /**
+ * @brief Inserts an element into the %deque.
+ * @param position An iterator into the %deque.
+ * @return An iterator that points to the inserted element.
+ *
+ * This function will insert a default-constructed element before the
+ * specified location. You should consider using
+ * insert(position,value_type()) instead.
+ *
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
+ * c++config.h.
+ */
+ iterator
+ insert(iterator __position)
+ { return insert(__position, value_type()); }
+ #endif
+
+ /**
+ * @brief Inserts a number of copies of given data into the %deque.
+ * @param position An iterator into the %deque.
+ * @param n Number of elements to be inserted.
+ * @param x Data to be inserted.
+ *
+ * This function will insert a specified number of copies of the given data
+ * before the location specified by @a position.
+ */
+ void
+ insert(iterator __position, size_type __n, const value_type& __x)
+ { _M_fill_insert(__position, __n, __x); }
+
+ /**
+ * @brief Inserts a range into the %deque.
+ * @param pos An iterator into the %deque.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * This function will insert copies of the data in the range [first,last)
+ * into the %deque before the location specified by @a pos. This is
+ * known as "range insert."
+ */
+ template<typename _InputIterator>
+ void
+ insert(iterator __pos, _InputIterator __first, _InputIterator __last)
{
- _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
- __throw_exception_again;
+ // Check whether it's an integral type. If so, it's not an iterator.
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_insert_dispatch(__pos, __first, __last, _Integral());
}
- }
- else if (__pos._M_cur == _M_finish._M_cur) {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- try {
- uninitialized_copy(__first, __last, _M_finish);
- _M_finish = __new_finish;
+
+ /**
+ * @brief Remove element at given position.
+ * @param position Iterator pointing to element to be erased.
+ * @return An iterator pointing to the next element (or end()).
+ *
+ * This function will erase the element at the given position and thus
+ * shorten the %deque by one.
+ *
+ * The user is cautioned that
+ * this function only erases the element, and that if the element is itself
+ * a pointer, the pointed-to memory is not touched in any way. Managing
+ * the pointer is the user's responsibilty.
+ */
+ iterator
+ erase(iterator __position);
+
+ /**
+ * @brief Remove a range of elements.
+ * @param first Iterator pointing to the first element to be erased.
+ * @param last Iterator pointing to one past the last element to be
+ * erased.
+ * @return An iterator pointing to the element pointed to by @a last
+ * prior to erasing (or end()).
+ *
+ * This function will erase the elements in the range [first,last) and
+ * shorten the %deque accordingly.
+ *
+ * The user is cautioned that
+ * this function only erases the elements, and that if the elements
+ * themselves are pointers, the pointed-to memory is not touched in any
+ * way. Managing the pointer is the user's responsibilty.
+ */
+ iterator
+ erase(iterator __first, iterator __last);
+
+ /**
+ * @brief Swaps data with another %deque.
+ * @param x A %deque of the same element and allocator types.
+ *
+ * This exchanges the elements between two deques in constant time.
+ * (Four pointers, so it should be quite fast.)
+ * Note that the global std::swap() function is specialized such that
+ * std::swap(d1,d2) will feed to this function.
+ */
+ void
+ swap(deque& __x)
+ {
+ std::swap(_M_start, __x._M_start);
+ std::swap(_M_finish, __x._M_finish);
+ std::swap(_M_map, __x._M_map);
+ std::swap(_M_map_size, __x._M_map_size);
}
- catch(...)
+
+ /**
+ * Erases all the elements. Note that this function only erases the
+ * elements, and that if the elements themselves are pointers, the
+ * pointed-to memory is not touched in any way. Managing the pointer is
+ * the user's responsibilty.
+ */
+ void clear();
+
+ protected:
+ // Internal constructor functions follow.
+
+ // called by the range constructor to implement [23.1.1]/9
+ template<typename _Integer>
+ void
+ _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{
- _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
- __throw_exception_again;
+ _M_initialize_map(__n);
+ _M_fill_initialize(__x);
}
- }
- else
- _M_insert_aux(__pos, __first, __last, __n);
-}
-
-template <class _Tp, class _Alloc>
-typename deque<_Tp, _Alloc>::iterator
-deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, const value_type& __x)
-{
- difference_type __index = __pos - _M_start;
- value_type __x_copy = __x;
- if (static_cast<size_type>(__index) < size() / 2) {
- push_front(front());
- iterator __front1 = _M_start;
- ++__front1;
- iterator __front2 = __front1;
- ++__front2;
- __pos = _M_start + __index;
- iterator __pos1 = __pos;
- ++__pos1;
- copy(__front2, __pos1, __front1);
- }
- else {
- push_back(back());
- iterator __back1 = _M_finish;
- --__back1;
- iterator __back2 = __back1;
- --__back2;
- __pos = _M_start + __index;
- copy_backward(__pos, __back2, __back1);
- }
- *__pos = __x_copy;
- return __pos;
-}
-
-template <class _Tp, class _Alloc>
-typename deque<_Tp,_Alloc>::iterator
-deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos)
-{
- difference_type __index = __pos - _M_start;
- if (static_cast<size_type>(__index) < size() / 2) {
- push_front(front());
- iterator __front1 = _M_start;
- ++__front1;
- iterator __front2 = __front1;
- ++__front2;
- __pos = _M_start + __index;
- iterator __pos1 = __pos;
- ++__pos1;
- copy(__front2, __pos1, __front1);
- }
- else {
- push_back(back());
- iterator __back1 = _M_finish;
- --__back1;
- iterator __back2 = __back1;
- --__back2;
- __pos = _M_start + __index;
- copy_backward(__pos, __back2, __back1);
- }
- *__pos = value_type();
- return __pos;
-}
-
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
- size_type __n,
- const value_type& __x)
-{
- const difference_type __elems_before = __pos - _M_start;
- size_type __length = this->size();
- value_type __x_copy = __x;
- if (__elems_before < difference_type(__length / 2)) {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- iterator __old_start = _M_start;
- __pos = _M_start + __elems_before;
- try {
- if (__elems_before >= difference_type(__n)) {
- iterator __start_n = _M_start + difference_type(__n);
- uninitialized_copy(_M_start, __start_n, __new_start);
- _M_start = __new_start;
- copy(__start_n, __pos, __old_start);
- fill(__pos - difference_type(__n), __pos, __x_copy);
- }
- else {
- __uninitialized_copy_fill(_M_start, __pos, __new_start,
- _M_start, __x_copy);
- _M_start = __new_start;
- fill(__old_start, __pos, __x_copy);
- }
- }
- catch(...)
- {
- _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
- __throw_exception_again;
+
+ // called by the range constructor to implement [23.1.1]/9
+ template<typename _InputIter>
+ void
+ _M_initialize_dispatch(_InputIter __first, _InputIter __last,
+ __false_type)
+ {
+ typedef typename iterator_traits<_InputIter>::iterator_category
+ _IterCategory;
+ _M_range_initialize(__first, __last, _IterCategory());
}
- }
- else {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- iterator __old_finish = _M_finish;
- const difference_type __elems_after =
- difference_type(__length) - __elems_before;
- __pos = _M_finish - __elems_after;
- try {
- if (__elems_after > difference_type(__n)) {
- iterator __finish_n = _M_finish - difference_type(__n);
- uninitialized_copy(__finish_n, _M_finish, _M_finish);
- _M_finish = __new_finish;
- copy_backward(__pos, __finish_n, __old_finish);
- fill(__pos, __pos + difference_type(__n), __x_copy);
+
+ // called by the second initialize_dispatch above
+ //@{
+ /**
+ * @if maint
+ * @brief Fills the deque with whatever is in [first,last).
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @return Nothing.
+ *
+ * If the iterators are actually forward iterators (or better), then the
+ * memory layout can be done all at once. Else we move forward using
+ * push_back on each value from the iterator.
+ * @endif
+ */
+ template <typename _InputIterator>
+ void
+ _M_range_initialize(_InputIterator __first, _InputIterator __last,
+ input_iterator_tag);
+
+ // called by the second initialize_dispatch above
+ template <typename _ForwardIterator>
+ void
+ _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
+ forward_iterator_tag);
+ //@}
+
+ /**
+ * @if maint
+ * @brief Fills the %deque with copies of value.
+ * @param value Initial value.
+ * @return Nothing.
+ * @pre _M_start and _M_finish have already been initialized, but none of
+ * the %deque's elements have yet been constructed.
+ *
+ * This function is called only when the user provides an explicit size
+ * (with or without an explicit exemplar value).
+ * @endif
+ */
+ void
+ _M_fill_initialize(const value_type& __value);
+
+
+ // Internal assign functions follow. The *_aux functions do the actual
+ // assignment work for the range versions.
+
+ // called by the range assign to implement [23.1.1]/9
+ template<typename _Integer>
+ void
+ _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
+ {
+ _M_fill_assign(static_cast<size_type>(__n),
+ static_cast<value_type>(__val));
}
- else {
- __uninitialized_fill_copy(_M_finish, __pos + difference_type(__n),
- __x_copy, __pos, _M_finish);
- _M_finish = __new_finish;
- fill(__pos, __old_finish, __x_copy);
+
+ // called by the range assign to implement [23.1.1]/9
+ template<typename _InputIter>
+ void
+ _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type)
+ {
+ typedef typename iterator_traits<_InputIter>::iterator_category
+ _IterCategory;
+ _M_assign_aux(__first, __last, _IterCategory());
}
- }
- catch(...)
- {
- _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
- __throw_exception_again;
+
+ // called by the second assign_dispatch above
+ template <typename _InputIterator>
+ void
+ _M_assign_aux(_InputIterator __first, _InputIterator __last,
+ input_iterator_tag);
+
+ // called by the second assign_dispatch above
+ template <typename _ForwardIterator>
+ void
+ _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
+ forward_iterator_tag)
+ {
+ size_type __len = distance(__first, __last);
+ if (__len > size()) {
+ _ForwardIterator __mid = __first;
+ advance(__mid, size());
+ copy(__first, __mid, begin());
+ insert(end(), __mid, __last);
+ }
+ else
+ erase(copy(__first, __last, begin()), end());
}
- }
-}
-
-template <class _Tp, class _Alloc> template <class _ForwardIterator>
-void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
- _ForwardIterator __first,
- _ForwardIterator __last,
- size_type __n)
-{
- const difference_type __elemsbefore = __pos - _M_start;
- size_type __length = size();
- if (static_cast<size_type>(__elemsbefore) < __length / 2) {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- iterator __old_start = _M_start;
- __pos = _M_start + __elemsbefore;
- try {
- if (__elemsbefore >= difference_type(__n)) {
- iterator __start_n = _M_start + difference_type(__n);
- uninitialized_copy(_M_start, __start_n, __new_start);
- _M_start = __new_start;
- copy(__start_n, __pos, __old_start);
- copy(__first, __last, __pos - difference_type(__n));
+
+ // Called by assign(n,t), and the range assign when it turns out to be the
+ // same thing.
+ void
+ _M_fill_assign(size_type __n, const value_type& __val)
+ {
+ if (__n > size())
+ {
+ fill(begin(), end(), __val);
+ insert(end(), __n - size(), __val);
}
- else {
- _ForwardIterator __mid = __first;
- advance(__mid, difference_type(__n) - __elemsbefore);
- __uninitialized_copy_copy(_M_start, __pos, __first, __mid,
- __new_start);
- _M_start = __new_start;
- copy(__mid, __last, __old_start);
+ else
+ {
+ erase(begin() + __n, end());
+ fill(begin(), end(), __val);
}
}
- catch(...)
+
+
+ //@{
+ /**
+ * @if maint
+ * @brief Helper functions for push_* and pop_*.
+ * @endif
+ */
+ void _M_push_back_aux(const value_type&);
+ void _M_push_front_aux(const value_type&);
+ #ifdef _GLIBCPP_DEPRECATED
+ void _M_push_back_aux();
+ void _M_push_front_aux();
+ #endif
+ void _M_pop_back_aux();
+ void _M_pop_front_aux();
+ //@}
+
+
+ // Internal insert functions follow. The *_aux functions do the actual
+ // insertion work when all shortcuts fail.
+
+ // called by the range insert to implement [23.1.1]/9
+ template<typename _Integer>
+ void
+ _M_insert_dispatch(iterator __pos,
+ _Integer __n, _Integer __x, __true_type)
{
- _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
- __throw_exception_again;
- }
- }
- else {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- iterator __old_finish = _M_finish;
- const difference_type __elemsafter =
- difference_type(__length) - __elemsbefore;
- __pos = _M_finish - __elemsafter;
- try {
- if (__elemsafter > difference_type(__n)) {
- iterator __finish_n = _M_finish - difference_type(__n);
- uninitialized_copy(__finish_n, _M_finish, _M_finish);
- _M_finish = __new_finish;
- copy_backward(__pos, __finish_n, __old_finish);
- copy(__first, __last, __pos);
- }
- else {
- _ForwardIterator __mid = __first;
- advance(__mid, __elemsafter);
- __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish);
- _M_finish = __new_finish;
- copy(__first, __mid, __pos);
+ _M_fill_insert(__pos, static_cast<size_type>(__n),
+ static_cast<value_type>(__x));
}
- }
- catch(...)
+
+ // called by the range insert to implement [23.1.1]/9
+ template<typename _InputIterator>
+ void
+ _M_insert_dispatch(iterator __pos,
+ _InputIterator __first, _InputIterator __last,
+ __false_type)
{
- _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
- __throw_exception_again;
+ typedef typename iterator_traits<_InputIterator>::iterator_category
+ _IterCategory;
+ _M_range_insert_aux(__pos, __first, __last, _IterCategory());
}
+
+ // called by the second insert_dispatch above
+ template <typename _InputIterator>
+ void
+ _M_range_insert_aux(iterator __pos, _InputIterator __first,
+ _InputIterator __last, input_iterator_tag);
+
+ // called by the second insert_dispatch above
+ template <typename _ForwardIterator>
+ void
+ _M_range_insert_aux(iterator __pos, _ForwardIterator __first,
+ _ForwardIterator __last, forward_iterator_tag);
+
+ // Called by insert(p,n,x), and the range insert when it turns out to be
+ // the same thing. Can use fill functions in optimal situations, otherwise
+ // passes off to insert_aux(p,n,x).
+ void
+ _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
+
+ // called by insert(p,x)
+ iterator
+ _M_insert_aux(iterator __pos, const value_type& __x);
+
+ // called by insert(p,n,x) via fill_insert
+ void
+ _M_insert_aux(iterator __pos, size_type __n, const value_type& __x);
+
+ // called by range_insert_aux for forward iterators
+ template <typename _ForwardIterator>
+ void
+ _M_insert_aux(iterator __pos,
+ _ForwardIterator __first, _ForwardIterator __last,
+ size_type __n);
+
+ #ifdef _GLIBCPP_DEPRECATED
+ // unused, see comment in implementation
+ iterator _M_insert_aux(iterator __pos);
+ #endif
+
+ //@{
+ /**
+ * @if maint
+ * @brief Memory-handling helpers for the previous internal insert
+ * functions.
+ * @endif
+ */
+ iterator
+ _M_reserve_elements_at_front(size_type __n)
+ {
+ size_type __vacancies = _M_start._M_cur - _M_start._M_first;
+ if (__n > __vacancies)
+ _M_new_elements_at_front(__n - __vacancies);
+ return _M_start - difference_type(__n);
+ }
+
+ iterator
+ _M_reserve_elements_at_back(size_type __n)
+ {
+ size_type __vacancies = (_M_finish._M_last - _M_finish._M_cur) - 1;
+ if (__n > __vacancies)
+ _M_new_elements_at_back(__n - __vacancies);
+ return _M_finish + difference_type(__n);
+ }
+
+ void
+ _M_new_elements_at_front(size_type __new_elements);
+
+ void
+ _M_new_elements_at_back(size_type __new_elements);
+ //@}
+
+
+ //@{
+ /**
+ * @if maint
+ * @brief Memory-handling helpers for the major %map.
+ *
+ * Makes sure the _M_map has space for new nodes. Does not actually add
+ * the nodes. Can invalidate _M_map pointers. (And consequently, %deque
+ * iterators.)
+ * @endif
+ */
+ void
+ _M_reserve_map_at_back (size_type __nodes_to_add = 1)
+ {
+ if (__nodes_to_add + 1 > _M_map_size - (_M_finish._M_node - _M_map))
+ _M_reallocate_map(__nodes_to_add, false);
+ }
+
+ void
+ _M_reserve_map_at_front (size_type __nodes_to_add = 1)
+ {
+ if (__nodes_to_add > size_type(_M_start._M_node - _M_map))
+ _M_reallocate_map(__nodes_to_add, true);
+ }
+
+ void
+ _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
+ //@}
+ };
+
+
+ /**
+ * @brief Deque equality comparison.
+ * @param x A %deque.
+ * @param y A %deque of the same type as @a x.
+ * @return True iff the size and elements of the deques are equal.
+ *
+ * This is an equivalence relation. It is linear in the size of the
+ * deques. Deques are considered equivalent if their sizes are equal,
+ * and if corresponding elements compare equal.
+ */
+ template <typename _Tp, typename _Alloc>
+ inline bool operator==(const deque<_Tp, _Alloc>& __x,
+ const deque<_Tp, _Alloc>& __y)
+ {
+ return __x.size() == __y.size() &&
+ equal(__x.begin(), __x.end(), __y.begin());
}
-}
-
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems)
-{
- size_type __new_nodes
- = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
- _M_reserve_map_at_front(__new_nodes);
- size_type __i;
- try {
- for (__i = 1; __i <= __new_nodes; ++__i)
- *(_M_start._M_node - __i) = _M_allocate_node();
+
+ /**
+ * @brief Deque ordering relation.
+ * @param x A %deque.
+ * @param y A %deque of the same type as @a x.
+ * @return True iff @a x is lexographically less than @a y.
+ *
+ * This is a total ordering relation. It is linear in the size of the
+ * deques. The elements must be comparable with @c <.
+ *
+ * See std::lexographical_compare() for how the determination is made.
+ */
+ template <typename _Tp, typename _Alloc>
+ inline bool operator<(const deque<_Tp, _Alloc>& __x,
+ const deque<_Tp, _Alloc>& __y)
+ {
+ return lexicographical_compare(__x.begin(), __x.end(),
+ __y.begin(), __y.end());
}
- catch(...) {
- for (size_type __j = 1; __j < __i; ++__j)
- _M_deallocate_node(*(_M_start._M_node - __j));
- __throw_exception_again;
+
+ /// Based on operator==
+ template <typename _Tp, typename _Alloc>
+ inline bool operator!=(const deque<_Tp, _Alloc>& __x,
+ const deque<_Tp, _Alloc>& __y) {
+ return !(__x == __y);
}
-}
-
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems)
-{
- size_type __new_nodes
- = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
- _M_reserve_map_at_back(__new_nodes);
- size_type __i;
- try {
- for (__i = 1; __i <= __new_nodes; ++__i)
- *(_M_finish._M_node + __i) = _M_allocate_node();
+
+ /// Based on operator<
+ template <typename _Tp, typename _Alloc>
+ inline bool operator>(const deque<_Tp, _Alloc>& __x,
+ const deque<_Tp, _Alloc>& __y) {
+ return __y < __x;
}
- catch(...) {
- for (size_type __j = 1; __j < __i; ++__j)
- _M_deallocate_node(*(_M_finish._M_node + __j));
- __throw_exception_again;
+
+ /// Based on operator<
+ template <typename _Tp, typename _Alloc>
+ inline bool operator<=(const deque<_Tp, _Alloc>& __x,
+ const deque<_Tp, _Alloc>& __y) {
+ return !(__y < __x);
}
-}
-
-template <class _Tp, class _Alloc>
-void deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add,
- bool __add_at_front)
-{
- size_type __old_num_nodes = _M_finish._M_node - _M_start._M_node + 1;
- size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
-
- _Map_pointer __new_nstart;
- if (_M_map_size > 2 * __new_num_nodes) {
- __new_nstart = _M_map + (_M_map_size - __new_num_nodes) / 2
- + (__add_at_front ? __nodes_to_add : 0);
- if (__new_nstart < _M_start._M_node)
- copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);
- else
- copy_backward(_M_start._M_node, _M_finish._M_node + 1,
- __new_nstart + __old_num_nodes);
+
+ /// Based on operator<
+ template <typename _Tp, typename _Alloc>
+ inline bool operator>=(const deque<_Tp, _Alloc>& __x,
+ const deque<_Tp, _Alloc>& __y) {
+ return !(__x < __y);
}
- else {
- size_type __new_map_size =
- _M_map_size + max(_M_map_size, __nodes_to_add) + 2;
-
- _Map_pointer __new_map = _M_allocate_map(__new_map_size);
- __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
- + (__add_at_front ? __nodes_to_add : 0);
- copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);
- _M_deallocate_map(_M_map, _M_map_size);
-
- _M_map = __new_map;
- _M_map_size = __new_map_size;
+
+ /// See std::deque::swap().
+ template <typename _Tp, typename _Alloc>
+ inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
+ {
+ __x.swap(__y);
}
-
- _M_start._M_set_node(__new_nstart);
- _M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
-}
-
-
-// Nonmember functions.
-
-template <class _Tp, class _Alloc>
-inline bool operator==(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y) {
- return __x.size() == __y.size() &&
- equal(__x.begin(), __x.end(), __y.begin());
-}
-
-template <class _Tp, class _Alloc>
-inline bool operator<(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y) {
- return lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end());
-}
-
-template <class _Tp, class _Alloc>
-inline bool operator!=(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y) {
- return !(__x == __y);
-}
-
-template <class _Tp, class _Alloc>
-inline bool operator>(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y) {
- return __y < __x;
-}
-
-template <class _Tp, class _Alloc>
-inline bool operator<=(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y) {
- return !(__y < __x);
-}
-template <class _Tp, class _Alloc>
-inline bool operator>=(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y) {
- return !(__x < __y);
-}
-
-template <class _Tp, class _Alloc>
-inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) {
- __x.swap(__y);
-}
-
} // namespace std
#endif /* __GLIBCPP_INTERNAL_DEQUE_H */
-
diff --git a/contrib/libstdc++/include/bits/stl_iterator.h b/contrib/libstdc++/include/bits/stl_iterator.h
index 6fb0d81..529ad77 100644
--- a/contrib/libstdc++/include/bits/stl_iterator.h
+++ b/contrib/libstdc++/include/bits/stl_iterator.h
@@ -106,9 +106,12 @@ namespace std
public:
/**
- * The default constructor gives an undefined state to this %iterator.
+ * The default constructor default-initializes member @p current.
+ * If it is a pointer, that means it is zero-initialized.
*/
- reverse_iterator() { }
+ // _GLIBCPP_RESOLVE_LIB_DEFECTS
+ // 235 No specification of default ctor for reverse_iterator
+ reverse_iterator() : current() { }
/**
* This %iterator will move in the opposite direction that @p x does.
@@ -317,6 +320,8 @@ namespace std
// 24.4.2.2.1 back_insert_iterator
/**
+ * @brief Turns assignment into insertion.
+ *
* These are output iterators, constructed from a container-of-T.
* Assigning a T to the iterator appends it to the container using
* push_back.
@@ -387,6 +392,8 @@ namespace std
{ return back_insert_iterator<_Container>(__x); }
/**
+ * @brief Turns assignment into insertion.
+ *
* These are output iterators, constructed from a container-of-T.
* Assigning a T to the iterator prepends it to the container using
* push_front.
@@ -456,6 +463,8 @@ namespace std
{ return front_insert_iterator<_Container>(__x); }
/**
+ * @brief Turns assignment into insertion.
+ *
* These are output iterators, constructed from a container-of-T.
* Assigning a T to the iterator inserts it in the container at the
* %iterator's position, rather than overwriting the value at that
diff --git a/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h b/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h
index 8389f5e..7c245d0 100644
--- a/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h
+++ b/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h
@@ -67,113 +67,105 @@
#pragma GCC system_header
#include <bits/concept_check.h>
-// Since this entire file is within namespace std, there's no reason to
-// waste two spaces along the left column. Thus the leading indentation is
-// slightly violated from here on.
namespace std
{
-template<typename _InputIterator>
- inline typename iterator_traits<_InputIterator>::difference_type
- __distance(_InputIterator __first, _InputIterator __last, input_iterator_tag)
- {
- // concept requirements
- __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>)
-
- typename iterator_traits<_InputIterator>::difference_type __n = 0;
- while (__first != __last) {
- ++__first; ++__n;
+ template<typename _InputIterator>
+ inline typename iterator_traits<_InputIterator>::difference_type
+ __distance(_InputIterator __first, _InputIterator __last,
+ input_iterator_tag)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>)
+
+ typename iterator_traits<_InputIterator>::difference_type __n = 0;
+ while (__first != __last) {
+ ++__first; ++__n;
+ }
+ return __n;
}
- return __n;
- }
-
-template<typename _RandomAccessIterator>
- inline typename iterator_traits<_RandomAccessIterator>::difference_type
- __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
- random_access_iterator_tag)
- {
- // concept requirements
- __glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
- return __last - __first;
- }
-
-/**
- * @brief A generalization of pointer arithmetic.
- * @param first An input iterator.
- * @param last An input iterator.
- * @return The distance between them.
- *
- * Returns @c n such that first + n == last. This requires that @p last
- * must be reachable from @p first. Note that @c n may be negative.
- *
- * For random access iterators, this uses their @c + and @c - operations
- * and are constant time. For other %iterator classes they are linear time.
-*/
-template<typename _InputIterator>
- inline typename iterator_traits<_InputIterator>::difference_type
- distance(_InputIterator __first, _InputIterator __last)
- {
- // concept requirements -- taken care of in __distance
- return __distance(__first, __last, __iterator_category(__first));
- }
-
-template<typename _InputIter, typename _Distance>
- inline void
- __advance(_InputIter& __i, _Distance __n, input_iterator_tag)
- {
- // concept requirements
- __glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
- while (__n--) ++__i;
- }
-
-template<typename _BidirectionalIterator, typename _Distance>
- inline void
- __advance(_BidirectionalIterator& __i, _Distance __n,
- bidirectional_iterator_tag)
- {
- // concept requirements
- __glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>)
-
- if (__n > 0)
+
+ template<typename _RandomAccessIterator>
+ inline typename iterator_traits<_RandomAccessIterator>::difference_type
+ __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
+ random_access_iterator_tag)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
+ return __last - __first;
+ }
+
+ /**
+ * @brief A generalization of pointer arithmetic.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @return The distance between them.
+ *
+ * Returns @c n such that first + n == last. This requires that @p last
+ * must be reachable from @p first. Note that @c n may be negative.
+ *
+ * For random access iterators, this uses their @c + and @c - operations
+ * and are constant time. For other %iterator classes they are linear time.
+ */
+ template<typename _InputIterator>
+ inline typename iterator_traits<_InputIterator>::difference_type
+ distance(_InputIterator __first, _InputIterator __last)
+ {
+ // concept requirements -- taken care of in __distance
+ return __distance(__first, __last, __iterator_category(__first));
+ }
+
+ template<typename _InputIter, typename _Distance>
+ inline void
+ __advance(_InputIter& __i, _Distance __n, input_iterator_tag)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
while (__n--) ++__i;
- else
- while (__n++) --__i;
- }
-
-template<typename _RandomAccessIterator, typename _Distance>
- inline void
- __advance(_RandomAccessIterator& __i, _Distance __n,
- random_access_iterator_tag)
- {
- // concept requirements
- __glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
- __i += __n;
- }
-
-/**
- * @brief A generalization of pointer arithmetic.
- * @param i An input iterator.
- * @param n The "delta" by which to change @p i.
- * @return Nothing.
- *
- * This increments @p i by @p n. For bidirectional and random access
- * iterators, @p n may be negative, in which case @p i is decremented.
- *
- * For random access iterators, this uses their @c + and @c - operations
- * and are constant time. For other %iterator classes they are linear time.
-*/
-template<typename _InputIterator, typename _Distance>
- inline void
- advance(_InputIterator& __i, _Distance __n)
- {
- // concept requirements -- taken care of in __advance
- __advance(__i, __n, __iterator_category(__i));
- }
-
+ }
+
+ template<typename _BidirectionalIterator, typename _Distance>
+ inline void
+ __advance(_BidirectionalIterator& __i, _Distance __n,
+ bidirectional_iterator_tag)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>)
+
+ if (__n > 0)
+ while (__n--) ++__i;
+ else
+ while (__n++) --__i;
+ }
+
+ template<typename _RandomAccessIterator, typename _Distance>
+ inline void
+ __advance(_RandomAccessIterator& __i, _Distance __n,
+ random_access_iterator_tag)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
+ __i += __n;
+ }
+
+ /**
+ * @brief A generalization of pointer arithmetic.
+ * @param i An input iterator.
+ * @param n The "delta" by which to change @p i.
+ * @return Nothing.
+ *
+ * This increments @p i by @p n. For bidirectional and random access
+ * iterators, @p n may be negative, in which case @p i is decremented.
+ *
+ * For random access iterators, this uses their @c + and @c - operations
+ * and are constant time. For other %iterator classes they are linear time.
+ */
+ template<typename _InputIterator, typename _Distance>
+ inline void
+ advance(_InputIterator& __i, _Distance __n)
+ {
+ // concept requirements -- taken care of in __advance
+ __advance(__i, __n, __iterator_category(__i));
+ }
} // namespace std
#endif /* __GLIBCPP_INTERNAL_ITERATOR_BASE_FUNCS_H */
-
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/bits/stl_iterator_base_types.h b/contrib/libstdc++/include/bits/stl_iterator_base_types.h
index 5dff8fc..8b040e4 100644
--- a/contrib/libstdc++/include/bits/stl_iterator_base_types.h
+++ b/contrib/libstdc++/include/bits/stl_iterator_base_types.h
@@ -68,13 +68,13 @@
namespace std
{
+ //@{
/**
* @defgroup iterator_tags Iterator Tags
* These are empty types, used to distinguish different iterators. The
* distinction is not made by what they contain, but simply by what they
* are. Different underlying algorithms can then be used based on the
* different operations supporetd by different iterator types.
- * @{
*/
/// Marking input iterators.
struct input_iterator_tag {};
@@ -90,6 +90,8 @@ namespace std
/**
+ * @brief Common %iterator class.
+ *
* This class does nothing but define nested typedefs. %Iterator classes
* can inherit from this class to save some work. The typedefs are then
* used in specializations and overloading.
@@ -98,8 +100,9 @@ namespace std
* such as @c operator++ and the like. (How could there be?)
*/
template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
- typename _Pointer = _Tp*, typename _Reference = _Tp&>
- struct iterator {
+ typename _Pointer = _Tp*, typename _Reference = _Tp&>
+ struct iterator
+ {
/// One of the @link iterator_tags tag types@endlink.
typedef _Category iterator_category;
/// The type "pointed to" by the iterator.
diff --git a/contrib/libstdc++/include/bits/stl_list.h b/contrib/libstdc++/include/bits/stl_list.h
index 3d470b1..fcba359 100644
--- a/contrib/libstdc++/include/bits/stl_list.h
+++ b/contrib/libstdc++/include/bits/stl_list.h
@@ -65,215 +65,263 @@
namespace std
{
-
+ // Supporting structures are split into common and templated types; the
+ // latter publicly inherits from the former in an effort to reduce code
+ // duplication. This results in some "needless" static_cast'ing later on,
+ // but it's all safe downcasting.
+
+ /// @if maint Common part of a node in the %list. @endif
struct _List_node_base
{
- _List_node_base* _M_next;
- _List_node_base* _M_prev;
+ _List_node_base* _M_next; ///< Self-explanatory
+ _List_node_base* _M_prev; ///< Self-explanatory
};
-
+
+ /// @if maint An actual node in the %list. @endif
template<typename _Tp>
struct _List_node : public _List_node_base
- {
- _Tp _M_data;
- };
-
+ {
+ _Tp _M_data; ///< User's data.
+ };
+
+
+ /**
+ * @if maint
+ * @brief Common part of a list::iterator.
+ *
+ * A simple type to walk a doubly-linked list. All operations here should
+ * be self-explanatory after taking any decent introductory data structures
+ * course.
+ * @endif
+ */
struct _List_iterator_base
{
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef bidirectional_iterator_tag iterator_category;
-
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef bidirectional_iterator_tag iterator_category;
+
+ /// The only member points to the %list element.
_List_node_base* _M_node;
-
+
_List_iterator_base(_List_node_base* __x)
: _M_node(__x)
{ }
-
+
_List_iterator_base()
{ }
-
+
+ /// Walk the %list forward.
void
_M_incr()
{ _M_node = _M_node->_M_next; }
-
+
+ /// Walk the %list backward.
void
_M_decr()
{ _M_node = _M_node->_M_prev; }
-
+
bool
operator==(const _List_iterator_base& __x) const
{ return _M_node == __x._M_node; }
-
+
bool
operator!=(const _List_iterator_base& __x) const
{ return _M_node != __x._M_node; }
- };
-
+ };
+
+ /**
+ * @brief A list::iterator.
+ *
+ * In addition to being used externally, a list holds one of these
+ * internally, pointing to the sequence of data.
+ *
+ * @if maint
+ * All the functions are op overloads.
+ * @endif
+ */
template<typename _Tp, typename _Ref, typename _Ptr>
struct _List_iterator : public _List_iterator_base
+ {
+ typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
+ typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
+ typedef _List_iterator<_Tp,_Ref,_Ptr> _Self;
+
+ typedef _Tp value_type;
+ typedef _Ptr pointer;
+ typedef _Ref reference;
+ typedef _List_node<_Tp> _Node;
+
+ _List_iterator(_Node* __x)
+ : _List_iterator_base(__x)
+ { }
+
+ _List_iterator()
+ { }
+
+ _List_iterator(const iterator& __x)
+ : _List_iterator_base(__x._M_node)
+ { }
+
+ reference
+ operator*() const
+ { return static_cast<_Node*>(_M_node)->_M_data; }
+ // Must downcast from List_node_base to _List_node to get to _M_data.
+
+ pointer
+ operator->() const
+ { return &(operator*()); }
+
+ _Self&
+ operator++()
{
- typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
- typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
- typedef _List_iterator<_Tp,_Ref,_Ptr> _Self;
-
- typedef _Tp value_type;
- typedef _Ptr pointer;
- typedef _Ref reference;
- typedef _List_node<_Tp> _Node;
-
- _List_iterator(_Node* __x)
- : _List_iterator_base(__x)
- { }
-
- _List_iterator()
- { }
-
- _List_iterator(const iterator& __x)
- : _List_iterator_base(__x._M_node)
- { }
-
- reference
- operator*() const
- { return ((_Node*) _M_node)->_M_data; }
-
- pointer
- operator->() const
- { return &(operator*()); }
-
- _Self&
- operator++()
- {
- this->_M_incr();
- return *this;
- }
-
- _Self
- operator++(int)
- {
- _Self __tmp = *this;
- this->_M_incr();
- return __tmp;
- }
-
- _Self&
- operator--()
- {
- this->_M_decr();
- return *this;
- }
-
- _Self
- operator--(int)
- {
- _Self __tmp = *this;
- this->_M_decr();
- return __tmp;
- }
- };
-
-
- // Base class that encapsulates details of allocators. Three cases:
- // an ordinary standard-conforming allocator, a standard-conforming
- // allocator with no non-static data, and an SGI-style allocator.
- // This complexity is necessary only because we're worrying about backward
- // compatibility and because we want to avoid wasting storage on an
- // allocator instance if it isn't necessary.
-
-
- // Base for general standard-conforming allocators.
+ this->_M_incr();
+ return *this;
+ }
+
+ _Self
+ operator++(int)
+ {
+ _Self __tmp = *this;
+ this->_M_incr();
+ return __tmp;
+ }
+
+ _Self&
+ operator--()
+ {
+ this->_M_decr();
+ return *this;
+ }
+
+ _Self
+ operator--(int)
+ {
+ _Self __tmp = *this;
+ this->_M_decr();
+ return __tmp;
+ }
+ };
+
+
+ /// @if maint Primary default version. @endif
+ /**
+ * @if maint
+ * See bits/stl_deque.h's _Deque_alloc_base for an explanation.
+ * @endif
+ */
template<typename _Tp, typename _Allocator, bool _IsStatic>
class _List_alloc_base
- {
- public:
- typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
- allocator_type;
-
- allocator_type
- get_allocator() const
- { return _Node_allocator; }
-
- _List_alloc_base(const allocator_type& __a)
- : _Node_allocator(__a)
- { }
-
- protected:
- _List_node<_Tp>*
- _M_get_node()
- { return _Node_allocator.allocate(1); }
-
- void
- _M_put_node(_List_node<_Tp>* __p)
- { _Node_allocator.deallocate(__p, 1); }
-
- protected:
- typename _Alloc_traits<_List_node<_Tp>, _Allocator>::allocator_type
- _Node_allocator;
-
- _List_node<_Tp>* _M_node;
- };
-
- // Specialization for instanceless allocators.
-
+ {
+ public:
+ typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
+ allocator_type;
+
+ allocator_type
+ get_allocator() const { return _M_node_allocator; }
+
+ _List_alloc_base(const allocator_type& __a)
+ : _M_node_allocator(__a)
+ { }
+
+ protected:
+ _List_node<_Tp>*
+ _M_get_node()
+ { return _M_node_allocator.allocate(1); }
+
+ void
+ _M_put_node(_List_node<_Tp>* __p)
+ { _M_node_allocator.deallocate(__p, 1); }
+
+ // NOTA BENE
+ // The stored instance is not actually of "allocator_type"'s type. Instead
+ // we rebind the type to Allocator<List_node<Tp>>, which according to
+ // [20.1.5]/4 should probably be the same. List_node<Tp> is not the same
+ // size as Tp (it's two pointers larger), and specializations on Tp may go
+ // unused because List_node<Tp> is being bound instead.
+ //
+ // We put this to the test in get_allocator above; if the two types are
+ // actually different, there had better be a conversion between them.
+ //
+ // None of the predefined allocators shipped with the library (as of 3.1)
+ // use this instantiation anyhow; they're all instanceless.
+ typename _Alloc_traits<_List_node<_Tp>, _Allocator>::allocator_type
+ _M_node_allocator;
+
+ _List_node<_Tp>* _M_node;
+ };
+
+ /// @if maint Specialization for instanceless allocators. @endif
template<typename _Tp, typename _Allocator>
class _List_alloc_base<_Tp, _Allocator, true>
+ {
+ public:
+ typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
+ allocator_type;
+
+ allocator_type
+ get_allocator() const { return allocator_type(); }
+
+ _List_alloc_base(const allocator_type&)
+ { }
+
+ protected:
+ // See comment in primary template class about why this is safe for the
+ // standard predefined classes.
+ typedef typename _Alloc_traits<_List_node<_Tp>, _Allocator>::_Alloc_type
+ _Alloc_type;
+
+ _List_node<_Tp>*
+ _M_get_node()
+ { return _Alloc_type::allocate(1); }
+
+ void
+ _M_put_node(_List_node<_Tp>* __p)
+ { _Alloc_type::deallocate(__p, 1); }
+
+ _List_node<_Tp>* _M_node;
+ };
+
+
+ /**
+ * @if maint
+ * See bits/stl_deque.h's _Deque_base for an explanation.
+ * @endif
+ */
+ template <typename _Tp, typename _Alloc>
+ class _List_base
+ : public _List_alloc_base<_Tp, _Alloc,
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
+ {
+ public:
+ typedef _List_alloc_base<_Tp, _Alloc,
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
+ _Base;
+ typedef typename _Base::allocator_type allocator_type;
+
+ _List_base(const allocator_type& __a)
+ : _Base(__a)
{
- public:
- typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
- allocator_type;
-
- allocator_type
- get_allocator() const
- { return allocator_type(); }
-
- _List_alloc_base(const allocator_type&)
- { }
-
- protected:
- typedef typename _Alloc_traits<_List_node<_Tp>, _Allocator>::_Alloc_type
- _Alloc_type;
-
- _List_node<_Tp>*
- _M_get_node()
- { return _Alloc_type::allocate(1); }
-
- void
- _M_put_node(_List_node<_Tp>* __p)
- { _Alloc_type::deallocate(__p, 1); }
-
- protected:
- _List_node<_Tp>* _M_node;
- };
-
- template<typename _Tp, typename _Alloc>
- class _List_base
- : public _List_alloc_base<_Tp, _Alloc,
- _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
+ _M_node = _M_get_node();
+ _M_node->_M_next = _M_node;
+ _M_node->_M_prev = _M_node;
+ }
+
+ // This is what actually destroys the list.
+ ~_List_base()
{
- public:
- typedef _List_alloc_base<_Tp, _Alloc,
- _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
- _Base;
- typedef typename _Base::allocator_type allocator_type;
-
- _List_base(const allocator_type& __a)
- : _Base(__a)
- {
- _M_node = _M_get_node();
- _M_node->_M_next = _M_node;
- _M_node->_M_prev = _M_node;
- }
-
- ~_List_base()
- {
- clear();
- _M_put_node(_M_node);
- }
-
- void clear();
- };
-
+ __clear();
+ _M_put_node(_M_node);
+ }
+
+ void
+ __clear();
+ };
+
+
/**
+ * @brief A standard container with linear time access to elements, and
+ * fixed time insertion/deletion at any point in the sequence.
+ *
* @ingroup Containers
* @ingroup Sequences
*
@@ -283,384 +331,778 @@ namespace std
* <a href="tables.html#68">optional sequence requirements</a> with the
* %exception of @c at and @c operator[].
*
- * @doctodo
+ * This is a @e doubly @e linked %list. Traversal up and down the %list
+ * requires linear time, but adding and removing elements (or @e nodes) is
+ * done in constant time, regardless of where the change takes place.
+ * Unlike std::vector and std::deque, random-access iterators are not
+ * provided, so subscripting ( @c [] ) access is not allowed. For algorithms
+ * which only need sequential access, this lack makes no difference.
+ *
+ * Also unlike the other standard containers, std::list provides specialized
+ * algorithms %unique to linked lists, such as splicing, sorting, and
+ * in-place reversal.
+ *
+ * @if maint
+ * A couple points on memory allocation for list<Tp>:
*
+ * First, we never actually allocate a Tp, we allocate List_node<Tp>'s
+ * and trust [20.1.5]/4 to DTRT. This is to ensure that after elements from
+ * %list<X,Alloc1> are spliced into %list<X,Alloc2>, destroying the memory of
+ * the second %list is a valid operation, i.e., Alloc1 giveth and Alloc2
+ * taketh away.
+ *
+ * Second, a %list conceptually represented as
+ * @code
+ * A <---> B <---> C <---> D
+ * @endcode
+ * is actually circular; a link exists between A and D. The %list class
+ * holds (as its only data member) a private list::iterator pointing to
+ * @e D, not to @e A! To get to the head of the %list, we start at the tail
+ * and move forward by one. When this member iterator's next/previous
+ * pointers refer to itself, the %list is %empty.
+ * @endif
*/
template<typename _Tp, typename _Alloc = allocator<_Tp> >
class list : protected _List_base<_Tp, _Alloc>
+ {
+ // concept requirements
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+
+ typedef _List_base<_Tp, _Alloc> _Base;
+
+ public:
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
+ typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef typename _Base::allocator_type allocator_type;
+
+ protected:
+ // Note that pointers-to-_Node's can be ctor-converted to iterator types.
+ typedef _List_node<_Tp> _Node;
+
+ /** @if maint
+ * One data member plus two memory-handling functions. If the _Alloc
+ * type requires separate instances, then one of those will also be
+ * included, accumulated from the topmost parent.
+ * @endif
+ */
+ using _Base::_M_node;
+ using _Base::_M_put_node;
+ using _Base::_M_get_node;
+
+ /**
+ * @if maint
+ * @param x An instance of user data.
+ *
+ * Allocates space for a new node and constructs a copy of @a x in it.
+ * @endif
+ */
+ _Node*
+ _M_create_node(const value_type& __x)
{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
-
- typedef _List_base<_Tp, _Alloc> _Base;
- protected:
- typedef void* _Void_pointer;
-
- public:
- typedef _Tp value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef _List_node<_Tp> _Node;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
-
- typedef typename _Base::allocator_type allocator_type;
-
- typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
- typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
-
- typedef reverse_iterator<const_iterator> const_reverse_iterator;
- typedef reverse_iterator<iterator> reverse_iterator;
-
- protected:
- using _Base::_M_node;
- using _Base::_M_put_node;
- using _Base::_M_get_node;
-
- protected:
- _Node*
- _M_create_node(const _Tp& __x)
+ _Node* __p = _M_get_node();
+ try {
+ _Construct(&__p->_M_data, __x);
+ }
+ catch(...)
{
- _Node* __p = _M_get_node();
- try {
- _Construct(&__p->_M_data, __x);
- }
- catch(...)
- {
- _M_put_node(__p);
- __throw_exception_again;
- }
- return __p;
+ _M_put_node(__p);
+ __throw_exception_again;
}
-
- _Node*
- _M_create_node()
+ return __p;
+ }
+
+ /**
+ * @if maint
+ * Allocates space for a new node and default-constructs a new instance
+ * of @c value_type in it.
+ * @endif
+ */
+ _Node*
+ _M_create_node()
+ {
+ _Node* __p = _M_get_node();
+ try {
+ _Construct(&__p->_M_data);
+ }
+ catch(...)
{
- _Node* __p = _M_get_node();
- try {
- _Construct(&__p->_M_data);
- }
- catch(...)
- {
- _M_put_node(__p);
- __throw_exception_again;
- }
- return __p;
+ _M_put_node(__p);
+ __throw_exception_again;
}
-
- public:
- allocator_type
- get_allocator() const
- { return _Base::get_allocator(); }
-
- explicit
- list(const allocator_type& __a = allocator_type())
+ return __p;
+ }
+
+ public:
+ // [23.2.2.1] construct/copy/destroy
+ // (assign() and get_allocator() are also listed in this section)
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ list(const allocator_type& __a = allocator_type())
+ : _Base(__a) { }
+
+ /**
+ * @brief Create a %list with copies of an exemplar element.
+ * @param n The number of elements to initially create.
+ * @param value An element to copy.
+ *
+ * This constructor fills the %list with @a n copies of @a value.
+ */
+ list(size_type __n, const value_type& __value,
+ const allocator_type& __a = allocator_type())
: _Base(__a)
- { }
-
- iterator
- begin()
- { return static_cast<_Node*>(_M_node->_M_next); }
-
- const_iterator
- begin() const
- { return static_cast<_Node*>(_M_node->_M_next); }
-
- iterator
- end()
- { return _M_node; }
-
- const_iterator
- end() const
- { return _M_node; }
-
- reverse_iterator
- rbegin()
- { return reverse_iterator(end()); }
-
- const_reverse_iterator
- rbegin() const
- { return const_reverse_iterator(end()); }
-
- reverse_iterator
- rend()
- { return reverse_iterator(begin()); }
-
- const_reverse_iterator
- rend() const
- { return const_reverse_iterator(begin()); }
-
- bool
- empty() const
- { return _M_node->_M_next == _M_node; }
-
- size_type
- size() const
- { return distance(begin(), end()); }
-
- size_type
- max_size() const
- { return size_type(-1); }
-
- reference
- front()
- { return *begin(); }
-
- const_reference
- front() const
- { return *begin(); }
-
- reference
- back()
- { return *(--end()); }
-
- const_reference
- back() const
- { return *(--end()); }
-
+ { this->insert(begin(), __n, __value); }
+
+ /**
+ * @brief Create a %list with default elements.
+ * @param n The number of elements to initially create.
+ *
+ * This constructor fills the %list with @a n copies of a
+ * default-constructed element.
+ */
+ explicit
+ list(size_type __n)
+ : _Base(allocator_type())
+ { this->insert(begin(), __n, value_type()); }
+
+ /**
+ * @brief %List copy constructor.
+ * @param x A %list of identical element and allocator types.
+ *
+ * The newly-created %list uses a copy of the allocation object used
+ * by @a x.
+ */
+ list(const list& __x)
+ : _Base(__x.get_allocator())
+ { this->insert(begin(), __x.begin(), __x.end()); }
+
+ /**
+ * @brief Builds a %list from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * Create a %list consisting of copies of the elements from [first,last).
+ * This is linear in N (where N is distance(first,last)).
+ *
+ * @if maint
+ * We don't need any dispatching tricks here, because insert does all of
+ * that anyway.
+ * @endif
+ */
+ template<typename _InputIterator>
+ list(_InputIterator __first, _InputIterator __last,
+ const allocator_type& __a = allocator_type())
+ : _Base(__a)
+ { this->insert(begin(), __first, __last); }
+
+ /**
+ * The dtor only erases the elements, and note that if the elements
+ * themselves are pointers, the pointed-to memory is not touched in any
+ * way. Managing the pointer is the user's responsibilty.
+ */
+ ~list() { }
+
+ /**
+ * @brief %List assignment operator.
+ * @param x A %list of identical element and allocator types.
+ *
+ * All the elements of @a x are copied, but unlike the copy constructor,
+ * the allocator object is not copied.
+ */
+ list&
+ operator=(const list& __x);
+
+ /**
+ * @brief Assigns a given value to a %list.
+ * @param n Number of elements to be assigned.
+ * @param val Value to be assigned.
+ *
+ * This function fills a %list with @a n copies of the given value.
+ * Note that the assignment completely changes the %list and that the
+ * resulting %list's size is the same as the number of elements assigned.
+ * Old data may be lost.
+ */
+ void
+ assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); }
+
+ /**
+ * @brief Assigns a range to a %list.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * This function fills a %list with copies of the elements in the
+ * range [first,last).
+ *
+ * Note that the assignment completely changes the %list and that the
+ * resulting %list's size is the same as the number of elements assigned.
+ * Old data may be lost.
+ */
+ template<typename _InputIterator>
void
- swap(list<_Tp, _Alloc>& __x)
- { std::swap(_M_node, __x._M_node); }
-
- iterator
- insert(iterator __position, const _Tp& __x)
+ assign(_InputIterator __first, _InputIterator __last)
{
- _Node* __tmp = _M_create_node(__x);
- __tmp->_M_next = __position._M_node;
- __tmp->_M_prev = __position._M_node->_M_prev;
- __position._M_node->_M_prev->_M_next = __tmp;
- __position._M_node->_M_prev = __tmp;
- return __tmp;
+ // Check whether it's an integral type. If so, it's not an iterator.
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_assign_dispatch(__first, __last, _Integral());
}
-
- iterator
- insert(iterator __position)
- { return insert(__position, _Tp()); }
-
- // Check whether it's an integral type. If so, it's not an iterator.
- template<typename _Integer>
- void
- _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, __true_type)
- { _M_fill_insert(__pos, (size_type) __n, (_Tp) __x); }
-
- template<typename _InputIterator>
- void
- _M_insert_dispatch(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- __false_type);
-
- template<typename _InputIterator>
- void
- insert(iterator __pos, _InputIterator __first, _InputIterator __last)
- {
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_insert_dispatch(__pos, __first, __last, _Integral());
- }
-
- void
- insert(iterator __pos, size_type __n, const _Tp& __x)
- { _M_fill_insert(__pos, __n, __x); }
-
- void
- _M_fill_insert(iterator __pos, size_type __n, const _Tp& __x);
-
- void
- push_front(const _Tp& __x)
- { insert(begin(), __x); }
-
- void
- push_front()
- { insert(begin()); }
-
- void
- push_back(const _Tp& __x)
- { insert(end(), __x); }
-
+
+ /// Get a copy of the memory allocation object.
+ allocator_type
+ get_allocator() const { return _Base::get_allocator(); }
+
+ // iterators
+ /**
+ * Returns a read/write iterator that points to the first element in the
+ * %list. Iteration is done in ordinary element order.
+ */
+ iterator
+ begin() { return static_cast<_Node*>(_M_node->_M_next); }
+
+ /**
+ * Returns a read-only (constant) iterator that points to the first element
+ * in the %list. Iteration is done in ordinary element order.
+ */
+ const_iterator
+ begin() const { return static_cast<_Node*>(_M_node->_M_next); }
+
+ /**
+ * Returns a read/write iterator that points one past the last element in
+ * the %list. Iteration is done in ordinary element order.
+ */
+ iterator
+ end() { return _M_node; }
+
+ /**
+ * Returns a read-only (constant) iterator that points one past the last
+ * element in the %list. Iteration is done in ordinary element order.
+ */
+ const_iterator
+ end() const { return _M_node; }
+
+ /**
+ * Returns a read/write reverse iterator that points to the last element in
+ * the %list. Iteration is done in reverse element order.
+ */
+ reverse_iterator
+ rbegin() { return reverse_iterator(end()); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to the last
+ * element in the %list. Iteration is done in reverse element order.
+ */
+ const_reverse_iterator
+ rbegin() const { return const_reverse_iterator(end()); }
+
+ /**
+ * Returns a read/write reverse iterator that points to one before the
+ * first element in the %list. Iteration is done in reverse element
+ * order.
+ */
+ reverse_iterator
+ rend() { return reverse_iterator(begin()); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to one
+ * before the first element in the %list. Iteration is done in reverse
+ * element order.
+ */
+ const_reverse_iterator
+ rend() const
+ { return const_reverse_iterator(begin()); }
+
+ // [23.2.2.2] capacity
+ /**
+ * Returns true if the %list is empty. (Thus begin() would equal end().)
+ */
+ bool
+ empty() const { return _M_node->_M_next == _M_node; }
+
+ /** Returns the number of elements in the %list. */
+ size_type
+ size() const { return distance(begin(), end()); }
+
+ /** Returns the size() of the largest possible %list. */
+ size_type
+ max_size() const { return size_type(-1); }
+
+ /**
+ * @brief Resizes the %list to the specified number of elements.
+ * @param new_size Number of elements the %list should contain.
+ * @param x Data with which new elements should be populated.
+ *
+ * This function will %resize the %list to the specified number of
+ * elements. If the number is smaller than the %list's current size the
+ * %list is truncated, otherwise the %list is extended and new elements
+ * are populated with given data.
+ */
+ void
+ resize(size_type __new_size, const value_type& __x);
+
+ /**
+ * @brief Resizes the %list to the specified number of elements.
+ * @param new_size Number of elements the %list should contain.
+ *
+ * This function will resize the %list to the specified number of
+ * elements. If the number is smaller than the %list's current size the
+ * %list is truncated, otherwise the %list is extended and new elements
+ * are default-constructed.
+ */
+ void
+ resize(size_type __new_size) { this->resize(__new_size, value_type()); }
+
+ // element access
+ /**
+ * Returns a read/write reference to the data at the first element of the
+ * %list.
+ */
+ reference
+ front() { return *begin(); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the first
+ * element of the %list.
+ */
+ const_reference
+ front() const { return *begin(); }
+
+ /**
+ * Returns a read/write reference to the data at the last element of the
+ * %list.
+ */
+ reference
+ back() { return *(--end()); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the last
+ * element of the %list.
+ */
+ const_reference
+ back() const { return *(--end()); }
+
+ // [23.2.2.3] modifiers
+ /**
+ * @brief Add data to the front of the %list.
+ * @param x Data to be added.
+ *
+ * This is a typical stack operation. The function creates an element at
+ * the front of the %list and assigns the given data to it. Due to the
+ * nature of a %list this operation can be done in constant time, and
+ * does not invalidate iterators and references.
+ */
+ void
+ push_front(const value_type& __x) { this->insert(begin(), __x); }
+
+ #ifdef _GLIBCPP_DEPRECATED
+ /**
+ * @brief Add data to the front of the %list.
+ *
+ * This is a typical stack operation. The function creates a
+ * default-constructed element at the front of the %list. Due to the
+ * nature of a %list this operation can be done in constant time. You
+ * should consider using push_front(value_type()) instead.
+ *
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
+ * c++config.h.
+ */
+ void
+ push_front() { this->insert(begin(), value_type()); }
+ #endif
+
+ /**
+ * @brief Removes first element.
+ *
+ * This is a typical stack operation. It shrinks the %list by one.
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and only invalidates iterators/references to the element being
+ * removed.
+ *
+ * Note that no data is returned, and if the first element's data is
+ * needed, it should be retrieved before pop_front() is called.
+ */
+ void
+ pop_front() { this->erase(begin()); }
+
+ /**
+ * @brief Add data to the end of the %list.
+ * @param x Data to be added.
+ *
+ * This is a typical stack operation. The function creates an element at
+ * the end of the %list and assigns the given data to it. Due to the
+ * nature of a %list this operation can be done in constant time, and
+ * does not invalidate iterators and references.
+ */
+ void
+ push_back(const value_type& __x) { this->insert(end(), __x); }
+
+ #ifdef _GLIBCPP_DEPRECATED
+ /**
+ * @brief Add data to the end of the %list.
+ *
+ * This is a typical stack operation. The function creates a
+ * default-constructed element at the end of the %list. Due to the nature
+ * of a %list this operation can be done in constant time. You should
+ * consider using push_back(value_type()) instead.
+ *
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
+ * c++config.h.
+ */
+ void
+ push_back() { this->insert(end(), value_type()); }
+ #endif
+
+ /**
+ * @brief Removes last element.
+ *
+ * This is a typical stack operation. It shrinks the %list by one.
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and only invalidates iterators/references to the element being
+ * removed.
+ *
+ * Note that no data is returned, and if the last element's data is
+ * needed, it should be retrieved before pop_back() is called.
+ */
+ void
+ pop_back()
+ {
+ iterator __tmp = end();
+ this->erase(--__tmp);
+ }
+
+ /**
+ * @brief Inserts given value into %list before specified iterator.
+ * @param position An iterator into the %list.
+ * @param x Data to be inserted.
+ * @return An iterator that points to the inserted data.
+ *
+ * This function will insert a copy of the given value before the specified
+ * location.
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and does not invalidate iterators and references.
+ */
+ iterator
+ insert(iterator __position, const value_type& __x);
+
+ #ifdef _GLIBCPP_DEPRECATED
+ /**
+ * @brief Inserts an element into the %list.
+ * @param position An iterator into the %list.
+ * @return An iterator that points to the inserted element.
+ *
+ * This function will insert a default-constructed element before the
+ * specified location. You should consider using
+ * insert(position,value_type()) instead.
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and does not invalidate iterators and references.
+ *
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
+ * c++config.h.
+ */
+ iterator
+ insert(iterator __position) { return insert(__position, value_type()); }
+ #endif
+
+ /**
+ * @brief Inserts a number of copies of given data into the %list.
+ * @param position An iterator into the %list.
+ * @param n Number of elements to be inserted.
+ * @param x Data to be inserted.
+ *
+ * This function will insert a specified number of copies of the given data
+ * before the location specified by @a position.
+ *
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and does not invalidate iterators and references.
+ */
+ void
+ insert(iterator __pos, size_type __n, const value_type& __x)
+ { _M_fill_insert(__pos, __n, __x); }
+
+ /**
+ * @brief Inserts a range into the %list.
+ * @param pos An iterator into the %list.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * This function will insert copies of the data in the range [first,last)
+ * into the %list before the location specified by @a pos.
+ *
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and does not invalidate iterators and references.
+ */
+ template<typename _InputIterator>
void
- push_back()
- { insert(end()); }
-
- iterator
- erase(iterator __position)
+ insert(iterator __pos, _InputIterator __first, _InputIterator __last)
{
- _List_node_base* __next_node = __position._M_node->_M_next;
- _List_node_base* __prev_node = __position._M_node->_M_prev;
- _Node* __n = static_cast<_Node*>(__position._M_node);
- __prev_node->_M_next = __next_node;
- __next_node->_M_prev = __prev_node;
- _Destroy(&__n->_M_data);
- _M_put_node(__n);
- return iterator(static_cast<_Node*>(__next_node));
+ // Check whether it's an integral type. If so, it's not an iterator.
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_insert_dispatch(__pos, __first, __last, _Integral());
}
-
- iterator
- erase(iterator __first, iterator __last);
-
- void
- clear()
- { _Base::clear(); }
-
- void
- resize(size_type __new_size, const _Tp& __x);
-
- void
- resize(size_type __new_size)
- { this->resize(__new_size, _Tp()); }
-
+
+ /**
+ * @brief Remove element at given position.
+ * @param position Iterator pointing to element to be erased.
+ * @return An iterator pointing to the next element (or end()).
+ *
+ * This function will erase the element at the given position and thus
+ * shorten the %list by one.
+ *
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and only invalidates iterators/references to the element being
+ * removed.
+ * The user is also cautioned that
+ * this function only erases the element, and that if the element is itself
+ * a pointer, the pointed-to memory is not touched in any way. Managing
+ * the pointer is the user's responsibilty.
+ */
+ iterator
+ erase(iterator __position);
+
+ /**
+ * @brief Remove a range of elements.
+ * @param first Iterator pointing to the first element to be erased.
+ * @param last Iterator pointing to one past the last element to be
+ * erased.
+ * @return An iterator pointing to the element pointed to by @a last
+ * prior to erasing (or end()).
+ *
+ * This function will erase the elements in the range [first,last) and
+ * shorten the %list accordingly.
+ *
+ * Due to the nature of a %list this operation can be done in constant
+ * time, and only invalidates iterators/references to the element being
+ * removed.
+ * The user is also cautioned that
+ * this function only erases the elements, and that if the elements
+ * themselves are pointers, the pointed-to memory is not touched in any
+ * way. Managing the pointer is the user's responsibilty.
+ */
+ iterator
+ erase(iterator __first, iterator __last)
+ {
+ while (__first != __last)
+ erase(__first++);
+ return __last;
+ }
+
+ /**
+ * @brief Swaps data with another %list.
+ * @param x A %list of the same element and allocator types.
+ *
+ * This exchanges the elements between two lists in constant time.
+ * (It is only swapping a single pointer, so it should be quite fast.)
+ * Note that the global std::swap() function is specialized such that
+ * std::swap(l1,l2) will feed to this function.
+ */
+ void
+ swap(list& __x) { std::swap(_M_node, __x._M_node); }
+
+ /**
+ * Erases all the elements. Note that this function only erases the
+ * elements, and that if the elements themselves are pointers, the
+ * pointed-to memory is not touched in any way. Managing the pointer is
+ * the user's responsibilty.
+ */
+ void
+ clear() { _Base::__clear(); }
+
+ // [23.2.2.4] list operations
+ /**
+ * @doctodo
+ */
+ void
+ splice(iterator __position, list& __x)
+ {
+ if (!__x.empty())
+ this->_M_transfer(__position, __x.begin(), __x.end());
+ }
+
+ /**
+ * @doctodo
+ */
+ void
+ splice(iterator __position, list&, iterator __i)
+ {
+ iterator __j = __i;
+ ++__j;
+ if (__position == __i || __position == __j) return;
+ this->_M_transfer(__position, __i, __j);
+ }
+
+ /**
+ * @doctodo
+ */
+ void
+ splice(iterator __position, list&, iterator __first, iterator __last)
+ {
+ if (__first != __last)
+ this->_M_transfer(__position, __first, __last);
+ }
+
+ /**
+ * @doctodo
+ */
+ void
+ remove(const _Tp& __value);
+
+ /**
+ * @doctodo
+ */
+ template<typename _Predicate>
void
- pop_front()
- { erase(begin()); }
-
+ remove_if(_Predicate);
+
+ /**
+ * @doctodo
+ */
+ void
+ unique();
+
+ /**
+ * @doctodo
+ */
+ template<typename _BinaryPredicate>
void
- pop_back()
- {
- iterator __tmp = end();
- erase(--__tmp);
- }
-
- list(size_type __n, const _Tp& __value,
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- { insert(begin(), __n, __value); }
-
- explicit
- list(size_type __n)
- : _Base(allocator_type())
- { insert(begin(), __n, _Tp()); }
-
- // We don't need any dispatching tricks here, because insert does all of
- // that anyway.
- template<typename _InputIterator>
- list(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- { insert(begin(), __first, __last); }
-
- list(const list<_Tp, _Alloc>& __x)
- : _Base(__x.get_allocator())
- { insert(begin(), __x.begin(), __x.end()); }
-
- ~list()
- { }
-
- list<_Tp, _Alloc>&
- operator=(const list<_Tp, _Alloc>& __x);
-
- public:
- // assign(), a generalized assignment member function. Two
- // versions: one that takes a count, and one that takes a range.
- // The range version is a member template, so we dispatch on whether
- // or not the type is an integer.
-
+ unique(_BinaryPredicate);
+
+ /**
+ * @doctodo
+ */
+ void
+ merge(list& __x);
+
+ /**
+ * @doctodo
+ */
+ template<typename _StrictWeakOrdering>
void
- assign(size_type __n, const _Tp& __val)
- { _M_fill_assign(__n, __val); }
-
+ merge(list&, _StrictWeakOrdering);
+
+ /**
+ * @doctodo
+ */
+ void
+ reverse() { __List_base_reverse(this->_M_node); }
+
+ /**
+ * @doctodo
+ */
+ void
+ sort();
+
+ /**
+ * @doctodo
+ */
+ template<typename _StrictWeakOrdering>
void
- _M_fill_assign(size_type __n, const _Tp& __val);
-
- template<typename _InputIterator>
- void
- assign(_InputIterator __first, _InputIterator __last)
- {
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_assign_dispatch(__first, __last, _Integral());
- }
-
- template<typename _Integer>
- void
- _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
- { _M_fill_assign((size_type) __n, (_Tp) __val); }
-
- template<typename _InputIterator>
- void
- _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type);
-
- protected:
+ sort(_StrictWeakOrdering);
+
+ protected:
+ // Internal assign functions follow.
+
+ // called by the range assign to implement [23.1.1]/9
+ template<typename _Integer>
void
- _M_transfer(iterator __position, iterator __first, iterator __last)
+ _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{
- if (__position != __last) {
- // Remove [first, last) from its old position.
- __last._M_node->_M_prev->_M_next = __position._M_node;
- __first._M_node->_M_prev->_M_next = __last._M_node;
- __position._M_node->_M_prev->_M_next = __first._M_node;
-
- // Splice [first, last) into its new position.
- _List_node_base* __tmp = __position._M_node->_M_prev;
- __position._M_node->_M_prev = __last._M_node->_M_prev;
- __last._M_node->_M_prev = __first._M_node->_M_prev;
- __first._M_node->_M_prev = __tmp;
- }
+ _M_fill_assign(static_cast<size_type>(__n),
+ static_cast<value_type>(__val));
}
-
- public:
+
+ // called by the range assign to implement [23.1.1]/9
+ template<typename _InputIter>
void
- splice(iterator __position, list& __x)
- {
- if (!__x.empty())
- this->_M_transfer(__position, __x.begin(), __x.end());
- }
-
+ _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type);
+
+ // Called by assign(n,t), and the range assign when it turns out to be the
+ // same thing.
+ void
+ _M_fill_assign(size_type __n, const value_type& __val);
+
+
+ // Internal insert functions follow.
+
+ // called by the range insert to implement [23.1.1]/9
+ template<typename _Integer>
void
- splice(iterator __position, list&, iterator __i)
+ _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
+ __true_type)
{
- iterator __j = __i;
- ++__j;
- if (__position == __i || __position == __j) return;
- this->_M_transfer(__position, __i, __j);
+ _M_fill_insert(__pos, static_cast<size_type>(__n),
+ static_cast<value_type>(__x));
}
-
+
+ // called by the range insert to implement [23.1.1]/9
+ template<typename _InputIterator>
void
- splice(iterator __position, list&, iterator __first, iterator __last)
+ _M_insert_dispatch(iterator __pos,
+ _InputIterator __first, _InputIterator __last,
+ __false_type)
{
- if (__first != __last)
- this->_M_transfer(__position, __first, __last);
+ for ( ; __first != __last; ++__first)
+ insert(__pos, *__first);
}
-
- void
- remove(const _Tp& __value);
-
- void
- unique();
-
- void
- merge(list& __x);
-
- void
- reverse();
-
- void
- sort();
-
- template<typename _Predicate>
- void
- remove_if(_Predicate);
-
- template<typename _BinaryPredicate>
- void
- unique(_BinaryPredicate);
-
- template<typename _StrictWeakOrdering>
- void
- merge(list&, _StrictWeakOrdering);
-
- template<typename _StrictWeakOrdering>
- void
- sort(_StrictWeakOrdering);
- };
-
+
+ // Called by insert(p,n,x), and the range insert when it turns out to be
+ // the same thing.
+ void
+ _M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
+ {
+ for ( ; __n > 0; --__n)
+ insert(__pos, __x);
+ }
+
+
+ // Moves the elements from [first,last) before position.
+ void
+ _M_transfer(iterator __position, iterator __first, iterator __last)
+ {
+ if (__position != __last) {
+ // Remove [first, last) from its old position.
+ __last._M_node->_M_prev->_M_next = __position._M_node;
+ __first._M_node->_M_prev->_M_next = __last._M_node;
+ __position._M_node->_M_prev->_M_next = __first._M_node;
+
+ // Splice [first, last) into its new position.
+ _List_node_base* __tmp = __position._M_node->_M_prev;
+ __position._M_node->_M_prev = __last._M_node->_M_prev;
+ __last._M_node->_M_prev = __first._M_node->_M_prev;
+ __first._M_node->_M_prev = __tmp;
+ }
+ }
+ };
+
+
+ /**
+ * @brief List equality comparison.
+ * @param x A %list.
+ * @param y A %list of the same type as @a x.
+ * @return True iff the size and elements of the lists are equal.
+ *
+ * This is an equivalence relation. It is linear in the size of the
+ * lists. Lists are considered equivalent if their sizes are equal,
+ * and if corresponding elements compare equal.
+ */
template<typename _Tp, typename _Alloc>
- inline bool
+ inline bool
operator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
{
typedef typename list<_Tp,_Alloc>::const_iterator const_iterator;
const_iterator __end1 = __x.end();
const_iterator __end2 = __y.end();
-
+
const_iterator __i1 = __x.begin();
const_iterator __i2 = __y.begin();
while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {
@@ -669,7 +1111,18 @@ namespace std
}
return __i1 == __end1 && __i2 == __end2;
}
-
+
+ /**
+ * @brief List ordering relation.
+ * @param x A %list.
+ * @param y A %list of the same type as @a x.
+ * @return True iff @a x is lexographically less than @a y.
+ *
+ * This is a total ordering relation. It is linear in the size of the
+ * lists. The elements must be comparable with @c <.
+ *
+ * See std::lexographical_compare() for how the determination is made.
+ */
template<typename _Tp, typename _Alloc>
inline bool
operator<(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
@@ -677,313 +1130,36 @@ namespace std
return lexicographical_compare(__x.begin(), __x.end(),
__y.begin(), __y.end());
}
-
+
+ /// Based on operator==
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
{ return !(__x == __y); }
-
+
+ /// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
{ return __y < __x; }
-
+
+ /// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
{ return !(__y < __x); }
-
+
+ /// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
{ return !(__x < __y); }
-
+
+ /// See std::list::swap().
template<typename _Tp, typename _Alloc>
- inline void
+ inline void
swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
{ __x.swap(__y); }
-
- // move these to stl_list.tcc
-
- template<typename _Tp, typename _Alloc>
- void _List_base<_Tp,_Alloc>::
- clear()
- {
- _List_node<_Tp>* __cur = static_cast<_List_node<_Tp>*>(_M_node->_M_next);
- while (__cur != _M_node) {
- _List_node<_Tp>* __tmp = __cur;
- __cur = static_cast<_List_node<_Tp>*>(__cur->_M_next);
- _Destroy(&__tmp->_M_data);
- _M_put_node(__tmp);
- }
- _M_node->_M_next = _M_node;
- _M_node->_M_prev = _M_node;
- }
-
- template<typename _Tp, typename _Alloc>
- template <typename _InputIter>
- void list<_Tp, _Alloc>::
- _M_insert_dispatch(iterator __position, _InputIter __first, _InputIter __last,
- __false_type)
- {
- for ( ; __first != __last; ++__first)
- insert(__position, *__first);
-
- }
-
- template<typename _Tp, typename _Alloc>
- void list<_Tp, _Alloc>::
- _M_fill_insert(iterator __position, size_type __n, const _Tp& __x)
- {
- for ( ; __n > 0; --__n)
- insert(__position, __x);
- }
-
- template<typename _Tp, typename _Alloc>
- typename list<_Tp,_Alloc>::iterator list<_Tp, _Alloc>::
- erase(iterator __first, iterator __last)
- {
- while (__first != __last)
- erase(__first++);
- return __last;
- }
-
- template<typename _Tp, typename _Alloc>
- void list<_Tp, _Alloc>::
- resize(size_type __new_size, const _Tp& __x)
- {
- iterator __i = begin();
- size_type __len = 0;
- for ( ; __i != end() && __len < __new_size; ++__i, ++__len)
- ;
- if (__len == __new_size)
- erase(__i, end());
- else // __i == end()
- insert(end(), __new_size - __len, __x);
- }
-
- template<typename _Tp, typename _Alloc>
- list<_Tp, _Alloc>& list<_Tp, _Alloc>::
- operator=(const list<_Tp, _Alloc>& __x)
- {
- if (this != &__x) {
- iterator __first1 = begin();
- iterator __last1 = end();
- const_iterator __first2 = __x.begin();
- const_iterator __last2 = __x.end();
- while (__first1 != __last1 && __first2 != __last2)
- *__first1++ = *__first2++;
- if (__first2 == __last2)
- erase(__first1, __last1);
- else
- insert(__last1, __first2, __last2);
- }
- return *this;
- }
-
- template<typename _Tp, typename _Alloc>
- void list<_Tp, _Alloc>::
- _M_fill_assign(size_type __n, const _Tp& __val) {
- iterator __i = begin();
- for ( ; __i != end() && __n > 0; ++__i, --__n)
- *__i = __val;
- if (__n > 0)
- insert(end(), __n, __val);
- else
- erase(__i, end());
- }
-
- template<typename _Tp, typename _Alloc>
- template <typename _InputIter>
- void list<_Tp, _Alloc>::
- _M_assign_dispatch(_InputIter __first2, _InputIter __last2, __false_type)
- {
- iterator __first1 = begin();
- iterator __last1 = end();
- for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
- *__first1 = *__first2;
- if (__first2 == __last2)
- erase(__first1, __last1);
- else
- insert(__last1, __first2, __last2);
- }
-
- template<typename _Tp, typename _Alloc>
- void list<_Tp, _Alloc>::
- remove(const _Tp& __value)
- {
- iterator __first = begin();
- iterator __last = end();
- while (__first != __last) {
- iterator __next = __first;
- ++__next;
- if (*__first == __value) erase(__first);
- __first = __next;
- }
- }
-
- template<typename _Tp, typename _Alloc>
- void list<_Tp, _Alloc>::
- unique()
- {
- iterator __first = begin();
- iterator __last = end();
- if (__first == __last) return;
- iterator __next = __first;
- while (++__next != __last) {
- if (*__first == *__next)
- erase(__next);
- else
- __first = __next;
- __next = __first;
- }
- }
-
- template<typename _Tp, typename _Alloc>
- void list<_Tp, _Alloc>::
- merge(list<_Tp, _Alloc>& __x)
- {
- iterator __first1 = begin();
- iterator __last1 = end();
- iterator __first2 = __x.begin();
- iterator __last2 = __x.end();
- while (__first1 != __last1 && __first2 != __last2)
- if (*__first2 < *__first1) {
- iterator __next = __first2;
- _M_transfer(__first1, __first2, ++__next);
- __first2 = __next;
- }
- else
- ++__first1;
- if (__first2 != __last2) _M_transfer(__last1, __first2, __last2);
- }
-
- inline void
- __List_base_reverse(_List_node_base* __p)
- {
- _List_node_base* __tmp = __p;
- do {
- std::swap(__tmp->_M_next, __tmp->_M_prev);
- __tmp = __tmp->_M_prev; // Old next node is now prev.
- } while (__tmp != __p);
- }
-
- template<typename _Tp, typename _Alloc>
- inline void list<_Tp, _Alloc>::
- reverse()
- { __List_base_reverse(this->_M_node); }
-
- template<typename _Tp, typename _Alloc>
- void list<_Tp, _Alloc>::
- sort()
- {
- // Do nothing if the list has length 0 or 1.
- if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) {
- list<_Tp, _Alloc> __carry;
- list<_Tp, _Alloc> __counter[64];
- int __fill = 0;
- while (!empty()) {
- __carry.splice(__carry.begin(), *this, begin());
- int __i = 0;
- while(__i < __fill && !__counter[__i].empty()) {
- __counter[__i].merge(__carry);
- __carry.swap(__counter[__i++]);
- }
- __carry.swap(__counter[__i]);
- if (__i == __fill) ++__fill;
- }
-
- for (int __i = 1; __i < __fill; ++__i)
- __counter[__i].merge(__counter[__i-1]);
- swap(__counter[__fill-1]);
- }
- }
-
- template<typename _Tp, typename _Alloc>
- template <typename _Predicate>
- void list<_Tp, _Alloc>::
- remove_if(_Predicate __pred)
- {
- iterator __first = begin();
- iterator __last = end();
- while (__first != __last) {
- iterator __next = __first;
- ++__next;
- if (__pred(*__first)) erase(__first);
- __first = __next;
- }
- }
-
- template<typename _Tp, typename _Alloc>
- template <typename _BinaryPredicate>
- void list<_Tp, _Alloc>::
- unique(_BinaryPredicate __binary_pred)
- {
- iterator __first = begin();
- iterator __last = end();
- if (__first == __last) return;
- iterator __next = __first;
- while (++__next != __last) {
- if (__binary_pred(*__first, *__next))
- erase(__next);
- else
- __first = __next;
- __next = __first;
- }
- }
-
- template<typename _Tp, typename _Alloc>
- template <typename _StrictWeakOrdering>
- void list<_Tp, _Alloc>::
- merge(list<_Tp, _Alloc>& __x, _StrictWeakOrdering __comp)
- {
- iterator __first1 = begin();
- iterator __last1 = end();
- iterator __first2 = __x.begin();
- iterator __last2 = __x.end();
- while (__first1 != __last1 && __first2 != __last2)
- if (__comp(*__first2, *__first1)) {
- iterator __next = __first2;
- _M_transfer(__first1, __first2, ++__next);
- __first2 = __next;
- }
- else
- ++__first1;
- if (__first2 != __last2) _M_transfer(__last1, __first2, __last2);
- }
-
- template<typename _Tp, typename _Alloc>
- template <typename _StrictWeakOrdering>
- void list<_Tp, _Alloc>::
- sort(_StrictWeakOrdering __comp)
- {
- // Do nothing if the list has length 0 or 1.
- if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) {
- list<_Tp, _Alloc> __carry;
- list<_Tp, _Alloc> __counter[64];
- int __fill = 0;
- while (!empty()) {
- __carry.splice(__carry.begin(), *this, begin());
- int __i = 0;
- while(__i < __fill && !__counter[__i].empty()) {
- __counter[__i].merge(__carry, __comp);
- __carry.swap(__counter[__i++]);
- }
- __carry.swap(__counter[__i]);
- if (__i == __fill) ++__fill;
- }
-
- for (int __i = 1; __i < __fill; ++__i)
- __counter[__i].merge(__counter[__i-1], __comp);
- swap(__counter[__fill-1]);
- }
- }
-
-} // namespace std
+} // namespace std
#endif /* __GLIBCPP_INTERNAL_LIST_H */
-
-// vi:set ts=2 sw=2:
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/bits/stl_map.h b/contrib/libstdc++/include/bits/stl_map.h
index 07c62e4..ed47bbb 100644
--- a/contrib/libstdc++/include/bits/stl_map.h
+++ b/contrib/libstdc++/include/bits/stl_map.h
@@ -58,446 +58,604 @@
* You should not attempt to use it directly.
*/
-#ifndef _CPP_BITS_STL_MAP_H
-#define _CPP_BITS_STL_MAP_H 1
+#ifndef __GLIBCPP_INTERNAL_MAP_H
+#define __GLIBCPP_INTERNAL_MAP_H
#include <bits/concept_check.h>
namespace std
{
-
-/**
- * @brief A standard container made up of pairs (see std::pair in <utility>)
- * which can be retrieved based on a key.
- *
- * This is an associative container. Values contained within it can be
- * quickly retrieved through a key element. Example: MyMap["First"] would
- * return the data associated with the key "First".
-*/
-template <class _Key, class _Tp, class _Compare = less<_Key>,
- class _Alloc = allocator<pair<const _Key, _Tp> > >
-class map
-{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
- __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept);
-
-public:
- // typedefs:
- typedef _Key key_type;
- typedef _Tp data_type;
- typedef _Tp mapped_type;
- typedef pair<const _Key, _Tp> value_type;
- typedef _Compare key_compare;
-
- class value_compare
- : public binary_function<value_type, value_type, bool> {
- friend class map<_Key,_Tp,_Compare,_Alloc>;
- protected :
- _Compare comp;
- value_compare(_Compare __c) : comp(__c) {}
- public:
- bool operator()(const value_type& __x, const value_type& __y) const {
- return comp(__x.first, __y.first);
- }
- };
-
-private:
- typedef _Rb_tree<key_type, value_type,
- _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
- _Rep_type _M_t; // red-black tree representing map
-public:
- typedef typename _Rep_type::pointer pointer;
- typedef typename _Rep_type::const_pointer const_pointer;
- typedef typename _Rep_type::reference reference;
- typedef typename _Rep_type::const_reference const_reference;
- typedef typename _Rep_type::iterator iterator;
- typedef typename _Rep_type::const_iterator const_iterator;
- typedef typename _Rep_type::reverse_iterator reverse_iterator;
- typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
- typedef typename _Rep_type::size_type size_type;
- typedef typename _Rep_type::difference_type difference_type;
- typedef typename _Rep_type::allocator_type allocator_type;
-
- // allocation/deallocation
-
- map() : _M_t(_Compare(), allocator_type()) {}
- explicit map(const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a) {}
-
- template <class _InputIterator>
- map(_InputIterator __first, _InputIterator __last)
- : _M_t(_Compare(), allocator_type())
- { _M_t.insert_unique(__first, __last); }
-
- template <class _InputIterator>
- map(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
- map(const map<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
-
- map<_Key,_Tp,_Compare,_Alloc>&
- operator=(const map<_Key, _Tp, _Compare, _Alloc>& __x)
- {
- _M_t = __x._M_t;
- return *this;
- }
-
- // accessors:
-
- key_compare key_comp() const { return _M_t.key_comp(); }
- value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
- allocator_type get_allocator() const { return _M_t.get_allocator(); }
-
- /**
- * Returns a read/write iterator that points to the first pair in the map.
- * Iteration is done in ascending order according to the keys.
- */
- iterator begin() { return _M_t.begin(); }
-
- /**
- * Returns a read-only (constant) iterator that points to the first pair
- * in the map. Iteration is done in ascending order according to the keys.
- */
- const_iterator begin() const { return _M_t.begin(); }
-
- /**
- * Returns a read/write iterator that points one past the last pair in the
- * map. Iteration is done in ascending order according to the keys.
- */
- iterator end() { return _M_t.end(); }
-
- /**
- * Returns a read-only (constant) iterator that points one past the last
- * pair in the map. Iteration is done in ascending order according to the
- * keys.
- */
- const_iterator end() const { return _M_t.end(); }
-
/**
- * Returns a read/write reverse iterator that points to the last pair in
- * the map. Iteration is done in descending order according to the keys.
- */
- reverse_iterator rbegin() { return _M_t.rbegin(); }
-
- /**
- * Returns a read-only (constant) reverse iterator that points to the last
- * pair in the map. Iteration is done in descending order according to
- * the keys.
- */
- const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
-
- /**
- * Returns a read/write reverse iterator that points to one before the
- * first pair in the map. Iteration is done in descending order according
- * to the keys.
- */
- reverse_iterator rend() { return _M_t.rend(); }
-
- /**
- * Returns a read-only (constant) reverse iterator that points to one
- * before the first pair in the map. Iteration is done in descending order
- * according to the keys.
- */
- const_reverse_iterator rend() const { return _M_t.rend(); }
-
- /** Returns true if the map is empty. (Thus begin() would equal end().) */
- bool empty() const { return _M_t.empty(); }
- /** Returns the size of the map. */
- size_type size() const { return _M_t.size(); }
- /** Returns the maximum size of the map. */
- size_type max_size() const { return _M_t.max_size(); }
-
- /**
- * @brief Subscript ( [] ) access to map data.
- * @param k The key for which data should be retrieved.
- *
- * Allows for easy lookup with the subscript ( [] ) operator. Returns the
- * data associated with the key specified in subscript. If the key does
- * not exist a pair with that key is created with a default value, which
- * is then returned.
- */
- _Tp& operator[](const key_type& __k) {
- iterator __i = lower_bound(__k);
- // __i->first is greater than or equivalent to __k.
- if (__i == end() || key_comp()(__k, (*__i).first))
- __i = insert(__i, value_type(__k, _Tp()));
- return (*__i).second;
- }
-
- void swap(map<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
-
- // insert/erase
- /**
- * @brief Attempts to insert a std::pair into the map.
- * @param x Pair to be inserted (see std::make_pair for easy creation of
- * pairs).
- * @return A pair of which the first element is an iterator that points
- * to the possibly inserted pair, a second element of type bool
- * to show if the pair was actually inserted.
+ * @brief A standard container made up of (key,value) pairs, which can be
+ * retrieved based on a key, in logarithmic time.
*
- * This function attempts to insert a (key, value) pair into the map. A
- * map relies on unique keys and thus a pair is only inserted if its first
- * element (the key) is not already present in the map.
- */
- pair<iterator,bool> insert(const value_type& __x)
- { return _M_t.insert_unique(__x); }
-
- /**
- * @brief Attempts to insert a std::pair into the map.
- * @param position An iterator that serves as a hint as to where the
- * pair should be inserted.
- * @param x Pair to be inserted (see std::make_pair for easy creation of
- * pairs).
- * @return An iterator that points to the inserted (key,value) pair.
+ * @ingroup Containers
+ * @ingroup Assoc_containers
*
- * This function is not concerned about whether the insertion took place
- * or not and thus does not return a boolean like the single-argument
- * insert() does. Note that the first parameter is only a hint and can
- * potentially improve the performance of the insertion process. A bad
- * hint would cause no gains in efficiency.
- */
- iterator insert(iterator position, const value_type& __x)
- { return _M_t.insert_unique(position, __x); }
-
- /**
- * @brief A template function that attemps to insert elements from
- * another range (possibly another map).
- * @param first Iterator pointing to the start of the range to be inserted.
- * @param last Iterator pointing to the end of the range.
- */
- template <class _InputIterator>
- void insert(_InputIterator __first, _InputIterator __last) {
- _M_t.insert_unique(__first, __last);
- }
-
- /**
- * @brief Erases an element from a map.
- * @param position An iterator pointing to the element to be erased.
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
+ * <a href="tables.html#66">reversible container</a>, and an
+ * <a href="tables.html#69">associative container</a> (using unique keys).
+ * For a @c map<Key,T> the key_type is Key, the mapped_type is T, and the
+ * value_type is std::pair<const Key,T>.
*
- * This function erases an element, pointed to by the given iterator, from
- * a map. Note that this function only erases the element, and that if
- * the element is itself a pointer, the pointed-to memory is not touched
- * in any way. Managing the pointer is the user's responsibilty.
- */
- void erase(iterator __position) { _M_t.erase(__position); }
-
- /**
- * @brief Erases an element according to the provided key.
- * @param x Key of element to be erased.
- * @return Doc me! (Number of elements that match key? Only makes sense
- * with multimap)
- *
- * This function erases an element, located by the given key, from a map.
- * Note that this function only erases the element, and that if
- * the element is itself a pointer, the pointed-to memory is not touched
- * in any way. Managing the pointer is the user's responsibilty.
- */
- size_type erase(const key_type& __x) { return _M_t.erase(__x); }
-
- /**
- * @brief Erases a [first,last) range of elements from a map.
- * @param first Iterator pointing to the start of the range to be erased.
- * @param last Iterator pointing to the end of the range to be erased.
- *
- * This function erases a sequence of elements from a map.
- * Note that this function only erases the element, and that if
- * the element is itself a pointer, the pointed-to memory is not touched
- * in any way. Managing the pointer is the user's responsibilty.
- */
- void erase(iterator __first, iterator __last)
- { _M_t.erase(__first, __last); }
-
- /** Erases all elements in a map. Note that this function only erases
- * the elements, and that if the elements themselves are pointers, the
- * pointed-to memory is not touched in any way. Managing the pointer is
- * the user's responsibilty.
- */
- void clear() { _M_t.clear(); }
-
- // map operations:
-
- /**
- * @brief Tries to locate an element in a map.
- * @param x Key of (key, value) pair to be located.
- * @return Iterator pointing to sought-after element, or end() if not
- * found.
- *
- * This function takes a key and tries to locate the element with which
- * the key matches. If successful the function returns an iterator
- * pointing to the sought after pair. If unsuccessful it returns the
- * one past the end ( end() ) iterator.
- */
- iterator find(const key_type& __x) { return _M_t.find(__x); }
-
- /**
- * @brief Tries to locate an element in a map.
- * @param x Key of (key, value) pair to be located.
- * @return Read-only (constant) iterator pointing to sought-after
- * element, or end() if not found.
- *
- * This function takes a key and tries to locate the element with which
- * the key matches. If successful the function returns a constant iterator
- * pointing to the sought after pair. If unsuccessful it returns the
- * one past the end ( end() ) iterator.
- */
- const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
-
- /**
- * @brief Finds the number of elements with given key.
- * @param x Key of (key, value) pairs to be located.
- * @return Number of elements with specified key.
- *
- * This function only makes sense for multimaps.
- */
- size_type count(const key_type& __x) const {
- return _M_t.find(__x) == _M_t.end() ? 0 : 1;
- }
-
- /**
- * @brief Finds the beginning of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Iterator pointing to first element matching given key, or
- * end() if not found.
- *
- * This function is useful only with std::multimap. It returns the first
- * element of a subsequence of elements that matches the given key. If
- * unsuccessful it returns an iterator pointing to the first element that
- * has a greater value than given key or end() if no such element exists.
- */
- iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
-
- /**
- * @brief Finds the beginning of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Read-only (constant) iterator pointing to first element
- * matching given key, or end() if not found.
+ * Maps support bidirectional iterators.
*
- * This function is useful only with std::multimap. It returns the first
- * element of a subsequence of elements that matches the given key. If
- * unsuccessful the iterator will point to the next greatest element or,
- * if no such greater element exists, to end().
+ * @if maint
+ * The private tree data is declared exactly the same way for map and
+ * multimap; the distinction is made entirely in how the tree functions are
+ * called (*_unique versus *_equal, same as the standard).
+ * @endif
*/
- const_iterator lower_bound(const key_type& __x) const {
- return _M_t.lower_bound(__x);
- }
-
- /**
- * @brief Finds the end of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Iterator pointing to last element matching given key.
- *
- * This function only makes sense with multimaps.
- */
- iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }
-
- /**
- * @brief Finds the end of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Read-only (constant) iterator pointing to last element matching
- * given key.
- *
- * This function only makes sense with multimaps.
- */
- const_iterator upper_bound(const key_type& __x) const {
- return _M_t.upper_bound(__x);
- }
-
+ template <typename _Key, typename _Tp, typename _Compare = less<_Key>,
+ typename _Alloc = allocator<pair<const _Key, _Tp> > >
+ class map
+ {
+ // concept requirements
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+ __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
+
+ public:
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const _Key, _Tp> value_type;
+ typedef _Compare key_compare;
+
+ class value_compare
+ : public binary_function<value_type, value_type, bool>
+ {
+ friend class map<_Key,_Tp,_Compare,_Alloc>;
+ protected:
+ _Compare comp;
+ value_compare(_Compare __c) : comp(__c) {}
+ public:
+ bool operator()(const value_type& __x, const value_type& __y) const
+ { return comp(__x.first, __y.first); }
+ };
+
+ private:
+ /// @if maint This turns a red-black tree into a [multi]map. @endif
+ typedef _Rb_tree<key_type, value_type,
+ _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
+ /// @if maint The actual tree structure. @endif
+ _Rep_type _M_t;
+
+ public:
+ // many of these are specified differently in ISO, but the following are
+ // "functionally equivalent"
+ typedef typename _Rep_type::allocator_type allocator_type;
+ typedef typename _Rep_type::reference reference;
+ typedef typename _Rep_type::const_reference const_reference;
+ typedef typename _Rep_type::iterator iterator;
+ typedef typename _Rep_type::const_iterator const_iterator;
+ typedef typename _Rep_type::size_type size_type;
+ typedef typename _Rep_type::difference_type difference_type;
+ typedef typename _Rep_type::pointer pointer;
+ typedef typename _Rep_type::const_pointer const_pointer;
+ typedef typename _Rep_type::reverse_iterator reverse_iterator;
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
+
+
+ // [23.3.1.1] construct/copy/destroy
+ // (get_allocator() is normally listed in this section, but seems to have
+ // been accidentally omitted in the printed standard)
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ map() : _M_t(_Compare(), allocator_type()) { }
+
+ // for some reason this was made a separate function
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ map(const _Compare& __comp, const allocator_type& __a = allocator_type())
+ : _M_t(__comp, __a) { }
+
+ /**
+ * @brief Map copy constructor.
+ * @param x A %map of identical element and allocator types.
+ *
+ * The newly-created %map uses a copy of the allocation object used
+ * by @a x.
+ */
+ map(const map& __x)
+ : _M_t(__x._M_t) { }
+
+ /**
+ * @brief Builds a %map from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * Create a %map consisting of copies of the elements from [first,last).
+ * This is linear in N if the range is already sorted, and NlogN
+ * otherwise (where N is distance(first,last)).
+ */
+ template <typename _InputIterator>
+ map(_InputIterator __first, _InputIterator __last)
+ : _M_t(_Compare(), allocator_type())
+ { _M_t.insert_unique(__first, __last); }
+
+ /**
+ * @brief Builds a %map from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @param comp A comparison functor.
+ * @param a An allocator object.
+ *
+ * Create a %map consisting of copies of the elements from [first,last).
+ * This is linear in N if the range is already sorted, and NlogN
+ * otherwise (where N is distance(first,last)).
+ */
+ template <typename _InputIterator>
+ map(_InputIterator __first, _InputIterator __last,
+ const _Compare& __comp, const allocator_type& __a = allocator_type())
+ : _M_t(__comp, __a)
+ { _M_t.insert_unique(__first, __last); }
+
+ // FIXME There is no dtor declared, but we should have something generated
+ // by Doxygen. I don't know what tags to add to this paragraph to make
+ // that happen:
+ /**
+ * The dtor only erases the elements, and note that if the elements
+ * themselves are pointers, the pointed-to memory is not touched in any
+ * way. Managing the pointer is the user's responsibilty.
+ */
+
+ /**
+ * @brief Map assignment operator.
+ * @param x A %map of identical element and allocator types.
+ *
+ * All the elements of @a x are copied, but unlike the copy constructor,
+ * the allocator object is not copied.
+ */
+ map&
+ operator=(const map& __x)
+ {
+ _M_t = __x._M_t;
+ return *this;
+ }
+
+ /// Get a copy of the memory allocation object.
+ allocator_type
+ get_allocator() const { return _M_t.get_allocator(); }
+
+ // iterators
+ /**
+ * Returns a read/write iterator that points to the first pair in the %map.
+ * Iteration is done in ascending order according to the keys.
+ */
+ iterator
+ begin() { return _M_t.begin(); }
+
+ /**
+ * Returns a read-only (constant) iterator that points to the first pair
+ * in the %map. Iteration is done in ascending order according to the
+ * keys.
+ */
+ const_iterator
+ begin() const { return _M_t.begin(); }
+
+ /**
+ * Returns a read/write iterator that points one past the last pair in the
+ * %map. Iteration is done in ascending order according to the keys.
+ */
+ iterator
+ end() { return _M_t.end(); }
+
+ /**
+ * Returns a read-only (constant) iterator that points one past the last
+ * pair in the %map. Iteration is done in ascending order according to the
+ * keys.
+ */
+ const_iterator
+ end() const { return _M_t.end(); }
+
+ /**
+ * Returns a read/write reverse iterator that points to the last pair in
+ * the %map. Iteration is done in descending order according to the keys.
+ */
+ reverse_iterator
+ rbegin() { return _M_t.rbegin(); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to the last
+ * pair in the %map. Iteration is done in descending order according to
+ * the keys.
+ */
+ const_reverse_iterator
+ rbegin() const { return _M_t.rbegin(); }
+
+ /**
+ * Returns a read/write reverse iterator that points to one before the
+ * first pair in the %map. Iteration is done in descending order according
+ * to the keys.
+ */
+ reverse_iterator
+ rend() { return _M_t.rend(); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to one
+ * before the first pair in the %map. Iteration is done in descending
+ * order according to the keys.
+ */
+ const_reverse_iterator
+ rend() const { return _M_t.rend(); }
+
+ // capacity
+ /** Returns true if the %map is empty. (Thus begin() would equal end().) */
+ bool
+ empty() const { return _M_t.empty(); }
+
+ /** Returns the size of the %map. */
+ size_type
+ size() const { return _M_t.size(); }
+
+ /** Returns the maximum size of the %map. */
+ size_type
+ max_size() const { return _M_t.max_size(); }
+
+ // [23.3.1.2] element access
+ /**
+ * @brief Subscript ( @c [] ) access to %map data.
+ * @param k The key for which data should be retrieved.
+ * @return A reference to the data of the (key,data) %pair.
+ *
+ * Allows for easy lookup with the subscript ( @c [] ) operator. Returns
+ * data associated with the key specified in subscript. If the key does
+ * not exist, a pair with that key is created using default values, which
+ * is then returned.
+ *
+ * Lookup requires logarithmic time.
+ */
+ mapped_type&
+ operator[](const key_type& __k)
+ {
+ // concept requirements
+ __glibcpp_function_requires(_DefaultConstructibleConcept<mapped_type>)
+
+ iterator __i = lower_bound(__k);
+ // __i->first is greater than or equivalent to __k.
+ if (__i == end() || key_comp()(__k, (*__i).first))
+ __i = insert(__i, value_type(__k, mapped_type()));
+ return (*__i).second;
+ }
+
+ // modifiers
+ /**
+ * @brief Attempts to insert a std::pair into the %map.
+ * @param x Pair to be inserted (see std::make_pair for easy creation of
+ * pairs).
+ * @return A pair, of which the first element is an iterator that points
+ * to the possibly inserted pair, and the second is a bool that
+ * is true if the pair was actually inserted.
+ *
+ * This function attempts to insert a (key, value) %pair into the %map.
+ * A %map relies on unique keys and thus a %pair is only inserted if its
+ * first element (the key) is not already present in the %map.
+ *
+ * Insertion requires logarithmic time.
+ */
+ pair<iterator,bool>
+ insert(const value_type& __x)
+ { return _M_t.insert_unique(__x); }
+
+ /**
+ * @brief Attempts to insert a std::pair into the %map.
+ * @param position An iterator that serves as a hint as to where the
+ * pair should be inserted.
+ * @param x Pair to be inserted (see std::make_pair for easy creation of
+ * pairs).
+ * @return An iterator that points to the element with key of @a x (may
+ * or may not be the %pair passed in).
+ *
+ * This function is not concerned about whether the insertion took place,
+ * and thus does not return a boolean like the single-argument
+ * insert() does. Note that the first parameter is only a hint and can
+ * potentially improve the performance of the insertion process. A bad
+ * hint would cause no gains in efficiency.
+ *
+ * See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
+ * for more on "hinting".
+ *
+ * Insertion requires logarithmic time (if the hint is not taken).
+ */
+ iterator
+ insert(iterator position, const value_type& __x)
+ { return _M_t.insert_unique(position, __x); }
+
+ /**
+ * @brief A template function that attemps to insert a range of elements.
+ * @param first Iterator pointing to the start of the range to be
+ * inserted.
+ * @param last Iterator pointing to the end of the range.
+ *
+ * Complexity similar to that of the range constructor.
+ */
+ template <typename _InputIterator>
+ void
+ insert(_InputIterator __first, _InputIterator __last)
+ { _M_t.insert_unique(__first, __last); }
+
+ /**
+ * @brief Erases an element from a %map.
+ * @param position An iterator pointing to the element to be erased.
+ *
+ * This function erases an element, pointed to by the given iterator, from
+ * a %map. Note that this function only erases the element, and that if
+ * the element is itself a pointer, the pointed-to memory is not touched
+ * in any way. Managing the pointer is the user's responsibilty.
+ */
+ void
+ erase(iterator __position) { _M_t.erase(__position); }
+
+ /**
+ * @brief Erases elements according to the provided key.
+ * @param x Key of element to be erased.
+ * @return The number of elements erased.
+ *
+ * This function erases all the elements located by the given key from
+ * a %map.
+ * Note that this function only erases the element, and that if
+ * the element is itself a pointer, the pointed-to memory is not touched
+ * in any way. Managing the pointer is the user's responsibilty.
+ */
+ size_type
+ erase(const key_type& __x) { return _M_t.erase(__x); }
+
+ /**
+ * @brief Erases a [first,last) range of elements from a %map.
+ * @param first Iterator pointing to the start of the range to be erased.
+ * @param last Iterator pointing to the end of the range to be erased.
+ *
+ * This function erases a sequence of elements from a %map.
+ * Note that this function only erases the element, and that if
+ * the element is itself a pointer, the pointed-to memory is not touched
+ * in any way. Managing the pointer is the user's responsibilty.
+ */
+ void
+ erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
+
+ /**
+ * @brief Swaps data with another %map.
+ * @param x A %map of the same element and allocator types.
+ *
+ * This exchanges the elements between two maps in constant time.
+ * (It is only swapping a pointer, an integer, and an instance of
+ * the @c Compare type (which itself is often stateless and empty), so it
+ * should be quite fast.)
+ * Note that the global std::swap() function is specialized such that
+ * std::swap(m1,m2) will feed to this function.
+ */
+ void
+ swap(map& __x) { _M_t.swap(__x._M_t); }
+
+ /**
+ * Erases all elements in a %map. Note that this function only erases
+ * the elements, and that if the elements themselves are pointers, the
+ * pointed-to memory is not touched in any way. Managing the pointer is
+ * the user's responsibilty.
+ */
+ void
+ clear() { _M_t.clear(); }
+
+ // observers
+ /**
+ * Returns the key comparison object out of which the %map was constructed.
+ */
+ key_compare
+ key_comp() const { return _M_t.key_comp(); }
+
+ /**
+ * Returns a value comparison object, built from the key comparison
+ * object out of which the %map was constructed.
+ */
+ value_compare
+ value_comp() const { return value_compare(_M_t.key_comp()); }
+
+ // [23.3.1.3] map operations
+ /**
+ * @brief Tries to locate an element in a %map.
+ * @param x Key of (key, value) %pair to be located.
+ * @return Iterator pointing to sought-after element, or end() if not
+ * found.
+ *
+ * This function takes a key and tries to locate the element with which
+ * the key matches. If successful the function returns an iterator
+ * pointing to the sought after %pair. If unsuccessful it returns the
+ * past-the-end ( @c end() ) iterator.
+ */
+ iterator
+ find(const key_type& __x) { return _M_t.find(__x); }
+
+ /**
+ * @brief Tries to locate an element in a %map.
+ * @param x Key of (key, value) %pair to be located.
+ * @return Read-only (constant) iterator pointing to sought-after
+ * element, or end() if not found.
+ *
+ * This function takes a key and tries to locate the element with which
+ * the key matches. If successful the function returns a constant iterator
+ * pointing to the sought after %pair. If unsuccessful it returns the
+ * past-the-end ( @c end() ) iterator.
+ */
+ const_iterator
+ find(const key_type& __x) const { return _M_t.find(__x); }
+
+ /**
+ * @brief Finds the number of elements with given key.
+ * @param x Key of (key, value) pairs to be located.
+ * @return Number of elements with specified key.
+ *
+ * This function only makes sense for multimaps; for map the result will
+ * either be 0 (not present) or 1 (present).
+ */
+ size_type
+ count(const key_type& __x) const
+ { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
+
+ /**
+ * @brief Finds the beginning of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Iterator pointing to first element matching given key, or
+ * end() if not found.
+ *
+ * This function is useful only with multimaps. It returns the first
+ * element of a subsequence of elements that matches the given key. If
+ * unsuccessful it returns an iterator pointing to the first element that
+ * has a greater value than given key or end() if no such element exists.
+ */
+ iterator
+ lower_bound(const key_type& __x) { return _M_t.lower_bound(__x); }
+
+ /**
+ * @brief Finds the beginning of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Read-only (constant) iterator pointing to first element
+ * matching given key, or end() if not found.
+ *
+ * This function is useful only with multimaps. It returns the first
+ * element of a subsequence of elements that matches the given key. If
+ * unsuccessful the iterator will point to the next greatest element or,
+ * if no such greater element exists, to end().
+ */
+ const_iterator
+ lower_bound(const key_type& __x) const { return _M_t.lower_bound(__x); }
+
+ /**
+ * @brief Finds the end of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Iterator pointing to last element matching given key.
+ *
+ * This function only makes sense with multimaps.
+ */
+ iterator
+ upper_bound(const key_type& __x) { return _M_t.upper_bound(__x); }
+
+ /**
+ * @brief Finds the end of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Read-only (constant) iterator pointing to last element matching
+ * given key.
+ *
+ * This function only makes sense with multimaps.
+ */
+ const_iterator
+ upper_bound(const key_type& __x) const
+ { return _M_t.upper_bound(__x); }
+
+ /**
+ * @brief Finds a subsequence matching given key.
+ * @param x Key of (key, value) pairs to be located.
+ * @return Pair of iterators that possibly points to the subsequence
+ * matching given key.
+ *
+ * This function returns a pair of which the first
+ * element possibly points to the first element matching the given key
+ * and the second element possibly points to the last element matching the
+ * given key. If unsuccessful the first element of the returned pair will
+ * contain an iterator pointing to the next greatest element or, if no such
+ * greater element exists, to end().
+ *
+ * This function only makes sense for multimaps.
+ */
+ pair<iterator,iterator>
+ equal_range(const key_type& __x)
+ { return _M_t.equal_range(__x); }
+
+ /**
+ * @brief Finds a subsequence matching given key.
+ * @param x Key of (key, value) pairs to be located.
+ * @return Pair of read-only (constant) iterators that possibly points to
+ * the subsequence matching given key.
+ *
+ * This function returns a pair of which the first
+ * element possibly points to the first element matching the given key
+ * and the second element possibly points to the last element matching the
+ * given key. If unsuccessful the first element of the returned pair will
+ * contain an iterator pointing to the next greatest element or, if no such
+ * a greater element exists, to end().
+ *
+ * This function only makes sense for multimaps.
+ */
+ pair<const_iterator,const_iterator>
+ equal_range(const key_type& __x) const
+ { return _M_t.equal_range(__x); }
+
+ template <typename _K1, typename _T1, typename _C1, typename _A1>
+ friend bool operator== (const map<_K1,_T1,_C1,_A1>&,
+ const map<_K1,_T1,_C1,_A1>&);
+ template <typename _K1, typename _T1, typename _C1, typename _A1>
+ friend bool operator< (const map<_K1,_T1,_C1,_A1>&,
+ const map<_K1,_T1,_C1,_A1>&);
+ };
+
+
/**
- * @brief Finds a subsequence matching given key.
- * @param x Key of (key, value) pairs to be located.
- * @return Pair of iterators that possibly points to the subsequence
- * matching given key.
+ * @brief Map equality comparison.
+ * @param x A %map.
+ * @param y A %map of the same type as @a x.
+ * @return True iff the size and elements of the maps are equal.
*
- * This function improves on lower_bound() and upper_bound() by giving a more
- * elegant and efficient solution. It returns a pair of which the first
- * element possibly points to the first element matching the given key
- * and the second element possibly points to the last element matching the
- * given key. If unsuccessful the first element of the returned pair will
- * contain an iterator pointing to the next greatest element or, if no such
- * greater element exists, to end().
- *
- * This function only makes sense for multimaps.
+ * This is an equivalence relation. It is linear in the size of the
+ * maps. Maps are considered equivalent if their sizes are equal,
+ * and if corresponding elements compare equal.
*/
- pair<iterator,iterator> equal_range(const key_type& __x) {
- return _M_t.equal_range(__x);
- }
-
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x,
+ const map<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return __x._M_t == __y._M_t; }
+
/**
- * @brief Finds a subsequence matching given key.
- * @param x Key of (key, value) pairs to be located.
- * @return Pair of read-only (constant) iterators that possibly points to
- * the subsequence matching given key.
+ * @brief Map ordering relation.
+ * @param x A %map.
+ * @param y A %map of the same type as @a x.
+ * @return True iff @a x is lexographically less than @a y.
*
- * This function improves on lower_bound() and upper_bound() by giving a more
- * elegant and efficient solution. It returns a pair of which the first
- * element possibly points to the first element matching the given key
- * and the second element possibly points to the last element matching the
- * given key. If unsuccessful the first element of the returned pair will
- * contain an iterator pointing to the next greatest element or, if no such
- * a greater element exists, to end().
+ * This is a total ordering relation. It is linear in the size of the
+ * maps. The elements must be comparable with @c <.
*
- * This function only makes sense for multimaps.
+ * See std::lexographical_compare() for how the determination is made.
*/
- pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
- return _M_t.equal_range(__x);
- }
-
- template <class _K1, class _T1, class _C1, class _A1>
- friend bool operator== (const map<_K1, _T1, _C1, _A1>&,
- const map<_K1, _T1, _C1, _A1>&);
- template <class _K1, class _T1, class _C1, class _A1>
- friend bool operator< (const map<_K1, _T1, _C1, _A1>&,
- const map<_K1, _T1, _C1, _A1>&);
-};
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x,
- const map<_Key,_Tp,_Compare,_Alloc>& __y) {
- return __x._M_t == __y._M_t;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x,
- const map<_Key,_Tp,_Compare,_Alloc>& __y) {
- return __x._M_t < __y._M_t;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator!=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
- const map<_Key,_Tp,_Compare,_Alloc>& __y) {
- return !(__x == __y);
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator>(const map<_Key,_Tp,_Compare,_Alloc>& __x,
- const map<_Key,_Tp,_Compare,_Alloc>& __y) {
- return __y < __x;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator<=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
- const map<_Key,_Tp,_Compare,_Alloc>& __y) {
- return !(__y < __x);
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator>=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
- const map<_Key,_Tp,_Compare,_Alloc>& __y) {
- return !(__x < __y);
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline void swap(map<_Key,_Tp,_Compare,_Alloc>& __x,
- map<_Key,_Tp,_Compare,_Alloc>& __y) {
- __x.swap(__y);
-}
-
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x,
+ const map<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return __x._M_t < __y._M_t; }
+
+ /// Based on operator==
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator!=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
+ const map<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return !(__x == __y); }
+
+ /// Based on operator<
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator>(const map<_Key,_Tp,_Compare,_Alloc>& __x,
+ const map<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return __y < __x; }
+
+ /// Based on operator<
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator<=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
+ const map<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return !(__y < __x); }
+
+ /// Based on operator<
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator>=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
+ const map<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return !(__x < __y); }
+
+ /// See std::map::swap().
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline void
+ swap(map<_Key,_Tp,_Compare,_Alloc>& __x, map<_Key,_Tp,_Compare,_Alloc>& __y)
+ { __x.swap(__y); }
} // namespace std
-#endif /* _CPP_BITS_STL_MAP_H */
-
-// Local Variables:
-// mode:C++
-// End:
+#endif /* __GLIBCPP_INTERNAL_MAP_H */
diff --git a/contrib/libstdc++/include/bits/stl_multimap.h b/contrib/libstdc++/include/bits/stl_multimap.h
index 5947d75..0fa79a8 100644
--- a/contrib/libstdc++/include/bits/stl_multimap.h
+++ b/contrib/libstdc++/include/bits/stl_multimap.h
@@ -1,6 +1,6 @@
// Multimap implementation -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -65,427 +65,572 @@
namespace std
{
-// Forward declaration of operators < and ==, needed for friend declaration.
-template <class _Key, class _Tp,
- class _Compare = less<_Key>,
- class _Alloc = allocator<pair<const _Key, _Tp> > >
-class multimap;
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
-
-/**
- * @brief A standard container made up of pairs (see std::pair in <utility>)
- * which can be retrieved based on a key.
- *
- * This is an associative container. Values contained within it can be
- * quickly retrieved through a key element. In contrast with a map a
- * multimap can have multiple duplicate keys.
-*/
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-class multimap
-{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
- __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept);
-
-public:
-
-// typedefs:
-
- typedef _Key key_type;
- typedef _Tp data_type;
- typedef _Tp mapped_type;
- typedef pair<const _Key, _Tp> value_type;
- typedef _Compare key_compare;
-
- class value_compare : public binary_function<value_type, value_type, bool> {
- friend class multimap<_Key,_Tp,_Compare,_Alloc>;
- protected:
- _Compare comp;
- value_compare(_Compare __c) : comp(__c) {}
- public:
- bool operator()(const value_type& __x, const value_type& __y) const {
- return comp(__x.first, __y.first);
- }
- };
-
-private:
- typedef _Rb_tree<key_type, value_type,
- _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
- _Rep_type _M_t; // red-black tree representing multimap
-public:
- typedef typename _Rep_type::pointer pointer;
- typedef typename _Rep_type::const_pointer const_pointer;
- typedef typename _Rep_type::reference reference;
- typedef typename _Rep_type::const_reference const_reference;
- typedef typename _Rep_type::iterator iterator;
- typedef typename _Rep_type::const_iterator const_iterator;
- typedef typename _Rep_type::reverse_iterator reverse_iterator;
- typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
- typedef typename _Rep_type::size_type size_type;
- typedef typename _Rep_type::difference_type difference_type;
- typedef typename _Rep_type::allocator_type allocator_type;
-
-// allocation/deallocation
-
- multimap() : _M_t(_Compare(), allocator_type()) { }
- explicit multimap(const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a) { }
-
- template <class _InputIterator>
- multimap(_InputIterator __first, _InputIterator __last)
- : _M_t(_Compare(), allocator_type())
- { _M_t.insert_equal(__first, __last); }
-
- template <class _InputIterator>
- multimap(_InputIterator __first, _InputIterator __last,
- const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
- multimap(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) { }
-
- multimap<_Key,_Tp,_Compare,_Alloc>&
- operator=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) {
- _M_t = __x._M_t;
- return *this;
- }
-
- // accessors:
-
- key_compare key_comp() const { return _M_t.key_comp(); }
- value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
- allocator_type get_allocator() const { return _M_t.get_allocator(); }
-
+ // Forward declaration of operators < and ==, needed for friend declaration.
+
+ template <typename _Key, typename _Tp,
+ typename _Compare = less<_Key>,
+ typename _Alloc = allocator<pair<const _Key, _Tp> > >
+ class multimap;
+
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
+
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
+
/**
- * Returns a read/write iterator that points to the first pair in the
- * multimap. Iteration is done in ascending order according to the keys.
- */
- iterator begin() { return _M_t.begin(); }
-
- /**
- * Returns a read-only (constant) iterator that points to the first pair
- * in the multimap. Iteration is done in ascending order according to the
- * keys.
- */
- const_iterator begin() const { return _M_t.begin(); }
-
- /**
- * Returns a read/write iterator that points one past the last pair in the
- * multimap. Iteration is done in ascending order according to the keys.
- */
- iterator end() { return _M_t.end(); }
-
- /**
- * Returns a read-only (constant) iterator that points one past the last
- * pair in the multimap. Iteration is done in ascending order according
- * to the keys.
- */
- const_iterator end() const { return _M_t.end(); }
-
- /**
- * Returns a read/write reverse iterator that points to the last pair in
- * the multimap. Iteration is done in descending order according to the
- * keys.
- */
- reverse_iterator rbegin() { return _M_t.rbegin(); }
-
- /**
- * Returns a read-only (constant) reverse iterator that points to the last
- * pair in the multimap. Iteration is done in descending order according
- * to the keys.
- */
- const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
-
- /**
- * Returns a read/write reverse iterator that points to one before the
- * first pair in the multimap. Iteration is done in descending order
- * according to the keys.
- */
- reverse_iterator rend() { return _M_t.rend(); }
-
- /**
- * Returns a read-only (constant) reverse iterator that points to one
- * before the first pair in the multimap. Iteration is done in descending
- * order according to the keys.
- */
- const_reverse_iterator rend() const { return _M_t.rend(); }
-
- /** Returns true if the map is empty. (Thus begin() would equal end().) */
- bool empty() const { return _M_t.empty(); }
-
- /** Returns the size of the map. */
- size_type size() const { return _M_t.size(); }
-
- /** Returns the maximum size of the map. */
- size_type max_size() const { return _M_t.max_size(); }
-
- void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
-
- // insert/erase
- /**
- * @brief Inserts a std::pair into the multimap.
- * @param x Pair to be inserted (see std::make_pair for easy creation of
- * pairs).
- * @return An iterator that points to the inserted (key,value) pair.
+ * @brief A standard container made up of (key,value) pairs, which can be
+ * retrieved based on a key, in logarithmic time.
*
- * This function inserts a (key, value) pair into the multimap. Contrary
- * to a std::map the multimap does not rely on unique keys and thus a
- * multiple pairs with the same key can be inserted.
- */
- iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }
-
- /**
- * @brief Inserts a std::pair into the multimap.
- * @param position An iterator that serves as a hint as to where the
- * pair should be inserted.
- * @param x Pair to be inserted (see std::make_pair for easy creation of
- * pairs).
- * @return An iterator that points to the inserted (key,value) pair.
+ * @ingroup Containers
+ * @ingroup Assoc_containers
*
- * This function inserts a (key, value) pair into the multimap. Contrary
- * to a std::map the multimap does not rely on unique keys and thus a
- * multiple pairs with the same key can be inserted.
- * Note that the first parameter is only a hint and can potentially
- * improve the performance of the insertion process. A bad hint would
- * cause no gains in efficiency.
- */
- iterator insert(iterator __position, const value_type& __x) {
- return _M_t.insert_equal(__position, __x);
- }
-
- /**
- * @brief A template function that attemps to insert elements from
- * another range (possibly another multimap or standard container).
- * @param first Iterator pointing to the start of the range to be
- * inserted.
- * @param last Iterator pointing to the end of the range to be inserted.
- */
- template <class _InputIterator>
- void insert(_InputIterator __first, _InputIterator __last) {
- _M_t.insert_equal(__first, __last);
- }
-
- /**
- * @brief Erases an element from a multimap.
- * @param position An iterator pointing to the element to be erased.
- *
- * This function erases an element, pointed to by the given iterator, from
- * a mutlimap. Note that this function only erases the element, and that
- * if the element is itself a pointer, the pointed-to memory is not
- * touched in any way. Managing the pointer is the user's responsibilty.
- */
- void erase(iterator __position) { _M_t.erase(__position); }
-
- /**
- * @brief Erases an element according to the provided key.
- * @param x Key of element to be erased.
- * @return Doc me! (Number of elements erased?)
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
+ * <a href="tables.html#66">reversible container</a>, and an
+ * <a href="tables.html#69">associative container</a> (using equivalent
+ * keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
+ * is T, and the value_type is std::pair<const Key,T>.
*
- * This function erases all elements, located by the given key, from a
- * multimap.
- * Note that this function only erases the element, and that if
- * the element is itself a pointer, the pointed-to memory is not touched
- * in any way. Managing the pointer is the user's responsibilty.
- */
- size_type erase(const key_type& __x) { return _M_t.erase(__x); }
-
- /**
- * @brief Erases a [first,last) range of elements from a multimap.
- * @param first Iterator pointing to the start of the range to be erased.
- * @param last Iterator pointing to the end of the range to be erased.
- *
- * This function erases a sequence of elements from a multimap.
- * Note that this function only erases the elements, and that if
- * the elements themselves are pointers, the pointed-to memory is not
- * touched in any way. Managing the pointer is the user's responsibilty.
- */
- void erase(iterator __first, iterator __last)
- { _M_t.erase(__first, __last); }
-
- /** Erases all elements in a multimap. Note that this function only erases
- * the elements, and that if the elements themselves are pointers, the
- * pointed-to memory is not touched in any way. Managing the pointer is
- * the user's responsibilty.
- */
- void clear() { _M_t.clear(); }
-
- // multimap operations:
-
- /**
- * @brief Tries to locate an element in a multimap.
- * @param x Key of (key, value) pair to be located.
- * @return Iterator pointing to sought-after (first matching?) element,
- * or end() if not found.
- *
- * This function takes a key and tries to locate the element with which
- * the key matches. If successful the function returns an iterator
- * pointing to the sought after pair. If unsuccessful it returns the
- * one past the end ( end() ) iterator.
- */
- iterator find(const key_type& __x) { return _M_t.find(__x); }
-
- /**
- * @brief Tries to locate an element in a multimap.
- * @param x Key of (key, value) pair to be located.
- * @return Read-only (constant) iterator pointing to sought-after (first
- * matching?) element, or end() if not found.
- *
- * This function takes a key and tries to locate the element with which
- * the key matches. If successful the function returns a constant iterator
- * pointing to the sought after pair. If unsuccessful it returns the
- * one past the end ( end() ) iterator.
- */
- const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
-
- /**
- * @brief Finds the number of elements with given key.
- * @param x Key of (key, value) pairs to be located.
- * @return Number of elements with specified key.
- */
- size_type count(const key_type& __x) const { return _M_t.count(__x); }
-
- /**
- * @brief Finds the beginning of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Iterator pointing to first element matching given key, or
- * end() if not found.
+ * Multimaps support bidirectional iterators.
*
- * This function returns the first element of a subsequence of elements
- * that matches the given key. If unsuccessful it returns an iterator
- * pointing to the first element that has a greater value than given key
- * or end() if no such element exists.
+ * @if maint
+ * The private tree data is declared exactly the same way for map and
+ * multimap; the distinction is made entirely in how the tree functions are
+ * called (*_unique versus *_equal, same as the standard).
+ * @endif
*/
- iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
-
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ class multimap
+ {
+ // concept requirements
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+ __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
+
+ public:
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const _Key, _Tp> value_type;
+ typedef _Compare key_compare;
+
+ class value_compare
+ : public binary_function<value_type, value_type, bool>
+ {
+ friend class multimap<_Key,_Tp,_Compare,_Alloc>;
+ protected:
+ _Compare comp;
+ value_compare(_Compare __c) : comp(__c) {}
+ public:
+ bool operator()(const value_type& __x, const value_type& __y) const
+ { return comp(__x.first, __y.first); }
+ };
+
+ private:
+ /// @if maint This turns a red-black tree into a [multi]map. @endif
+ typedef _Rb_tree<key_type, value_type,
+ _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
+ /// @if maint The actual tree structure. @endif
+ _Rep_type _M_t;
+
+ public:
+ // many of these are specified differently in ISO, but the following are
+ // "functionally equivalent"
+ typedef typename _Rep_type::allocator_type allocator_type;
+ typedef typename _Rep_type::reference reference;
+ typedef typename _Rep_type::const_reference const_reference;
+ typedef typename _Rep_type::iterator iterator;
+ typedef typename _Rep_type::const_iterator const_iterator;
+ typedef typename _Rep_type::size_type size_type;
+ typedef typename _Rep_type::difference_type difference_type;
+ typedef typename _Rep_type::pointer pointer;
+ typedef typename _Rep_type::const_pointer const_pointer;
+ typedef typename _Rep_type::reverse_iterator reverse_iterator;
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
+
+
+ // [23.3.2] construct/copy/destroy
+ // (get_allocator() is also listed in this section)
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ multimap() : _M_t(_Compare(), allocator_type()) { }
+
+ // for some reason this was made a separate function
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ multimap(const _Compare& __comp, const allocator_type& __a = allocator_type())
+ : _M_t(__comp, __a) { }
+
+ /**
+ * @brief %Multimap copy constructor.
+ * @param x A %multimap of identical element and allocator types.
+ *
+ * The newly-created %multimap uses a copy of the allocation object used
+ * by @a x.
+ */
+ multimap(const multimap& __x)
+ : _M_t(__x._M_t) { }
+
+ /**
+ * @brief Builds a %multimap from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * Create a %multimap consisting of copies of the elements from
+ * [first,last). This is linear in N if the range is already sorted,
+ * and NlogN otherwise (where N is distance(first,last)).
+ */
+ template <typename _InputIterator>
+ multimap(_InputIterator __first, _InputIterator __last)
+ : _M_t(_Compare(), allocator_type())
+ { _M_t.insert_equal(__first, __last); }
+
+ /**
+ * @brief Builds a %multimap from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @param comp A comparison functor.
+ * @param a An allocator object.
+ *
+ * Create a %multimap consisting of copies of the elements from
+ * [first,last). This is linear in N if the range is already sorted,
+ * and NlogN otherwise (where N is distance(first,last)).
+ */
+ template <typename _InputIterator>
+ multimap(_InputIterator __first, _InputIterator __last,
+ const _Compare& __comp,
+ const allocator_type& __a = allocator_type())
+ : _M_t(__comp, __a)
+ { _M_t.insert_equal(__first, __last); }
+
+ // FIXME There is no dtor declared, but we should have something generated
+ // by Doxygen. I don't know what tags to add to this paragraph to make
+ // that happen:
+ /**
+ * The dtor only erases the elements, and note that if the elements
+ * themselves are pointers, the pointed-to memory is not touched in any
+ * way. Managing the pointer is the user's responsibilty.
+ */
+
+ /**
+ * @brief %Multimap assignment operator.
+ * @param x A %multimap of identical element and allocator types.
+ *
+ * All the elements of @a x are copied, but unlike the copy constructor,
+ * the allocator object is not copied.
+ */
+ multimap&
+ operator=(const multimap& __x)
+ {
+ _M_t = __x._M_t;
+ return *this;
+ }
+
+ /// Get a copy of the memory allocation object.
+ allocator_type
+ get_allocator() const { return _M_t.get_allocator(); }
+
+ // iterators
+ /**
+ * Returns a read/write iterator that points to the first pair in the
+ * %multimap. Iteration is done in ascending order according to the keys.
+ */
+ iterator
+ begin() { return _M_t.begin(); }
+
+ /**
+ * Returns a read-only (constant) iterator that points to the first pair
+ * in the %multimap. Iteration is done in ascending order according to the
+ * keys.
+ */
+ const_iterator
+ begin() const { return _M_t.begin(); }
+
+ /**
+ * Returns a read/write iterator that points one past the last pair in the
+ * %multimap. Iteration is done in ascending order according to the keys.
+ */
+ iterator
+ end() { return _M_t.end(); }
+
+ /**
+ * Returns a read-only (constant) iterator that points one past the last
+ * pair in the %multimap. Iteration is done in ascending order according
+ * to the keys.
+ */
+ const_iterator
+ end() const { return _M_t.end(); }
+
+ /**
+ * Returns a read/write reverse iterator that points to the last pair in
+ * the %multimap. Iteration is done in descending order according to the
+ * keys.
+ */
+ reverse_iterator
+ rbegin() { return _M_t.rbegin(); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to the last
+ * pair in the %multimap. Iteration is done in descending order according
+ * to the keys.
+ */
+ const_reverse_iterator
+ rbegin() const { return _M_t.rbegin(); }
+
+ /**
+ * Returns a read/write reverse iterator that points to one before the
+ * first pair in the %multimap. Iteration is done in descending order
+ * according to the keys.
+ */
+ reverse_iterator
+ rend() { return _M_t.rend(); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points to one
+ * before the first pair in the %multimap. Iteration is done in descending
+ * order according to the keys.
+ */
+ const_reverse_iterator
+ rend() const { return _M_t.rend(); }
+
+ // capacity
+ /** Returns true if the %multimap is empty. */
+ bool
+ empty() const { return _M_t.empty(); }
+
+ /** Returns the size of the %multimap. */
+ size_type
+ size() const { return _M_t.size(); }
+
+ /** Returns the maximum size of the %multimap. */
+ size_type
+ max_size() const { return _M_t.max_size(); }
+
+ // modifiers
+ /**
+ * @brief Inserts a std::pair into the %multimap.
+ * @param x Pair to be inserted (see std::make_pair for easy creation of
+ * pairs).
+ * @return An iterator that points to the inserted (key,value) pair.
+ *
+ * This function inserts a (key, value) pair into the %multimap. Contrary
+ * to a std::map the %multimap does not rely on unique keys and thus
+ * multiple pairs with the same key can be inserted.
+ *
+ * Insertion requires logarithmic time.
+ */
+ iterator
+ insert(const value_type& __x) { return _M_t.insert_equal(__x); }
+
+ /**
+ * @brief Inserts a std::pair into the %multimap.
+ * @param position An iterator that serves as a hint as to where the
+ * pair should be inserted.
+ * @param x Pair to be inserted (see std::make_pair for easy creation of
+ * pairs).
+ * @return An iterator that points to the inserted (key,value) pair.
+ *
+ * This function inserts a (key, value) pair into the %multimap. Contrary
+ * to a std::map the %multimap does not rely on unique keys and thus
+ * multiple pairs with the same key can be inserted.
+ * Note that the first parameter is only a hint and can potentially
+ * improve the performance of the insertion process. A bad hint would
+ * cause no gains in efficiency.
+ *
+ * See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
+ * for more on "hinting".
+ *
+ * Insertion requires logarithmic time (if the hint is not taken).
+ */
+ iterator
+ insert(iterator __position, const value_type& __x)
+ { return _M_t.insert_equal(__position, __x); }
+
+ /**
+ * @brief A template function that attemps to insert a range of elements.
+ * @param first Iterator pointing to the start of the range to be
+ * inserted.
+ * @param last Iterator pointing to the end of the range.
+ *
+ * Complexity similar to that of the range constructor.
+ */
+ template <typename _InputIterator>
+ void
+ insert(_InputIterator __first, _InputIterator __last)
+ { _M_t.insert_equal(__first, __last); }
+
+ /**
+ * @brief Erases an element from a %multimap.
+ * @param position An iterator pointing to the element to be erased.
+ *
+ * This function erases an element, pointed to by the given iterator, from
+ * a %multimap. Note that this function only erases the element, and that
+ * if the element is itself a pointer, the pointed-to memory is not
+ * touched in any way. Managing the pointer is the user's responsibilty.
+ */
+ void
+ erase(iterator __position) { _M_t.erase(__position); }
+
+ /**
+ * @brief Erases elements according to the provided key.
+ * @param x Key of element to be erased.
+ * @return The number of elements erased.
+ *
+ * This function erases all elements located by the given key from a
+ * %multimap.
+ * Note that this function only erases the element, and that if
+ * the element is itself a pointer, the pointed-to memory is not touched
+ * in any way. Managing the pointer is the user's responsibilty.
+ */
+ size_type
+ erase(const key_type& __x) { return _M_t.erase(__x); }
+
+ /**
+ * @brief Erases a [first,last) range of elements from a %multimap.
+ * @param first Iterator pointing to the start of the range to be erased.
+ * @param last Iterator pointing to the end of the range to be erased.
+ *
+ * This function erases a sequence of elements from a %multimap.
+ * Note that this function only erases the elements, and that if
+ * the elements themselves are pointers, the pointed-to memory is not
+ * touched in any way. Managing the pointer is the user's responsibilty.
+ */
+ void
+ erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
+
+ /**
+ * @brief Swaps data with another %multimap.
+ * @param x A %multimap of the same element and allocator types.
+ *
+ * This exchanges the elements between two multimaps in constant time.
+ * (It is only swapping a pointer, an integer, and an instance of
+ * the @c Compare type (which itself is often stateless and empty), so it
+ * should be quite fast.)
+ * Note that the global std::swap() function is specialized such that
+ * std::swap(m1,m2) will feed to this function.
+ */
+ void
+ swap(multimap& __x) { _M_t.swap(__x._M_t); }
+
+ /**
+ * Erases all elements in a %multimap. Note that this function only erases
+ * the elements, and that if the elements themselves are pointers, the
+ * pointed-to memory is not touched in any way. Managing the pointer is
+ * the user's responsibilty.
+ */
+ void
+ clear() { _M_t.clear(); }
+
+ // observers
+ /**
+ * Returns the key comparison object out of which the %multimap
+ * was constructed.
+ */
+ key_compare
+ key_comp() const { return _M_t.key_comp(); }
+
+ /**
+ * Returns a value comparison object, built from the key comparison
+ * object out of which the %multimap was constructed.
+ */
+ value_compare
+ value_comp() const { return value_compare(_M_t.key_comp()); }
+
+ // multimap operations
+ /**
+ * @brief Tries to locate an element in a %multimap.
+ * @param x Key of (key, value) pair to be located.
+ * @return Iterator pointing to sought-after element,
+ * or end() if not found.
+ *
+ * This function takes a key and tries to locate the element with which
+ * the key matches. If successful the function returns an iterator
+ * pointing to the sought after %pair. If unsuccessful it returns the
+ * past-the-end ( @c end() ) iterator.
+ */
+ iterator
+ find(const key_type& __x) { return _M_t.find(__x); }
+
+ /**
+ * @brief Tries to locate an element in a %multimap.
+ * @param x Key of (key, value) pair to be located.
+ * @return Read-only (constant) iterator pointing to sought-after
+ * element, or end() if not found.
+ *
+ * This function takes a key and tries to locate the element with which
+ * the key matches. If successful the function returns a constant iterator
+ * pointing to the sought after %pair. If unsuccessful it returns the
+ * past-the-end ( @c end() ) iterator.
+ */
+ const_iterator
+ find(const key_type& __x) const { return _M_t.find(__x); }
+
+ /**
+ * @brief Finds the number of elements with given key.
+ * @param x Key of (key, value) pairs to be located.
+ * @return Number of elements with specified key.
+ */
+ size_type
+ count(const key_type& __x) const { return _M_t.count(__x); }
+
+ /**
+ * @brief Finds the beginning of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Iterator pointing to first element matching given key, or
+ * end() if not found.
+ *
+ * This function returns the first element of a subsequence of elements
+ * that matches the given key. If unsuccessful it returns an iterator
+ * pointing to the first element that has a greater value than given key
+ * or end() if no such element exists.
+ */
+ iterator
+ lower_bound(const key_type& __x) { return _M_t.lower_bound(__x); }
+
+ /**
+ * @brief Finds the beginning of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Read-only (constant) iterator pointing to first element
+ * matching given key, or end() if not found.
+ *
+ * This function returns the first element of a subsequence of elements
+ * that matches the given key. If unsuccessful the iterator will point
+ * to the next greatest element or, if no such greater element exists, to
+ * end().
+ */
+ const_iterator
+ lower_bound(const key_type& __x) const { return _M_t.lower_bound(__x); }
+
+ /**
+ * @brief Finds the end of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Iterator pointing to last element matching given key.
+ */
+ iterator
+ upper_bound(const key_type& __x) { return _M_t.upper_bound(__x); }
+
+ /**
+ * @brief Finds the end of a subsequence matching given key.
+ * @param x Key of (key, value) pair to be located.
+ * @return Read-only (constant) iterator pointing to last element matching
+ * given key.
+ */
+ const_iterator
+ upper_bound(const key_type& __x) const { return _M_t.upper_bound(__x); }
+
+ /**
+ * @brief Finds a subsequence matching given key.
+ * @param x Key of (key, value) pairs to be located.
+ * @return Pair of iterators that possibly points to the subsequence
+ * matching given key.
+ *
+ * This function returns a pair of which the first
+ * element possibly points to the first element matching the given key
+ * and the second element possibly points to the last element matching the
+ * given key. If unsuccessful the first element of the returned pair will
+ * contain an iterator pointing to the next greatest element or, if no such
+ * greater element exists, to end().
+ */
+ pair<iterator,iterator>
+ equal_range(const key_type& __x) { return _M_t.equal_range(__x); }
+
+ /**
+ * @brief Finds a subsequence matching given key.
+ * @param x Key of (key, value) pairs to be located.
+ * @return Pair of read-only (constant) iterators that possibly points to
+ * the subsequence matching given key.
+ *
+ * This function returns a pair of which the first
+ * element possibly points to the first element matching the given key
+ * and the second element possibly points to the last element matching the
+ * given key. If unsuccessful the first element of the returned pair will
+ * contain an iterator pointing to the next greatest element or, if no such
+ * a greater element exists, to end().
+ */
+ pair<const_iterator,const_iterator>
+ equal_range(const key_type& __x) const { return _M_t.equal_range(__x); }
+
+ template <typename _K1, typename _T1, typename _C1, typename _A1>
+ friend bool operator== (const multimap<_K1,_T1,_C1,_A1>&,
+ const multimap<_K1,_T1,_C1,_A1>&);
+ template <typename _K1, typename _T1, typename _C1, typename _A1>
+ friend bool operator< (const multimap<_K1,_T1,_C1,_A1>&,
+ const multimap<_K1,_T1,_C1,_A1>&);
+ };
+
+
/**
- * @brief Finds the beginning of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Read-only (constant) iterator pointing to first element
- * matching given key, or end() if not found.
+ * @brief Multimap equality comparison.
+ * @param x A %multimap.
+ * @param y A %multimap of the same type as @a x.
+ * @return True iff the size and elements of the maps are equal.
*
- * This function returns the first element of a subsequence of elements
- * that matches the given key. If unsuccessful the iterator will point
- * to the next greatest element or, if no such greater element exists, to
- * end().
- */
- const_iterator lower_bound(const key_type& __x) const {
- return _M_t.lower_bound(__x);
- }
-
- /**
- * @brief Finds the end of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Iterator pointing to last element matching given key.
+ * This is an equivalence relation. It is linear in the size of the
+ * multimaps. Multimaps are considered equivalent if their sizes are equal,
+ * and if corresponding elements compare equal.
*/
- iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }
-
- /**
- * @brief Finds the end of a subsequence matching given key.
- * @param x Key of (key, value) pair to be located.
- * @return Read-only (constant) iterator pointing to last element matching
- * given key.
- */
- const_iterator upper_bound(const key_type& __x) const {
- return _M_t.upper_bound(__x);
- }
-
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y)
+ {
+ return __x._M_t == __y._M_t;
+ }
+
/**
- * @brief Finds a subsequence matching given key.
- * @param x Key of (key, value) pairs to be located.
- * @return Pair of iterators that possibly points to the subsequence
- * matching given key.
+ * @brief Multimap ordering relation.
+ * @param x A %multimap.
+ * @param y A %multimap of the same type as @a x.
+ * @return True iff @a x is lexographically less than @a y.
*
- * This function improves on lower_bound() and upper_bound() by giving a more
- * elegant and efficient solution. It returns a pair of which the first
- * element possibly points to the first element matching the given key
- * and the second element possibly points to the last element matching the
- * given key. If unsuccessful the first element of the returned pair will
- * contain an iterator pointing to the next greatest element or, if no such
- * greater element exists, to end().
- */
- pair<iterator,iterator> equal_range(const key_type& __x) {
- return _M_t.equal_range(__x);
- }
-
- /**
- * @brief Finds a subsequence matching given key.
- * @param x Key of (key, value) pairs to be located.
- * @return Pair of read-only (constant) iterators that possibly points to
- * the subsequence matching given key.
+ * This is a total ordering relation. It is linear in the size of the
+ * multimaps. The elements must be comparable with @c <.
*
- * This function improves on lower_bound() and upper_bound() by giving a more
- * elegant and efficient solution. It returns a pair of which the first
- * element possibly points to the first element matching the given key
- * and the second element possibly points to the last element matching the
- * given key. If unsuccessful the first element of the returned pair will
- * contain an iterator pointing to the next greatest element or, if no such
- * a greater element exists, to end().
+ * See std::lexographical_compare() for how the determination is made.
*/
- pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
- return _M_t.equal_range(__x);
- }
-
- template <class _K1, class _T1, class _C1, class _A1>
- friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&,
- const multimap<_K1, _T1, _C1, _A1>&);
- template <class _K1, class _T1, class _C1, class _A1>
- friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&,
- const multimap<_K1, _T1, _C1, _A1>&);
-};
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
- return __x._M_t == __y._M_t;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
- return __x._M_t < __y._M_t;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
- return !(__x == __y);
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
- return __y < __x;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
- return !(__y < __x);
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline bool operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
- return !(__x < __y);
-}
-
-template <class _Key, class _Tp, class _Compare, class _Alloc>
-inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
- __x.swap(__y);
-}
-
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return __x._M_t < __y._M_t; }
+
+ /// Based on operator==
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return !(__x == __y); }
+
+ /// Based on operator<
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return __y < __x; }
+
+ /// Based on operator<
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return !(__y < __x); }
+
+ /// Based on operator<
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline bool
+ operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y)
+ { return !(__x < __y); }
+
+ /// See std::multimap::swap().
+ template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline void
+ swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ multimap<_Key,_Tp,_Compare,_Alloc>& __y)
+ { __x.swap(__y); }
} // namespace std
#endif /* __GLIBCPP_INTERNAL_MULTIMAP_H */
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/bits/stl_queue.h b/contrib/libstdc++/include/bits/stl_queue.h
index 5503640..ff2ba26 100644
--- a/contrib/libstdc++/include/bits/stl_queue.h
+++ b/contrib/libstdc++/include/bits/stl_queue.h
@@ -1,6 +1,6 @@
// Queue implementation -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -65,180 +65,366 @@
namespace std
{
-
-// Forward declarations of operators < and ==, needed for friend declaration.
-
-template <class _Tp,
- class _Sequence = deque<_Tp> >
-class queue;
-
-template <class _Tp, class _Seq>
-inline bool operator==(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&);
-
-template <class _Tp, class _Seq>
-inline bool operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&);
-
-
-template <class _Tp, class _Sequence>
-class queue
-{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
- __glibcpp_class_requires(_Sequence, _FrontInsertionSequenceConcept)
- __glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
- typedef typename _Sequence::value_type _Sequence_value_type;
- __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept);
-
- template <class _Tp1, class _Seq1>
- friend bool operator== (const queue<_Tp1, _Seq1>&,
- const queue<_Tp1, _Seq1>&);
- template <class _Tp1, class _Seq1>
- friend bool operator< (const queue<_Tp1, _Seq1>&,
- const queue<_Tp1, _Seq1>&);
-public:
- typedef typename _Sequence::value_type value_type;
- typedef typename _Sequence::size_type size_type;
- typedef _Sequence container_type;
-
- typedef typename _Sequence::reference reference;
- typedef typename _Sequence::const_reference const_reference;
-protected:
- _Sequence c;
-public:
- explicit queue(const _Sequence& __c = _Sequence()) : c(__c) {}
-
- bool empty() const { return c.empty(); }
- size_type size() const { return c.size(); }
- reference front() { return c.front(); }
- const_reference front() const { return c.front(); }
- reference back() { return c.back(); }
- const_reference back() const { return c.back(); }
- void push(const value_type& __x) { c.push_back(__x); }
- void pop() { c.pop_front(); }
-};
-
-template <class _Tp, class _Sequence>
-bool
-operator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
-{
- return __x.c == __y.c;
-}
-
-template <class _Tp, class _Sequence>
-bool
-operator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
-{
- return __x.c < __y.c;
-}
-
-template <class _Tp, class _Sequence>
-bool
-operator!=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
-{
- return !(__x == __y);
-}
-
-template <class _Tp, class _Sequence>
-bool
-operator>(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
-{
- return __y < __x;
-}
-
-template <class _Tp, class _Sequence>
-bool
-operator<=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
-{
- return !(__y < __x);
-}
-
-template <class _Tp, class _Sequence>
-bool
-operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
-{
- return !(__x < __y);
-}
-
-template <class _Tp,
- class _Sequence = vector<_Tp>,
- class _Compare = less<typename _Sequence::value_type> >
-class priority_queue
-{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
- __glibcpp_class_requires(_Sequence, _SequenceConcept)
- __glibcpp_class_requires(_Sequence, _RandomAccessContainerConcept)
- typedef typename _Sequence::value_type _Sequence_value_type;
- __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept);
- __glibcpp_class_requires4(_Compare, bool, _Tp, _Tp, _BinaryFunctionConcept);
-
-public:
- typedef typename _Sequence::value_type value_type;
- typedef typename _Sequence::size_type size_type;
- typedef _Sequence container_type;
-
- typedef typename _Sequence::reference reference;
- typedef typename _Sequence::const_reference const_reference;
-protected:
- _Sequence c;
- _Compare comp;
-public:
- explicit priority_queue(const _Compare& __x = _Compare(),
- const _Sequence& __s = _Sequence())
- : c(__s), comp(__x)
- { make_heap(c.begin(), c.end(), comp); }
-
- template <class _InputIterator>
- priority_queue(_InputIterator __first, _InputIterator __last,
- const _Compare& __x = _Compare(),
- const _Sequence& __s = _Sequence())
- : c(__s), comp(__x)
- {
- c.insert(c.end(), __first, __last);
- make_heap(c.begin(), c.end(), comp);
- }
-
- bool empty() const { return c.empty(); }
- size_type size() const { return c.size(); }
- const_reference top() const { return c.front(); }
-
- void
- push(const value_type& __x)
+ // Forward declarations of operators < and ==, needed for friend declaration.
+
+ template <typename _Tp, typename _Sequence = deque<_Tp> >
+ class queue;
+
+ template <typename _Tp, typename _Seq>
+ inline bool operator==(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&);
+
+ template <typename _Tp, typename _Seq>
+ inline bool operator<(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&);
+
+
+ /**
+ * @brief A standard container giving FIFO behavior.
+ *
+ * @ingroup Containers
+ * @ingroup Sequences
+ *
+ * Meets many of the requirements of a
+ * <a href="tables.html#65">container</a>,
+ * but does not define anything to do with iterators. Very few of the
+ * other standard container interfaces are defined.
+ *
+ * This is not a true container, but an @e adaptor. It holds another
+ * container, and provides a wrapper interface to that container. The
+ * wrapper is what enforces strict first-in-first-out %queue behavior.
+ *
+ * The second template parameter defines the type of the underlying
+ * sequence/container. It defaults to std::deque, but it can be any type
+ * that supports @c front, @c back, @c push_back, and @c pop_front,
+ * such as std::list or an appropriate user-defined type.
+ *
+ * Members not found in "normal" containers are @c container_type,
+ * which is a typedef for the second Sequence parameter, and @c push and
+ * @c pop, which are standard %queue/FIFO operations.
+ */
+ template <typename _Tp, typename _Sequence>
+ class queue
{
- try
- {
- c.push_back(__x);
- push_heap(c.begin(), c.end(), comp);
- }
- catch(...)
- {
- c.clear();
- __throw_exception_again;
- }
- }
-
- void
- pop()
+ // concept requirements
+ typedef typename _Sequence::value_type _Sequence_value_type;
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+ __glibcpp_class_requires(_Sequence, _FrontInsertionSequenceConcept)
+ __glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
+ __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
+
+ template <typename _Tp1, typename _Seq1>
+ friend bool operator== (const queue<_Tp1, _Seq1>&,
+ const queue<_Tp1, _Seq1>&);
+ template <typename _Tp1, typename _Seq1>
+ friend bool operator< (const queue<_Tp1, _Seq1>&,
+ const queue<_Tp1, _Seq1>&);
+
+ public:
+ typedef typename _Sequence::value_type value_type;
+ typedef typename _Sequence::reference reference;
+ typedef typename _Sequence::const_reference const_reference;
+ typedef typename _Sequence::size_type size_type;
+ typedef _Sequence container_type;
+
+ protected:
+ /**
+ * 'c' is the underlying container. Maintainers wondering why this isn't
+ * uglified as per style guidelines should note that this name is
+ * specified in the standard, [23.2.3.1]. (Why? Presumably for the same
+ * reason that it's protected instead of private: to allow derivation.
+ * But none of the other containers allow for derivation. Odd.)
+ */
+ _Sequence c;
+
+ public:
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ queue(const _Sequence& __c = _Sequence())
+ : c(__c) {}
+
+ /**
+ * Returns true if the %queue is empty.
+ */
+ bool
+ empty() const { return c.empty(); }
+
+ /** Returns the number of elements in the %queue. */
+ size_type
+ size() const { return c.size(); }
+
+ /**
+ * Returns a read/write reference to the data at the first element of the
+ * %queue.
+ */
+ reference
+ front() { return c.front(); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the first
+ * element of the %queue.
+ */
+ const_reference
+ front() const { return c.front(); }
+
+ /**
+ * Returns a read/write reference to the data at the last element of the
+ * %queue.
+ */
+ reference
+ back() { return c.back(); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the last
+ * element of the %queue.
+ */
+ const_reference
+ back() const { return c.back(); }
+
+ /**
+ * @brief Add data to the end of the %queue.
+ * @param x Data to be added.
+ *
+ * This is a typical %queue operation. The function creates an element at
+ * the end of the %queue and assigns the given data to it.
+ * The time complexity of the operation depends on the underlying
+ * sequence.
+ */
+ void
+ push(const value_type& __x) { c.push_back(__x); }
+
+ /**
+ * @brief Removes first element.
+ *
+ * This is a typical %queue operation. It shrinks the %queue by one.
+ * The time complexity of the operation depends on the underlying
+ * sequence.
+ *
+ * Note that no data is returned, and if the first element's data is
+ * needed, it should be retrieved before pop() is called.
+ */
+ void
+ pop() { c.pop_front(); }
+ };
+
+
+ /**
+ * @brief Queue equality comparison.
+ * @param x A %queue.
+ * @param y A %queue of the same type as @a x.
+ * @return True iff the size and elements of the queues are equal.
+ *
+ * This is an equivalence relation. Complexity and semantics depend on the
+ * underlying sequence type, but the expected rules are: this relation is
+ * linear in the size of the sequences, and queues are considered equivalent
+ * if their sequences compare equal.
+ */
+ template <typename _Tp, typename _Sequence>
+ inline bool
+ operator==(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
+ { return __x.c == __y.c; }
+
+ /**
+ * @brief Queue ordering relation.
+ * @param x A %queue.
+ * @param y A %queue of the same type as @a x.
+ * @return True iff @a x is lexographically less than @a y.
+ *
+ * This is an total ordering relation. Complexity and semantics depend on
+ * the underlying sequence type, but the expected rules are: this relation
+ * is linear in the size of the sequences, the elements must be comparable
+ * with @c <, and std::lexographical_compare() is usually used to make the
+ * determination.
+ */
+ template <typename _Tp, typename _Sequence>
+ inline bool
+ operator<(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
+ { return __x.c < __y.c; }
+
+ /// Based on operator==
+ template <typename _Tp, typename _Sequence>
+ inline bool
+ operator!=(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
+ { return !(__x == __y); }
+
+ /// Based on operator<
+ template <typename _Tp, typename _Sequence>
+ inline bool
+ operator>(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
+ { return __y < __x; }
+
+ /// Based on operator<
+ template <typename _Tp, typename _Sequence>
+ inline bool
+ operator<=(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
+ { return !(__y < __x); }
+
+ /// Based on operator<
+ template <typename _Tp, typename _Sequence>
+ inline bool
+ operator>=(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
+ { return !(__x < __y); }
+
+
+ /**
+ * @brief A standard container automatically sorting its contents.
+ *
+ * @ingroup Containers
+ * @ingroup Sequences
+ *
+ * This is not a true container, but an @e adaptor. It holds another
+ * container, and provides a wrapper interface to that container. The
+ * wrapper is what enforces sorting and first-in-first-out %queue behavior.
+ * Very few of the standard container/sequence interface requirements are
+ * met (e.g., iterators).
+ *
+ * The second template parameter defines the type of the underlying
+ * sequence/container. It defaults to std::vector, but it can be any type
+ * that supports @c front(), @c push_back, @c pop_back, and random-access
+ * iterators, such as std::deque or an appropriate user-defined type.
+ *
+ * The third template parameter supplies the means of making priority
+ * comparisons. It defaults to @c less<value_type> but can be anything
+ * defining a strict weak ordering.
+ *
+ * Members not found in "normal" containers are @c container_type,
+ * which is a typedef for the second Sequence parameter, and @c push,
+ * @c pop, and @c top, which are standard %queue/FIFO operations.
+ *
+ * @note No equality/comparison operators are provided for %priority_queue.
+ *
+ * @note Sorting of the elements takes place as they are added to, and
+ * removed from, the %priority_queue using the %priority_queue's
+ * member functions. If you access the elements by other means, and
+ * change their data such that the sorting order would be different,
+ * the %priority_queue will not re-sort the elements for you. (How
+ * could it know to do so?)
+ */
+ template <typename _Tp, typename _Sequence = vector<_Tp>,
+ typename _Compare = less<typename _Sequence::value_type> >
+ class priority_queue
{
- try
- {
- pop_heap(c.begin(), c.end(), comp);
- c.pop_back();
- }
- catch(...)
- {
- c.clear();
- __throw_exception_again;
+ // concept requirements
+ typedef typename _Sequence::value_type _Sequence_value_type;
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+ __glibcpp_class_requires(_Sequence, _SequenceConcept)
+ __glibcpp_class_requires(_Sequence, _RandomAccessContainerConcept)
+ __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
+ __glibcpp_class_requires4(_Compare, bool, _Tp, _Tp, _BinaryFunctionConcept)
+
+ public:
+ typedef typename _Sequence::value_type value_type;
+ typedef typename _Sequence::reference reference;
+ typedef typename _Sequence::const_reference const_reference;
+ typedef typename _Sequence::size_type size_type;
+ typedef _Sequence container_type;
+
+ protected:
+ // See queue::c for notes on these names.
+ _Sequence c;
+ _Compare comp;
+
+ public:
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ priority_queue(const _Compare& __x = _Compare(),
+ const _Sequence& __s = _Sequence())
+ : c(__s), comp(__x)
+ { make_heap(c.begin(), c.end(), comp); }
+
+ /**
+ * @brief Builds a %queue from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @param x A comparison functor describing a strict weak ordering.
+ * @param s An initial sequence with which to start.
+ *
+ * Begins by copying @a s, inserting a copy of the elements from
+ * @a [first,last) into the copy of @a s, then ordering the copy
+ * according to @a x.
+ *
+ * For more information on function objects, see the documentation on
+ * @link s20_3_1_base functor base classes@endlink.
+ */
+ template <typename _InputIterator>
+ priority_queue(_InputIterator __first, _InputIterator __last,
+ const _Compare& __x = _Compare(),
+ const _Sequence& __s = _Sequence())
+ : c(__s), comp(__x)
+ {
+ c.insert(c.end(), __first, __last);
+ make_heap(c.begin(), c.end(), comp);
}
- }
-};
-
-// no equality is provided
-
+
+ /**
+ * Returns true if the %queue is empty.
+ */
+ bool
+ empty() const { return c.empty(); }
+
+ /** Returns the number of elements in the %queue. */
+ size_type
+ size() const { return c.size(); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the first
+ * element of the %queue.
+ */
+ const_reference
+ top() const { return c.front(); }
+
+ /**
+ * @brief Add data to the %queue.
+ * @param x Data to be added.
+ *
+ * This is a typical %queue operation.
+ * The time complexity of the operation depends on the underlying
+ * sequence.
+ */
+ void
+ push(const value_type& __x)
+ {
+ try
+ {
+ c.push_back(__x);
+ push_heap(c.begin(), c.end(), comp);
+ }
+ catch(...)
+ {
+ c.clear();
+ __throw_exception_again;
+ }
+ }
+
+ /**
+ * @brief Removes first element.
+ *
+ * This is a typical %queue operation. It shrinks the %queue by one.
+ * The time complexity of the operation depends on the underlying
+ * sequence.
+ *
+ * Note that no data is returned, and if the first element's data is
+ * needed, it should be retrieved before pop() is called.
+ */
+ void
+ pop()
+ {
+ try
+ {
+ pop_heap(c.begin(), c.end(), comp);
+ c.pop_back();
+ }
+ catch(...)
+ {
+ c.clear();
+ __throw_exception_again;
+ }
+ }
+ };
+
+ // No equality/comparison operators are provided for priority_queue.
} // namespace std
#endif /* __GLIBCPP_INTERNAL_QUEUE_H */
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/bits/stl_stack.h b/contrib/libstdc++/include/bits/stl_stack.h
index 0a80b10..7f2496c 100644
--- a/contrib/libstdc++/include/bits/stl_stack.h
+++ b/contrib/libstdc++/include/bits/stl_stack.h
@@ -1,6 +1,6 @@
// Stack implementation -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -65,96 +65,186 @@
namespace std
{
-
-// Forward declarations of operators == and <, needed for friend declaration.
-
-template <class _Tp,
- class _Sequence = deque<_Tp> >
-class stack;
-
-template <class _Tp, class _Seq>
-bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
-
-template <class _Tp, class _Seq>
-bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
-
-
-template <class _Tp, class _Sequence>
-class stack
-{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
- __glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
- typedef typename _Sequence::value_type _Sequence_value_type;
- __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept);
-
- template <class _Tp1, class _Seq1>
- friend bool operator== (const stack<_Tp1, _Seq1>&,
- const stack<_Tp1, _Seq1>&);
- template <class _Tp1, class _Seq1>
- friend bool operator< (const stack<_Tp1, _Seq1>&,
- const stack<_Tp1, _Seq1>&);
-public:
- typedef typename _Sequence::value_type value_type;
- typedef typename _Sequence::size_type size_type;
- typedef _Sequence container_type;
-
- typedef typename _Sequence::reference reference;
- typedef typename _Sequence::const_reference const_reference;
-protected:
- _Sequence c;
-public:
- stack() : c() {}
- explicit stack(const _Sequence& __s) : c(__s) {}
-
- bool empty() const { return c.empty(); }
- size_type size() const { return c.size(); }
- reference top() { return c.back(); }
- const_reference top() const { return c.back(); }
- void push(const value_type& __x) { c.push_back(__x); }
- void pop() { c.pop_back(); }
-};
-
-template <class _Tp, class _Seq>
-bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
-{
- return __x.c == __y.c;
-}
-
-template <class _Tp, class _Seq>
-bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
-{
- return __x.c < __y.c;
-}
-
-template <class _Tp, class _Seq>
-bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
-{
- return !(__x == __y);
-}
-
-template <class _Tp, class _Seq>
-bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
-{
- return __y < __x;
-}
-
-template <class _Tp, class _Seq>
-bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
-{
- return !(__y < __x);
-}
-
-template <class _Tp, class _Seq>
-bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
-{
- return !(__x < __y);
-}
-
+ // Forward declarations of operators == and <, needed for friend declaration.
+
+ template <typename _Tp, typename _Sequence = deque<_Tp> >
+ class stack;
+
+ template <typename _Tp, typename _Seq>
+ inline bool operator==(const stack<_Tp,_Seq>& __x,
+ const stack<_Tp,_Seq>& __y);
+
+ template <typename _Tp, typename _Seq>
+ inline bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
+
+
+ /**
+ * @brief A standard container giving FILO behavior.
+ *
+ * @ingroup Containers
+ * @ingroup Sequences
+ *
+ * Meets many of the requirements of a
+ * <a href="tables.html#65">container</a>,
+ * but does not define anything to do with iterators. Very few of the
+ * other standard container interfaces are defined.
+ *
+ * This is not a true container, but an @e adaptor. It holds another
+ * container, and provides a wrapper interface to that container. The
+ * wrapper is what enforces strict first-in-last-out %stack behavior.
+ *
+ * The second template parameter defines the type of the underlying
+ * sequence/container. It defaults to std::deque, but it can be any type
+ * that supports @c back, @c push_back, and @c pop_front, such as
+ * std::list, std::vector, or an appropriate user-defined type.
+ *
+ * Members not found in "normal" containers are @c container_type,
+ * which is a typedef for the second Sequence parameter, and @c push,
+ * @c pop, and @c top, which are standard %stack/FILO operations.
+ */
+ template <typename _Tp, typename _Sequence>
+ class stack
+ {
+ // concept requirements
+ typedef typename _Sequence::value_type _Sequence_value_type;
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+ __glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
+ __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
+
+ template <typename _Tp1, typename _Seq1>
+ friend bool operator== (const stack<_Tp1, _Seq1>&,
+ const stack<_Tp1, _Seq1>&);
+ template <typename _Tp1, typename _Seq1>
+ friend bool operator< (const stack<_Tp1, _Seq1>&,
+ const stack<_Tp1, _Seq1>&);
+
+ public:
+ typedef typename _Sequence::value_type value_type;
+ typedef typename _Sequence::reference reference;
+ typedef typename _Sequence::const_reference const_reference;
+ typedef typename _Sequence::size_type size_type;
+ typedef _Sequence container_type;
+
+ protected:
+ // See queue::c for notes on this name.
+ _Sequence c;
+
+ public:
+ // XXX removed old def ctor, added def arg to this one to match 14882
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ stack(const _Sequence& __c = _Sequence())
+ : c(__c) {}
+
+ /**
+ * Returns true if the %stack is empty.
+ */
+ bool
+ empty() const { return c.empty(); }
+
+ /** Returns the number of elements in the %stack. */
+ size_type
+ size() const { return c.size(); }
+
+ /**
+ * Returns a read/write reference to the data at the first element of the
+ * %stack.
+ */
+ reference
+ top() { return c.back(); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the first
+ * element of the %stack.
+ */
+ const_reference
+ top() const { return c.back(); }
+
+ /**
+ * @brief Add data to the top of the %stack.
+ * @param x Data to be added.
+ *
+ * This is a typical %stack operation. The function creates an element at
+ * the top of the %stack and assigns the given data to it.
+ * The time complexity of the operation depends on the underlying
+ * sequence.
+ */
+ void
+ push(const value_type& __x) { c.push_back(__x); }
+
+ /**
+ * @brief Removes first element.
+ *
+ * This is a typical %stack operation. It shrinks the %stack by one.
+ * The time complexity of the operation depends on the underlying
+ * sequence.
+ *
+ * Note that no data is returned, and if the first element's data is
+ * needed, it should be retrieved before pop() is called.
+ */
+ void
+ pop() { c.pop_back(); }
+ };
+
+
+ /**
+ * @brief Stack equality comparison.
+ * @param x A %stack.
+ * @param y A %stack of the same type as @a x.
+ * @return True iff the size and elements of the stacks are equal.
+ *
+ * This is an equivalence relation. Complexity and semantics depend on the
+ * underlying sequence type, but the expected rules are: this relation is
+ * linear in the size of the sequences, and stacks are considered equivalent
+ * if their sequences compare equal.
+ */
+ template <typename _Tp, typename _Seq>
+ inline bool
+ operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
+ { return __x.c == __y.c; }
+
+ /**
+ * @brief Stack ordering relation.
+ * @param x A %stack.
+ * @param y A %stack of the same type as @a x.
+ * @return True iff @a x is lexographically less than @a y.
+ *
+ * This is an total ordering relation. Complexity and semantics depend on
+ * the underlying sequence type, but the expected rules are: this relation
+ * is linear in the size of the sequences, the elements must be comparable
+ * with @c <, and std::lexographical_compare() is usually used to make the
+ * determination.
+ */
+ template <typename _Tp, typename _Seq>
+ inline bool
+ operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
+ { return __x.c < __y.c; }
+
+ /// Based on operator==
+ template <typename _Tp, typename _Seq>
+ inline bool
+ operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
+ { return !(__x == __y); }
+
+ /// Based on operator<
+ template <typename _Tp, typename _Seq>
+ inline bool
+ operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
+ { return __y < __x; }
+
+ /// Based on operator<
+ template <typename _Tp, typename _Seq>
+ inline bool
+ operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
+ { return !(__y < __x); }
+
+ /// Based on operator<
+ template <typename _Tp, typename _Seq>
+ inline bool
+ operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
+ { return !(__x < __y); }
} // namespace std
#endif /* __GLIBCPP_INTERNAL_STACK_H */
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/bits/stl_threads.h b/contrib/libstdc++/include/bits/stl_threads.h
index 0150cd5..b21ebdd 100644
--- a/contrib/libstdc++/include/bits/stl_threads.h
+++ b/contrib/libstdc++/include/bits/stl_threads.h
@@ -1,6 +1,6 @@
// Threading support -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -126,6 +126,7 @@ namespace std
return __result;
}
#endif
+} //namespace std
// Locking class. Note that this class *does not have a
// constructor*. It must be initialized either statically, with
@@ -141,13 +142,18 @@ namespace std
// functions, and no private or protected members.
#if !defined(__GTHREAD_MUTEX_INIT) && defined(__GTHREAD_MUTEX_INIT_FUNCTION)
+namespace __gnu_cxx
+{
extern __gthread_mutex_t _GLIBCPP_mutex;
extern __gthread_mutex_t *_GLIBCPP_mutex_address;
extern __gthread_once_t _GLIBCPP_once;
extern void _GLIBCPP_mutex_init (void);
extern void _GLIBCPP_mutex_address_init (void);
+}
#endif
+namespace std
+{
struct _STL_mutex_lock
{
// The class must be statically initialized with __STL_MUTEX_INITIALIZER.
@@ -164,22 +170,24 @@ namespace std
// There should be no code in this path given the usage rules above.
#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
if (_M_init_flag) return;
- if (__gthread_once (&_GLIBCPP_once, _GLIBCPP_mutex_init) != 0
+ if (__gthread_once (&__gnu_cxx::_GLIBCPP_once,
+ __gnu_cxx::_GLIBCPP_mutex_init) != 0
&& __gthread_active_p ())
abort ();
- __gthread_mutex_lock (&_GLIBCPP_mutex);
+ __gthread_mutex_lock (&__gnu_cxx::_GLIBCPP_mutex);
if (!_M_init_flag)
{
// Even though we have a global lock, we use __gthread_once to be
// absolutely certain the _M_lock mutex is only initialized once on
// multiprocessor systems.
- _GLIBCPP_mutex_address = &_M_lock;
- if (__gthread_once (&_M_once, _GLIBCPP_mutex_address_init) != 0
+ __gnu_cxx::_GLIBCPP_mutex_address = &_M_lock;
+ if (__gthread_once (&_M_once,
+ __gnu_cxx::_GLIBCPP_mutex_address_init) != 0
&& __gthread_active_p ())
abort ();
_M_init_flag = 1;
}
- __gthread_mutex_unlock (&_GLIBCPP_mutex);
+ __gthread_mutex_unlock (&__gnu_cxx::_GLIBCPP_mutex);
#endif
}
diff --git a/contrib/libstdc++/include/bits/stl_tree.h b/contrib/libstdc++/include/bits/stl_tree.h
index d2ae142..1e7fdf5 100644
--- a/contrib/libstdc++/include/bits/stl_tree.h
+++ b/contrib/libstdc++/include/bits/stl_tree.h
@@ -457,7 +457,7 @@ namespace std
if (__w->_M_right == 0
|| __w->_M_right->_M_color == _M_black)
{
- if (__w->_M_left) __w->_M_left->_M_color = _M_black;
+ __w->_M_left->_M_color = _M_black;
__w->_M_color = _M_red;
_Rb_tree_rotate_right(__w, __root);
__w = __x_parent->_M_right;
@@ -494,7 +494,7 @@ namespace std
{
if (__w->_M_left == 0 || __w->_M_left->_M_color == _M_black)
{
- if (__w->_M_right) __w->_M_right->_M_color = _M_black;
+ __w->_M_right->_M_color = _M_black;
__w->_M_color = _M_red;
_Rb_tree_rotate_left(__w, __root);
__w = __x_parent->_M_left;
@@ -702,8 +702,8 @@ namespace std
typedef _Rb_tree_iterator<value_type, const_reference, const_pointer>
const_iterator;
- typedef reverse_iterator<const_iterator> const_reverse_iterator;
- typedef reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
private:
iterator
diff --git a/contrib/libstdc++/include/bits/stl_vector.h b/contrib/libstdc++/include/bits/stl_vector.h
index ef3b1c2..5354732 100644
--- a/contrib/libstdc++/include/bits/stl_vector.h
+++ b/contrib/libstdc++/include/bits/stl_vector.h
@@ -67,1019 +67,926 @@
namespace std
{
-
-// The vector base class serves two purposes. First, its constructor
-// and destructor allocate (but don't initialize) storage. This makes
-// exception safety easier. Second, the base class encapsulates all of
-// the differences between SGI-style allocators and standard-conforming
-// allocators.
-
-// Base class for ordinary allocators.
-template <class _Tp, class _Allocator, bool _IsStatic>
-class _Vector_alloc_base {
-public:
- typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
- allocator_type;
- allocator_type get_allocator() const { return _M_data_allocator; }
-
- _Vector_alloc_base(const allocator_type& __a)
- : _M_data_allocator(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
- {}
-
-protected:
- allocator_type _M_data_allocator;
- _Tp* _M_start;
- _Tp* _M_finish;
- _Tp* _M_end_of_storage;
-
- _Tp* _M_allocate(size_t __n)
- { return _M_data_allocator.allocate(__n); }
- void _M_deallocate(_Tp* __p, size_t __n)
- { if (__p) _M_data_allocator.deallocate(__p, __n); }
-};
-
-// Specialization for allocators that have the property that we don't
-// actually have to store an allocator object.
-template <class _Tp, class _Allocator>
-class _Vector_alloc_base<_Tp, _Allocator, true> {
-public:
- typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
- allocator_type;
- allocator_type get_allocator() const { return allocator_type(); }
-
- _Vector_alloc_base(const allocator_type&)
- : _M_start(0), _M_finish(0), _M_end_of_storage(0)
- {}
-
-protected:
- _Tp* _M_start;
- _Tp* _M_finish;
- _Tp* _M_end_of_storage;
-
- typedef typename _Alloc_traits<_Tp, _Allocator>::_Alloc_type _Alloc_type;
- _Tp* _M_allocate(size_t __n)
- { return _Alloc_type::allocate(__n); }
- void _M_deallocate(_Tp* __p, size_t __n)
- { _Alloc_type::deallocate(__p, __n);}
-};
-
-template <class _Tp, class _Alloc>
-struct _Vector_base
- : public _Vector_alloc_base<_Tp, _Alloc,
- _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
-{
- typedef _Vector_alloc_base<_Tp, _Alloc,
- _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
- _Base;
- typedef typename _Base::allocator_type allocator_type;
-
- _Vector_base(const allocator_type& __a) : _Base(__a) {}
- _Vector_base(size_t __n, const allocator_type& __a) : _Base(__a) {
- _M_start = _M_allocate(__n);
- _M_finish = _M_start;
- _M_end_of_storage = _M_start + __n;
- }
-
- ~_Vector_base() { _M_deallocate(_M_start, _M_end_of_storage - _M_start); }
-};
-
-
-/**
- * @brief A standard container which offers fixed time access to individual
- * elements in any order.
- *
- * @ingroup Containers
- * @ingroup Sequences
- *
- * Meets the requirements of a <a href="tables.html#65">container</a>, a
- * <a href="tables.html#66">reversible container</a>, and a
- * <a href="tables.html#67">sequence</a>, including the
- * <a href="tables.html#68">optional sequence requirements</a> with the
- * %exception of @c push_front and @c pop_front.
- *
- * In some terminology a vector can be described as a dynamic C-style array,
- * it offers fast and efficient access to individual elements in any order
- * and saves the user from worrying about memory and size allocation.
- * Subscripting ( [] ) access is also provided as with C-style arrays.
-*/
-template <class _Tp, class _Alloc = allocator<_Tp> >
-class vector : protected _Vector_base<_Tp, _Alloc>
-{
- // concept requirements
- __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
-
-private:
- typedef _Vector_base<_Tp, _Alloc> _Base;
- typedef vector<_Tp, _Alloc> vector_type;
-public:
- typedef _Tp value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator;
- typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type>
- const_iterator;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
-
- typedef typename _Base::allocator_type allocator_type;
- allocator_type get_allocator() const { return _Base::get_allocator(); }
-
- typedef reverse_iterator<const_iterator> const_reverse_iterator;
- typedef reverse_iterator<iterator> reverse_iterator;
-
-protected:
- using _Base::_M_allocate;
- using _Base::_M_deallocate;
- using _Base::_M_start;
- using _Base::_M_finish;
- using _Base::_M_end_of_storage;
-
-protected:
- void _M_insert_aux(iterator __position, const _Tp& __x);
- void _M_insert_aux(iterator __position);
-
-public:
- /**
- * Returns a read/write iterator that points to the first element in the
- * vector. Iteration is done in ordinary element order.
- */
- iterator begin() { return iterator (_M_start); }
-
- /**
- * Returns a read-only (constant) iterator that points to the first element
- * in the vector. Iteration is done in ordinary element order.
- */
- const_iterator begin() const
- { return const_iterator (_M_start); }
-
+ /// @if maint Primary default version. @endif
/**
- * Returns a read/write iterator that points one past the last element in
- * the vector. Iteration is done in ordinary element order.
+ * @if maint
+ * See bits/stl_deque.h's _Deque_alloc_base for an explanation.
+ * @endif
*/
- iterator end() { return iterator (_M_finish); }
-
- /**
- * Returns a read-only (constant) iterator that points one past the last
- * element in the vector. Iteration is done in ordinary element order.
- */
- const_iterator end() const { return const_iterator (_M_finish); }
-
- /**
- * Returns a read/write reverse iterator that points to the last element in
- * the vector. Iteration is done in reverse element order.
- */
- reverse_iterator rbegin()
- { return reverse_iterator(end()); }
-
- /**
- * Returns a read-only (constant) reverse iterator that points to the last
- * element in the vector. Iteration is done in reverse element order.
- */
- const_reverse_iterator rbegin() const
- { return const_reverse_iterator(end()); }
-
- /**
- * Returns a read/write reverse iterator that points to one before the
- * first element in the vector. Iteration is done in reverse element
- * order.
- */
- reverse_iterator rend()
- { return reverse_iterator(begin()); }
-
- /**
- * Returns a read-only (constant) reverse iterator that points to one
- * before the first element in the vector. Iteration is done in reverse
- * element order.
- */
- const_reverse_iterator rend() const
- { return const_reverse_iterator(begin()); }
-
- /** Returns the number of elements in the vector. */
- size_type size() const
- { return size_type(end() - begin()); }
-
- /** Returns the size of the largest possible vector. */
- size_type max_size() const
- { return size_type(-1) / sizeof(_Tp); }
-
- /**
- * Returns the amount of memory that has been alocated for the current
- * elements (?).
- */
- size_type capacity() const
- { return size_type(const_iterator(_M_end_of_storage) - begin()); }
-
- /**
- * Returns true if the vector is empty. (Thus begin() would equal end().)
- */
- bool empty() const
- { return begin() == end(); }
-
+ template<typename _Tp, typename _Allocator, bool _IsStatic>
+ class _Vector_alloc_base
+ {
+ public:
+ typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
+ allocator_type;
+
+ allocator_type
+ get_allocator() const { return _M_data_allocator; }
+
+ _Vector_alloc_base(const allocator_type& __a)
+ : _M_data_allocator(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
+ { }
+
+ protected:
+ allocator_type _M_data_allocator;
+ _Tp* _M_start;
+ _Tp* _M_finish;
+ _Tp* _M_end_of_storage;
+
+ _Tp*
+ _M_allocate(size_t __n) { return _M_data_allocator.allocate(__n); }
+
+ void
+ _M_deallocate(_Tp* __p, size_t __n)
+ { if (__p) _M_data_allocator.deallocate(__p, __n); }
+ };
+
+ /// @if maint Specialization for instanceless allocators. @endif
+ template<typename _Tp, typename _Allocator>
+ class _Vector_alloc_base<_Tp, _Allocator, true>
+ {
+ public:
+ typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
+ allocator_type;
+
+ allocator_type
+ get_allocator() const { return allocator_type(); }
+
+ _Vector_alloc_base(const allocator_type&)
+ : _M_start(0), _M_finish(0), _M_end_of_storage(0)
+ { }
+
+ protected:
+ _Tp* _M_start;
+ _Tp* _M_finish;
+ _Tp* _M_end_of_storage;
+
+ typedef typename _Alloc_traits<_Tp, _Allocator>::_Alloc_type _Alloc_type;
+
+ _Tp*
+ _M_allocate(size_t __n) { return _Alloc_type::allocate(__n); }
+
+ void
+ _M_deallocate(_Tp* __p, size_t __n) { _Alloc_type::deallocate(__p, __n);}
+ };
+
+
/**
- * @brief Subscript access to the data contained in the vector.
- * @param n The element for which data should be accessed.
- * @return Read/write reference to data.
- *
- * This operator allows for easy, array-style, data access.
- * Note that data access with this operator is unchecked and out_of_range
- * lookups are not defined. (For checked lookups see at().)
+ * @if maint
+ * See bits/stl_deque.h's _Deque_base for an explanation.
+ * @endif
*/
- reference operator[](size_type __n) { return *(begin() + __n); }
-
+ template<typename _Tp, typename _Alloc>
+ struct _Vector_base
+ : public _Vector_alloc_base<_Tp, _Alloc,
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
+ {
+ public:
+ typedef _Vector_alloc_base<_Tp, _Alloc,
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
+ _Base;
+ typedef typename _Base::allocator_type allocator_type;
+
+ _Vector_base(const allocator_type& __a)
+ : _Base(__a) { }
+
+ _Vector_base(size_t __n, const allocator_type& __a)
+ : _Base(__a)
+ {
+ _M_start = _M_allocate(__n);
+ _M_finish = _M_start;
+ _M_end_of_storage = _M_start + __n;
+ }
+
+ ~_Vector_base()
+ { _M_deallocate(_M_start, _M_end_of_storage - _M_start); }
+ };
+
+
/**
- * @brief Subscript access to the data contained in the vector.
- * @param n The element for which data should be accessed.
- * @return Read-only (constant) reference to data.
+ * @brief A standard container which offers fixed time access to individual
+ * elements in any order.
*
- * This operator allows for easy, array-style, data access.
- * Note that data access with this operator is unchecked and out_of_range
- * lookups are not defined. (For checked lookups see at().)
- */
- const_reference operator[](size_type __n) const { return *(begin() + __n); }
-
- void _M_range_check(size_type __n) const {
- if (__n >= this->size())
- __throw_out_of_range("vector");
- }
-
- /**
- * @brief Provides access to the data contained in the vector.
- * @param n The element for which data should be accessed.
- * @return Read/write reference to data.
+ * @ingroup Containers
+ * @ingroup Sequences
*
- * This function provides for safer data access. The parameter is first
- * checked that it is in the range of the vector. The function throws
- * out_of_range if the check fails.
- */
- reference at(size_type __n)
- { _M_range_check(__n); return (*this)[__n]; }
-
- /**
- * @brief Provides access to the data contained in the vector.
- * @param n The element for which data should be accessed.
- * @return Read-only (constant) reference to data.
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
+ * <a href="tables.html#66">reversible container</a>, and a
+ * <a href="tables.html#67">sequence</a>, including the
+ * <a href="tables.html#68">optional sequence requirements</a> with the
+ * %exception of @c push_front and @c pop_front.
*
- * This function provides for safer data access. The parameter is first
- * checked that it is in the range of the vector. The function throws
- * out_of_range if the check fails.
+ * In some terminology a %vector can be described as a dynamic C-style array,
+ * it offers fast and efficient access to individual elements in any order
+ * and saves the user from worrying about memory and size allocation.
+ * Subscripting ( @c [] ) access is also provided as with C-style arrays.
*/
- const_reference at(size_type __n) const
- { _M_range_check(__n); return (*this)[__n]; }
-
-
- explicit vector(const allocator_type& __a = allocator_type())
- : _Base(__a) {}
-
- vector(size_type __n, const _Tp& __value,
- const allocator_type& __a = allocator_type())
- : _Base(__n, __a)
- { _M_finish = uninitialized_fill_n(_M_start, __n, __value); }
-
- explicit vector(size_type __n)
- : _Base(__n, allocator_type())
- { _M_finish = uninitialized_fill_n(_M_start, __n, _Tp()); }
-
- vector(const vector<_Tp, _Alloc>& __x)
- : _Base(__x.size(), __x.get_allocator())
- { _M_finish = uninitialized_copy(__x.begin(), __x.end(), _M_start); }
-
- // Check whether it's an integral type. If so, it's not an iterator.
- template <class _InputIterator>
- vector(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type())
+ template<typename _Tp, typename _Alloc = allocator<_Tp> >
+ class vector : protected _Vector_base<_Tp, _Alloc>
+ {
+ // Concept requirements.
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
+
+ typedef _Vector_base<_Tp, _Alloc> _Base;
+ typedef vector<_Tp, _Alloc> vector_type;
+
+ public:
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator;
+ typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type>
+ const_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef typename _Base::allocator_type allocator_type;
+
+ protected:
+ /** @if maint
+ * These two functions and three data members are all from the
+ * top-most base class, which varies depending on the type of
+ * %allocator. They should be pretty self-explanatory, as
+ * %vector uses a simple contiguous allocation scheme. @endif
+ */
+ using _Base::_M_allocate;
+ using _Base::_M_deallocate;
+ using _Base::_M_start;
+ using _Base::_M_finish;
+ using _Base::_M_end_of_storage;
+
+ public:
+ // [23.2.4.1] construct/copy/destroy
+ // (assign() and get_allocator() are also listed in this section)
+ /**
+ * @brief Default constructor creates no elements.
+ */
+ explicit
+ vector(const allocator_type& __a = allocator_type())
+ : _Base(__a) { }
+
+ /**
+ * @brief Create a %vector with copies of an exemplar element.
+ * @param n The number of elements to initially create.
+ * @param value An element to copy.
+ *
+ * This constructor fills the %vector with @a n copies of @a value.
+ */
+ vector(size_type __n, const value_type& __value,
+ const allocator_type& __a = allocator_type())
+ : _Base(__n, __a)
+ { _M_finish = uninitialized_fill_n(_M_start, __n, __value); }
+
+ /**
+ * @brief Create a %vector with default elements.
+ * @param n The number of elements to initially create.
+ *
+ * This constructor fills the %vector with @a n copies of a
+ * default-constructed element.
+ */
+ explicit
+ vector(size_type __n)
+ : _Base(__n, allocator_type())
+ { _M_finish = uninitialized_fill_n(_M_start, __n, value_type()); }
+
+ /**
+ * @brief %Vector copy constructor.
+ * @param x A %vector of identical element and allocator types.
+ *
+ * The newly-created %vector uses a copy of the allocation
+ * object used by @a x. All the elements of @a x are copied,
+ * but any extra memory in
+ * @a x (for fast expansion) will not be copied.
+ */
+ vector(const vector& __x)
+ : _Base(__x.size(), __x.get_allocator())
+ { _M_finish = uninitialized_copy(__x.begin(), __x.end(), _M_start); }
+
+ /**
+ * @brief Builds a %vector from a range.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * Create a %vector consisting of copies of the elements from
+ * [first,last).
+ *
+ * If the iterators are forward, bidirectional, or random-access, then
+ * this will call the elements' copy constructor N times (where N is
+ * distance(first,last)) and do no memory reallocation. But if only
+ * input iterators are used, then this will do at most 2N calls to the
+ * copy constructor, and logN memory reallocations.
+ */
+ template<typename _InputIterator>
+ vector(_InputIterator __first, _InputIterator __last,
+ const allocator_type& __a = allocator_type())
: _Base(__a)
- {
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_initialize_aux(__first, __last, _Integral());
- }
-
- template <class _Integer>
- void _M_initialize_aux(_Integer __n, _Integer __value, __true_type)
- {
- _M_start = _M_allocate(__n);
- _M_end_of_storage = _M_start + __n;
- _M_finish = uninitialized_fill_n(_M_start, __n, __value);
- }
-
- template<class _InputIterator>
- void
- _M_initialize_aux(_InputIterator __first, _InputIterator __last, __false_type)
- {
- typedef typename iterator_traits<_InputIterator>::iterator_category _IterCategory;
+ {
+ // Check whether it's an integral type. If so, it's not an iterator.
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_initialize_dispatch(__first, __last, _Integral());
+ }
+
+ /**
+ * The dtor only erases the elements, and note that if the elements
+ * themselves are pointers, the pointed-to memory is not touched in any
+ * way. Managing the pointer is the user's responsibilty.
+ */
+ ~vector() { _Destroy(_M_start, _M_finish); }
+
+ /**
+ * @brief %Vector assignment operator.
+ * @param x A %vector of identical element and allocator types.
+ *
+ * All the elements of @a x are copied, but any extra memory in
+ * @a x (for fast expansion) will not be copied. Unlike the
+ * copy constructor, the allocator object is not copied.
+ */
+ vector&
+ operator=(const vector& __x);
+
+ /**
+ * @brief Assigns a given value to a %vector.
+ * @param n Number of elements to be assigned.
+ * @param val Value to be assigned.
+ *
+ * This function fills a %vector with @a n copies of the given
+ * value. Note that the assignment completely changes the
+ * %vector and that the resulting %vector's size is the same as
+ * the number of elements assigned. Old data may be lost.
+ */
+ void
+ assign(size_type __n, const value_type& __val)
+ { _M_fill_assign(__n, __val); }
+
+ /**
+ * @brief Assigns a range to a %vector.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * This function fills a %vector with copies of the elements in the
+ * range [first,last).
+ *
+ * Note that the assignment completely changes the %vector and
+ * that the resulting %vector's size is the same as the number
+ * of elements assigned. Old data may be lost.
+ */
+ template<typename _InputIterator>
+ void
+ assign(_InputIterator __first, _InputIterator __last)
+ {
+ // Check whether it's an integral type. If so, it's not an iterator.
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_assign_dispatch(__first, __last, _Integral());
+ }
+
+ /// Get a copy of the memory allocation object.
+ allocator_type
+ get_allocator() const { return _Base::get_allocator(); }
+
+ // iterators
+ /**
+ * Returns a read/write iterator that points to the first element in the
+ * %vector. Iteration is done in ordinary element order.
+ */
+ iterator
+ begin() { return iterator (_M_start); }
+
+ /**
+ * Returns a read-only (constant) iterator that points to the
+ * first element in the %vector. Iteration is done in ordinary
+ * element order.
+ */
+ const_iterator
+ begin() const { return const_iterator (_M_start); }
+
+ /**
+ * Returns a read/write iterator that points one past the last
+ * element in the %vector. Iteration is done in ordinary
+ * element order.
+ */
+ iterator
+ end() { return iterator (_M_finish); }
+
+ /**
+ * Returns a read-only (constant) iterator that points one past the last
+ * element in the %vector. Iteration is done in ordinary element order.
+ */
+ const_iterator
+ end() const { return const_iterator (_M_finish); }
+
+ /**
+ * Returns a read/write reverse iterator that points to the
+ * last element in the %vector. Iteration is done in reverse
+ * element order.
+ */
+ reverse_iterator
+ rbegin() { return reverse_iterator(end()); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points
+ * to the last element in the %vector. Iteration is done in
+ * reverse element order.
+ */
+ const_reverse_iterator
+ rbegin() const { return const_reverse_iterator(end()); }
+
+ /**
+ * Returns a read/write reverse iterator that points to one before the
+ * first element in the %vector. Iteration is done in reverse element
+ * order.
+ */
+ reverse_iterator
+ rend() { return reverse_iterator(begin()); }
+
+ /**
+ * Returns a read-only (constant) reverse iterator that points
+ * to one before the first element in the %vector. Iteration
+ * is done in reverse element order.
+ */
+ const_reverse_iterator
+ rend() const { return const_reverse_iterator(begin()); }
+
+ // [23.2.4.2] capacity
+ /** Returns the number of elements in the %vector. */
+ size_type
+ size() const { return size_type(end() - begin()); }
+
+ /** Returns the size() of the largest possible %vector. */
+ size_type
+ max_size() const { return size_type(-1) / sizeof(value_type); }
+
+ /**
+ * @brief Resizes the %vector to the specified number of elements.
+ * @param new_size Number of elements the %vector should contain.
+ * @param x Data with which new elements should be populated.
+ *
+ * This function will %resize the %vector to the specified
+ * number of elements. If the number is smaller than the
+ * %vector's current size the %vector is truncated, otherwise
+ * the %vector is extended and new elements are populated with
+ * given data.
+ */
+ void
+ resize(size_type __new_size, const value_type& __x)
+ {
+ if (__new_size < size())
+ erase(begin() + __new_size, end());
+ else
+ insert(end(), __new_size - size(), __x);
+ }
+
+ /**
+ * @brief Resizes the %vector to the specified number of elements.
+ * @param new_size Number of elements the %vector should contain.
+ *
+ * This function will resize the %vector to the specified
+ * number of elements. If the number is smaller than the
+ * %vector's current size the %vector is truncated, otherwise
+ * the %vector is extended and new elements are
+ * default-constructed.
+ */
+ void
+ resize(size_type __new_size) { resize(__new_size, value_type()); }
+
+ /**
+ * Returns the total number of elements that the %vector can hold before
+ * needing to allocate more memory.
+ */
+ size_type
+ capacity() const
+ { return size_type(const_iterator(_M_end_of_storage) - begin()); }
+
+ /**
+ * Returns true if the %vector is empty. (Thus begin() would
+ * equal end().)
+ */
+ bool
+ empty() const { return begin() == end(); }
+
+ /**
+ * @brief Attempt to preallocate enough memory for specified number of
+ * elements.
+ * @param n Number of elements required.
+ * @throw std::length_error If @a n exceeds @c max_size().
+ *
+ * This function attempts to reserve enough memory for the
+ * %vector to hold the specified number of elements. If the
+ * number requested is more than max_size(), length_error is
+ * thrown.
+ *
+ * The advantage of this function is that if optimal code is a
+ * necessity and the user can determine the number of elements
+ * that will be required, the user can reserve the memory in
+ * %advance, and thus prevent a possible reallocation of memory
+ * and copying of %vector data.
+ */
+ void
+ reserve(size_type __n);
+
+ // element access
+ /**
+ * @brief Subscript access to the data contained in the %vector.
+ * @param n The index of the element for which data should be accessed.
+ * @return Read/write reference to data.
+ *
+ * This operator allows for easy, array-style, data access.
+ * Note that data access with this operator is unchecked and
+ * out_of_range lookups are not defined. (For checked lookups
+ * see at().)
+ */
+ reference
+ operator[](size_type __n) { return *(begin() + __n); }
+
+ /**
+ * @brief Subscript access to the data contained in the %vector.
+ * @param n The index of the element for which data should be
+ * accessed.
+ * @return Read-only (constant) reference to data.
+ *
+ * This operator allows for easy, array-style, data access.
+ * Note that data access with this operator is unchecked and
+ * out_of_range lookups are not defined. (For checked lookups
+ * see at().)
+ */
+ const_reference
+ operator[](size_type __n) const { return *(begin() + __n); }
+
+ protected:
+ /// @if maint Safety check used only from at(). @endif
+ void
+ _M_range_check(size_type __n) const
+ {
+ if (__n >= this->size())
+ __throw_out_of_range("vector [] access out of range");
+ }
+
+ public:
+ /**
+ * @brief Provides access to the data contained in the %vector.
+ * @param n The index of the element for which data should be
+ * accessed.
+ * @return Read/write reference to data.
+ * @throw std::out_of_range If @a n is an invalid index.
+ *
+ * This function provides for safer data access. The parameter is first
+ * checked that it is in the range of the vector. The function throws
+ * out_of_range if the check fails.
+ */
+ reference
+ at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
+
+ /**
+ * @brief Provides access to the data contained in the %vector.
+ * @param n The index of the element for which data should be
+ * accessed.
+ * @return Read-only (constant) reference to data.
+ * @throw std::out_of_range If @a n is an invalid index.
+ *
+ * This function provides for safer data access. The parameter
+ * is first checked that it is in the range of the vector. The
+ * function throws out_of_range if the check fails.
+ */
+ const_reference
+ at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
+
+ /**
+ * Returns a read/write reference to the data at the first
+ * element of the %vector.
+ */
+ reference
+ front() { return *begin(); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the first
+ * element of the %vector.
+ */
+ const_reference
+ front() const { return *begin(); }
+
+ /**
+ * Returns a read/write reference to the data at the last element of the
+ * %vector.
+ */
+ reference
+ back() { return *(end() - 1); }
+
+ /**
+ * Returns a read-only (constant) reference to the data at the last
+ * element of the %vector.
+ */
+ const_reference
+ back() const { return *(end() - 1); }
+
+ // [23.2.4.3] modifiers
+ /**
+ * @brief Add data to the end of the %vector.
+ * @param x Data to be added.
+ *
+ * This is a typical stack operation. The function creates an
+ * element at the end of the %vector and assigns the given data
+ * to it. Due to the nature of a %vector this operation can be
+ * done in constant time if the %vector has preallocated space
+ * available.
+ */
+ void
+ push_back(const value_type& __x)
+ {
+ if (_M_finish != _M_end_of_storage)
+ {
+ _Construct(_M_finish, __x);
+ ++_M_finish;
+ }
+ else
+ _M_insert_aux(end(), __x);
+ }
+
+ /**
+ * @brief Removes last element.
+ *
+ * This is a typical stack operation. It shrinks the %vector by one.
+ *
+ * Note that no data is returned, and if the last element's data is
+ * needed, it should be retrieved before pop_back() is called.
+ */
+ void
+ pop_back()
+ {
+ --_M_finish;
+ _Destroy(_M_finish);
+ }
+
+ /**
+ * @brief Inserts given value into %vector before specified iterator.
+ * @param position An iterator into the %vector.
+ * @param x Data to be inserted.
+ * @return An iterator that points to the inserted data.
+ *
+ * This function will insert a copy of the given value before
+ * the specified location. Note that this kind of operation
+ * could be expensive for a %vector and if it is frequently
+ * used the user should consider using std::list.
+ */
+ iterator
+ insert(iterator __position, const value_type& __x);
+
+#ifdef _GLIBCPP_DEPRECATED
+ /**
+ * @brief Inserts an element into the %vector.
+ * @param position An iterator into the %vector.
+ * @return An iterator that points to the inserted element.
+ *
+ * This function will insert a default-constructed element
+ * before the specified location. You should consider using
+ * insert(position,value_type()) instead. Note that this kind
+ * of operation could be expensive for a vector and if it is
+ * frequently used the user should consider using std::list.
+ *
+ * @note This was deprecated in 3.2 and will be removed in 3.4.
+ * You must define @c _GLIBCPP_DEPRECATED to make this visible
+ * in 3.2; see c++config.h.
+ */
+ iterator
+ insert(iterator __position)
+ { return insert(__position, value_type()); }
+#endif
+
+ /**
+ * @brief Inserts a number of copies of given data into the %vector.
+ * @param position An iterator into the %vector.
+ * @param n Number of elements to be inserted.
+ * @param x Data to be inserted.
+ *
+ * This function will insert a specified number of copies of
+ * the given data before the location specified by @a position.
+ *
+ * Note that this kind of operation could be expensive for a
+ * %vector and if it is frequently used the user should
+ * consider using std::list.
+ */
+ void
+ insert(iterator __pos, size_type __n, const value_type& __x)
+ { _M_fill_insert(__pos, __n, __x); }
+
+ /**
+ * @brief Inserts a range into the %vector.
+ * @param pos An iterator into the %vector.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ *
+ * This function will insert copies of the data in the range
+ * [first,last) into the %vector before the location specified
+ * by @a pos.
+ *
+ * Note that this kind of operation could be expensive for a
+ * %vector and if it is frequently used the user should
+ * consider using std::list.
+ */
+ template<typename _InputIterator>
+ void
+ insert(iterator __pos, _InputIterator __first, _InputIterator __last)
+ {
+ // Check whether it's an integral type. If so, it's not an iterator.
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
+ _M_insert_dispatch(__pos, __first, __last, _Integral());
+ }
+
+ /**
+ * @brief Remove element at given position.
+ * @param position Iterator pointing to element to be erased.
+ * @return An iterator pointing to the next element (or end()).
+ *
+ * This function will erase the element at the given position and thus
+ * shorten the %vector by one.
+ *
+ * Note This operation could be expensive and if it is
+ * frequently used the user should consider using std::list.
+ * The user is also cautioned that this function only erases
+ * the element, and that if the element is itself a pointer,
+ * the pointed-to memory is not touched in any way. Managing
+ * the pointer is the user's responsibilty.
+ */
+ iterator
+ erase(iterator __position);
+
+ /**
+ * @brief Remove a range of elements.
+ * @param first Iterator pointing to the first element to be erased.
+ * @param last Iterator pointing to one past the last element to be
+ * erased.
+ * @return An iterator pointing to the element pointed to by @a last
+ * prior to erasing (or end()).
+ *
+ * This function will erase the elements in the range [first,last) and
+ * shorten the %vector accordingly.
+ *
+ * Note This operation could be expensive and if it is
+ * frequently used the user should consider using std::list.
+ * The user is also cautioned that this function only erases
+ * the elements, and that if the elements themselves are
+ * pointers, the pointed-to memory is not touched in any way.
+ * Managing the pointer is the user's responsibilty.
+ */
+ iterator
+ erase(iterator __first, iterator __last);
+
+ /**
+ * @brief Swaps data with another %vector.
+ * @param x A %vector of the same element and allocator types.
+ *
+ * This exchanges the elements between two vectors in constant time.
+ * (Three pointers, so it should be quite fast.)
+ * Note that the global std::swap() function is specialized such that
+ * std::swap(v1,v2) will feed to this function.
+ */
+ void
+ swap(vector& __x)
+ {
+ std::swap(_M_start, __x._M_start);
+ std::swap(_M_finish, __x._M_finish);
+ std::swap(_M_end_of_storage, __x._M_end_of_storage);
+ }
+
+ /**
+ * Erases all the elements. Note that this function only erases the
+ * elements, and that if the elements themselves are pointers, the
+ * pointed-to memory is not touched in any way. Managing the pointer is
+ * the user's responsibilty.
+ */
+ void
+ clear() { erase(begin(), end()); }
+
+ protected:
+ /**
+ * @if maint
+ * Memory expansion handler. Uses the member allocation function to
+ * obtain @a n bytes of memory, and then copies [first,last) into it.
+ * @endif
+ */
+ template<typename _ForwardIterator>
+ pointer
+ _M_allocate_and_copy(size_type __n,
+ _ForwardIterator __first, _ForwardIterator __last)
+ {
+ pointer __result = _M_allocate(__n);
+ try
+ {
+ uninitialized_copy(__first, __last, __result);
+ return __result;
+ }
+ catch(...)
+ {
+ _M_deallocate(__result, __n);
+ __throw_exception_again;
+ }
+ }
+
+
+ // Internal constructor functions follow.
+
+ // Called by the range constructor to implement [23.1.1]/9
+ template<typename _Integer>
+ void
+ _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
+ {
+ _M_start = _M_allocate(__n);
+ _M_end_of_storage = _M_start + __n;
+ _M_finish = uninitialized_fill_n(_M_start, __n, __value);
+ }
+
+ // Called by the range constructor to implement [23.1.1]/9
+ template<typename _InputIter>
+ void
+ _M_initialize_dispatch(_InputIter __first, _InputIter __last,
+ __false_type)
+ {
+ typedef typename iterator_traits<_InputIter>::iterator_category
+ _IterCategory;
_M_range_initialize(__first, __last, _IterCategory());
}
-
- ~vector()
- { _Destroy(_M_start, _M_finish); }
-
- vector<_Tp, _Alloc>& operator=(const vector<_Tp, _Alloc>& __x);
-
- /**
- * @brief Attempt to preallocate enough memory for specified number of
- * elements.
- * @param n Number of elements required
- *
- * This function attempts to reserve enough memory for the vector to hold
- * the specified number of elements. If the number requested is more than
- * max_size() length_error is thrown.
- *
- * The advantage of this function is that if optimal code is a necessity
- * and the user can determine the number of elements that will be required
- * the user can reserve the memory and thus prevent a possible
- * reallocation of memory and copy of vector data.
- */
- void reserve(size_type __n) {
- if (__n > this->max_size())
- __throw_length_error("vector::reserve");
- if (this->capacity() < __n) {
- const size_type __old_size = size();
- pointer __tmp = _M_allocate_and_copy(__n, _M_start, _M_finish);
- _Destroy(_M_start, _M_finish);
- _M_deallocate(_M_start, _M_end_of_storage - _M_start);
- _M_start = __tmp;
- _M_finish = __tmp + __old_size;
- _M_end_of_storage = _M_start + __n;
- }
- }
-
- // assign(), a generalized assignment member function. Two
- // versions: one that takes a count, and one that takes a range.
- // The range version is a member template, so we dispatch on whether
- // or not the type is an integer.
-
- /**
- * @brief Assigns a given value or range to a vector.
- * @param n Number of elements to be assigned.
- * @param val Value to be assigned.
- *
- * This function can be used to assign a range to a vector or fill it
- * with a specified number of copies of the given value.
- * Note that the assignment completely changes the vector and that the
- * resulting vector's size is the same as the number of elements assigned.
- * Old data may be lost.
- */
- void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); }
- void _M_fill_assign(size_type __n, const _Tp& __val);
-
- template<class _InputIterator>
- void
- assign(_InputIterator __first, _InputIterator __last)
- {
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_assign_dispatch(__first, __last, _Integral());
- }
-
- template<class _Integer>
- void
- _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
- { _M_fill_assign((size_type) __n, (_Tp) __val); }
-
- template<class _InputIter>
- void
- _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type)
- {
- typedef typename iterator_traits<_InputIter>::iterator_category _IterCategory;
- _M_assign_aux(__first, __last, _IterCategory());
- }
-
- template <class _InputIterator>
- void
- _M_assign_aux(_InputIterator __first, _InputIterator __last,
- input_iterator_tag);
-
- template <class _ForwardIterator>
- void
- _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
- forward_iterator_tag);
-
- /**
- * Returns a read/write reference to the data at the first element of the
- * vector.
- */
- reference front() { return *begin(); }
-
- /**
- * Returns a read-only (constant) reference to the data at the first
- * element of the vector.
- */
- const_reference front() const { return *begin(); }
-
- /**
- * Returns a read/write reference to the data at the last element of the
- * vector.
- */
- reference back() { return *(end() - 1); }
-
- /**
- * Returns a read-only (constant) reference to the data at the first
- * element of the vector.
- */
- const_reference back() const { return *(end() - 1); }
-
- /**
- * @brief Add data to the end of the vector.
- * @param x Data to be added.
- *
- * This is a typical stack operation. The function creates an element at
- * the end of the vector and assigns the given data to it.
- * Due to the nature of a vector this operation can be done in constant
- * time if the vector has preallocated space available.
- */
- void
- push_back(const _Tp& __x)
- {
- if (_M_finish != _M_end_of_storage) {
- _Construct(_M_finish, __x);
- ++_M_finish;
- }
- else
- _M_insert_aux(end(), __x);
- }
-
+
+ // Called by the second initialize_dispatch above
+ template<typename _InputIterator>
+ void
+ _M_range_initialize(_InputIterator __first,
+ _InputIterator __last, input_iterator_tag)
+ {
+ for ( ; __first != __last; ++__first)
+ push_back(*__first);
+ }
+
+ // Called by the second initialize_dispatch above
+ template<typename _ForwardIterator>
+ void
+ _M_range_initialize(_ForwardIterator __first,
+ _ForwardIterator __last, forward_iterator_tag)
+ {
+ size_type __n = distance(__first, __last);
+ _M_start = _M_allocate(__n);
+ _M_end_of_storage = _M_start + __n;
+ _M_finish = uninitialized_copy(__first, __last, _M_start);
+ }
+
+
+ // Internal assign functions follow. The *_aux functions do the actual
+ // assignment work for the range versions.
+
+ // Called by the range assign to implement [23.1.1]/9
+ template<typename _Integer>
+ void
+ _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
+ {
+ _M_fill_assign(static_cast<size_type>(__n),
+ static_cast<value_type>(__val));
+ }
+
+ // Called by the range assign to implement [23.1.1]/9
+ template<typename _InputIter>
+ void
+ _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type)
+ {
+ typedef typename iterator_traits<_InputIter>::iterator_category
+ _IterCategory;
+ _M_assign_aux(__first, __last, _IterCategory());
+ }
+
+ // Called by the second assign_dispatch above
+ template<typename _InputIterator>
+ void
+ _M_assign_aux(_InputIterator __first, _InputIterator __last,
+ input_iterator_tag);
+
+ // Called by the second assign_dispatch above
+ template<typename _ForwardIterator>
+ void
+ _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
+ forward_iterator_tag);
+
+ // Called by assign(n,t), and the range assign when it turns out
+ // to be the same thing.
+ void
+ _M_fill_assign(size_type __n, const value_type& __val);
+
+
+ // Internal insert functions follow.
+
+ // Called by the range insert to implement [23.1.1]/9
+ template<typename _Integer>
+ void
+ _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
+ __true_type)
+ {
+ _M_fill_insert(__pos, static_cast<size_type>(__n),
+ static_cast<value_type>(__val));
+ }
+
+ // Called by the range insert to implement [23.1.1]/9
+ template<typename _InputIterator>
+ void
+ _M_insert_dispatch(iterator __pos, _InputIterator __first,
+ _InputIterator __last, __false_type)
+ {
+ typedef typename iterator_traits<_InputIterator>::iterator_category
+ _IterCategory;
+ _M_range_insert(__pos, __first, __last, _IterCategory());
+ }
+
+ // Called by the second insert_dispatch above
+ template<typename _InputIterator>
+ void
+ _M_range_insert(iterator __pos, _InputIterator __first,
+ _InputIterator __last, input_iterator_tag);
+
+ // Called by the second insert_dispatch above
+ template<typename _ForwardIterator>
+ void
+ _M_range_insert(iterator __pos, _ForwardIterator __first,
+ _ForwardIterator __last, forward_iterator_tag);
+
+ // Called by insert(p,n,x), and the range insert when it turns out to be
+ // the same thing.
+ void
+ _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
+
+ // Called by insert(p,x)
+ void
+ _M_insert_aux(iterator __position, const value_type& __x);
+
#ifdef _GLIBCPP_DEPRECATED
- /**
- * Add an element to the end of the vector. The element is
- * default-constructed.
- *
- * @note You must define _GLIBCPP_DEPRECATED to make this visible; see
- * c++config.h.
- */
- void
- push_back()
- {
- if (_M_finish != _M_end_of_storage) {
- _Construct(_M_finish);
- ++_M_finish;
- }
- else
- _M_insert_aux(end());
- }
+ // Unused now (same situation as in deque)
+ void _M_insert_aux(iterator __position);
#endif
-
- void
- swap(vector<_Tp, _Alloc>& __x)
- {
- std::swap(_M_start, __x._M_start);
- std::swap(_M_finish, __x._M_finish);
- std::swap(_M_end_of_storage, __x._M_end_of_storage);
- }
-
+ };
+
+
/**
- * @brief Inserts given value into vector at specified element.
- * @param position An iterator that points to the element where data
- * should be inserted.
- * @param x Data to be inserted.
- * @return An iterator that points to the inserted data.
+ * @brief Vector equality comparison.
+ * @param x A %vector.
+ * @param y A %vector of the same type as @a x.
+ * @return True iff the size and elements of the vectors are equal.
*
- * This function will insert the given value into the specified location.
- * Note that this kind of operation could be expensive for a vector and if
- * it is frequently used the user should consider using std::list.
+ * This is an equivalence relation. It is linear in the size of the
+ * vectors. Vectors are considered equivalent if their sizes are equal,
+ * and if corresponding elements compare equal.
*/
- iterator
- insert(iterator __position, const _Tp& __x)
- {
- size_type __n = __position - begin();
- if (_M_finish != _M_end_of_storage && __position == end()) {
- _Construct(_M_finish, __x);
- ++_M_finish;
- }
- else
- _M_insert_aux(iterator(__position), __x);
- return begin() + __n;
- }
-
- /**
- * @brief Inserts an empty element into the vector.
- * @param position An iterator that points to the element where empty
- * element should be inserted.
- * @param x Data to be inserted.
- * @return An iterator that points to the inserted element.
- *
- * This function will insert an empty element into the specified location.
- * Note that this kind of operation could be expensive for a vector and if
- * it is frequently used the user should consider using std::list.
- */
- iterator
- insert(iterator __position)
- {
- size_type __n = __position - begin();
- if (_M_finish != _M_end_of_storage && __position == end()) {
- _Construct(_M_finish);
- ++_M_finish;
- }
- else
- _M_insert_aux(iterator(__position));
- return begin() + __n;
- }
-
- // Check whether it's an integral type. If so, it's not an iterator.
- template<class _InputIterator>
- void
- insert(iterator __pos, _InputIterator __first, _InputIterator __last)
- {
- typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
- _M_insert_dispatch(__pos, __first, __last, _Integral());
- }
-
- template <class _Integer>
- void
- _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, __true_type)
- { _M_fill_insert(__pos, static_cast<size_type>(__n), static_cast<_Tp>(__val)); }
-
- template<class _InputIterator>
- void
- _M_insert_dispatch(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- __false_type)
- {
- typedef typename iterator_traits<_InputIterator>::iterator_category _IterCategory;
- _M_range_insert(__pos, __first, __last, _IterCategory());
+ template<typename _Tp, typename _Alloc>
+ inline bool
+ operator==(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ {
+ return __x.size() == __y.size() &&
+ equal(__x.begin(), __x.end(), __y.begin());
}
-
- /**
- * @brief Inserts a number of copies of given data into the vector.
- * @param position An iterator that points to the element where data
- * should be inserted.
- * @param n Amount of elements to be inserted.
- * @param x Data to be inserted.
- *
- * This function will insert a specified number of copies of the given data
- * into the specified location.
- *
- * Note that this kind of operation could be expensive for a vector and if
- * it is frequently used the user should consider using std::list.
- */
- void insert (iterator __pos, size_type __n, const _Tp& __x)
- { _M_fill_insert(__pos, __n, __x); }
-
- void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);
-
+
/**
- * @brief Removes last element from vector.
+ * @brief Vector ordering relation.
+ * @param x A %vector.
+ * @param y A %vector of the same type as @a x.
+ * @return True iff @a x is lexographically less than @a y.
*
- * This is a typical stack operation. It allows us to shrink the vector by
- * one.
+ * This is a total ordering relation. It is linear in the size of the
+ * vectors. The elements must be comparable with @c <.
*
- * Note that no data is returned and if last element's data is needed it
- * should be retrieved before pop_back() is called.
+ * See std::lexographical_compare() for how the determination is made.
*/
- void pop_back() {
- --_M_finish;
- _Destroy(_M_finish);
- }
-
- /**
- * @brief Remove element at given position
- * @param position Iterator pointing to element to be erased.
- * @return Doc Me! (Iterator pointing to new element at old location?)
- *
- * This function will erase the element at the given position and thus
- * shorten the vector by one.
- *
- * Note This operation could be expensive and if it is frequently used the
- * user should consider using std::list. The user is also cautioned that
- * this function only erases the element, and that if the element is itself
- * a pointer, the pointed-to memory is not touched in any way. Managing
- * the pointer is the user's responsibilty.
- */
- iterator erase(iterator __position) {
- if (__position + 1 != end())
- copy(__position + 1, end(), __position);
- --_M_finish;
- _Destroy(_M_finish);
- return __position;
- }
-
- /**
- * @brief Remove a range of elements from a vector.
- * @param first Iterator pointing to the first element to be erased.
- * @param last Iterator pointing to the last element to be erased.
- * @return Doc Me! (Iterator pointing to new element at old location?)
- *
- * This function will erase the elements in the given range and shorten the
- * vector accordingly.
- *
- * Note This operation could be expensive and if it is frequently used the
- * user should consider using std::list. The user is also cautioned that
- * this function only erases the elements, and that if the elements
- * themselves are pointers, the pointed-to memory is not touched in any
- * way. Managing the pointer is the user's responsibilty.
- */
- iterator erase(iterator __first, iterator __last) {
- iterator __i(copy(__last, end(), __first));
- _Destroy(__i, end());
- _M_finish = _M_finish - (__last - __first);
- return __first;
- }
-
- /**
- * @brief Resizes the vector to the specified number of elements.
- * @param new_size Number of elements the vector should contain.
- * @param x Data with which new elements should be populated.
- *
- * This function will resize the vector to the specified number of
- * elements. If the number is smaller than the vector's current size the
- * vector is truncated, otherwise the vector is extended and new elements
- * are populated with given data.
- */
- void resize(size_type __new_size, const _Tp& __x) {
- if (__new_size < size())
- erase(begin() + __new_size, end());
- else
- insert(end(), __new_size - size(), __x);
- }
-
- /**
- * @brief Resizes the vector to the specified number of elements.
- * @param new_size Number of elements the vector should contain.
- *
- * This function will resize the vector to the specified number of
- * elements. If the number is smaller than the vector's current size the
- * vector is truncated, otherwise the vector is extended and new elements
- * are left uninitialized.
- */
- void resize(size_type __new_size) { resize(__new_size, _Tp()); }
-
- /**
- * Erases all elements in vector. Note that this function only erases the
- * elements, and that if the elements themselves are pointers, the
- * pointed-to memory is not touched in any way. Managing the pointer is
- * the user's responsibilty.
- */
- void clear() { erase(begin(), end()); }
-
-protected:
-
- template <class _ForwardIterator>
- pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first,
- _ForwardIterator __last)
- {
- pointer __result = _M_allocate(__n);
- try {
- uninitialized_copy(__first, __last, __result);
- return __result;
- }
- catch(...)
- {
- _M_deallocate(__result, __n);
- __throw_exception_again;
- }
- }
-
- template <class _InputIterator>
- void _M_range_initialize(_InputIterator __first,
- _InputIterator __last, input_iterator_tag)
- {
- for ( ; __first != __last; ++__first)
- push_back(*__first);
- }
-
- // This function is only called by the constructor.
- template <class _ForwardIterator>
- void _M_range_initialize(_ForwardIterator __first,
- _ForwardIterator __last, forward_iterator_tag)
- {
- size_type __n = distance(__first, __last);
- _M_start = _M_allocate(__n);
- _M_end_of_storage = _M_start + __n;
- _M_finish = uninitialized_copy(__first, __last, _M_start);
- }
-
- template <class _InputIterator>
- void _M_range_insert(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- input_iterator_tag);
-
- template <class _ForwardIterator>
- void _M_range_insert(iterator __pos,
- _ForwardIterator __first, _ForwardIterator __last,
- forward_iterator_tag);
-};
-
-template <class _Tp, class _Alloc>
-inline bool
-operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
-{
- return __x.size() == __y.size() &&
- equal(__x.begin(), __x.end(), __y.begin());
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
-{
- return lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end());
-}
-
-template <class _Tp, class _Alloc>
-inline void swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
-{
- __x.swap(__y);
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {
- return !(__x == __y);
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {
- return __y < __x;
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {
- return !(__y < __x);
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {
- return !(__x < __y);
-}
-
-template <class _Tp, class _Alloc>
-vector<_Tp,_Alloc>&
-vector<_Tp,_Alloc>::operator=(const vector<_Tp, _Alloc>& __x)
-{
- if (&__x != this) {
- const size_type __xlen = __x.size();
- if (__xlen > capacity()) {
- pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());
- _Destroy(_M_start, _M_finish);
- _M_deallocate(_M_start, _M_end_of_storage - _M_start);
- _M_start = __tmp;
- _M_end_of_storage = _M_start + __xlen;
- }
- else if (size() >= __xlen) {
- iterator __i(copy(__x.begin(), __x.end(), begin()));
- _Destroy(__i, end());
- }
- else {
- copy(__x.begin(), __x.begin() + size(), _M_start);
- uninitialized_copy(__x.begin() + size(), __x.end(), _M_finish);
- }
- _M_finish = _M_start + __xlen;
- }
- return *this;
-}
-
-template <class _Tp, class _Alloc>
-void vector<_Tp, _Alloc>::_M_fill_assign(size_t __n, const value_type& __val)
-{
- if (__n > capacity()) {
- vector<_Tp, _Alloc> __tmp(__n, __val, get_allocator());
- __tmp.swap(*this);
- }
- else if (__n > size()) {
- fill(begin(), end(), __val);
- _M_finish = uninitialized_fill_n(_M_finish, __n - size(), __val);
- }
- else
- erase(fill_n(begin(), __n, __val), end());
-}
-
-template <class _Tp, class _Alloc> template <class _InputIter>
-void vector<_Tp, _Alloc>::_M_assign_aux(_InputIter __first, _InputIter __last,
- input_iterator_tag) {
- iterator __cur(begin());
- for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
- *__cur = *__first;
- if (__first == __last)
- erase(__cur, end());
- else
- insert(end(), __first, __last);
-}
-
-template <class _Tp, class _Alloc> template <class _ForwardIter>
-void
-vector<_Tp, _Alloc>::_M_assign_aux(_ForwardIter __first, _ForwardIter __last,
- forward_iterator_tag) {
- size_type __len = distance(__first, __last);
-
- if (__len > capacity()) {
- pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
- _Destroy(_M_start, _M_finish);
- _M_deallocate(_M_start, _M_end_of_storage - _M_start);
- _M_start = __tmp;
- _M_end_of_storage = _M_finish = _M_start + __len;
- }
- else if (size() >= __len) {
- iterator __new_finish(copy(__first, __last, _M_start));
- _Destroy(__new_finish, end());
- _M_finish = __new_finish.base();
- }
- else {
- _ForwardIter __mid = __first;
- advance(__mid, size());
- copy(__first, __mid, _M_start);
- _M_finish = uninitialized_copy(__mid, __last, _M_finish);
- }
-}
-
-template <class _Tp, class _Alloc>
-void
-vector<_Tp, _Alloc>::_M_insert_aux(iterator __position, const _Tp& __x)
-{
- if (_M_finish != _M_end_of_storage) {
- _Construct(_M_finish, *(_M_finish - 1));
- ++_M_finish;
- _Tp __x_copy = __x;
- copy_backward(__position, iterator(_M_finish - 2), iterator(_M_finish- 1));
- *__position = __x_copy;
- }
- else {
- const size_type __old_size = size();
- const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
- iterator __new_start(_M_allocate(__len));
- iterator __new_finish(__new_start);
- try {
- __new_finish = uninitialized_copy(iterator(_M_start), __position,
- __new_start);
- _Construct(__new_finish.base(), __x);
- ++__new_finish;
- __new_finish = uninitialized_copy(__position, iterator(_M_finish),
- __new_finish);
- }
- catch(...)
- {
- _Destroy(__new_start,__new_finish);
- _M_deallocate(__new_start.base(),__len);
- __throw_exception_again;
- }
- _Destroy(begin(), end());
- _M_deallocate(_M_start, _M_end_of_storage - _M_start);
- _M_start = __new_start.base();
- _M_finish = __new_finish.base();
- _M_end_of_storage = __new_start.base() + __len;
- }
-}
-
-template <class _Tp, class _Alloc>
-void
-vector<_Tp, _Alloc>::_M_insert_aux(iterator __position)
-{
- if (_M_finish != _M_end_of_storage) {
- _Construct(_M_finish, *(_M_finish - 1));
- ++_M_finish;
- copy_backward(__position, iterator(_M_finish - 2),
- iterator(_M_finish - 1));
- *__position = _Tp();
- }
- else {
- const size_type __old_size = size();
- const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
- pointer __new_start = _M_allocate(__len);
- pointer __new_finish = __new_start;
- try {
- __new_finish = uninitialized_copy(iterator(_M_start), __position,
- __new_start);
- _Construct(__new_finish);
- ++__new_finish;
- __new_finish = uninitialized_copy(__position, iterator(_M_finish),
- __new_finish);
- }
- catch(...)
- {
- _Destroy(__new_start,__new_finish);
- _M_deallocate(__new_start,__len);
- __throw_exception_again;
- }
- _Destroy(begin(), end());
- _M_deallocate(_M_start, _M_end_of_storage - _M_start);
- _M_start = __new_start;
- _M_finish = __new_finish;
- _M_end_of_storage = __new_start + __len;
- }
-}
-
-template <class _Tp, class _Alloc>
-void vector<_Tp, _Alloc>::_M_fill_insert(iterator __position, size_type __n,
- const _Tp& __x)
-{
- if (__n != 0) {
- if (size_type(_M_end_of_storage - _M_finish) >= __n) {
- _Tp __x_copy = __x;
- const size_type __elems_after = end() - __position;
- iterator __old_finish(_M_finish);
- if (__elems_after > __n) {
- uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
- _M_finish += __n;
- copy_backward(__position, __old_finish - __n, __old_finish);
- fill(__position, __position + __n, __x_copy);
- }
- else {
- uninitialized_fill_n(_M_finish, __n - __elems_after, __x_copy);
- _M_finish += __n - __elems_after;
- uninitialized_copy(__position, __old_finish, _M_finish);
- _M_finish += __elems_after;
- fill(__position, __old_finish, __x_copy);
- }
- }
- else {
- const size_type __old_size = size();
- const size_type __len = __old_size + max(__old_size, __n);
- iterator __new_start(_M_allocate(__len));
- iterator __new_finish(__new_start);
- try {
- __new_finish = uninitialized_copy(begin(), __position, __new_start);
- __new_finish = uninitialized_fill_n(__new_finish, __n, __x);
- __new_finish
- = uninitialized_copy(__position, end(), __new_finish);
- }
- catch(...)
- {
- _Destroy(__new_start,__new_finish);
- _M_deallocate(__new_start.base(),__len);
- __throw_exception_again;
- }
- _Destroy(_M_start, _M_finish);
- _M_deallocate(_M_start, _M_end_of_storage - _M_start);
- _M_start = __new_start.base();
- _M_finish = __new_finish.base();
- _M_end_of_storage = __new_start.base() + __len;
- }
- }
-}
-
-template <class _Tp, class _Alloc> template <class _InputIterator>
-void
-vector<_Tp, _Alloc>::_M_range_insert(iterator __pos,
- _InputIterator __first,
- _InputIterator __last,
- input_iterator_tag)
-{
- for ( ; __first != __last; ++__first) {
- __pos = insert(__pos, *__first);
- ++__pos;
- }
-}
-
-template <class _Tp, class _Alloc> template <class _ForwardIterator>
-void
-vector<_Tp, _Alloc>::_M_range_insert(iterator __position,
- _ForwardIterator __first,
- _ForwardIterator __last,
- forward_iterator_tag)
-{
- if (__first != __last) {
- size_type __n = distance(__first, __last);
- if (size_type(_M_end_of_storage - _M_finish) >= __n) {
- const size_type __elems_after = end() - __position;
- iterator __old_finish(_M_finish);
- if (__elems_after > __n) {
- uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
- _M_finish += __n;
- copy_backward(__position, __old_finish - __n, __old_finish);
- copy(__first, __last, __position);
- }
- else {
- _ForwardIterator __mid = __first;
- advance(__mid, __elems_after);
- uninitialized_copy(__mid, __last, _M_finish);
- _M_finish += __n - __elems_after;
- uninitialized_copy(__position, __old_finish, _M_finish);
- _M_finish += __elems_after;
- copy(__first, __mid, __position);
- }
- }
- else {
- const size_type __old_size = size();
- const size_type __len = __old_size + max(__old_size, __n);
- iterator __new_start(_M_allocate(__len));
- iterator __new_finish(__new_start);
- try {
- __new_finish = uninitialized_copy(iterator(_M_start),
- __position, __new_start);
- __new_finish = uninitialized_copy(__first, __last, __new_finish);
- __new_finish
- = uninitialized_copy(__position, iterator(_M_finish), __new_finish);
- }
- catch(...)
- {
- _Destroy(__new_start,__new_finish);
- _M_deallocate(__new_start.base(), __len);
- __throw_exception_again;
- }
- _Destroy(_M_start, _M_finish);
- _M_deallocate(_M_start, _M_end_of_storage - _M_start);
- _M_start = __new_start.base();
- _M_finish = __new_finish.base();
- _M_end_of_storage = __new_start.base() + __len;
+ template<typename _Tp, typename _Alloc>
+ inline bool
+ operator<(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ {
+ return lexicographical_compare(__x.begin(), __x.end(),
+ __y.begin(), __y.end());
}
- }
-}
-
+
+ /// Based on operator==
+ template<typename _Tp, typename _Alloc>
+ inline bool
+ operator!=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ { return !(__x == __y); }
+
+ /// Based on operator<
+ template<typename _Tp, typename _Alloc>
+ inline bool
+ operator>(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ { return __y < __x; }
+
+ /// Based on operator<
+ template<typename _Tp, typename _Alloc>
+ inline bool
+ operator<=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ { return !(__y < __x); }
+
+ /// Based on operator<
+ template<typename _Tp, typename _Alloc>
+ inline bool
+ operator>=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ { return !(__x < __y); }
+
+ /// See std::vector::swap().
+ template<typename _Tp, typename _Alloc>
+ inline void
+ swap(vector<_Tp,_Alloc>& __x, vector<_Tp,_Alloc>& __y)
+ { __x.swap(__y); }
} // namespace std
#endif /* __GLIBCPP_INTERNAL_VECTOR_H */
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/bits/streambuf.tcc b/contrib/libstdc++/include/bits/streambuf.tcc
index 5f57df5..be85862 100644
--- a/contrib/libstdc++/include/bits/streambuf.tcc
+++ b/contrib/libstdc++/include/bits/streambuf.tcc
@@ -1,6 +1,6 @@
// Stream buffer classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -67,8 +67,7 @@ namespace std
{
int_type __ret;
bool __testpos = _M_in_cur && _M_in_beg < _M_in_cur;
- bool __testne = _M_in_cur && !traits_type::eq(__c, this->gptr()[-1]);
- if (!__testpos || __testne)
+ if (!__testpos || !traits_type::eq(__c, this->gptr()[-1]))
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
@@ -199,54 +198,46 @@ namespace std
basic_streambuf<_CharT, _Traits>* __sbin,
basic_streambuf<_CharT, _Traits>* __sbout)
{
- typedef typename _Traits::int_type int_type;
-
- streamsize __ret = 0;
- streamsize __bufsize = __sbin->in_avail();
- streamsize __xtrct;
- bool __testput = __sbout->_M_mode & ios_base::out;
- try
- {
- while (__testput && __bufsize != -1)
- {
- if (__bufsize != 0 && __sbin->gptr() != NULL
- && __sbin->gptr() + __bufsize <= __sbin->egptr())
- {
- __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
- __ret += __xtrct;
- __sbin->_M_in_cur_move(__xtrct);
- if (__xtrct != __bufsize)
- break;
- }
- else
- {
- size_t __size =
- __sbin->_M_buf_size_opt > 0 ? __sbin->_M_buf_size_opt : 1;
- _CharT* __buf =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __size));
- streamsize __charsread = __sbin->sgetn(__buf, __size);
- __xtrct = __sbout->sputn(__buf, __charsread);
- __ret += __xtrct;
- if (__xtrct != __charsread)
- break;
- }
- if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
- break;
- __bufsize = __sbin->in_avail();
- }
- }
- catch(exception& __fail)
- {
- __ios.setstate(ios_base::failbit);
- if ((__ios.exceptions() & ios_base::failbit) != 0)
- __throw_exception_again;
- }
- return __ret;
- }
+ streamsize __ret = 0;
+ try
+ {
+ typename _Traits::int_type __c = __sbin->sgetc();
+ while (!_Traits::eq_int_type(__c, _Traits::eof()))
+ {
+ const size_t __n = __sbin->_M_in_end - __sbin->_M_in_cur;
+ if (__n > 1)
+ {
+ const size_t __wrote = __sbout->sputn(__sbin->_M_in_cur,
+ __n);
+ __sbin->_M_in_cur_move(__wrote);
+ __ret += __wrote;
+ if (__wrote < __n)
+ break;
+ __c = __sbin->underflow();
+ }
+ else
+ {
+ __c = __sbout->sputc(_Traits::to_char_type(__c));
+ if (_Traits::eq_int_type(__c, _Traits::eof()))
+ break;
+ ++__ret;
+ __c = __sbin->snextc();
+ }
+ }
+ }
+ catch(exception& __fail)
+ {
+ __ios.setstate(ios_base::failbit);
+ if ((__ios.exceptions() & ios_base::failbit) != 0)
+ __throw_exception_again;
+ }
+ return __ret;
+ }
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_streambuf<char>;
extern template
streamsize
@@ -260,6 +251,7 @@ namespace std
__copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*,
basic_streambuf<wchar_t>*);
#endif
+#endif
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/streambuf_iterator.h b/contrib/libstdc++/include/bits/streambuf_iterator.h
index 152df9c..d482aba 100644
--- a/contrib/libstdc++/include/bits/streambuf_iterator.h
+++ b/contrib/libstdc++/include/bits/streambuf_iterator.h
@@ -1,6 +1,6 @@
// Streambuf iterators
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -28,8 +28,6 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-// XXX Should specialize copy, find algorithms for streambuf iterators.
-
/** @file streambuf_iterator.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
@@ -40,6 +38,10 @@
#pragma GCC system_header
+#include <streambuf>
+
+// NB: Should specialize copy, find algorithms for streambuf iterators.
+
namespace std
{
// 24.5.3 Template class istreambuf_iterator
@@ -166,7 +168,6 @@ namespace std
bool _M_failed;
public:
- inline
ostreambuf_iterator(ostream_type& __s) throw ()
: _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
@@ -174,7 +175,13 @@ namespace std
: _M_sbuf(__s), _M_failed(!_M_sbuf) { }
ostreambuf_iterator&
- operator=(_CharT __c);
+ operator=(_CharT __c)
+ {
+ if (!_M_failed &&
+ _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof()))
+ _M_failed = true;
+ return *this;
+ }
ostreambuf_iterator&
operator*() throw()
@@ -191,16 +198,15 @@ namespace std
bool
failed() const throw()
{ return _M_failed; }
- };
- template<typename _CharT, typename _Traits>
- inline ostreambuf_iterator<_CharT, _Traits>&
- ostreambuf_iterator<_CharT, _Traits>::operator=(_CharT __c)
- {
- if (!_M_failed &&
- _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof()))
- _M_failed = true;
- return *this;
- }
+ ostreambuf_iterator&
+ _M_put(const _CharT* __ws, streamsize __len)
+ {
+ if (__builtin_expect(!_M_failed, true) &&
+ __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len, false))
+ _M_failed = true;
+ return *this;
+ }
+ };
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/bits/valarray_array.h b/contrib/libstdc++/include/bits/valarray_array.h
index 48dd2aa..c880478 100644
--- a/contrib/libstdc++/include/bits/valarray_array.h
+++ b/contrib/libstdc++/include/bits/valarray_array.h
@@ -603,16 +603,16 @@ _Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \
} \
}
- _DEFINE_ARRAY_FUNCTION(+, plus)
- _DEFINE_ARRAY_FUNCTION(-, minus)
- _DEFINE_ARRAY_FUNCTION(*, multiplies)
- _DEFINE_ARRAY_FUNCTION(/, divides)
- _DEFINE_ARRAY_FUNCTION(%, modulus)
- _DEFINE_ARRAY_FUNCTION(^, xor)
- _DEFINE_ARRAY_FUNCTION(|, or)
- _DEFINE_ARRAY_FUNCTION(&, and)
- _DEFINE_ARRAY_FUNCTION(<<, shift_left)
- _DEFINE_ARRAY_FUNCTION(>>, shift_right)
+ _DEFINE_ARRAY_FUNCTION(+, __plus)
+ _DEFINE_ARRAY_FUNCTION(-, __minus)
+ _DEFINE_ARRAY_FUNCTION(*, __multiplies)
+ _DEFINE_ARRAY_FUNCTION(/, __divides)
+ _DEFINE_ARRAY_FUNCTION(%, __modulus)
+ _DEFINE_ARRAY_FUNCTION(^, __bitwise_xor)
+ _DEFINE_ARRAY_FUNCTION(|, __bitwise_or)
+ _DEFINE_ARRAY_FUNCTION(&, __bitwise_and)
+ _DEFINE_ARRAY_FUNCTION(<<, __shift_left)
+ _DEFINE_ARRAY_FUNCTION(>>, __shift_right)
#undef _DEFINE_VALARRAY_FUNCTION
diff --git a/contrib/libstdc++/include/bits/valarray_meta.h b/contrib/libstdc++/include/bits/valarray_meta.h
index f2926c0..29a2dac 100644
--- a/contrib/libstdc++/include/bits/valarray_meta.h
+++ b/contrib/libstdc++/include/bits/valarray_meta.h
@@ -41,469 +41,601 @@
namespace std
{
+ //
+ // Implementing a loosened valarray return value is tricky.
+ // First we need to meet 26.3.1/3: we should not add more than
+ // two levels of template nesting. Therefore we resort to template
+ // template to "flatten" loosened return value types.
+ // At some point we use partial specialization to remove one level
+ // template nesting due to _Expr<>
+ //
+
+ // This class is NOT defined. It doesn't need to.
+ template<typename _Tp1, typename _Tp2> class _Constant;
+
+ // Implementations of unary functions applied to valarray<>s.
+ // I use hard-coded object functions here instead of a generic
+ // approach like pointers to function:
+ // 1) correctness: some functions take references, others values.
+ // we can't deduce the correct type afterwards.
+ // 2) efficiency -- object functions can be easily inlined
+ // 3) be Koenig-lookup-friendly
+
+ struct __abs
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return abs(__t); }
+ };
- //
- // Implementing a loosened valarray return value is tricky.
- // First we need to meet 26.3.1/3: we should not add more than
- // two levels of template nesting. Therefore we resort to template
- // template to "flatten" loosened return value types.
- // At some point we use partial specialization to remove one level
- // template nesting due to _Expr<>
- //
-
+ struct __cos
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return cos(__t); }
+ };
- // This class is NOT defined. It doesn't need to.
- template<typename _Tp1, typename _Tp2> class _Constant;
+ struct __acos
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return acos(__t); }
+ };
- //
- // Unary function application closure.
- //
- template<class _Dom> class _UnFunBase {
- public:
- typedef typename _Dom::value_type value_type;
- typedef value_type _Vt;
-
- _UnFunBase (const _Dom& __e, _Vt __f(_Vt))
- : _M_expr(__e), _M_func(__f) {}
-
- _Vt operator[] (size_t __i) const { return _M_func(_M_expr[__i]); }
- size_t size () const { return _M_expr.size(); }
-
- private:
- const _Dom& _M_expr;
- _Vt (*_M_func)(_Vt);
- };
+ struct __cosh
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return cosh(__t); }
+ };
- template<template<class, class> class _Meta, class _Dom>
- class _UnFunClos;
-
- template<class _Dom>
- struct _UnFunClos<_Expr,_Dom> : _UnFunBase<_Dom> {
- typedef _UnFunBase<_Dom> _Base;
- typedef typename _Base::value_type value_type;
-
- _UnFunClos (const _Dom& __e, value_type __f(value_type))
- : _Base (__e, __f) {}
- };
-
+ struct __sin
+ {
template<typename _Tp>
- struct _UnFunClos<_ValArray,_Tp> : _UnFunBase<valarray<_Tp> > {
- typedef _UnFunBase<valarray<_Tp> > _Base;
- typedef typename _Base::value_type value_type;
-
- _UnFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
- : _Base (__v, __f) {}
- };
+ _Tp operator()(const _Tp& __t) const { return sin(__t); }
+ };
- //
- // Binary function application closure.
- //
- template<template<class, class> class _Meta1,
- template<class, class> class Meta2,
- class _Dom1, class _Dom2> class _BinFunClos;
-
- template<class _Dom1, class _Dom2> class _BinFunBase {
- public:
- typedef typename _Dom1::value_type value_type;
- typedef value_type _Vt;
+ struct __asin
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return asin(__t); }
+ };
- _BinFunBase (const _Dom1& __e1, const _Dom2& __e2,
- _Vt __f (_Vt, _Vt))
- : _M_expr1 (__e1), _M_expr2 (__e2), _M_func (__f) {}
+ struct __sinh
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return sinh(__t); }
+ };
- value_type operator[] (size_t __i) const
- { return _M_func (_M_expr1[__i], _M_expr2[__i]); }
- size_t size () const { return _M_expr1.size (); }
+ struct __tan
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return tan(__t); }
+ };
- private:
- const _Dom1& _M_expr1;
- const _Dom2& _M_expr2;
- _Vt (*_M_func)(_Vt, _Vt);
- };
+ struct __atan
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return atan(__t); }
+ };
- template<class _Dom> class _BinFunBase1 {
- public:
- typedef typename _Dom::value_type value_type ;
- typedef value_type _Vt;
+ struct __tanh
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return tanh(__t); }
+ };
- _BinFunBase1 (const _Vt& __c, const _Dom& __e, _Vt __f(_Vt, _Vt))
- : _M_expr1 (__c), _M_expr2 (__e), _M_func (__f) {}
+ struct __exp
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return exp(__t); }
+ };
- value_type operator[] (size_t __i) const
- { return _M_func (_M_expr1, _M_expr2[__i]); }
- size_t size () const { return _M_expr2.size (); }
+ struct __log
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return log(__t); }
+ };
- private:
- const _Vt& _M_expr1;
- const _Dom& _M_expr2;
- _Vt (*_M_func)(_Vt, _Vt);
- };
+ struct __log10
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return log10(__t); }
+ };
- template<class _Dom> class _BinFunBase2 {
- public:
- typedef typename _Dom::value_type value_type;
- typedef value_type _Vt;
+ struct __sqrt
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return sqrt(__t); }
+ };
- _BinFunBase2 (const _Dom& __e, const _Vt& __c, _Vt __f(_Vt, _Vt))
- : _M_expr1 (__e), _M_expr2 (__c), _M_func (__f) {}
+ // In the past, we used to tailor operator applications semantics
+ // to the specialization of standard function objects (i.e. plus<>, etc.)
+ // That is incorrect. Therefore we provide our own surrogates.
- value_type operator[] (size_t __i) const
- { return _M_func (_M_expr1[__i], _M_expr2); }
- size_t size () const { return _M_expr1.size (); }
+ struct __unary_plus
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return +__t; }
+ };
- private:
- const _Dom& _M_expr1;
- const _Vt& _M_expr2;
- _Vt (*_M_func)(_Vt, _Vt);
- };
+ struct __negate
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return -__t; }
+ };
- template<class _Dom1, class _Dom2>
- struct _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> : _BinFunBase<_Dom1,_Dom2> {
- typedef _BinFunBase<_Dom1,_Dom2> _Base;
- typedef typename _Base::value_type value_type;
- typedef value_type _Tp;
+ struct __bitwise_not
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __t) const { return ~__t; }
+ };
- _BinFunClos (const _Dom1& __e1, const _Dom2& __e2,
- _Tp __f(_Tp, _Tp))
- : _Base (__e1, __e2, __f) {}
- };
+ struct __plus
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x + __y; }
+ };
+ struct __minus
+ {
template<typename _Tp>
- struct _BinFunClos<_ValArray,_ValArray,_Tp,_Tp>
- : _BinFunBase<valarray<_Tp>, valarray<_Tp> > {
- typedef _BinFunBase<valarray<_Tp>, valarray<_Tp> > _Base;
- typedef _Tp value_type;
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x - __y; }
+ };
- _BinFunClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w,
- _Tp __f(_Tp, _Tp))
- : _Base (__v, __w, __f) {}
- };
-
- template<class _Dom>
- struct _BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>
- : _BinFunBase<_Dom,valarray<typename _Dom::value_type> > {
- typedef typename _Dom::value_type _Tp;
- typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
- typedef _Tp value_type;
+ struct __multiplies
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x * __y; }
+ };
- _BinFunClos (const _Dom& __e, const valarray<_Tp>& __v,
- _Tp __f(_Tp, _Tp))
- : _Base (__e, __v, __f) {}
- };
+ struct __divides
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x / __y; }
+ };
- template<class _Dom>
- struct _BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>
- : _BinFunBase<valarray<typename _Dom::value_type>,_Dom> {
- typedef typename _Dom::value_type _Tp;
- typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
- typedef _Tp value_type;
+ struct __modulus
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x % __y; }
+ };
+
+ struct __bitwise_xor
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x ^ __y; }
+ };
+
+ struct __bitwise_and
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x & __y; }
+ };
+
+ struct __bitwise_or
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x | __y; }
+ };
+
+ struct __shift_left
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x << __y; }
+ };
+
+ struct __shift_right
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x >> __y; }
+ };
+
+ struct __logical_and
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x && __y; }
+ };
+
+ struct __logical_or
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x || __y; }
+ };
+
+ struct __logical_not
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x) const { return !__x; }
+ };
+
+ struct __equal_to
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x == __y; }
+ };
+
+ struct __not_equal_to
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x != __y; }
+ };
- _BinFunClos (const valarray<_Tp>& __v, const _Dom& __e,
- _Tp __f(_Tp, _Tp))
- : _Base (__v, __e, __f) {}
+ struct __less
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x < __y; }
+ };
+
+ struct __greater
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x > __y; }
+ };
+
+ struct __less_equal
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x <= __y; }
+ };
+
+ struct __greater_equal
+ {
+ template<typename _Tp>
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ { return __x >= __y; }
+ };
+
+ // The few binary functions we miss.
+ struct __atan2
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return atan2(__x, __y); }
+ };
+
+ struct __pow
+ {
+ template<typename _Tp>
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ { return pow(__x, __y); }
+ };
+
+
+ // We need these bits in order to recover the return type of
+ // some functions/operators now that we're no longer using
+ // function templates.
+ template<typename, typename _Tp>
+ struct __fun
+ {
+ typedef _Tp result_type;
};
- template<class _Dom>
- struct _BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>
- : _BinFunBase2<_Dom> {
- typedef typename _Dom::value_type _Tp;
- typedef _Tp value_type;
- typedef _BinFunBase2<_Dom> _Base;
+ // several specializations for relational operators.
+ template<typename _Tp>
+ struct __fun<__logical_not, _Tp>
+ {
+ typedef bool result_type;
+ };
- _BinFunClos (const _Dom& __e, const _Tp& __t, _Tp __f (_Tp, _Tp))
- : _Base (__e, __t, __f) {}
+ template<typename _Tp>
+ struct __fun<__logical_and, _Tp>
+ {
+ typedef bool result_type;
};
- template<class _Dom>
- struct _BinFunClos<_Constant,_Expr,_Dom,typename _Dom::value_type>
- : _BinFunBase1<_Dom> {
- typedef typename _Dom::value_type _Tp;
- typedef _Tp value_type;
- typedef _BinFunBase1<_Dom> _Base;
+ template<typename _Tp>
+ struct __fun<__logical_or, _Tp>
+ {
+ typedef bool result_type;
+ };
- _BinFunClos (const _Tp& __t, const _Dom& __e, _Tp __f (_Tp, _Tp))
- : _Base (__t, __e, __f) {}
+ template<typename _Tp>
+ struct __fun<__less, _Tp>
+ {
+ typedef bool result_type;
};
- template<typename _Tp>
- struct _BinFunClos<_ValArray,_Constant,_Tp,_Tp>
- : _BinFunBase2<valarray<_Tp> > {
- typedef _BinFunBase2<valarray<_Tp> > _Base;
- typedef _Tp value_type;
+ template<typename _Tp>
+ struct __fun<__greater, _Tp>
+ {
+ typedef bool result_type;
+ };
- _BinFunClos (const valarray<_Tp>& __v, const _Tp& __t,
- _Tp __f(_Tp, _Tp))
- : _Base (__v, __t, __f) {}
+ template<typename _Tp>
+ struct __fun<__less_equal, _Tp>
+ {
+ typedef bool result_type;
};
- template<typename _Tp>
- struct _BinFunClos<_Constant,_ValArray,_Tp,_Tp>
- : _BinFunBase1<valarray<_Tp> > {
- typedef _BinFunBase1<valarray<_Tp> > _Base;
- typedef _Tp value_type;
+ template<typename _Tp>
+ struct __fun<__greater_equal, _Tp>
+ {
+ typedef bool result_type;
+ };
+
+ template<typename _Tp>
+ struct __fun<__equal_to, _Tp>
+ {
+ typedef bool result_type;
+ };
- _BinFunClos (const _Tp& __t, const valarray<_Tp>& __v,
- _Tp __f (_Tp, _Tp))
- : _Base (__t, __v, __f) {}
+ template<typename _Tp>
+ struct __fun<__not_equal_to, _Tp>
+ {
+ typedef bool result_type;
};
//
// Apply function taking a value/const reference closure
//
- template<typename _Dom, typename _Arg> class _FunBase {
+ template<typename _Dom, typename _Arg>
+ class _FunBase
+ {
public:
- typedef typename _Dom::value_type value_type;
+ typedef typename _Dom::value_type value_type;
+
+ _FunBase(const _Dom& __e, value_type __f(_Arg))
+ : _M_expr(__e), _M_func(__f) {}
- _FunBase (const _Dom& __e, value_type __f(_Arg))
- : _M_expr (__e), _M_func (__f) {}
+ value_type operator[](size_t __i) const
+ { return _M_func (_M_expr[__i]); }
- value_type operator[] (size_t __i) const
- { return _M_func (_M_expr[__i]); }
- size_t size() const { return _M_expr.size ();}
+ size_t size() const { return _M_expr.size ();}
private:
const _Dom& _M_expr;
value_type (*_M_func)(_Arg);
};
- template<class _Dom>
- struct _ValFunClos<_Expr,_Dom>
- : _FunBase<_Dom, typename _Dom::value_type> {
- typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
- typedef typename _Base::value_type value_type;
- typedef value_type _Tp;
+ template<class _Dom>
+ struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type>
+ {
+ typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
+ typedef typename _Base::value_type value_type;
+ typedef value_type _Tp;
- _ValFunClos (const _Dom& __e, _Tp __f (_Tp)) : _Base (__e, __f) {}
+ _ValFunClos(const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {}
};
- template<typename _Tp>
- struct _ValFunClos<_ValArray,_Tp>
- : _FunBase<valarray<_Tp>, _Tp> {
- typedef _FunBase<valarray<_Tp>, _Tp> _Base;
- typedef _Tp value_type;
-
- _ValFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
- : _Base (__v, __f) {}
+ template<typename _Tp>
+ struct _ValFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, _Tp>
+ {
+ typedef _FunBase<valarray<_Tp>, _Tp> _Base;
+ typedef _Tp value_type;
+
+ _ValFunClos(const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {}
};
- template<class _Dom>
+ template<class _Dom>
struct _RefFunClos<_Expr,_Dom> :
- _FunBase<_Dom, const typename _Dom::value_type&> {
- typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
- typedef typename _Base::value_type value_type;
- typedef value_type _Tp;
-
- _RefFunClos (const _Dom& __e, _Tp __f (const _Tp&))
- : _Base (__e, __f) {}
+ _FunBase<_Dom, const typename _Dom::value_type&>
+ {
+ typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
+ typedef typename _Base::value_type value_type;
+ typedef value_type _Tp;
+
+ _RefFunClos(const _Dom& __e, _Tp __f(const _Tp&))
+ : _Base(__e, __f) {}
};
- template<typename _Tp>
- struct _RefFunClos<_ValArray,_Tp>
- : _FunBase<valarray<_Tp>, const _Tp&> {
- typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
- typedef _Tp value_type;
-
- _RefFunClos (const valarray<_Tp>& __v, _Tp __f(const _Tp&))
- : _Base (__v, __f) {}
+ template<typename _Tp>
+ struct _RefFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, const _Tp&>
+ {
+ typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
+ typedef _Tp value_type;
+
+ _RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&))
+ : _Base(__v, __f) {}
};
- //
- // Unary expression closure.
- //
+ //
+ // Unary expression closure.
+ //
- template<template<class> class _Oper, typename _Arg>
- class _UnBase {
+ template<class _Oper, class _Arg>
+ class _UnBase
+ {
public:
- typedef _Oper<typename _Arg::value_type> _Op;
- typedef typename _Op::result_type value_type;
+ typedef typename _Arg::value_type _Vt;
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
+
+ _UnBase(const _Arg& __e) : _M_expr(__e) {}
+
+ value_type operator[](size_t __i) const
+ { return _Oper()(_M_expr[__i]); }
- _UnBase (const _Arg& __e) : _M_expr(__e) {}
- value_type operator[] (size_t) const;
- size_t size () const { return _M_expr.size (); }
+ size_t size() const { return _M_expr.size(); }
private:
- const _Arg& _M_expr;
+ const _Arg& _M_expr;
};
- template<template<class> class _Oper, typename _Arg>
- inline typename _UnBase<_Oper, _Arg>::value_type
- _UnBase<_Oper, _Arg>::operator[] (size_t __i) const
- { return _Op() (_M_expr[__i]); }
-
- template<template<class> class _Oper, class _Dom>
- struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom> {
- typedef _Dom _Arg;
- typedef _UnBase<_Oper, _Dom> _Base;
- typedef typename _Base::value_type value_type;
-
- _UnClos (const _Arg& __e) : _Base(__e) {}
+ template<class _Oper, class _Dom>
+ struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom>
+ {
+ typedef _Dom _Arg;
+ typedef _UnBase<_Oper, _Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _UnClos(const _Arg& __e) : _Base(__e) {}
};
- template<template<class> class _Oper, typename _Tp>
- struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > {
- typedef valarray<_Tp> _Arg;
- typedef _UnBase<_Oper, valarray<_Tp> > _Base;
- typedef typename _Base::value_type value_type;
-
- _UnClos (const _Arg& __e) : _Base(__e) {}
+ template<class _Oper, typename _Tp>
+ struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> >
+ {
+ typedef valarray<_Tp> _Arg;
+ typedef _UnBase<_Oper, valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _UnClos(const _Arg& __e) : _Base(__e) {}
};
- //
- // Binary expression closure.
- //
+ //
+ // Binary expression closure.
+ //
- template<template<class> class _Oper,
- typename _FirstArg, typename _SecondArg>
- class _BinBase {
+ template<class _Oper, class _FirstArg, class _SecondArg>
+ class _BinBase
+ {
public:
- typedef _Oper<typename _FirstArg::value_type> _Op;
- typedef typename _Op::result_type value_type;
+ typedef typename _FirstArg::value_type _Vt;
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
- _BinBase (const _FirstArg& __e1, const _SecondArg& __e2)
- : _M_expr1 (__e1), _M_expr2 (__e2) {}
- value_type operator[] (size_t) const;
- size_t size () const { return _M_expr1.size (); }
+ _BinBase(const _FirstArg& __e1, const _SecondArg& __e2)
+ : _M_expr1(__e1), _M_expr2(__e2) {}
+
+ value_type operator[](size_t __i) const
+ { return _Oper()(_M_expr1[__i], _M_expr2[__i]); }
+
+ size_t size() const { return _M_expr1.size(); }
private:
- const _FirstArg& _M_expr1;
- const _SecondArg& _M_expr2;
+ const _FirstArg& _M_expr1;
+ const _SecondArg& _M_expr2;
};
- template<template<class> class _Oper,
- typename _FirstArg, typename _SecondArg>
- inline typename _BinBase<_Oper,_FirstArg,_SecondArg>::value_type
- _BinBase<_Oper,_FirstArg,_SecondArg>::operator[] (size_t __i) const
- { return _Op() (_M_expr1[__i], _M_expr2[__i]); }
-
- template<template<class> class _Oper, class _Clos>
- class _BinBase2 {
+ template<class _Oper, class _Clos>
+ class _BinBase2
+ {
public:
- typedef typename _Clos::value_type _Vt;
- typedef _Oper<_Vt> _Op;
- typedef typename _Op::result_type value_type;
+ typedef typename _Clos::value_type _Vt;
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
- _BinBase2 (const _Clos& __e, const _Vt& __t)
- : _M_expr1 (__e), _M_expr2 (__t) {}
- value_type operator[] (size_t) const;
- size_t size () const { return _M_expr1.size (); }
+ _BinBase2(const _Clos& __e, const _Vt& __t)
+ : _M_expr1(__e), _M_expr2(__t) {}
- private:
- const _Clos& _M_expr1;
- const _Vt& _M_expr2;
- };
+ value_type operator[](size_t __i) const
+ { return _Oper()(_M_expr1[__i], _M_expr2); }
- template<template<class> class _Oper, class _Clos>
- inline typename _BinBase2<_Oper,_Clos>::value_type
- _BinBase2<_Oper,_Clos>::operator[] (size_t __i) const
- { return _Op() (_M_expr1[__i], _M_expr2); }
+ size_t size() const { return _M_expr1.size(); }
+ private:
+ const _Clos& _M_expr1;
+ const _Vt& _M_expr2;
+ };
- template<template<class> class _Oper, class _Clos>
- class _BinBase1 {
+ template<class _Oper, class _Clos>
+ class _BinBase1
+ {
public:
- typedef typename _Clos::value_type _Vt;
- typedef _Oper<_Vt> _Op;
- typedef typename _Op::result_type value_type;
+ typedef typename _Clos::value_type _Vt;
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
+
+ _BinBase1(const _Vt& __t, const _Clos& __e)
+ : _M_expr1(__t), _M_expr2(__e) {}
- _BinBase1 (const _Vt& __t, const _Clos& __e)
- : _M_expr1 (__t), _M_expr2 (__e) {}
- value_type operator[] (size_t) const;
- size_t size () const { return _M_expr2.size (); }
+ value_type operator[](size_t __i) const
+ { return _Oper()(_M_expr1, _M_expr2[__i]); }
+
+ size_t size() const { return _M_expr2.size(); }
private:
- const _Vt& _M_expr1;
- const _Clos& _M_expr2;
+ const _Vt& _M_expr1;
+ const _Clos& _M_expr2;
};
-
- template<template<class> class _Oper, class _Clos>
- inline typename
- _BinBase1<_Oper,_Clos>::value_type
- _BinBase1<_Oper,_Clos>:: operator[] (size_t __i) const
- { return _Op() (_M_expr1, _M_expr2[__i]); }
-
- template<template<class> class _Oper, class _Dom1, class _Dom2>
- struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
- : _BinBase<_Oper,_Dom1,_Dom2> {
- typedef _BinBase<_Oper,_Dom1,_Dom2> _Base;
- typedef typename _Base::value_type value_type;
+ template<class _Oper, class _Dom1, class _Dom2>
+ struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
+ : _BinBase<_Oper,_Dom1,_Dom2>
+ {
+ typedef _BinBase<_Oper,_Dom1,_Dom2> _Base;
+ typedef typename _Base::value_type value_type;
- _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
+ _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
};
- template<template<class> class _Oper, typename _Tp>
+ template<class _Oper, typename _Tp>
struct _BinClos<_Oper,_ValArray,_ValArray,_Tp,_Tp>
- : _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > {
- typedef _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > _Base;
- typedef _Tp value_type;
+ : _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> >
+ {
+ typedef _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > _Base;
+ typedef _Tp value_type;
- _BinClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w)
- : _Base (__v, __w) {}
+ _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w)
+ : _Base(__v, __w) {}
};
- template<template<class> class _Oper, class _Dom>
- struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type>
- : _BinBase<_Oper,_Dom,valarray<typename _Dom::value_type> > {
- typedef typename _Dom::value_type _Tp;
- typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
- typedef typename _Base::value_type value_type;
-
- _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
- : _Base (__e1, __e2) {}
+ template<class _Oper, class _Dom>
+ struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type>
+ : _BinBase<_Oper,_Dom,valarray<typename _Dom::value_type> >
+ {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
+ : _Base(__e1, __e2) {}
};
- template<template<class> class _Oper, class _Dom>
+ template<class _Oper, class _Dom>
struct _BinClos<_Oper,_ValArray,_Expr,typename _Dom::value_type,_Dom>
- : _BinBase<_Oper,valarray<typename _Dom::value_type>,_Dom> {
- typedef typename _Dom::value_type _Tp;
- typedef _BinBase<_Oper,valarray<_Tp>,_Dom> _Base;
- typedef typename _Base::value_type value_type;
-
- _BinClos (const valarray<_Tp>& __e1, const _Dom& __e2)
- : _Base (__e1, __e2) {}
+ : _BinBase<_Oper,valarray<typename _Dom::value_type>,_Dom>
+ {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase<_Oper,valarray<_Tp>,_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2)
+ : _Base(__e1, __e2) {}
};
- template<template<class> class _Oper, class _Dom>
+ template<class _Oper, class _Dom>
struct _BinClos<_Oper,_Expr,_Constant,_Dom,typename _Dom::value_type>
- : _BinBase2<_Oper,_Dom> {
- typedef typename _Dom::value_type _Tp;
- typedef _BinBase2<_Oper,_Dom> _Base;
- typedef typename _Base::value_type value_type;
-
- _BinClos (const _Dom& __e1, const _Tp& __e2) : _Base (__e1, __e2) {}
+ : _BinBase2<_Oper,_Dom>
+ {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase2<_Oper,_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const _Dom& __e1, const _Tp& __e2) : _Base(__e1, __e2) {}
};
- template<template<class> class _Oper, class _Dom>
+ template<class _Oper, class _Dom>
struct _BinClos<_Oper,_Constant,_Expr,typename _Dom::value_type,_Dom>
- : _BinBase1<_Oper,_Dom> {
- typedef typename _Dom::value_type _Tp;
- typedef _BinBase1<_Oper,_Dom> _Base;
- typedef typename _Base::value_type value_type;
-
- _BinClos (const _Tp& __e1, const _Dom& __e2) : _Base (__e1, __e2) {}
+ : _BinBase1<_Oper,_Dom>
+ {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase1<_Oper,_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {}
};
- template<template<class> class _Oper, typename _Tp>
+ template<class _Oper, typename _Tp>
struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp>
- : _BinBase2<_Oper,valarray<_Tp> > {
- typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
- typedef typename _Base::value_type value_type;
-
- _BinClos (const valarray<_Tp>& __v, const _Tp& __t)
- : _Base (__v, __t) {}
+ : _BinBase2<_Oper,valarray<_Tp> >
+ {
+ typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const valarray<_Tp>& __v, const _Tp& __t) : _Base(__v, __t) {}
};
- template<template<class> class _Oper, typename _Tp>
+ template<class _Oper, typename _Tp>
struct _BinClos<_Oper,_Constant,_ValArray,_Tp,_Tp>
- : _BinBase1<_Oper,valarray<_Tp> > {
- typedef _BinBase1<_Oper,valarray<_Tp> > _Base;
- typedef typename _Base::value_type value_type;
-
- _BinClos (const _Tp& __t, const valarray<_Tp>& __v)
- : _Base (__t, __v) {}
+ : _BinBase1<_Oper,valarray<_Tp> >
+ {
+ typedef _BinBase1<_Oper,valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {}
};
@@ -643,317 +775,261 @@ namespace std
: _Base (__a, __i) {}
};
- //
- // class _Expr
- //
- template<class _Clos, typename _Tp> class _Expr {
+ //
+ // class _Expr
+ //
+ template<class _Clos, typename _Tp>
+ class _Expr
+ {
public:
- typedef _Tp value_type;
+ typedef _Tp value_type;
+
+ _Expr(const _Clos&);
+
+ const _Clos& operator()() const;
- _Expr (const _Clos&);
-
- const _Clos& operator() () const;
-
- value_type operator[] (size_t) const;
- valarray<value_type> operator[] (slice) const;
- valarray<value_type> operator[] (const gslice&) const;
- valarray<value_type> operator[] (const valarray<bool>&) const;
- valarray<value_type> operator[] (const valarray<size_t>&) const;
+ value_type operator[](size_t) const;
+ valarray<value_type> operator[](slice) const;
+ valarray<value_type> operator[](const gslice&) const;
+ valarray<value_type> operator[](const valarray<bool>&) const;
+ valarray<value_type> operator[](const valarray<size_t>&) const;
- _Expr<_UnClos<_Unary_plus,std::_Expr,_Clos>, value_type>
- operator+ () const;
+ _Expr<_UnClos<__unary_plus,std::_Expr,_Clos>, value_type>
+ operator+() const;
- _Expr<_UnClos<negate,std::_Expr,_Clos>, value_type>
- operator- () const;
+ _Expr<_UnClos<__negate,std::_Expr,_Clos>, value_type>
+ operator-() const;
- _Expr<_UnClos<_Bitwise_not,std::_Expr,_Clos>, value_type>
- operator~ () const;
+ _Expr<_UnClos<__bitwise_not,std::_Expr,_Clos>, value_type>
+ operator~() const;
- _Expr<_UnClos<logical_not,std::_Expr,_Clos>, bool>
- operator! () const;
+ _Expr<_UnClos<__logical_not,std::_Expr,_Clos>, bool>
+ operator!() const;
- size_t size () const;
- value_type sum () const;
+ size_t size() const;
+ value_type sum() const;
- valarray<value_type> shift (int) const;
- valarray<value_type> cshift (int) const;
+ valarray<value_type> shift(int) const;
+ valarray<value_type> cshift(int) const;
value_type min() const;
value_type max() const;
- valarray<value_type> apply(value_type (*) (const value_type&)) const;
- valarray<value_type> apply(value_type (*) (value_type)) const;
+ valarray<value_type> apply(value_type (*)(const value_type&)) const;
+ valarray<value_type> apply(value_type (*)(value_type)) const;
private:
- const _Clos _M_closure;
+ const _Clos _M_closure;
};
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline
- _Expr<_Clos,_Tp>::_Expr (const _Clos& __c) : _M_closure(__c) {}
+ _Expr<_Clos,_Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {}
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline const _Clos&
- _Expr<_Clos,_Tp>::operator() () const
+ _Expr<_Clos,_Tp>::operator()() const
{ return _M_closure; }
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline _Tp
- _Expr<_Clos,_Tp>::operator[] (size_t __i) const
+ _Expr<_Clos,_Tp>::operator[](size_t __i) const
{ return _M_closure[__i]; }
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline valarray<_Tp>
- _Expr<_Clos,_Tp>::operator[] (slice __s) const
+ _Expr<_Clos,_Tp>::operator[](slice __s) const
{ return _M_closure[__s]; }
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline valarray<_Tp>
- _Expr<_Clos,_Tp>::operator[] (const gslice& __gs) const
+ _Expr<_Clos,_Tp>::operator[](const gslice& __gs) const
{ return _M_closure[__gs]; }
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline valarray<_Tp>
- _Expr<_Clos,_Tp>::operator[] (const valarray<bool>& __m) const
+ _Expr<_Clos,_Tp>::operator[](const valarray<bool>& __m) const
{ return _M_closure[__m]; }
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline valarray<_Tp>
- _Expr<_Clos,_Tp>::operator[] (const valarray<size_t>& __i) const
+ _Expr<_Clos,_Tp>::operator[](const valarray<size_t>& __i) const
{ return _M_closure[__i]; }
- template<class _Clos, typename _Tp>
+ template<class _Clos, typename _Tp>
inline size_t
- _Expr<_Clos,_Tp>::size () const { return _M_closure.size (); }
+ _Expr<_Clos,_Tp>::size() const { return _M_closure.size (); }
template<class _Clos, typename _Tp>
- inline valarray<_Tp>
- _Expr<_Clos, _Tp>::shift(int __n) const
- { return valarray<_Tp>(_M_closure).shift(__n); }
+ inline valarray<_Tp>
+ _Expr<_Clos, _Tp>::shift(int __n) const
+ { return valarray<_Tp>(_M_closure).shift(__n); }
template<class _Clos, typename _Tp>
- inline valarray<_Tp>
- _Expr<_Clos, _Tp>::cshift(int __n) const
- { return valarray<_Tp>(_M_closure).cshift(__n); }
+ inline valarray<_Tp>
+ _Expr<_Clos, _Tp>::cshift(int __n) const
+ { return valarray<_Tp>(_M_closure).cshift(__n); }
template<class _Clos, typename _Tp>
- inline valarray<_Tp>
- _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
- { return valarray<_Tp>(_M_closure).apply(__f); }
+ inline valarray<_Tp>
+ _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
+ { return valarray<_Tp>(_M_closure).apply(__f); }
template<class _Clos, typename _Tp>
- inline valarray<_Tp>
- _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
- { return valarray<_Tp>(_M_closure).apply(__f); }
+ inline valarray<_Tp>
+ _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
+ { return valarray<_Tp>(_M_closure).apply(__f); }
- // XXX: replace this with a more robust summation algorithm.
- template<class _Clos, typename _Tp>
+ // XXX: replace this with a more robust summation algorithm.
+ template<class _Clos, typename _Tp>
inline _Tp
- _Expr<_Clos,_Tp>::sum () const
+ _Expr<_Clos,_Tp>::sum() const
{
- size_t __n = _M_closure.size();
- if (__n == 0) return _Tp();
- else {
- _Tp __s = _M_closure[--__n];
- while (__n != 0) __s += _M_closure[--__n];
- return __s;
+ size_t __n = _M_closure.size();
+ if (__n == 0)
+ return _Tp();
+ else
+ {
+ _Tp __s = _M_closure[--__n];
+ while (__n != 0)
+ __s += _M_closure[--__n];
+ return __s;
}
}
template<class _Clos, typename _Tp>
- inline _Tp
- _Expr<_Clos, _Tp>::min() const
- { return __valarray_min(_M_closure); }
+ inline _Tp
+ _Expr<_Clos, _Tp>::min() const
+ { return __valarray_min(_M_closure); }
template<class _Clos, typename _Tp>
- inline _Tp
- _Expr<_Clos, _Tp>::max() const
- { return __valarray_max(_M_closure); }
+ inline _Tp
+ _Expr<_Clos, _Tp>::max() const
+ { return __valarray_max(_M_closure); }
- template<class _Dom, typename _Tp>
- inline _Expr<_UnClos<logical_not,_Expr,_Dom>, bool>
- _Expr<_Dom,_Tp>::operator! () const
+ template<class _Dom, typename _Tp>
+ inline _Expr<_UnClos<__logical_not,_Expr,_Dom>, bool>
+ _Expr<_Dom,_Tp>::operator!() const
{
- typedef _UnClos<logical_not,std::_Expr,_Dom> _Closure;
- return _Expr<_Closure,_Tp> (_Closure(this->_M_closure));
+ typedef _UnClos<__logical_not,std::_Expr,_Dom> _Closure;
+ return _Expr<_Closure,_Tp>(_Closure(this->_M_closure));
}
-#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
-template<class _Dom, typename _Tp> \
-inline _Expr<_UnClos<_Name,std::_Expr,_Dom>,_Tp> \
-_Expr<_Dom,_Tp>::operator _Op () const \
-{ \
- typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \
- return _Expr<_Closure,_Tp> (_Closure (this->_M_closure)); \
-}
+#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
+ template<class _Dom, typename _Tp> \
+ inline _Expr<_UnClos<_Name,std::_Expr,_Dom>,_Tp> \
+ _Expr<_Dom,_Tp>::operator _Op() const \
+ { \
+ typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); \
+ }
- _DEFINE_EXPR_UNARY_OPERATOR(+, _Unary_plus)
- _DEFINE_EXPR_UNARY_OPERATOR(-, negate)
- _DEFINE_EXPR_UNARY_OPERATOR(~, _Bitwise_not)
+ _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus)
+ _DEFINE_EXPR_UNARY_OPERATOR(-, __negate)
+ _DEFINE_EXPR_UNARY_OPERATOR(~, __bitwise_not)
#undef _DEFINE_EXPR_UNARY_OPERATOR
#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \
-template<class _Dom1, class _Dom2> \
-inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \
- typename _Name<typename _Dom1::value_type>::result_type> \
-operator _Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
- const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
-{ \
+ template<class _Dom1, class _Dom2> \
+ inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \
+ typename __fun<_Name, typename _Dom1::value_type>::result_type>\
+ operator _Op(const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
+ const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
+ { \
typedef typename _Dom1::value_type _Arg; \
- typedef typename _Name<_Arg>::result_type _Value; \
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
- return _Expr<_Closure,_Value> (_Closure (__v (), __w ())); \
-} \
+ return _Expr<_Closure,_Value>(_Closure(__v(), __w())); \
+ } \
\
template<class _Dom> \
-inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
- typename _Name<typename _Dom::value_type>::result_type> \
-operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
- const typename _Dom::value_type& __t) \
+inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>,\
+ typename __fun<_Name, typename _Dom::value_type>::result_type>\
+operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __v, \
+ const typename _Dom::value_type& __t) \
{ \
- typedef typename _Dom::value_type _Arg; \
- typedef typename _Name<_Arg>::result_type _Value; \
- typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
- return _Expr<_Closure,_Value> (_Closure (__v (), __t)); \
+ typedef typename _Dom::value_type _Arg; \
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
+ typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
+ return _Expr<_Closure,_Value>(_Closure(__v(), __t)); \
} \
\
template<class _Dom> \
-inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
- typename _Name<typename _Dom::value_type>::result_type> \
-operator _Op (const typename _Dom::value_type& __t, \
- const _Expr<_Dom,typename _Dom::value_type>& __v) \
+inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>,\
+ typename __fun<_Name, typename _Dom::value_type>::result_type>\
+operator _Op(const typename _Dom::value_type& __t, \
+ const _Expr<_Dom,typename _Dom::value_type>& __v) \
{ \
- typedef typename _Dom::value_type _Arg; \
- typedef typename _Name<_Arg>::result_type _Value; \
- typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
- return _Expr<_Closure,_Value> (_Closure (__t, __v ())); \
+ typedef typename _Dom::value_type _Arg; \
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
+ typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
+ return _Expr<_Closure,_Value>(_Closure(__t, __v())); \
} \
\
template<class _Dom> \
-inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
- typename _Name<typename _Dom::value_type>::result_type> \
-operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
- const valarray<typename _Dom::value_type>& __v) \
+inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>,\
+ typename __fun<_Name, typename _Dom::value_type>::result_type>\
+operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \
+ const valarray<typename _Dom::value_type>& __v) \
{ \
- typedef typename _Dom::value_type _Arg; \
- typedef typename _Name<_Arg>::result_type _Value; \
- typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \
- return _Expr<_Closure,_Value> (_Closure (__e (), __v)); \
+ typedef typename _Dom::value_type _Arg; \
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
+ typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \
+ return _Expr<_Closure,_Value>(_Closure(__e(), __v)); \
} \
\
template<class _Dom> \
-inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
- typename _Name<typename _Dom::value_type>::result_type> \
-operator _Op (const valarray<typename _Dom::value_type>& __v, \
- const _Expr<_Dom,typename _Dom::value_type>& __e) \
+inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>,\
+ typename __fun<_Name, typename _Dom::value_type>::result_type>\
+operator _Op(const valarray<typename _Dom::value_type>& __v, \
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
{ \
- typedef typename _Dom::value_type _Tp; \
- typedef typename _Name<_Tp>::result_type _Value; \
- typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
- return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \
+ typedef typename _Dom::value_type _Tp; \
+ typedef typename __fun<_Name, _Tp>::result_type _Value; \
+ typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
+ return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \
}
- _DEFINE_EXPR_BINARY_OPERATOR(+, plus)
- _DEFINE_EXPR_BINARY_OPERATOR(-, minus)
- _DEFINE_EXPR_BINARY_OPERATOR(*, multiplies)
- _DEFINE_EXPR_BINARY_OPERATOR(/, divides)
- _DEFINE_EXPR_BINARY_OPERATOR(%, modulus)
- _DEFINE_EXPR_BINARY_OPERATOR(^, _Bitwise_xor)
- _DEFINE_EXPR_BINARY_OPERATOR(&, _Bitwise_and)
- _DEFINE_EXPR_BINARY_OPERATOR(|, _Bitwise_or)
- _DEFINE_EXPR_BINARY_OPERATOR(<<, _Shift_left)
- _DEFINE_EXPR_BINARY_OPERATOR(>>, _Shift_right)
+ _DEFINE_EXPR_BINARY_OPERATOR(+, __plus)
+ _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
+ _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
+ _DEFINE_EXPR_BINARY_OPERATOR(/, __divides)
+ _DEFINE_EXPR_BINARY_OPERATOR(%, __modulus)
+ _DEFINE_EXPR_BINARY_OPERATOR(^, __bitwise_xor)
+ _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
+ _DEFINE_EXPR_BINARY_OPERATOR(|, __bitwise_or)
+ _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)
+ _DEFINE_EXPR_BINARY_OPERATOR(>>, __shift_right)
+ _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
+ _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
+ _DEFINE_EXPR_BINARY_OPERATOR(==, __equal_to)
+ _DEFINE_EXPR_BINARY_OPERATOR(!=, __not_equal_to)
+ _DEFINE_EXPR_BINARY_OPERATOR(<, __less)
+ _DEFINE_EXPR_BINARY_OPERATOR(>, __greater)
+ _DEFINE_EXPR_BINARY_OPERATOR(<=, __less_equal)
+ _DEFINE_EXPR_BINARY_OPERATOR(>=, __greater_equal)
#undef _DEFINE_EXPR_BINARY_OPERATOR
-
-#define _DEFINE_EXPR_RELATIONAL_OPERATOR(_Op, _Name) \
-template<class _Dom1, class _Dom2> \
-inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, bool> \
-operator _Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
- const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
-{ \
- typedef typename _Dom1::value_type _Arg; \
- typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
- return _Expr<_Closure,bool> (_Closure (__v (), __w ())); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
- bool> \
-operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
- const typename _Dom::value_type& __t) \
-{ \
- typedef typename _Dom::value_type _Arg; \
- typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
- return _Expr<_Closure,bool> (_Closure (__v (), __t)); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
- bool> \
-operator _Op (const typename _Dom::value_type& __t, \
- const _Expr<_Dom,typename _Dom::value_type>& __v) \
-{ \
- typedef typename _Dom::value_type _Arg; \
- typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
- return _Expr<_Closure,bool> (_Closure (__t, __v ())); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
- bool> \
-operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
- const valarray<typename _Dom::value_type>& __v) \
-{ \
- typedef typename _Dom::value_type _Tp; \
- typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Tp> _Closure; \
- return _Expr<_Closure,bool> (_Closure (__e (), __v)); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
- bool> \
-operator _Op (const valarray<typename _Dom::value_type>& __v, \
- const _Expr<_Dom,typename _Dom::value_type>& __e) \
-{ \
- typedef typename _Dom::value_type _Tp; \
- typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
- return _Expr<_Closure,bool> (_Closure (__v, __e ())); \
-}
-
- _DEFINE_EXPR_RELATIONAL_OPERATOR(&&, logical_and)
- _DEFINE_EXPR_RELATIONAL_OPERATOR(||, logical_or)
- _DEFINE_EXPR_RELATIONAL_OPERATOR(==, equal_to)
- _DEFINE_EXPR_RELATIONAL_OPERATOR(!=, not_equal_to)
- _DEFINE_EXPR_RELATIONAL_OPERATOR(<, less)
- _DEFINE_EXPR_RELATIONAL_OPERATOR(>, greater)
- _DEFINE_EXPR_RELATIONAL_OPERATOR(<=, less_equal)
- _DEFINE_EXPR_RELATIONAL_OPERATOR(>=, greater_equal)
-
-#undef _DEFINE_EXPR_RELATIONAL_OPERATOR
-
-
-
-#define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
-template<class _Dom> \
-inline _Expr<_UnFunClos<_Expr,_Dom>,typename _Dom::value_type> \
-_Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \
-{ \
- typedef typename _Dom::value_type _Tp; \
- typedef _UnFunClos<_Expr,_Dom> _Closure; \
- return _Expr<_Closure,_Tp>(_Closure(__e(), (_Tp(*)(_Tp))(&_Name))); \
-} \
- \
-template<typename _Tp> \
-inline _Expr<_UnFunClos<_ValArray,_Tp>,_Tp> \
-_Name(const valarray<_Tp>& __v) \
-{ \
- typedef _UnFunClos<_ValArray,_Tp> _Closure; \
- return _Expr<_Closure,_Tp> (_Closure (__v, (_Tp(*)(_Tp))(&_Name))); \
-}
+#define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
+ template<class _Dom> \
+ inline _Expr<_UnClos<__##_Name,_Expr,_Dom>,typename _Dom::value_type>\
+ _Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \
+ { \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _UnClos<__##_Name,_Expr,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__e())); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_UnClos<__##_Name,_ValArray,_Tp>,_Tp> \
+ _Name(const valarray<_Tp>& __v) \
+ { \
+ typedef _UnClos<__##_Name,_ValArray,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__v)); \
+ }
_DEFINE_EXPR_UNARY_FUNCTION(abs)
_DEFINE_EXPR_UNARY_FUNCTION(cos)
@@ -972,93 +1048,89 @@ _Name(const valarray<_Tp>& __v) \
#undef _DEFINE_EXPR_UNARY_FUNCTION
-
-#define _DEFINE_EXPR_BINARY_FUNCTION(_Name) \
-template<class _Dom1, class _Dom2> \
-inline _Expr<_BinFunClos<_Expr,_Expr,_Dom1,_Dom2>,typename _Dom1::value_type>\
-_Name (const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \
- const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \
-{ \
- typedef typename _Dom1::value_type _Tp; \
- typedef _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__e1 (), __e2 (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
- typename _Dom::value_type> \
-_Name (const _Expr<_Dom,typename _Dom::value_type>& __e, \
- const valarray<typename _Dom::value_type>& __v) \
-{ \
- typedef typename _Dom::value_type _Tp; \
- typedef _BinFunClos<_Expr,_ValArray,_Dom,_Tp> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__e (), __v, (_Tp(*)(_Tp, _Tp))(&_Name))); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
- typename _Dom::value_type> \
-_Name (const valarray<typename _Dom::valarray>& __v, \
- const _Expr<_Dom,typename _Dom::value_type>& __e) \
-{ \
- typedef typename _Dom::value_type _Tp; \
- typedef _BinFunClos<_ValArray,_Expr,_Tp,_Dom> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__v, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>, \
- typename _Dom::value_type> \
-_Name (const _Expr<_Dom, typename _Dom::value_type>& __e, \
- const typename _Dom::value_type& __t) \
-{ \
- typedef typename _Dom::value_type _Tp; \
- typedef _BinFunClos<_Expr,_Constant,_Dom,_Tp> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__e (), __t, (_Tp(*)(_Tp, _Tp))(&_Name))); \
-} \
- \
-template<class _Dom> \
-inline _Expr<_BinFunClos<_Constant,_Expr,typename _Dom::value_type,_Dom>, \
- typename _Dom::value_type> \
-_Name (const typename _Dom::value_type& __t, \
- const _Expr<_Dom,typename _Dom::value_type>& __e) \
-{ \
- typedef typename _Dom::value_type _Tp; \
- typedef _BinFunClos<_Constant,_Expr,_Tp,_Dom> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__t, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
-} \
- \
-template<typename _Tp> \
-inline _Expr<_BinFunClos<_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
-_Name (const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
-{ \
- typedef _BinFunClos<_ValArray,_ValArray,_Tp,_Tp> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__v, __w, (_Tp(*)(_Tp,_Tp))(&_Name))); \
-} \
- \
-template<typename _Tp> \
-inline _Expr<_BinFunClos<_ValArray,_Constant,_Tp,_Tp>,_Tp> \
-_Name (const valarray<_Tp>& __v, const _Tp& __t) \
-{ \
- typedef _BinFunClos<_ValArray,_Constant,_Tp,_Tp> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__v, __t, (_Tp(*)(_Tp,_Tp))(&_Name))); \
-} \
- \
-template<typename _Tp> \
-inline _Expr<_BinFunClos<_Constant,_ValArray,_Tp,_Tp>,_Tp> \
-_Name (const _Tp& __t, const valarray<_Tp>& __v) \
-{ \
- typedef _BinFunClos<_Constant,_ValArray,_Tp,_Tp> _Closure; \
- return _Expr<_Closure,_Tp> \
- (_Closure (__t, __v, (_Tp(*)(_Tp,_Tp))(&_Name))); \
-}
+#define _DEFINE_EXPR_BINARY_FUNCTION(_Fun) \
+ template<class _Dom1, class _Dom2> \
+ inline _Expr<_BinClos<__##_Fun,_Expr,_Expr,_Dom1,_Dom2>, \
+ typename _Dom1::value_type> \
+ _Fun(const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \
+ const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \
+ { \
+ typedef typename _Dom1::value_type _Tp; \
+ typedef _BinClos<__##_Fun,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__e1(), __e2())); \
+ } \
+ \
+ template<class _Dom> \
+ inline _Expr<_BinClos<__##_Fun, _Expr, _ValArray, _Dom, \
+ typename _Dom::value_type>, \
+ typename _Dom::value_type> \
+ _Fun(const _Expr<_Dom,typename _Dom::value_type>& __e, \
+ const valarray<typename _Dom::value_type>& __v) \
+ { \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure;\
+ return _Expr<_Closure,_Tp>(_Closure(__e(), __v)); \
+ } \
+ \
+ template<class _Dom> \
+ inline _Expr<_BinClos<__##_Fun, _ValArray, _Expr, \
+ typename _Dom::value_type,_Dom>, \
+ typename _Dom::value_type> \
+ _Fun(const valarray<typename _Dom::valarray>& __v, \
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
+ { \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinClos<__##_Fun,_ValArray,_Expr,_Tp,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__v, __e())); \
+ } \
+ \
+ template<class _Dom> \
+ inline _Expr<_BinClos<__##_Fun,_Expr,_Constant,_Dom, \
+ typename _Dom::value_type>, \
+ typename _Dom::value_type> \
+ _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \
+ const typename _Dom::value_type& __t) \
+ { \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinClos<__##_Fun,_Expr,_Constant,_Dom,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__e(), __t)); \
+ } \
+ \
+ template<class _Dom> \
+ inline _Expr<_BinClos<__##_Fun,_Constant,_Expr, \
+ typename _Dom::value_type,_Dom>, \
+ typename _Dom::value_type> \
+ _Fun(const typename _Dom::value_type& __t, \
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
+ { \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinClos<__##_Fun, _Constant,_Expr,_Tp,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__t, __e())); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<__##_Fun,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
+ _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
+ { \
+ typedef _BinClos<__##_Fun,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__v, __w)); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<__##_Fun,_ValArray,_Constant,_Tp,_Tp>,_Tp> \
+ _Fun(const valarray<_Tp>& __v, const _Tp& __t) \
+ { \
+ typedef _BinClos<__##_Fun,_ValArray,_Constant,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__v, __t)); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<__##_Fun,_Constant,_ValArray,_Tp,_Tp>,_Tp> \
+ _Fun(const _Tp& __t, const valarray<_Tp>& __v) \
+ { \
+ typedef _BinClos<__##_Fun,_Constant,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__t, __v)); \
+ }
_DEFINE_EXPR_BINARY_FUNCTION(atan2)
_DEFINE_EXPR_BINARY_FUNCTION(pow)
diff --git a/contrib/libstdc++/include/bits/vector.tcc b/contrib/libstdc++/include/bits/vector.tcc
new file mode 100644
index 0000000..da5cf7e
--- /dev/null
+++ b/contrib/libstdc++/include/bits/vector.tcc
@@ -0,0 +1,437 @@
+// Vector implementation (out of line) -*- C++ -*-
+
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file vector.tcc
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+#ifndef __GLIBCPP_INTERNAL_VECTOR_TCC
+#define __GLIBCPP_INTERNAL_VECTOR_TCC
+
+namespace std
+{
+ template<typename _Tp, typename _Alloc>
+ void
+ vector<_Tp,_Alloc>::
+ reserve(size_type __n)
+ {
+ if (__n > this->max_size())
+ __throw_length_error("vector::reserve");
+ if (this->capacity() < __n)
+ {
+ const size_type __old_size = size();
+ pointer __tmp = _M_allocate_and_copy(__n, _M_start, _M_finish);
+ _Destroy(_M_start, _M_finish);
+ _M_deallocate(_M_start, _M_end_of_storage - _M_start);
+ _M_start = __tmp;
+ _M_finish = __tmp + __old_size;
+ _M_end_of_storage = _M_start + __n;
+ }
+ }
+
+ template<typename _Tp, typename _Alloc>
+ typename vector<_Tp,_Alloc>::iterator
+ vector<_Tp,_Alloc>::
+ insert(iterator __position, const value_type& __x)
+ {
+ size_type __n = __position - begin();
+ if (_M_finish != _M_end_of_storage && __position == end())
+ {
+ _Construct(_M_finish, __x);
+ ++_M_finish;
+ }
+ else
+ _M_insert_aux(__position, __x);
+ return begin() + __n;
+ }
+
+ template<typename _Tp, typename _Alloc>
+ typename vector<_Tp,_Alloc>::iterator
+ vector<_Tp,_Alloc>::
+ erase(iterator __position)
+ {
+ if (__position + 1 != end())
+ copy(__position + 1, end(), __position);
+ --_M_finish;
+ _Destroy(_M_finish);
+ return __position;
+ }
+
+ template<typename _Tp, typename _Alloc>
+ typename vector<_Tp,_Alloc>::iterator
+ vector<_Tp,_Alloc>::
+ erase(iterator __first, iterator __last)
+ {
+ iterator __i(copy(__last, end(), __first));
+ _Destroy(__i, end());
+ _M_finish = _M_finish - (__last - __first);
+ return __first;
+ }
+
+ template<typename _Tp, typename _Alloc>
+ vector<_Tp,_Alloc>&
+ vector<_Tp,_Alloc>::
+ operator=(const vector<_Tp,_Alloc>& __x)
+ {
+ if (&__x != this)
+ {
+ const size_type __xlen = __x.size();
+ if (__xlen > capacity())
+ {
+ pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());
+ _Destroy(_M_start, _M_finish);
+ _M_deallocate(_M_start, _M_end_of_storage - _M_start);
+ _M_start = __tmp;
+ _M_end_of_storage = _M_start + __xlen;
+ }
+ else if (size() >= __xlen)
+ {
+ iterator __i(copy(__x.begin(), __x.end(), begin()));
+ _Destroy(__i, end());
+ }
+ else
+ {
+ copy(__x.begin(), __x.begin() + size(), _M_start);
+ uninitialized_copy(__x.begin() + size(), __x.end(), _M_finish);
+ }
+ _M_finish = _M_start + __xlen;
+ }
+ return *this;
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ vector<_Tp,_Alloc>::
+ _M_fill_assign(size_t __n, const value_type& __val)
+ {
+ if (__n > capacity())
+ {
+ vector __tmp(__n, __val, get_allocator());
+ __tmp.swap(*this);
+ }
+ else if (__n > size())
+ {
+ fill(begin(), end(), __val);
+ _M_finish = uninitialized_fill_n(_M_finish, __n - size(), __val);
+ }
+ else
+ erase(fill_n(begin(), __n, __val), end());
+ }
+
+ template<typename _Tp, typename _Alloc> template<typename _InputIter>
+ void
+ vector<_Tp,_Alloc>::
+ _M_assign_aux(_InputIter __first, _InputIter __last, input_iterator_tag)
+ {
+ iterator __cur(begin());
+ for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
+ *__cur = *__first;
+ if (__first == __last)
+ erase(__cur, end());
+ else
+ insert(end(), __first, __last);
+ }
+
+ template<typename _Tp, typename _Alloc> template<typename _ForwardIter>
+ void
+ vector<_Tp,_Alloc>::
+ _M_assign_aux(_ForwardIter __first, _ForwardIter __last,
+ forward_iterator_tag)
+ {
+ size_type __len = distance(__first, __last);
+
+ if (__len > capacity())
+ {
+ pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
+ _Destroy(_M_start, _M_finish);
+ _M_deallocate(_M_start, _M_end_of_storage - _M_start);
+ _M_start = __tmp;
+ _M_end_of_storage = _M_finish = _M_start + __len;
+ }
+ else if (size() >= __len)
+ {
+ iterator __new_finish(copy(__first, __last, _M_start));
+ _Destroy(__new_finish, end());
+ _M_finish = __new_finish.base();
+ }
+ else
+ {
+ _ForwardIter __mid = __first;
+ advance(__mid, size());
+ copy(__first, __mid, _M_start);
+ _M_finish = uninitialized_copy(__mid, __last, _M_finish);
+ }
+ }
+
+ template<typename _Tp, typename _Alloc>
+ void
+ vector<_Tp,_Alloc>::
+ _M_insert_aux(iterator __position, const _Tp& __x)
+ {
+ if (_M_finish != _M_end_of_storage)
+ {
+ _Construct(_M_finish, *(_M_finish - 1));
+ ++_M_finish;
+ _Tp __x_copy = __x;
+ copy_backward(__position, iterator(_M_finish-2), iterator(_M_finish-1));
+ *__position = __x_copy;
+ }
+ else
+ {
+ const size_type __old_size = size();
+ const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
+ iterator __new_start(_M_allocate(__len));
+ iterator __new_finish(__new_start);
+ try
+ {
+ __new_finish = uninitialized_copy(iterator(_M_start), __position,
+ __new_start);
+ _Construct(__new_finish.base(), __x);
+ ++__new_finish;
+ __new_finish = uninitialized_copy(__position, iterator(_M_finish),
+ __new_finish);
+ }
+ catch(...)
+ {
+ _Destroy(__new_start,__new_finish);
+ _M_deallocate(__new_start.base(),__len);
+ __throw_exception_again;
+ }
+ _Destroy(begin(), end());
+ _M_deallocate(_M_start, _M_end_of_storage - _M_start);
+ _M_start = __new_start.base();
+ _M_finish = __new_finish.base();
+ _M_end_of_storage = __new_start.base() + __len;
+ }
+ }
+
+ #ifdef _GLIBCPP_DEPRECATED
+ template<typename _Tp, typename _Alloc>
+ void
+ vector<_Tp,_Alloc>::
+ _M_insert_aux(iterator __position)
+ {
+ if (_M_finish != _M_end_of_storage)
+ {
+ _Construct(_M_finish, *(_M_finish - 1));
+ ++_M_finish;
+ copy_backward(__position, iterator(_M_finish - 2),
+ iterator(_M_finish - 1));
+ *__position = value_type();
+ }
+ else
+ {
+ const size_type __old_size = size();
+ const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
+ pointer __new_start = _M_allocate(__len);
+ pointer __new_finish = __new_start;
+ try
+ {
+ __new_finish = uninitialized_copy(iterator(_M_start), __position,
+ __new_start);
+ _Construct(__new_finish);
+ ++__new_finish;
+ __new_finish = uninitialized_copy(__position, iterator(_M_finish),
+ __new_finish);
+ }
+ catch(...)
+ {
+ _Destroy(__new_start,__new_finish);
+ _M_deallocate(__new_start,__len);
+ __throw_exception_again;
+ }
+ _Destroy(begin(), end());
+ _M_deallocate(_M_start, _M_end_of_storage - _M_start);
+ _M_start = __new_start;
+ _M_finish = __new_finish;
+ _M_end_of_storage = __new_start + __len;
+ }
+ }
+ #endif
+
+ template<typename _Tp, typename _Alloc>
+ void
+ vector<_Tp,_Alloc>::
+ _M_fill_insert(iterator __position, size_type __n, const value_type& __x)
+ {
+ if (__n != 0)
+ {
+ if (size_type(_M_end_of_storage - _M_finish) >= __n)
+ {
+ value_type __x_copy = __x;
+ const size_type __elems_after = end() - __position;
+ iterator __old_finish(_M_finish);
+ if (__elems_after > __n)
+ {
+ uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
+ _M_finish += __n;
+ copy_backward(__position, __old_finish - __n, __old_finish);
+ fill(__position, __position + __n, __x_copy);
+ }
+ else
+ {
+ uninitialized_fill_n(_M_finish, __n - __elems_after, __x_copy);
+ _M_finish += __n - __elems_after;
+ uninitialized_copy(__position, __old_finish, _M_finish);
+ _M_finish += __elems_after;
+ fill(__position, __old_finish, __x_copy);
+ }
+ }
+ else
+ {
+ const size_type __old_size = size();
+ const size_type __len = __old_size + max(__old_size, __n);
+ iterator __new_start(_M_allocate(__len));
+ iterator __new_finish(__new_start);
+ try
+ {
+ __new_finish = uninitialized_copy(begin(), __position,
+ __new_start);
+ __new_finish = uninitialized_fill_n(__new_finish, __n, __x);
+ __new_finish = uninitialized_copy(__position, end(),
+ __new_finish);
+ }
+ catch(...)
+ {
+ _Destroy(__new_start,__new_finish);
+ _M_deallocate(__new_start.base(),__len);
+ __throw_exception_again;
+ }
+ _Destroy(_M_start, _M_finish);
+ _M_deallocate(_M_start, _M_end_of_storage - _M_start);
+ _M_start = __new_start.base();
+ _M_finish = __new_finish.base();
+ _M_end_of_storage = __new_start.base() + __len;
+ }
+ }
+ }
+
+ template<typename _Tp, typename _Alloc> template<typename _InputIterator>
+ void
+ vector<_Tp,_Alloc>::
+ _M_range_insert(iterator __pos,
+ _InputIterator __first, _InputIterator __last,
+ input_iterator_tag)
+ {
+ for ( ; __first != __last; ++__first)
+ {
+ __pos = insert(__pos, *__first);
+ ++__pos;
+ }
+ }
+
+ template<typename _Tp, typename _Alloc> template<typename _ForwardIterator>
+ void
+ vector<_Tp,_Alloc>::
+ _M_range_insert(iterator __position,_ForwardIterator __first,
+ _ForwardIterator __last, forward_iterator_tag)
+ {
+ if (__first != __last)
+ {
+ size_type __n = distance(__first, __last);
+ if (size_type(_M_end_of_storage - _M_finish) >= __n)
+ {
+ const size_type __elems_after = end() - __position;
+ iterator __old_finish(_M_finish);
+ if (__elems_after > __n)
+ {
+ uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
+ _M_finish += __n;
+ copy_backward(__position, __old_finish - __n, __old_finish);
+ copy(__first, __last, __position);
+ }
+ else
+ {
+ _ForwardIterator __mid = __first;
+ advance(__mid, __elems_after);
+ uninitialized_copy(__mid, __last, _M_finish);
+ _M_finish += __n - __elems_after;
+ uninitialized_copy(__position, __old_finish, _M_finish);
+ _M_finish += __elems_after;
+ copy(__first, __mid, __position);
+ }
+ }
+ else
+ {
+ const size_type __old_size = size();
+ const size_type __len = __old_size + max(__old_size, __n);
+ iterator __new_start(_M_allocate(__len));
+ iterator __new_finish(__new_start);
+ try
+ {
+ __new_finish = uninitialized_copy(iterator(_M_start),
+ __position, __new_start);
+ __new_finish = uninitialized_copy(__first, __last, __new_finish);
+ __new_finish = uninitialized_copy(__position, iterator(_M_finish),
+ __new_finish);
+ }
+ catch(...)
+ {
+ _Destroy(__new_start,__new_finish);
+ _M_deallocate(__new_start.base(), __len);
+ __throw_exception_again;
+ }
+ _Destroy(_M_start, _M_finish);
+ _M_deallocate(_M_start, _M_end_of_storage - _M_start);
+ _M_start = __new_start.base();
+ _M_finish = __new_finish.base();
+ _M_end_of_storage = __new_start.base() + __len;
+ }
+ }
+ }
+} // namespace std
+
+#endif /* __GLIBCPP_INTERNAL_VECTOR_TCC */
diff --git a/contrib/libstdc++/include/c_std/std_cmath.h b/contrib/libstdc++/include/c_std/std_cmath.h
index b2f65c8..1264c4d 100644
--- a/contrib/libstdc++/include/c_std/std_cmath.h
+++ b/contrib/libstdc++/include/c_std/std_cmath.h
@@ -1,6 +1,6 @@
// -*- C++ -*- C forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -76,6 +76,91 @@
#undef tan
#undef tanh
+// ...and in the darkness bind them...
+namespace __gnu_cxx
+{
+ namespace __c99_binding
+ {
+#if _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_CHECK || \
+ _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
+ extern "C" float (acosf)(float);
+ extern "C" float (asinf)(float);
+ extern "C" float (atanf)(float);
+ extern "C" float (atan2f)(float, float);
+ extern "C" float (ceilf)(float);
+ extern "C" float (coshf)(float);
+ extern "C" float (expf)(float);
+ extern "C" float (floorf)(float);
+ extern "C" float (fmodf)(float, float);
+ extern "C" float (frexpf)(float, int*);
+ extern "C" float (ldexpf)(float, int);
+ extern "C" float (logf)(float);
+ extern "C" float (log10f)(float);
+ extern "C" float (modff)(float, float*);
+ extern "C" float (powf)(float, float);
+ extern "C" float (sinhf)(float);
+ extern "C" float (tanf)(float);
+ extern "C" float (tanhf)(float);
+#endif
+#if !_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
+#if _GLIBCPP_HAVE_ACOSF
+ using ::acosf;
+#endif
+#if _GLIBCPP_HAVE_ASINF
+ using ::asinf;
+#endif
+#if _GLIBCPP_HAVE_ATANF
+ using ::atanf;
+#endif
+#if _GLIBCPP_HAVE_ATAN2F
+ using ::atan2f;
+#endif
+#if _GLIBCPP_HAVE_CEILF
+ using ::ceilf;
+#endif
+#if _GLIBCPP_HAVE_COSHF
+ using ::coshf;
+#endif
+#if _GLIBCPP_HAVE_EXPF
+ using ::expf;
+#endif
+#if _GLIBCPP_HAVE_FLOORF
+ using ::floorf;
+#endif
+#if _GLIBCPP_HAVE_FMODF
+ using ::fmodf;
+#endif
+#if _GLIBCPP_HAVE_FREXPF
+ using ::frexpf;
+#endif
+#if _GLIBCPP_HAVE_LDEXPF
+ using ::ldexpf;
+#endif
+#if _GLIBCPP_HAVE_LOGF
+ using ::logf;
+#endif
+#if _GLIBCPP_HAVE_LOG10F
+ using ::log10f;
+#endif
+#if _GLIBCPP_HAVE_MODFF
+ using ::modff;
+#endif
+#if _GLIBCPP_HAVE_POWF
+ using ::powf;
+#endif
+#if _GLIBCPP_HAVE_SINHF
+ using ::sinhf;
+#endif
+#if _GLIBCPP_HAVE_TANF
+ using ::tanf;
+#endif
+#if _GLIBCPP_HAVE_TANHF
+ using ::tanhf;
+#endif
+#endif /* _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC */
+ }
+}
+
namespace std
{
// Forward declaration of a helper function. This really should be
@@ -96,7 +181,7 @@ namespace std
#if _GLIBCPP_HAVE_ACOSF
inline float
- acos(float __x) { return ::acosf(__x); }
+ acos(float __x) { return __gnu_cxx::__c99_binding::acosf(__x); }
#else
inline float
acos(float __x) { return ::acos(static_cast<double>(__x)); }
@@ -116,7 +201,7 @@ namespace std
#if _GLIBCPP_HAVE_ASINF
inline float
- asin(float __x) { return ::asinf(__x); }
+ asin(float __x) { return __gnu_cxx::__c99_binding::asinf(__x); }
#else
inline float
asin(float __x) { return ::asin(static_cast<double>(__x)); }
@@ -134,7 +219,7 @@ namespace std
#if _GLIBCPP_HAVE_ATANF
inline float
- atan(float __x) { return ::atanf(__x); }
+ atan(float __x) { return __gnu_cxx::__c99_binding::atanf(__x); }
#else
inline float
atan(float __x) { return ::atan(static_cast<double>(__x)); }
@@ -152,7 +237,7 @@ namespace std
#if _GLIBCPP_HAVE_ATAN2F
inline float
- atan2(float __y, float __x) { return ::atan2f(__y, __x); }
+ atan2(float __y, float __x) { return __gnu_cxx::__c99_binding::atan2f(__y, __x); }
#else
inline float
atan2(float __y, float __x)
@@ -172,7 +257,7 @@ namespace std
#if _GLIBCPP_HAVE_CEILF
inline float
- ceil(float __x) { return ::ceilf(__x); }
+ ceil(float __x) { return __gnu_cxx::__c99_binding::ceilf(__x); }
#else
inline float
ceil(float __x) { return ::ceil(static_cast<double>(__x)); }
@@ -200,7 +285,7 @@ namespace std
#if _GLIBCPP_HAVE_COSHF
inline float
- cosh(float __x) { return ::coshf(__x); }
+ cosh(float __x) { return __gnu_cxx::__c99_binding::coshf(__x); }
#else
inline float
cosh(float __x) { return ::cosh(static_cast<double>(__x)); }
@@ -218,7 +303,7 @@ namespace std
#if _GLIBCPP_HAVE_EXPF
inline float
- exp(float __x) { return ::expf(__x); }
+ exp(float __x) { return __gnu_cxx::__c99_binding::expf(__x); }
#else
inline float
exp(float __x) { return ::exp(static_cast<double>(__x)); }
@@ -246,7 +331,7 @@ namespace std
#if _GLIBCPP_HAVE_FLOORF
inline float
- floor(float __x) { return ::floorf(__x); }
+ floor(float __x) { return __gnu_cxx::__c99_binding::floorf(__x); }
#else
inline float
floor(float __x) { return ::floor(static_cast<double>(__x)); }
@@ -264,7 +349,7 @@ namespace std
#if _GLIBCPP_HAVE_FMODF
inline float
- fmod(float __x, float __y) { return ::fmodf(__x, __y); }
+ fmod(float __x, float __y) { return __gnu_cxx::__c99_binding::fmodf(__x, __y); }
#else
inline float
fmod(float __x, float __y)
@@ -284,7 +369,7 @@ namespace std
#if _GLIBCPP_HAVE_FREXPF
inline float
- frexp(float __x, int* __exp) { return ::frexpf(__x, __exp); }
+ frexp(float __x, int* __exp) { return __gnu_cxx::__c99_binding::frexpf(__x, __exp); }
#else
inline float
frexp(float __x, int* __exp) { return ::frexp(__x, __exp); }
@@ -303,7 +388,7 @@ namespace std
#if _GLIBCPP_HAVE_LDEXPF
inline float
- ldexp(float __x, int __exp) { return ::ldexpf(__x, __exp); }
+ ldexp(float __x, int __exp) { return __gnu_cxx::__c99_binding::ldexpf(__x, __exp); }
#else
inline float
ldexp(float __x, int __exp)
@@ -323,7 +408,7 @@ namespace std
#if _GLIBCPP_HAVE_LOGF
inline float
- log(float __x) { return ::logf(__x); }
+ log(float __x) { return __gnu_cxx::__c99_binding::logf(__x); }
#else
inline float log(float __x)
{ return ::log(static_cast<double>(__x)); }
@@ -341,7 +426,7 @@ namespace std
#if _GLIBCPP_HAVE_LOG10F
inline float
- log10(float __x) { return ::log10f(__x); }
+ log10(float __x) { return __gnu_cxx::__c99_binding::log10f(__x); }
#else
inline float
log10(float __x) { return ::log10(static_cast<double>(__x)); }
@@ -359,7 +444,7 @@ namespace std
#if _GLIBCPP_HAVE_MODFF
inline float
- modf(float __x, float* __iptr) { return ::modff(__x, __iptr); }
+ modf(float __x, float* __iptr) { return __gnu_cxx::__c99_binding::modff(__x, __iptr); }
#else
inline float
modf(float __x, float* __iptr)
@@ -398,7 +483,7 @@ namespace std
#if _GLIBCPP_HAVE_POWF
inline float
- pow(float __x, float __y) { return ::powf(__x, __y); }
+ pow(float __x, float __y) { return __gnu_cxx::__c99_binding::powf(__x, __y); }
#else
inline float
pow(float __x, float __y)
@@ -440,7 +525,7 @@ namespace std
#if _GLIBCPP_HAVE_SINHF
inline float
- sinh(float __x) { return ::sinhf(__x); }
+ sinh(float __x) { return __gnu_cxx::__c99_binding::sinhf(__x); }
#else
inline float
sinh(float __x) { return ::sinh(static_cast<double>(__x)); }
@@ -468,7 +553,7 @@ namespace std
#if _GLIBCPP_HAVE_TANF
inline float
- tan(float __x) { return ::tanf(__x); }
+ tan(float __x) { return __gnu_cxx::__c99_binding::tanf(__x); }
#else
inline float
tan(float __x) { return ::tan(static_cast<double>(__x)); }
@@ -486,7 +571,7 @@ namespace std
#if _GLIBCPP_HAVE_TANHF
inline float
- tanh(float __x) { return ::tanhf(__x); }
+ tanh(float __x) { return __gnu_cxx::__c99_binding::tanhf(__x); }
#else
inline float
tanh(float __x) { return ::tanh(static_cast<double>(__x)); }
@@ -503,6 +588,7 @@ namespace std
#if _GLIBCPP_USE_C99
+#if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
// These are possible macros imported from C99-land. For strict
// conformance, remove possible C99-injected names from the global
// namespace, and sequester them in the __gnu_cxx extension namespace.
@@ -561,6 +647,7 @@ namespace __gnu_cxx
__capture_isunordered(_Tp __f1, _Tp __f2)
{ return isunordered(__f1, __f2); }
}
+#endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */
#endif
#undef fpclassify
@@ -577,6 +664,7 @@ namespace __gnu_cxx
#undef isunordered
#if _GLIBCPP_USE_C99
+#if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
namespace __gnu_cxx
{
template<typename _Tp>
@@ -647,6 +735,7 @@ namespace std
using __gnu_cxx::islessgreater;
using __gnu_cxx::isunordered;
}
+#endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */
#endif
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
diff --git a/contrib/libstdc++/include/c_std/std_cstdio.h b/contrib/libstdc++/include/c_std/std_cstdio.h
index 6fb8c79..3b4a685 100644
--- a/contrib/libstdc++/include/c_std/std_cstdio.h
+++ b/contrib/libstdc++/include/c_std/std_cstdio.h
@@ -1,6 +1,6 @@
// -*- C++ -*- forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -152,11 +152,24 @@ namespace std
namespace __gnu_cxx
{
+#if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" int
+ (snprintf)(char * restrict, size_t, const char * restrict, ...);
+ extern "C" int
+ (vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list);
+ extern "C" int (vscanf)(const char * restrict, __gnuc_va_list);
+ extern "C" int
+ (vsnprintf)(char * restrict, size_t, const char * restrict, __gnuc_va_list);
+ extern "C" int
+ (vsscanf)(const char * restrict, const char * restrict, __gnuc_va_list);
+#endif
+#if !_GLIBCPP_USE_C99_DYNAMIC
using ::snprintf;
using ::vfscanf;
using ::vscanf;
using ::vsnprintf;
using ::vsscanf;
+#endif
}
namespace std
diff --git a/contrib/libstdc++/include/c_std/std_cstdlib.h b/contrib/libstdc++/include/c_std/std_cstdlib.h
index 70fc8d3..e1436be 100644
--- a/contrib/libstdc++/include/c_std/std_cstdlib.h
+++ b/contrib/libstdc++/include/c_std/std_cstdlib.h
@@ -1,6 +1,6 @@
// -*- C++ -*- forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -135,8 +135,15 @@ namespace std
namespace __gnu_cxx
{
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::lldiv_t;
+#endif
+#if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" void (_Exit)(int);
+#endif
+#if !_GLIBCPP_USE_C99_DYNAMIC
using ::_Exit;
+#endif
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
@@ -144,6 +151,7 @@ namespace __gnu_cxx
inline long long
llabs(long long __x) { return __x >= 0 ? __x : -__x; }
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
inline lldiv_t
div(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
@@ -151,22 +159,36 @@ namespace __gnu_cxx
inline lldiv_t
lldiv(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
+#endif
+#if _GLIBCPP_USE_C99_LONG_LONG_CHECK || _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
+ extern "C" long long int (atoll)(const char *);
+ extern "C" long long int
+ (strtoll)(const char * restrict, char ** restrict, int);
+ extern "C" unsigned long long int
+ (strtoull)(const char * restrict, char ** restrict, int);
+#endif
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::atoll;
- using ::strtof;
using ::strtoll;
using ::strtoull;
+#endif
+ using ::strtof;
using ::strtold;
}
namespace std
{
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using __gnu_cxx::lldiv_t;
+#endif
using __gnu_cxx::_Exit;
using __gnu_cxx::abs;
using __gnu_cxx::llabs;
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using __gnu_cxx::div;
using __gnu_cxx::lldiv;
+#endif
using __gnu_cxx::atoll;
using __gnu_cxx::strtof;
using __gnu_cxx::strtoll;
diff --git a/contrib/libstdc++/include/c_std/std_cwchar.h b/contrib/libstdc++/include/c_std/std_cwchar.h
index f67f006..8b33c52 100644
--- a/contrib/libstdc++/include/c_std/std_cwchar.h
+++ b/contrib/libstdc++/include/c_std/std_cwchar.h
@@ -1,6 +1,6 @@
// -*- C++ -*- forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -225,9 +225,23 @@ namespace std
namespace __gnu_cxx
{
+#if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" long double
+ (wcstold)(const wchar_t * restrict, wchar_t ** restrict);
+#endif
+#if !_GLIBCPP_USE_C99_DYNAMIC
using ::wcstold;
+#endif
+#if _GLIBCPP_USE_C99_LONG_LONG_CHECK || _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
+ extern "C" long long int
+ (wcstoll)(const wchar_t * restrict, wchar_t ** restrict, int);
+ extern "C" unsigned long long int
+ (wcstoull)(const wchar_t * restrict, wchar_t ** restrict, int);
+#endif
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::wcstoll;
using ::wcstoull;
+#endif
}
namespace std
diff --git a/contrib/libstdc++/include/ext/stdio_filebuf.h b/contrib/libstdc++/include/ext/stdio_filebuf.h
index 59ab41a..4c6bf90 100644
--- a/contrib/libstdc++/include/ext/stdio_filebuf.h
+++ b/contrib/libstdc++/include/ext/stdio_filebuf.h
@@ -58,6 +58,7 @@ namespace __gnu_cxx
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
+ typedef std::size_t size_t;
protected:
// Stack-based buffer for unbuffered input.
@@ -75,7 +76,7 @@ namespace __gnu_cxx
* file will be closed when the stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(int __fd, std::ios_base::openmode __mode, bool __del,
- int_type __size);
+ size_t __size);
/**
* @param f An open @c FILE*.
@@ -88,7 +89,7 @@ namespace __gnu_cxx
* stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
- int_type __size = static_cast<int_type>(BUFSIZ));
+ size_t __size = static_cast<size_t>(BUFSIZ));
/**
* Possibly closes the external data stream, in the case of the file
@@ -117,7 +118,7 @@ namespace __gnu_cxx
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(int __fd, std::ios_base::openmode __mode, bool __del,
- int_type __size)
+ size_t __size)
{
_M_file.sys_open(__fd, __mode, __del);
if (this->is_open())
@@ -125,7 +126,7 @@ namespace __gnu_cxx
_M_mode = __mode;
if (__size > 0 && __size < 4)
{
- // Specify unbuffered.
+ // Specify not to use an allocated buffer.
_M_buf = _M_unbuf;
_M_buf_size = __size;
_M_buf_size_opt = 0;
@@ -142,7 +143,7 @@ namespace __gnu_cxx
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
- int_type __size)
+ size_t __size)
{
_M_file.sys_open(__f, __mode);
if (this->is_open())
@@ -150,7 +151,7 @@ namespace __gnu_cxx
_M_mode = __mode;
if (__size > 0 && __size < 4)
{
- // Specify unbuffered.
+ // Specify not to use an allocated buffer.
_M_buf = _M_unbuf;
_M_buf_size = __size;
_M_buf_size_opt = 0;
diff --git a/contrib/libstdc++/include/ext/stl_hashtable.h b/contrib/libstdc++/include/ext/stl_hashtable.h
index 2bc8a2f..b41c821 100644
--- a/contrib/libstdc++/include/ext/stl_hashtable.h
+++ b/contrib/libstdc++/include/ext/stl_hashtable.h
@@ -65,13 +65,10 @@
// Hashtable class, used to implement the hashed associative containers
// hash_set, hash_map, hash_multiset, and hash_multimap.
-#include <bits/stl_algobase.h>
-#include <bits/stl_alloc.h>
-#include <bits/stl_construct.h>
+#include <vector>
+#include <iterator>
#include <bits/stl_algo.h>
-#include <bits/stl_uninitialized.h>
#include <bits/stl_function.h>
-#include <bits/stl_vector.h>
#include <ext/stl_hash_fun.h>
namespace __gnu_cxx
diff --git a/contrib/libstdc++/include/std/std_bitset.h b/contrib/libstdc++/include/std/std_bitset.h
index fe60b01..ebe1650 100644
--- a/contrib/libstdc++/include/std/std_bitset.h
+++ b/contrib/libstdc++/include/std/std_bitset.h
@@ -219,7 +219,7 @@ namespace std
void
_Base_bitset<_Nw>::_M_do_left_shift(size_t __shift)
{
- if (__shift != 0)
+ if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD;
const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD;
@@ -244,7 +244,7 @@ namespace std
void
_Base_bitset<_Nw>::_M_do_right_shift(size_t __shift)
{
- if (__shift != 0)
+ if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD;
const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD;
@@ -570,6 +570,7 @@ namespace std
struct _Sanitize<0>
{ static void _S_do_sanitize(unsigned long) { } };
+
/**
* @brief The %bitset class represents a @e fixed-size sequence of bits.
*
@@ -578,17 +579,19 @@ namespace std
* (Note that %bitset does @e not meet the formal requirements of a
* <a href="tables.html#65">container</a>. Mainly, it lacks iterators.)
*
- * The template argument, @a _Nb, may be any nonzero number of type
- * size_t.
+ * The template argument, @a Nb, may be any non-negative number,
+ * specifying the number of bits (e.g., "0", "12", "1024*1024").
*
- * A %bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused
- * bits. (They are the high-order bits in the highest word.) It is
- * a class invariant that those unused bits are always zero.
+ * In the general unoptimized case, storage is allocated in word-sized
+ * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B
+ * words will be used for storage. B - Nb%B bits are unused. (They are
+ * the high-order bits in the highest word.) It is a class invariant
+ * that those unused bits are always zero.
*
* If you think of %bitset as "a simple array of bits," be aware that
* your mental picture is reversed: a %bitset behaves the same way as
* bits in integers do, with the bit at index 0 in the "least significant
- * / right-hand" position, and the bit at index N-1 in the "most
+ * / right-hand" position, and the bit at index Nb-1 in the "most
* significant / left-hand" position. Thus, unlike other containers, a
* %bitset's index "counts from right to left," to put it very loosely.
*
@@ -619,6 +622,7 @@ namespace std
* @endcode
*
* Also see http://gcc.gnu.org/onlinedocs/libstdc++/ext/sgiexts.html#ch23
+ * for a description of extensions.
*
* @if maint
* Most of the actual code isn't contained in %bitset<> itself, but in the
@@ -805,16 +809,26 @@ namespace std
bitset<_Nb>&
operator<<=(size_t __pos)
{
- this->_M_do_left_shift(__pos);
- this->_M_do_sanitize();
+ if (__builtin_expect(__pos < _Nb, 1))
+ {
+ this->_M_do_left_shift(__pos);
+ this->_M_do_sanitize();
+ }
+ else
+ this->_M_do_reset();
return *this;
}
bitset<_Nb>&
operator>>=(size_t __pos)
{
- this->_M_do_right_shift(__pos);
- this->_M_do_sanitize();
+ if (__builtin_expect(__pos < _Nb, 1))
+ {
+ this->_M_do_right_shift(__pos);
+ this->_M_do_sanitize();
+ }
+ else
+ this->_M_do_reset();
return *this;
}
//@}
@@ -1183,6 +1197,7 @@ namespace std
typename basic_istream<_CharT, _Traits>::sentry __sentry(__is);
if (__sentry)
{
+ ios_base::iostate __state = ios_base::goodbit;
basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
for (size_t __i = 0; __i < _Nb; ++__i)
{
@@ -1191,7 +1206,7 @@ namespace std
typename _Traits::int_type __c1 = __buf->sbumpc();
if (_Traits::eq_int_type(__c1, __eof))
{
- __is.setstate(ios_base::eofbit);
+ __state |= ios_base::eofbit;
break;
}
else
@@ -1201,19 +1216,21 @@ namespace std
if (__c == '0' || __c == '1')
__tmp.push_back(__c);
- else if (_Traits::eq_int_type(__buf->sputbackc(__c2),
- __eof))
+ else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof))
{
- __is.setstate(ios_base::failbit);
+ __state |= ios_base::failbit;
break;
}
}
}
if (__tmp.empty() && !_Nb)
- __is.setstate(ios_base::failbit);
+ __state |= ios_base::failbit;
else
__x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb);
+
+ if (__state != ios_base::goodbit)
+ __is.setstate(__state); // may throw an exception
}
return __is;
diff --git a/contrib/libstdc++/include/std/std_complex.h b/contrib/libstdc++/include/std/std_complex.h
index bcfcedd..252070b 100644
--- a/contrib/libstdc++/include/std/std_complex.h
+++ b/contrib/libstdc++/include/std/std_complex.h
@@ -390,7 +390,7 @@ namespace std
__s.flags(__os.flags());
__s.imbue(__os.getloc());
__s.precision(__os.precision());
- __s << '(' << __x.real() << "," << __x.imag() << ')';
+ __s << '(' << __x.real() << ',' << __x.imag() << ')';
return __os << __s.str();
}
@@ -456,7 +456,7 @@ namespace std
inline _Tp
norm(const complex<_Tp>& __z)
{
- return _Norm_helper<__is_floating<_Tp>::_M_type>::_S_do_it(__z);
+ return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCPP_FAST_MATH>::_S_do_it(__z);
}
template<typename _Tp>
@@ -565,24 +565,30 @@ namespace std
}
template<typename _Tp>
- inline complex<_Tp>
+ complex<_Tp>
pow(const complex<_Tp>& __x, const _Tp& __y)
{
- return exp(__y * log(__x));
+ if (__x.imag() == _Tp())
+ return pow(__x.real(), __y);
+
+ complex<_Tp> __t = log(__x);
+ return polar(exp(__y * __t.real()), __y * __t.imag());
}
template<typename _Tp>
inline complex<_Tp>
pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
- return exp(__y * log(__x));
+ return __x == _Tp() ? _Tp() : exp(__y * log(__x));
}
template<typename _Tp>
inline complex<_Tp>
pow(const _Tp& __x, const complex<_Tp>& __y)
{
- return exp(__y * log(__x));
+ return __x == _Tp()
+ ? _Tp()
+ : polar(pow(__x, __y.real()), __y.imag() * log(__x));
}
// 26.2.3 complex specializations
diff --git a/contrib/libstdc++/include/std/std_deque.h b/contrib/libstdc++/include/std/std_deque.h
index 0fca0d1..921c25f 100644
--- a/contrib/libstdc++/include/std/std_deque.h
+++ b/contrib/libstdc++/include/std/std_deque.h
@@ -70,8 +70,9 @@
#include <bits/stl_uninitialized.h>
#include <bits/stl_deque.h>
+#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
+# include <bits/deque.tcc>
+#endif
+
#endif /* _CPP_DEQUE */
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/std/std_fstream.h b/contrib/libstdc++/include/std/std_fstream.h
index 838b99d..bcbbb97 100644
--- a/contrib/libstdc++/include/std/std_fstream.h
+++ b/contrib/libstdc++/include/std/std_fstream.h
@@ -50,6 +50,15 @@
namespace std
{
+ // [27.8.1.1] template class basic_filebuf
+ /**
+ * @brief The actual work of input and output (for files).
+ *
+ * This class associates both its input and output sequence with an
+ * external disk file, and maintains a joint file position for both
+ * sequences. Many of its sematics are described in terms of similar
+ * behavior in the Standard C Library's @c FILE streams.
+ */
template<typename _CharT, typename _Traits>
class basic_filebuf : public basic_streambuf<_CharT, _Traits>
{
@@ -61,30 +70,55 @@ namespace std
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
- // Non-standard Types:
+ //@{
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
typedef basic_streambuf<char_type, traits_type> __streambuf_type;
typedef basic_filebuf<char_type, traits_type> __filebuf_type;
typedef __basic_file<char> __file_type;
typedef typename traits_type::state_type __state_type;
typedef codecvt<char_type, char, __state_type> __codecvt_type;
- typedef typename __codecvt_type::result __res_type;
typedef ctype<char_type> __ctype_type;
+ //@}
friend class ios_base; // For sync_with_stdio.
protected:
// Data Members:
// MT lock inherited from libio or other low-level io library.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__c_lock _M_lock;
// External buffer.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__file_type _M_file;
// Current and beginning state type for codecvt.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__state_type _M_state_cur;
__state_type _M_state_beg;
// Set iff _M_buf is allocated memory from _M_allocate_internal_buffer.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
bool _M_buf_allocated;
// XXX Needed?
@@ -92,12 +126,26 @@ namespace std
// The position in the buffer corresponding to the external file
// pointer.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
char_type* _M_filepos;
public:
// Constructors/destructor:
+ /**
+ * @brief Does not open any files.
+ *
+ * The default constructor initializes the parent class using its
+ * own default ctor.
+ */
basic_filebuf();
+ /**
+ * @brief The destructor closes the file first.
+ */
virtual
~basic_filebuf()
{
@@ -106,23 +154,61 @@ namespace std
}
// Members:
+ /**
+ * @brief Returns true if the external file is open.
+ */
bool
- is_open() const { return _M_file.is_open(); }
+ is_open() const throw() { return _M_file.is_open(); }
+ /**
+ * @brief Opens an external file.
+ * @param s The name of the file.
+ * @param mode The open mode flags.
+ * @return @c this on success, NULL on failure
+ *
+ * If a file is already open, this function immediately fails.
+ * Otherwise it tries to open the file named @a s using the flags
+ * given in @a mode.
+ *
+ * [Table 92 gives the relation between openmode combinations and the
+ * equivalent fopen() flags, but the table has not been copied yet.]
+ */
__filebuf_type*
open(const char* __s, ios_base::openmode __mode);
+ /**
+ * @brief Closes the currently associated file.
+ * @return @c this on success, NULL on failure
+ *
+ * If no file is currently open, this function immediately fails.
+ *
+ * If a "put buffer area" exists, @c overflow(eof) is called to flush
+ * all the characters. The file is then closed.
+ *
+ * If any operations fail, this function also fails.
+ */
__filebuf_type*
- close();
+ close() throw();
protected:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
void
_M_allocate_internal_buffer();
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
void
- _M_destroy_internal_buffer();
+ _M_destroy_internal_buffer() throw();
- // Overridden virtual functions:
+ // [27.8.1.4] overridden virtual functions
+ // [documentation is inherited]
virtual streamsize
showmanyc();
@@ -137,15 +223,23 @@ namespace std
// the underflow() case in order to maintain synchronization. So
// instead of calling underflow() from uflow(), we create a common
// subroutine to do the real work.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
int_type
_M_underflow_common(bool __bump);
+ // [documentation is inherited]
virtual int_type
underflow();
+ // [documentation is inherited]
virtual int_type
uflow();
+ // [documentation is inherited]
virtual int_type
pbackfail(int_type __c = _Traits::eof());
@@ -157,6 +251,8 @@ namespace std
// this in actuality be a helper function that checks for the
// eccentricities of this implementation, and then call
// overflow() if indeed the buffer is full.
+
+ // [documentation is inherited]
virtual int_type
overflow(int_type __c = _Traits::eof());
@@ -167,28 +263,54 @@ namespace std
// character c.
// 27.5.2.4.5
// Consume some sequence of the characters in the pending sequence.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
int_type
_M_really_overflow(int_type __c = _Traits::eof());
// Convert internal byte sequence to external, char-based
// sequence via codecvt.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
void
_M_convert_to_external(char_type*, streamsize, streamsize&, streamsize&);
+ /**
+ * @brief Manipulates the buffer.
+ * @param s Pointer to a buffer area.
+ * @param n Size of @a s.
+ * @return @c this
+ *
+ * If no file has been opened, and both @a s and @a n are zero, then
+ * the stream becomes unbuffered. Otherwise, @c s is used as a
+ * buffer; see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2
+ * for more.
+ */
virtual __streambuf_type*
setbuf(char_type* __s, streamsize __n);
+ // [documentation is inherited]
virtual pos_type
seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __mode = ios_base::in | ios_base::out);
+ // [documentation is inherited]
virtual pos_type
seekpos(pos_type __pos,
ios_base::openmode __mode = ios_base::in | ios_base::out);
+ // [documentation is inherited]
virtual int
sync()
{
+ int __ret = 0;
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
// Make sure that the internal buffer resyncs its idea of
@@ -197,19 +319,26 @@ namespace std
{
// Need to restore current position after the write.
off_type __off = _M_out_cur - _M_out_end;
- _M_really_overflow(); // _M_file.sync() will be called within
- if (__off)
+
+ // _M_file.sync() will be called within
+ if (traits_type::eq_int_type(_M_really_overflow(),
+ traits_type::eof()))
+ __ret = -1;
+ else if (__off)
_M_file.seekoff(__off, ios_base::cur);
}
else
_M_file.sync();
+
_M_last_overflowed = false;
- return 0;
+ return __ret;
}
+ // [documentation is inherited]
virtual void
imbue(const locale& __loc);
+ // [documentation is inherited]
virtual streamsize
xsgetn(char_type* __s, streamsize __n)
{
@@ -231,6 +360,7 @@ namespace std
return __ret;
}
+ // [documentation is inherited]
virtual streamsize
xsputn(const char_type* __s, streamsize __n)
{
@@ -238,6 +368,11 @@ namespace std
return __streambuf_type::xsputn(__s, __n);
}
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
void
_M_output_unshift();
@@ -248,6 +383,11 @@ namespace std
// internal buffer does not truly reflect the contents of the
// external buffer. At this point, for whatever reason, it is in
// an indeterminate state.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
void
_M_set_indeterminate(void)
{
@@ -258,6 +398,11 @@ namespace std
_M_filepos = _M_buf;
}
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
void
_M_set_determinate(off_type __off)
{
@@ -270,6 +415,11 @@ namespace std
_M_filepos = _M_buf + __off;
}
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
bool
_M_is_indeterminate(void)
{
@@ -286,7 +436,7 @@ namespace std
}
};
- // Explicit specializations.
+ // Explicit specialization declarations, defined in src/fstream.cc.
template<>
basic_filebuf<char>::int_type
basic_filebuf<char>::_M_underflow_common(bool __bump);
@@ -299,19 +449,24 @@ namespace std
// Generic definitions.
template <typename _CharT, typename _Traits>
- basic_filebuf<_CharT, _Traits>::int_type
+ typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::underflow()
{ return _M_underflow_common(false); }
template <typename _CharT, typename _Traits>
- basic_filebuf<_CharT, _Traits>::int_type
+ typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::uflow()
{ return _M_underflow_common(true); }
- // 27.8.1.5 Template class basic_ifstream
+ // [27.8.1.5] Template class basic_ifstream
/**
- * Derivation of general input streams, specific to files.
+ * @brief Controlling input for files.
+ *
+ * This class supports reading from named files, using the inherited
+ * functions from std::basic_istream. To control the associated
+ * sequence, an instance of std::basic_filebuf is used, which this page
+ * refers to as @c sb.
*/
template<typename _CharT, typename _Traits>
class basic_ifstream : public basic_istream<_CharT, _Traits>
@@ -329,20 +484,33 @@ namespace std
typedef basic_istream<char_type, traits_type> __istream_type;
private:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__filebuf_type _M_filebuf;
public:
- // Constructors/Destructors:
- /** Default constructor. Create an input file stream. */
+ // Constructors/Destructors:
+ /**
+ * @brief Default constructor.
+ *
+ * Initializes @c sb using its default constructor, and passes
+ * @c &sb to the base class initializer. Does not open any files
+ * (you haven't given it a filename to open).
+ */
basic_ifstream()
: __istream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }
/**
- * @brief Create an input file stream.
- * @param s Null terminated string specifying filename.
+ * @brief Create an input file stream.
+ * @param s Null terminated string specifying the filename.
* @param mode Open file in specified mode (see std::ios_base).
*
+ * @c ios_base::in is automatically included in @a mode.
+ *
* Tip: When using std::string to hold the filename, you must use
* .c_str() before passing it to this constructor.
*/
@@ -354,21 +522,44 @@ namespace std
this->open(__s, __mode);
}
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The file is closed by the filebuf object, not the formatting
+ * stream.
+ */
~basic_ifstream()
{ }
// Members:
/**
- * @brief Get a pointer to the file stream's buffer.
- * @return Pointer to basic_filebuf.
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_filebuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
*/
__filebuf_type*
rdbuf() const
{ return const_cast<__filebuf_type*>(&_M_filebuf); }
+ /**
+ * @brief Wrapper to test for an open file.
+ * @return @c rdbuf()->is_open()
+ */
bool
is_open() { return _M_filebuf.is_open(); }
+ /**
+ * @brief Opens an external file.
+ * @param s The name of the file.
+ * @param mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(s,mode|in). If that function
+ * fails, @c failbit is set in the stream's error state.
+ *
+ * Tip: When using std::string to hold the filename, you must use
+ * .c_str() before passing it to this constructor.
+ */
void
open(const char* __s, ios_base::openmode __mode = ios_base::in)
{
@@ -376,7 +567,12 @@ namespace std
this->setstate(ios_base::failbit);
}
- /** Close the file. */
+ /**
+ * @brief Close the file.
+ *
+ * Calls @c std::basic_filebuf::close(). If that function
+ * fails, @c failbit is set in the stream's error state.
+ */
void
close()
{
@@ -386,9 +582,14 @@ namespace std
};
- // 27.8.1.8 Template class basic_ofstream
+ // [27.8.1.8] Template class basic_ofstream
/**
- * Derivation of general output streams, specific to files.
+ * @brief Controlling output for files.
+ *
+ * This class supports reading from named files, using the inherited
+ * functions from std::basic_ostream. To control the associated
+ * sequence, an instance of std::basic_filebuf is used, which this page
+ * refers to as @c sb.
*/
template<typename _CharT, typename _Traits>
class basic_ofstream : public basic_ostream<_CharT,_Traits>
@@ -406,20 +607,34 @@ namespace std
typedef basic_ostream<char_type, traits_type> __ostream_type;
private:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__filebuf_type _M_filebuf;
public:
// Constructors:
- /** Default constructor for output file_stream. */
+ /**
+ * @brief Default constructor.
+ *
+ * Initializes @c sb using its default constructor, and passes
+ * @c &sb to the base class initializer. Does not open any files
+ * (you haven't given it a filename to open).
+ */
basic_ofstream()
: __ostream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }
/**
- * @brief Create an output stream.
- * @param s Null terminated string specifying filename.
+ * @brief Create an output file stream.
+ * @param s Null terminated string specifying the filename.
* @param mode Open file in specified mode (see std::ios_base).
*
+ * @c ios_base::out|ios_base::trunc is automatically included in
+ * @a mode.
+ *
* Tip: When using std::string to hold the filename, you must use
* .c_str() before passing it to this constructor.
*/
@@ -432,29 +647,40 @@ namespace std
this->open(__s, __mode);
}
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The file is closed by the filebuf object, not the formatting
+ * stream.
+ */
~basic_ofstream()
{ }
// Members:
/**
- * @brief Get a pointer to the file stream's buffer.
- * @return Pointer to basic_filebuf.
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_filebuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
*/
__filebuf_type*
rdbuf() const
{ return const_cast<__filebuf_type*>(&_M_filebuf); }
/**
- * @brief Query to see if file stream is open.
- * @return True if stream is open.
+ * @brief Wrapper to test for an open file.
+ * @return @c rdbuf()->is_open()
*/
bool
is_open() { return _M_filebuf.is_open(); }
/**
- * @brief Specify a file to open for output.
- * @param s Null terminated string specifying filename.
- * @param mode Mode in which to open file (see std::ios_base).
+ * @brief Opens an external file.
+ * @param s The name of the file.
+ * @param mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that
+ * function fails, @c failbit is set in the stream's error state.
*
* Tip: When using std::string to hold the filename, you must use
* .c_str() before passing it to this constructor.
@@ -467,7 +693,12 @@ namespace std
this->setstate(ios_base::failbit);
}
- /** Close the file stream. */
+ /**
+ * @brief Close the file.
+ *
+ * Calls @c std::basic_filebuf::close(). If that function
+ * fails, @c failbit is set in the stream's error state.
+ */
void
close()
{
@@ -477,9 +708,14 @@ namespace std
};
- // 27.8.1.11 Template class basic_fstream
+ // [27.8.1.11] Template class basic_fstream
/**
- * Derivation of general input/output streams, specific to files.
+ * @brief Controlling intput and output for files.
+ *
+ * This class supports reading from and writing to named files, using
+ * the inherited functions from std::basic_iostream. To control the
+ * associated sequence, an instance of std::basic_filebuf is used, which
+ * this page refers to as @c sb.
*/
template<typename _CharT, typename _Traits>
class basic_fstream : public basic_iostream<_CharT, _Traits>
@@ -498,18 +734,29 @@ namespace std
typedef basic_iostream<char_type, traits_type> __iostream_type;
private:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__filebuf_type _M_filebuf;
public:
// Constructors/destructor:
- /** Default constructor. Create a file stream. */
+ /**
+ * @brief Default constructor.
+ *
+ * Initializes @c sb using its default constructor, and passes
+ * @c &sb to the base class initializer. Does not open any files
+ * (you haven't given it a filename to open).
+ */
basic_fstream()
: __iostream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }
/**
- * @brief Create an input/output stream.
- * @param s Null terminated string specifying filename.
+ * @brief Create an input/output file stream.
+ * @param s Null terminated string specifying the filename.
* @param mode Open file in specified mode (see std::ios_base).
*
* Tip: When using std::string to hold the filename, you must use
@@ -524,29 +771,40 @@ namespace std
this->open(__s, __mode);
}
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The file is closed by the filebuf object, not the formatting
+ * stream.
+ */
~basic_fstream()
{ }
// Members:
/**
- * @brief Get a pointer to the file stream's buffer.
- * @return Pointer to basic_filebuf.
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_filebuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
*/
__filebuf_type*
rdbuf() const
{ return const_cast<__filebuf_type*>(&_M_filebuf); }
/**
- * @brief Query to see if file stream is open.
- * @return True if stream is open.
+ * @brief Wrapper to test for an open file.
+ * @return @c rdbuf()->is_open()
*/
bool
is_open() { return _M_filebuf.is_open(); }
/**
- * @brief Specify a file to open for input and/or output.
- * @param s Null terminated string specifying filename.
- * @param mode Mode in which to open file (see std::ios_base).
+ * @brief Opens an external file.
+ * @param s The name of the file.
+ * @param mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(s,mode). If that
+ * function fails, @c failbit is set in the stream's error state.
*
* Tip: When using std::string to hold the filename, you must use
* .c_str() before passing it to this constructor.
@@ -559,7 +817,12 @@ namespace std
setstate(ios_base::failbit);
}
- /** Close the file stream. */
+ /**
+ * @brief Close the file.
+ *
+ * Calls @c std::basic_filebuf::close(). If that function
+ * fails, @c failbit is set in the stream's error state.
+ */
void
close()
{
diff --git a/contrib/libstdc++/include/std/std_iomanip.h b/contrib/libstdc++/include/std/std_iomanip.h
index 23237ce..490d5ac 100644
--- a/contrib/libstdc++/include/std/std_iomanip.h
+++ b/contrib/libstdc++/include/std/std_iomanip.h
@@ -1,6 +1,7 @@
// Standard stream manipulators -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 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
@@ -47,8 +48,18 @@
namespace std
{
+ // [27.6.3] standard manipulators
+ // Also see DR 183.
+
struct _Resetiosflags { ios_base::fmtflags _M_mask; };
+ /**
+ * @brief Manipulator for @c setf.
+ * @param mask A format flags mask.
+ *
+ * Sent to a stream object, this manipulator resets the specified flags,
+ * via @e stream.setf(0,mask).
+ */
inline _Resetiosflags
resetiosflags(ios_base::fmtflags __mask)
{
@@ -76,6 +87,13 @@ namespace std
struct _Setiosflags { ios_base::fmtflags _M_mask; };
+ /**
+ * @brief Manipulator for @c setf.
+ * @param mask A format flags mask.
+ *
+ * Sent to a stream object, this manipulator sets the format flags
+ * to @a mask.
+ */
inline _Setiosflags
setiosflags(ios_base::fmtflags __mask)
{
@@ -103,6 +121,14 @@ namespace std
struct _Setbase { int _M_base; };
+ /**
+ * @brief Manipulator for @c setf.
+ * @param base A numeric base.
+ *
+ * Sent to a stream object, this manipulator changes the
+ * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base
+ * is 8, 10, or 16, accordingly, and to 0 if @a base is any other value.
+ */
inline _Setbase
setbase(int __base)
{
@@ -137,6 +163,13 @@ namespace std
template<typename _CharT>
struct _Setfill { _CharT _M_c; };
+ /**
+ * @brief Manipulator for @c fill.
+ * @param c The new fill character.
+ *
+ * Sent to a stream object, this manipulator calls @c fill(c) for that
+ * object.
+ */
template<typename _CharT>
inline _Setfill<_CharT>
setfill(_CharT __c)
@@ -165,6 +198,13 @@ namespace std
struct _Setprecision { int _M_n; };
+ /**
+ * @brief Manipulator for @c precision.
+ * @param n The new precision.
+ *
+ * Sent to a stream object, this manipulator calls @c precision(n) for
+ * that object.
+ */
inline _Setprecision
setprecision(int __n)
{
@@ -192,6 +232,13 @@ namespace std
struct _Setw { int _M_n; };
+ /**
+ * @brief Manipulator for @c width.
+ * @param n The new width.
+ *
+ * Sent to a stream object, this manipulator calls @c width(n) for
+ * that object.
+ */
inline _Setw
setw(int __n)
{
@@ -219,6 +266,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template ostream& operator<<(ostream&, _Setfill<char>);
extern template ostream& operator<<(ostream&, _Setiosflags);
extern template ostream& operator<<(ostream&, _Resetiosflags);
@@ -246,6 +294,7 @@ namespace std
extern template wistream& operator>>(wistream&, _Setprecision);
extern template wistream& operator>>(wistream&, _Setw);
#endif
+#endif
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/std/std_iosfwd.h b/contrib/libstdc++/include/std/std_iosfwd.h
index 797f493..55b0e0b 100644
--- a/contrib/libstdc++/include/std/std_iosfwd.h
+++ b/contrib/libstdc++/include/std/std_iosfwd.h
@@ -1,6 +1,7 @@
// Forwarding declarations -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 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
@@ -42,7 +43,9 @@
#pragma GCC system_header
#include <bits/c++config.h>
-#include <bits/stringfwd.h> // For string forward declarations.
+#include <bits/c++locale.h>
+#include <cctype> // For isspace, etc.
+#include <bits/stringfwd.h> // For string forward declarations.
#include <bits/fpos.h>
#include <bits/functexcept.h>
@@ -102,35 +105,64 @@ namespace std
class ios_base;
#endif
- typedef basic_ios<char> ios;
- typedef basic_streambuf<char> streambuf;
- typedef basic_istream<char> istream;
- typedef basic_ostream<char> ostream;
- typedef basic_iostream<char> iostream;
- typedef basic_stringbuf<char> stringbuf;
- typedef basic_istringstream<char> istringstream;
- typedef basic_ostringstream<char> ostringstream;
- typedef basic_stringstream<char> stringstream;
- typedef basic_filebuf<char> filebuf;
- typedef basic_ifstream<char> ifstream;
- typedef basic_ofstream<char> ofstream;
- typedef basic_fstream<char> fstream;
+ /**
+ * @defgroup s27_2_iosfwd I/O Forward Declarations
+ *
+ * Nearly all of the I/O classes are parameterized on the type of
+ * characters they read and write. (The major exception is ios_base at
+ * the top of the hierarchy.) This is a change from pre-Standard
+ * streams, which were not templates.
+ *
+ * For ease of use and compatibility, all of the basic_* I/O-related
+ * classes are given typedef names for both of the builtin character
+ * widths (wide and narrow). The typedefs are the same as the
+ * pre-Standard names, for example:
+ *
+ * @code
+ * typedef basic_ifstream<char> ifstream;
+ * @endcode
+ *
+ * Because properly forward-declaring these classes can be difficult, you
+ * should not do it yourself. Instead, include the &lt;iosfwd&gt;
+ * header, which contains only declarations of all the I/O classes as
+ * well as the typedefs. Trying to forward-declare the typedefs
+ * themselves (e.g., "class ostream;") is not valid ISO C++.
+ *
+ * For more specific declarations, see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10
+ *
+ * @{
+ */
+ typedef basic_ios<char> ios; ///< @isiosfwd
+ typedef basic_streambuf<char> streambuf; ///< @isiosfwd
+ typedef basic_istream<char> istream; ///< @isiosfwd
+ typedef basic_ostream<char> ostream; ///< @isiosfwd
+ typedef basic_iostream<char> iostream; ///< @isiosfwd
+ typedef basic_stringbuf<char> stringbuf; ///< @isiosfwd
+ typedef basic_istringstream<char> istringstream; ///< @isiosfwd
+ typedef basic_ostringstream<char> ostringstream; ///< @isiosfwd
+ typedef basic_stringstream<char> stringstream; ///< @isiosfwd
+ typedef basic_filebuf<char> filebuf; ///< @isiosfwd
+ typedef basic_ifstream<char> ifstream; ///< @isiosfwd
+ typedef basic_ofstream<char> ofstream; ///< @isiosfwd
+ typedef basic_fstream<char> fstream; ///< @isiosfwd
#ifdef _GLIBCPP_USE_WCHAR_T
- typedef basic_ios<wchar_t> wios;
- typedef basic_streambuf<wchar_t> wstreambuf;
- typedef basic_istream<wchar_t> wistream;
- typedef basic_ostream<wchar_t> wostream;
- typedef basic_iostream<wchar_t> wiostream;
- typedef basic_stringbuf<wchar_t> wstringbuf;
- typedef basic_istringstream<wchar_t> wistringstream;
- typedef basic_ostringstream<wchar_t> wostringstream;
- typedef basic_stringstream<wchar_t> wstringstream;
- typedef basic_filebuf<wchar_t> wfilebuf;
- typedef basic_ifstream<wchar_t> wifstream;
- typedef basic_ofstream<wchar_t> wofstream;
- typedef basic_fstream<wchar_t> wfstream;
+ typedef basic_ios<wchar_t> wios; ///< @isiosfwd
+ typedef basic_streambuf<wchar_t> wstreambuf; ///< @isiosfwd
+ typedef basic_istream<wchar_t> wistream; ///< @isiosfwd
+ typedef basic_ostream<wchar_t> wostream; ///< @isiosfwd
+ typedef basic_iostream<wchar_t> wiostream; ///< @isiosfwd
+ typedef basic_stringbuf<wchar_t> wstringbuf; ///< @isiosfwd
+ typedef basic_istringstream<wchar_t> wistringstream; ///< @isiosfwd
+ typedef basic_ostringstream<wchar_t> wostringstream; ///< @isiosfwd
+ typedef basic_stringstream<wchar_t> wstringstream; ///< @isiosfwd
+ typedef basic_filebuf<wchar_t> wfilebuf; ///< @isiosfwd
+ typedef basic_ifstream<wchar_t> wifstream; ///< @isiosfwd
+ typedef basic_ofstream<wchar_t> wofstream; ///< @isiosfwd
+ typedef basic_fstream<wchar_t> wfstream; ///< @isiosfwd
#endif
+ /** @} */
} // namespace std
#endif
diff --git a/contrib/libstdc++/include/std/std_iostream.h b/contrib/libstdc++/include/std/std_iostream.h
index d0736b8..d709493 100644
--- a/contrib/libstdc++/include/std/std_iostream.h
+++ b/contrib/libstdc++/include/std/std_iostream.h
@@ -47,17 +47,31 @@
namespace std
{
- extern istream cin;
- extern ostream cout;
- extern ostream cerr;
- extern ostream clog;
+ /**
+ * @name Standard Stream Objects
+ *
+ * The &lt;iostream&gt; header declares the eight <em>standard stream
+ * objects</em>. For other declarations, see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10 and the
+ * @link s27_2_iosfwd I/O forward declarations @endlink
+ *
+ * They are required by default to cooperate with the global C library's
+ * @c FILE streams, and to be available during program startup and
+ * termination. For more information, see the HOWTO linked to above.
+ */
+ //@{
+ extern istream cin; ///< Linked to standard input
+ extern ostream cout; ///< Linked to standard output
+ extern ostream cerr; ///< Linked to standard error (unbuffered)
+ extern ostream clog; ///< Linked to standard error (buffered)
#ifdef _GLIBCPP_USE_WCHAR_T
- extern wistream wcin;
- extern wostream wcout;
- extern wostream wcerr;
- extern wostream wclog;
+ extern wistream wcin; ///< Linked to standard input
+ extern wostream wcout; ///< Linked to standard output
+ extern wostream wcerr; ///< Linked to standard error (unbuffered)
+ extern wostream wclog; ///< Linked to standard error (buffered)
#endif
+ //@}
// For construction of filebuffers for cout, cin, cerr, clog et. al.
static ios_base::Init __ioinit;
diff --git a/contrib/libstdc++/include/std/std_istream.h b/contrib/libstdc++/include/std/std_istream.h
index 8aa9123..da9c7db 100644
--- a/contrib/libstdc++/include/std/std_istream.h
+++ b/contrib/libstdc++/include/std/std_istream.h
@@ -46,7 +46,14 @@
namespace std
{
- // 27.6.1.1 Template class basic_istream
+ // [27.6.1.1] Template class basic_istream
+ /**
+ * @brief Controlling input.
+ *
+ * This is the base class for all input streams. It provides text
+ * formatting of all builtin types, and communicates with any class
+ * derived from basic_streambuf to do the actual input.
+ */
template<typename _CharT, typename _Traits>
class basic_istream : virtual public basic_ios<_CharT, _Traits>
{
@@ -66,12 +73,33 @@ namespace std
typedef num_get<_CharT, __istreambuf_iter> __numget_type;
typedef ctype<_CharT> __ctype_type;
+ template<typename _CharT2, typename _Traits2>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2&);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
+
protected:
// Data Members:
+ /**
+ * @if maint
+ * The number of characters extracted in the previous unformatted
+ * function; see gcount().
+ * @endif
+ */
streamsize _M_gcount;
public:
- // 27.6.1.1.1 Constructor/destructor:
+ // [27.6.1.1.1] constructor/destructor
+ /**
+ * @brief Base constructor.
+ *
+ * This ctor is almost never called by the user directly, rather from
+ * derived classes' initialization lists, which pass a pointer to
+ * their own stream buffer.
+ */
explicit
basic_istream(__streambuf_type* __sb)
{
@@ -79,16 +107,29 @@ namespace std
_M_gcount = streamsize(0);
}
+ /**
+ * @brief Base destructor.
+ *
+ * This does very little apart from providing a virtual base dtor.
+ */
virtual
~basic_istream()
{ _M_gcount = streamsize(0); }
- // 27.6.1.1.2 Prefix/suffix:
+ // [27.6.1.1.2] prefix/suffix
class sentry;
friend class sentry;
- // 27.6.1.2 Formatted input:
- // 27.6.1.2.3 basic_istream::operator>>
+ // [27.6.1.2] formatted input
+ // [27.6.1.2.3] basic_istream::operator>>
+ //@{
+ /**
+ * @brief Interface for manipulators.
+ *
+ * Manuipulators such as @c std::ws and @c std::dec use these
+ * functions in constructs like "std::cin >> std::ws". For more
+ * information, see the iomanip header.
+ */
__istream_type&
operator>>(__istream_type& (*__pf)(__istream_type&));
@@ -97,8 +138,36 @@ namespace std
__istream_type&
operator>>(ios_base& (*__pf)(ios_base&));
+ //@}
- // 27.6.1.2.2 Arithmetic Extractors
+ // [27.6.1.2.2] arithmetic extractors
+ /**
+ * @name Arithmetic Extractors
+ *
+ * All the @c operator>> functions (aka <em>formatted input
+ * functions</em>) have some common behavior. Each starts by
+ * constructing a temporary object of type std::basic_istream::sentry
+ * with the second argument (noskipws) set to false. This has several
+ * effects, concluding with the setting of a status flag; see the
+ * sentry documentation for more.
+ *
+ * If the sentry status is good, the function tries to extract
+ * whatever data is appropriate for the type of the argument.
+ *
+ * If an exception is thrown during extraction, ios_base::badbit
+ * will be turned on in the stream's error state without causing an
+ * ios_base::failure to be thrown. The original exception will then
+ * be rethrown.
+ */
+ //@{
+ /**
+ * @brief Basic arithmetic extractors
+ * @param A variable of builtin type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to parse the input data.
+ */
__istream_type&
operator>>(bool& __n);
@@ -140,92 +209,431 @@ namespace std
__istream_type&
operator>>(void*& __p);
+ /**
+ * @brief Extracting into another streambuf.
+ * @param sb A pointer to a streambuf
+ *
+ * This function behaves like one of the basic arithmetic extractors,
+ * in that it also constructs a sentry onject and has the same error
+ * handling behavior.
+ *
+ * If @a sb is NULL, the stream will set failbit in its error state.
+ *
+ * Characters are extracted from this stream and inserted into the
+ * @a sb streambuf until one of the following occurs:
+ *
+ * - the input stream reaches end-of-file,
+ * - insertion into the output buffer fails (in this case, the
+ * character that would have been inserted is not extracted), or
+ * - an exception occurs (and in this case is caught)
+ *
+ * If the function inserts no characters, failbit is set.
+ */
__istream_type&
operator>>(__streambuf_type* __sb);
+ //@}
- // 27.6.1.3 Unformatted input:
+ // [27.6.1.3] unformatted input
+ /**
+ * @brief Character counting
+ * @return The number of characters extracted by the previous
+ * unformatted input function dispatched for this stream.
+ */
inline streamsize
- gcount(void) const
+ gcount() const
{ return _M_gcount; }
+ /**
+ * @name Unformatted Input Functions
+ *
+ * All the unformatted input functions have some common behavior.
+ * Each starts by constructing a temporary object of type
+ * std::basic_istream::sentry with the second argument (noskipws)
+ * set to true. This has several effects, concluding with the
+ * setting of a status flag; see the sentry documentation for more.
+ *
+ * If the sentry status is good, the function tries to extract
+ * whatever data is appropriate for the type of the argument.
+ *
+ * The number of characters extracted is stored for later retrieval
+ * by gcount().
+ *
+ * If an exception is thrown during extraction, ios_base::badbit
+ * will be turned on in the stream's error state without causing an
+ * ios_base::failure to be thrown. The original exception will then
+ * be rethrown.
+ */
+ //@{
+ /**
+ * @brief Simple extraction.
+ * @return A character, or eof().
+ *
+ * Tries to extract a character. If none are available, sets failbit
+ * and returns traits::eof().
+ */
int_type
- get(void);
-
+ get();
+
+ /**
+ * @brief Simple extraction.
+ * @param c The character in which to store data.
+ * @return *this
+ *
+ * Tries to extract a character and store it in @a c. If none are
+ * available, sets failbit and returns traits::eof().
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
__istream_type&
get(char_type& __c);
+ /**
+ * @brief Simple multiple-character extraction.
+ * @param s Pointer to an array.
+ * @param n Maximum number of characters to store in @a s.
+ * @param delim A "stop" character.
+ * @return *this
+ *
+ * Characters are extracted and stored into @a s until one of the
+ * following happens:
+ *
+ * - @c n-1 characters are stored
+ * - the input sequence reaches EOF
+ * - the next character equals @a delim, in which case the character
+ * is not extracted
+ *
+ * If no characters are stored, failbit is set in the stream's error
+ * state.
+ *
+ * In any case, a null character is stored into the next location in
+ * the array.
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
__istream_type&
get(char_type* __s, streamsize __n, char_type __delim);
+ /**
+ * @brief Simple multiple-character extraction.
+ * @param s Pointer to an array.
+ * @param n Maximum number of characters to store in @a s.
+ * @return *this
+ *
+ * Returns @c get(s,n,widen('\n')).
+ */
inline __istream_type&
get(char_type* __s, streamsize __n)
{ return this->get(__s, __n, this->widen('\n')); }
+ /**
+ * @brief Extraction into another streambuf.
+ * @param sb A streambuf in which to store data.
+ * @param delim A "stop" character.
+ * @return *this
+ *
+ * Characters are extracted and inserted into @a sb until one of the
+ * following happens:
+ *
+ * - the input sequence reaches EOF
+ * - insertion into the output buffer fails (in this case, the
+ * character that would have been inserted is not extracted)
+ * - the next character equals @a delim (in this case, the character
+ * is not extracted)
+ * - an exception occurs (and in this case is caught)
+ *
+ * If no characters are stored, failbit is set in the stream's error
+ * state.
+ */
__istream_type&
get(__streambuf_type& __sb, char_type __delim);
+ /**
+ * @brief Extraction into another streambuf.
+ * @param sb A streambuf in which to store data.
+ * @return *this
+ *
+ * Returns @c get(sb,widen('\n')).
+ */
inline __istream_type&
get(__streambuf_type& __sb)
{ return this->get(__sb, this->widen('\n')); }
+ /**
+ * @brief String extraction.
+ * @param s A character array in which to store the data.
+ * @param n Maximum number of characters to extract.
+ * @param delim A "stop" character.
+ * @return *this
+ *
+ * Extracts and stores characters into @a s until one of the
+ * following happens. Note that these criteria are required to be
+ * tested in the order listed here, to allow an input line to exactly
+ * fill the @a s array without setting failbit.
+ *
+ * -# the input sequence reaches end-of-file, in which case eofbit
+ * is set in the stream error state
+ * -# the next character equals @c delim, in which case the character
+ * is extracted (and therefore counted in @c gcount()) but not stored
+ * -# @c n-1 characters are stored, in which case failbit is set
+ * in the stream error state
+ *
+ * If no characters are extracted, failbit is set. (An empty line of
+ * input should therefore not cause failbit to be set.)
+ *
+ * In any case, a null character is stored in the next location in
+ * the array.
+ */
__istream_type&
getline(char_type* __s, streamsize __n, char_type __delim);
+ /**
+ * @brief String extraction.
+ * @param s A character array in which to store the data.
+ * @param n Maximum number of characters to extract.
+ * @return *this
+ *
+ * Returns @c getline(s,n,widen('\n')).
+ */
inline __istream_type&
getline(char_type* __s, streamsize __n)
{ return this->getline(__s, __n, this->widen('\n')); }
+ /**
+ * @brief Discarding characters
+ * @param n Number of characters to discard.
+ * @param delim A "stop" character.
+ * @return *this
+ *
+ * Extracts characters and throws them away until one of the
+ * following happens:
+ * - if @a n @c != @c std::numeric_limits<int>::max(), @a n
+ * characters are extracted
+ * - the input sequence reaches end-of-file
+ * - the next character equals @a delim (in this case, the character
+ * is extracted); note that this condition will never occur if
+ * @a delim equals @c traits::eof().
+ */
__istream_type&
ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
+ /**
+ * @brief Looking ahead in the stream
+ * @return The next character, or eof().
+ *
+ * If, after constructing the sentry object, @c good() is false,
+ * returns @c traits::eof(). Otherwise reads but does not extract
+ * the next input character.
+ */
int_type
- peek(void);
+ peek();
+ /**
+ * @brief Extraction without delimiters.
+ * @param s A character array.
+ * @param n Maximum number of characters to store.
+ * @return *this
+ *
+ * If the stream state is @c good(), extracts characters and stores
+ * them into @a s until one of the following happens:
+ * - @a n characters are stored
+ * - the input sequence reaches end-of-file, in which case the error
+ * state is set to @c failbit|eofbit.
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
__istream_type&
read(char_type* __s, streamsize __n);
+ /**
+ * @brief Extraction until the buffer is exhausted, but no more.
+ * @param s A character array.
+ * @param n Maximum number of characters to store.
+ * @return The number of characters extracted.
+ *
+ * Extracts characters and stores them into @a s depending on the
+ * number of characters remaining in the streambuf's buffer,
+ * @c rdbuf()->in_avail(), called @c A here:
+ * - if @c A @c == @c -1, sets eofbit and extracts no characters
+ * - if @c A @c == @c 0, extracts no characters
+ * - if @c A @c > @c 0, extracts @c min(A,n)
+ *
+ * The goal is to empty the current buffer, and to not request any
+ * more from the external input sequence controlled by the streambuf.
+ */
streamsize
readsome(char_type* __s, streamsize __n);
+ /**
+ * @brief Unextracting a single character.
+ * @param c The character to push back into the input stream.
+ * @return *this
+ *
+ * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
+ *
+ * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
+ * the error state.
+ *
+ * @note Since no characters are extracted, the next call to
+ * @c gcount() will return 0, as required by DR 60.
+ */
__istream_type&
putback(char_type __c);
+ /**
+ * @brief Unextracting the previous character.
+ * @return *this
+ *
+ * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
+ *
+ * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
+ * the error state.
+ *
+ * @note Since no characters are extracted, the next call to
+ * @c gcount() will return 0, as required by DR 60.
+ */
__istream_type&
- unget(void);
-
+ unget();
+
+ /**
+ * @brief Synchronizing the stream buffer.
+ * @return 0 on success, -1 on failure
+ *
+ * If @c rdbuf() is a null pointer, returns -1.
+ *
+ * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
+ * sets badbit and returns -1.
+ *
+ * Otherwise, returns 0.
+ *
+ * @note This function does not count the number of characters
+ * extracted, if any, and therefore does not affect the next
+ * call to @c gcount().
+ */
int
- sync(void);
-
+ sync();
+
+ /**
+ * @brief Getting the current read position.
+ * @return A file position object.
+ *
+ * If @c fail() is not false, returns @c pos_type(-1) to indicate
+ * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
+ *
+ * @note This function does not count the number of characters
+ * extracted, if any, and therefore does not affect the next
+ * call to @c gcount().
+ */
pos_type
- tellg(void);
-
+ tellg();
+
+ /**
+ * @brief Changing the current read position.
+ * @param pos A file position object.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If
+ * that function fails, sets failbit.
+ *
+ * @note This function does not count the number of characters
+ * extracted, if any, and therefore does not affect the next
+ * call to @c gcount().
+ */
__istream_type&
seekg(pos_type);
+ /**
+ * @brief Changing the current read position.
+ * @param off A file offset object.
+ * @param dir The direction in which to seek.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
+ * If that function fails, sets failbit.
+ *
+ * @note This function does not count the number of characters
+ * extracted, if any, and therefore does not affect the next
+ * call to @c gcount().
+ */
__istream_type&
seekg(off_type, ios_base::seekdir);
+ //@}
};
+ /**
+ * @brief Performs setup work for input streams.
+ *
+ * Objects of this class are created before all of the standard
+ * extractors are run. It is responsible for "exception-safe prefix and
+ * suffix operations," although only prefix actions are currently required
+ * by the standard. Additional actions may be added by the
+ * implementation, and we list them in
+ * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5
+ * under [27.6] notes.
+ */
template<typename _CharT, typename _Traits>
class basic_istream<_CharT, _Traits>::sentry
{
public:
+ /// Easy access to dependant types.
typedef _Traits traits_type;
typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::__ctype_type __ctype_type;
typedef typename _Traits::int_type __int_type;
+ /**
+ * @brief The constructor performs all the work.
+ * @param is The input stream to guard.
+ * @param noskipws Whether to consume whitespace or not.
+ *
+ * If the stream state is good (@a is.good() is true), then the
+ * following actions are performed, otherwise the sentry state is
+ * false ("not okay") and failbit is set in the stream state.
+ *
+ * The sentry's preparatory actions are:
+ *
+ * -# if the stream is tied to an output stream, @c is.tie()->flush()
+ * is called to synchronize the output sequence
+ * -# if @a noskipws is false, and @c ios_base::skipws is set in
+ * @c is.flags(), the sentry extracts and discards whitespace
+ * characters from the stream. The currently imbued locale is
+ * used to determine whether each character is whitespace.
+ *
+ * If the stream state is still good, then the sentry state becomes
+ * true ("okay").
+ */
explicit
sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
+ /**
+ * @brief Quick status checking.
+ * @return The sentry state.
+ *
+ * For ease of use, sentries may be converted to booleans. The
+ * return value is that of the sentry state (true == okay).
+ */
operator bool() { return _M_ok; }
private:
bool _M_ok;
};
- // 27.6.1.2.3 Character extraction templates
+ // [27.6.1.2.3] character extraction templates
+ //@{
+ /**
+ * @brief Character extractors
+ * @param in An input stream.
+ * @param c A character reference.
+ * @return in
+ *
+ * Behaves like one of the formatted arithmetic extractors described in
+ * std::basic_istream. After constructing a sentry object with good
+ * status, this function extracts a character (if one is available) and
+ * stores it in @a c. Otherwise, sets failbit in the input stream.
+ */
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
@@ -239,7 +647,34 @@ namespace std
basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
{ return (__in >> reinterpret_cast<char&>(__c)); }
-
+ //@}
+
+ //@{
+ /**
+ * @brief Character string extractors
+ * @param in An input stream.
+ * @param s A pointer to a character array.
+ * @return in
+ *
+ * Behaves like one of the formatted arithmetic extractors described in
+ * std::basic_istream. After constructing a sentry object with good
+ * status, this function extracts up to @c n characters and stores them
+ * into the array starting at @a s. @c n is defined as:
+ *
+ * - if @c width() is greater than zero, @c n is width()
+ * - otherwise @c n is "the number of elements of the largest array of
+ * @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6
+ *
+ * Characters are extracted and stored until one of the following happens:
+ * - @c n-1 characters are stored
+ * - EOF is reached
+ * - the next character is whitespace according to the current locale
+ * - the next character is a null byte (i.e., @c charT() )
+ *
+ * @c width(0) is then called for the input stream.
+ *
+ * If no characters are extracted, sets failbit.
+ */
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
@@ -253,8 +688,15 @@ namespace std
basic_istream<char,_Traits>&
operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
{ return (__in >> reinterpret_cast<char*>(__s)); }
+ //@}
// 27.6.1.5 Template class basic_iostream
+ /**
+ * @brief Merging istream and ostream capabilities.
+ *
+ * This class multiply inherits from the input and output stream classes
+ * simply to provide a single interface.
+ */
template<typename _CharT, typename _Traits>
class basic_iostream
: public basic_istream<_CharT, _Traits>,
@@ -275,16 +717,45 @@ namespace std
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef basic_ostream<_CharT, _Traits> __ostream_type;
+ /**
+ * @brief Constructor does nothing.
+ *
+ * Both of the parent classes are initialized with the same
+ * streambuf pointer passed to this constructor.
+ */
explicit
basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
: __istream_type(__sb), __ostream_type(__sb)
{ }
+ /**
+ * @brief Destructor does nothing.
+ */
virtual
~basic_iostream() { }
};
- // 27.6.1.4 Standard basic_istream manipulators
+ // [27.6.1.4] standard basic_istream manipulators
+ /**
+ * @brief Quick and easy way to eat whitespace
+ *
+ * This manipulator extracts whitespace characters, stopping when the
+ * next character is non-whitespace, or when the input sequence is empty.
+ * If the sequence is empty, @c eofbit is set in the stream, but not
+ * @c failbit.
+ *
+ * The current locale is used to distinguish whitespace characters.
+ *
+ * Example:
+ * @code
+ * MyClass mc;
+ *
+ * std::cin >> std::ws >> mc;
+ * @endcode
+ * will skip leading whitespace before calling operator>> on cin and your
+ * object. Note that the same effect can be achieved by creating a
+ * std::basic_istream::sentry inside your definition of operator>>.
+ */
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is);
diff --git a/contrib/libstdc++/include/std/std_limits.h b/contrib/libstdc++/include/std/std_limits.h
index 5f70dda..9be6947 100644
--- a/contrib/libstdc++/include/std/std_limits.h
+++ b/contrib/libstdc++/include/std/std_limits.h
@@ -45,7 +45,6 @@
#pragma GCC system_header
-#include <bits/cpu_limits.h>
#include <bits/c++config.h>
//
@@ -64,13 +63,13 @@
// double (1)
// long double (1)
//
-// GNU C++ undertstands (where supported by the host C-library)
+// GNU C++ undertstands (where supported by the host C-library)
// * integer
// long long, unsigned long long (2)
//
// which brings us to 15 fundamental arithmetic data types in GNU C++.
//
-//
+//
// Since a numeric_limits<> is a bit tricky to get right, we rely on
// an interface composed of macros which should be defined in config/os
// or config/cpu when they differ from the generic (read arbitrary)
@@ -80,813 +79,77 @@
// These values can be overridden in the target configuration file.
// The default values are appropriate for many 32-bit targets.
-#ifndef __glibcpp_char_bits
-#define __glibcpp_char_bits 8
-#endif
-#ifdef __CHAR_UNSIGNED__
-#define __glibcpp_plain_char_is_signed false
-#else
-#define __glibcpp_plain_char_is_signed true
-#endif
-#ifndef __glibcpp_short_bits
-#define __glibcpp_short_bits 16
-#endif
-#ifndef __glibcpp_int_bits
-#define __glibcpp_int_bits 32
-#endif
-#ifndef __glibcpp_long_bits
-#define __glibcpp_long_bits 32
-#endif
-#ifndef __glibcpp_wchar_t_bits
-#define __glibcpp_wchar_t_bits 32
-#endif
-#ifndef __glibcpp_wchar_t_is_signed
-#define __glibcpp_wchar_t_is_signed true
-#endif
-#ifndef __glibcpp_long_long_bits
-#define __glibcpp_long_long_bits 64
-#endif
-#ifndef __glibcpp_float_bits
-#define __glibcpp_float_bits 32
-#endif
-#ifndef __glibcpp_double_bits
-#define __glibcpp_double_bits 64
-#endif
-#ifndef __glibcpp_long_double_bits
-#define __glibcpp_long_double_bits 128
-#endif
-
-#ifndef __glibcpp_char_traps
-#define __glibcpp_char_traps true
-#endif
-#ifndef __glibcpp_short_traps
-#define __glibcpp_short_traps true
-#endif
-#ifndef __glibcpp_int_traps
-#define __glibcpp_int_traps true
-#endif
-#ifndef __glibcpp_long_traps
-#define __glibcpp_long_traps true
-#endif
-#ifndef __glibcpp_wchar_t_traps
-#define __glibcpp_wchar_t_traps true
-#endif
-#ifndef __glibcpp_long_long_traps
-#define __glibcpp_long_long_traps true
-#endif
-
-// You should not need to define any macros below this point, unless
-// you have a machine with non-standard bit-widths.
-
-// These values are the minimums and maximums for standard data types
-// of common widths.
-
-#define __glibcpp_s8_max 127
-#define __glibcpp_s8_min (-__glibcpp_s8_max - 1)
-#define __glibcpp_s8_digits 7
-#define __glibcpp_s8_digits10 2
-#define __glibcpp_u8_min 0U
-#define __glibcpp_u8_max (__glibcpp_s8_max * 2 + 1)
-#define __glibcpp_u8_digits 8
-#define __glibcpp_u8_digits10 2
-#define __glibcpp_s16_max 32767
-#define __glibcpp_s16_min (-__glibcpp_s16_max - 1)
-#define __glibcpp_s16_digits 15
-#define __glibcpp_s16_digits10 4
-#define __glibcpp_u16_min 0U
-#define __glibcpp_u16_max (__glibcpp_s16_max * 2 + 1)
-#define __glibcpp_u16_digits 16
-#define __glibcpp_u16_digits10 4
-#define __glibcpp_s32_max 2147483647L
-#define __glibcpp_s32_min (-__glibcpp_s32_max - 1)
-#define __glibcpp_s32_digits 31
-#define __glibcpp_s32_digits10 9
-#define __glibcpp_u32_min 0UL
-#define __glibcpp_u32_max (__glibcpp_s32_max * 2U + 1)
-#define __glibcpp_u32_digits 32
-#define __glibcpp_u32_digits10 9
-#define __glibcpp_s64_max 9223372036854775807LL
-#define __glibcpp_s64_min (-__glibcpp_s64_max - 1)
-#define __glibcpp_s64_digits 63
-#define __glibcpp_s64_digits10 18
-#define __glibcpp_u64_min 0ULL
-#define __glibcpp_u64_max (__glibcpp_s64_max * 2ULL + 1)
-#define __glibcpp_u64_digits 64
-#define __glibcpp_u64_digits10 19
-
-#define __glibcpp_f32_min 1.17549435e-38F
-#define __glibcpp_f32_max 3.40282347e+38F
-#define __glibcpp_f32_digits 24
-#define __glibcpp_f32_digits10 6
-#define __glibcpp_f32_radix 2
-#define __glibcpp_f32_epsilon 1.19209290e-07F
-#define __glibcpp_f32_round_error 1.0F
-#define __glibcpp_f32_min_exponent -125
-#define __glibcpp_f32_min_exponent10 -37
-#define __glibcpp_f32_max_exponent 128
-#define __glibcpp_f32_max_exponent10 38
-#define __glibcpp_f64_min 2.2250738585072014e-308
-#define __glibcpp_f64_max 1.7976931348623157e+308
-#define __glibcpp_f64_digits 53
-#define __glibcpp_f64_digits10 15
-#define __glibcpp_f64_radix 2
-#define __glibcpp_f64_epsilon 2.2204460492503131e-16
-#define __glibcpp_f64_round_error 1.0
-#define __glibcpp_f64_min_exponent -1021
-#define __glibcpp_f64_min_exponent10 -307
-#define __glibcpp_f64_max_exponent 1024
-#define __glibcpp_f64_max_exponent10 308
-#define __glibcpp_f80_min 3.36210314311209350626e-4932L
-#define __glibcpp_f80_max 1.18973149535723176502e+4932L
-#define __glibcpp_f80_digits 64
-#define __glibcpp_f80_digits10 18
-#define __glibcpp_f80_radix 2
-#define __glibcpp_f80_epsilon 1.08420217248550443401e-19L
-#define __glibcpp_f80_round_error 1.0L
-#define __glibcpp_f80_min_exponent -16381
-#define __glibcpp_f80_min_exponent10 -4931
-#define __glibcpp_f80_max_exponent 16384
-#define __glibcpp_f80_max_exponent10 4932
-#define __glibcpp_f96_min 1.68105157155604675313e-4932L
-#define __glibcpp_f96_max 1.18973149535723176502e+4932L
-#define __glibcpp_f96_digits 64
-#define __glibcpp_f96_digits10 18
-#define __glibcpp_f96_radix 2
-#define __glibcpp_f96_epsilon 1.08420217248550443401e-19L
-#define __glibcpp_f96_round_error 1.0L
-#define __glibcpp_f96_min_exponent -16382
-#define __glibcpp_f96_min_exponent10 -4931
-#define __glibcpp_f96_max_exponent 16384
-#define __glibcpp_f96_max_exponent10 4932
-#define __glibcpp_f128_min 3.362103143112093506262677817321752603E-4932L
-#define __glibcpp_f128_max 1.189731495357231765085759326628007016E+4932L
-#define __glibcpp_f128_digits 113
-#define __glibcpp_f128_digits10 33
-#define __glibcpp_f128_radix 2
-#define __glibcpp_f128_epsilon 1.925929944387235853055977942584927319E-34L
-#define __glibcpp_f128_round_error 1.0L
-#define __glibcpp_f128_min_exponent -16381
-#define __glibcpp_f128_min_exponent10 -4931
-#define __glibcpp_f128_max_exponent 16384
-#define __glibcpp_f128_max_exponent10 4932
-
-// bool-specific hooks:
-// __glibcpp_bool_digits __glibcpp_int_traps __glibcpp_long_traps
-
-#ifndef __glibcpp_bool_digits
-#define __glibcpp_bool_digits 1
-#endif
-
-// char.
-
-#define __glibcpp_plain_char_traps true
-#define __glibcpp_signed_char_traps true
-#define __glibcpp_unsigned_char_traps true
-#ifndef __glibcpp_char_is_modulo
-#define __glibcpp_char_is_modulo true
-#endif
-#ifndef __glibcpp_signed_char_is_modulo
-#define __glibcpp_signed_char_is_modulo true
-#endif
-#if __glibcpp_char_bits == 8
-#define __glibcpp_signed_char_min __glibcpp_s8_min
-#define __glibcpp_signed_char_max __glibcpp_s8_max
-#define __glibcpp_signed_char_digits __glibcpp_s8_digits
-#define __glibcpp_signed_char_digits10 __glibcpp_s8_digits10
-#define __glibcpp_unsigned_char_min __glibcpp_u8_min
-#define __glibcpp_unsigned_char_max __glibcpp_u8_max
-#define __glibcpp_unsigned_char_digits __glibcpp_u8_digits
-#define __glibcpp_unsigned_char_digits10 __glibcpp_u8_digits10
-#elif __glibcpp_char_bits == 16
-#define __glibcpp_signed_char_min __glibcpp_s16_min
-#define __glibcpp_signed_char_max __glibcpp_s16_max
-#define __glibcpp_signed_char_digits __glibcpp_s16_digits
-#define __glibcpp_signed_char_digits10 __glibcpp_s16_digits10
-#define __glibcpp_unsigned_char_min __glibcpp_u16_min
-#define __glibcpp_unsigned_char_max __glibcpp_u16_max
-#define __glibcpp_unsigned_char_digits __glibcpp_u16_digits
-#define __glibcpp_unsigned_char_digits10 __glibcpp_u16_digits10
-#elif __glibcpp_char_bits == 32
-#define __glibcpp_signed_char_min (signed char)__glibcpp_s32_min
-#define __glibcpp_signed_char_max (signed char)__glibcpp_s32_max
-#define __glibcpp_signed_char_digits __glibcpp_s32_digits
-#define __glibcpp_signed_char_digits10 __glibcpp_s32_digits10
-#define __glibcpp_unsigned_char_min (unsigned char)__glibcpp_u32_min
-#define __glibcpp_unsigned_char_max (unsigned char)__glibcpp_u32_max
-#define __glibcpp_unsigned_char_digits __glibcpp_u32_digits
-#define __glibcpp_unsigned_char_digits10 __glibcpp_u32_digits10
-#elif __glibcpp_char_bits == 64
-#define __glibcpp_signed_char_min (signed char)__glibcpp_s64_min
-#define __glibcpp_signed_char_max (signed char)__glibcpp_s64_max
-#define __glibcpp_signed_char_digits __glibcpp_s64_digits
-#define __glibcpp_signed_char_digits10 __glibcpp_s64_digits10
-#define __glibcpp_unsigned_char_min (unsigned char)__glibcpp_u64_min
-#define __glibcpp_unsigned_char_max (unsigned char)__glibcpp_u64_max
-#define __glibcpp_unsigned_char_digits __glibcpp_u64_digits
-#define __glibcpp_unsigned_char_digits10 __glibcpp_u64_digits10
-#else
-// You must define these macros in the configuration file.
-#endif
-
-#if __glibcpp_plain_char_is_signed
-#define __glibcpp_char_min (char)__glibcpp_signed_char_min
-#define __glibcpp_char_max (char)__glibcpp_signed_char_max
-#define __glibcpp_char_digits __glibcpp_signed_char_digits
-#define __glibcpp_char_digits10 __glibcpp_signed_char_digits10
-#else
-#define __glibcpp_char_min (char)__glibcpp_unsigned_char_min
-#define __glibcpp_char_max (char)__glibcpp_unsigned_char_max
-#define __glibcpp_char_digits __glibcpp_unsigned_char_digits
-#define __glibcpp_char_digits10 __glibcpp_unsigned_char_digits10
-#endif
-
-// short
-
-#define __glibcpp_signed_short_traps true
-#define __glibcpp_unsigned_short_traps true
-#ifndef __glibcpp_signed_short_is_modulo
-#define __glibcpp_signed_short_is_modulo true
-#endif
-#if __glibcpp_short_bits == 8
-#define __glibcpp_signed_short_min __glibcpp_s8_min
-#define __glibcpp_signed_short_max __glibcpp_s8_max
-#define __glibcpp_signed_short_digits __glibcpp_s8_digits
-#define __glibcpp_signed_short_digits10 __glibcpp_s8_digits10
-#define __glibcpp_unsigned_short_min __glibcpp_u8_min
-#define __glibcpp_unsigned_short_max __glibcpp_u8_max
-#define __glibcpp_unsigned_short_digits __glibcpp_u8_digits
-#define __glibcpp_unsigned_short_digits10 __glibcpp_u8_digits10
-#elif __glibcpp_short_bits == 16
-#define __glibcpp_signed_short_min __glibcpp_s16_min
-#define __glibcpp_signed_short_max __glibcpp_s16_max
-#define __glibcpp_signed_short_digits __glibcpp_s16_digits
-#define __glibcpp_signed_short_digits10 __glibcpp_s16_digits10
-#define __glibcpp_unsigned_short_min __glibcpp_u16_min
-#define __glibcpp_unsigned_short_max __glibcpp_u16_max
-#define __glibcpp_unsigned_short_digits __glibcpp_u16_digits
-#define __glibcpp_unsigned_short_digits10 __glibcpp_u16_digits10
-#elif __glibcpp_short_bits == 32
-#define __glibcpp_signed_short_min (short)__glibcpp_s32_min
-#define __glibcpp_signed_short_max (short)__glibcpp_s32_max
-#define __glibcpp_signed_short_digits __glibcpp_s32_digits
-#define __glibcpp_signed_short_digits10 __glibcpp_s32_digits10
-#define __glibcpp_unsigned_short_min (unsigned short)__glibcpp_u32_min
-#define __glibcpp_unsigned_short_max (unsigned short)__glibcpp_u32_max
-#define __glibcpp_unsigned_short_digits __glibcpp_u32_digits
-#define __glibcpp_unsigned_short_digits10 __glibcpp_u32_digits10
-#elif __glibcpp_short_bits == 64
-#define __glibcpp_signed_short_min (short)__glibcpp_s64_min
-#define __glibcpp_signed_short_max (short)__glibcpp_s64_max
-#define __glibcpp_signed_short_digits __glibcpp_s64_digits
-#define __glibcpp_signed_short_digits10 __glibcpp_s64_digits10
-#define __glibcpp_unsigned_short_min (unsigned short)__glibcpp_u64_min
-#define __glibcpp_unsigned_short_max (unsigned short)__glibcpp_u64_max
-#define __glibcpp_unsigned_short_digits __glibcpp_u64_digits
-#define __glibcpp_unsigned_short_digits10 __glibcpp_u64_digits10
-#else
-// You must define these macros in the configuration file.
-#endif
-
-// int
-
-#define __glibcpp_signed_int_traps true
-#define __glibcpp_unsigned_int_traps true
-#ifndef __glibcpp_signed_int_is_modulo
-#define __glibcpp_signed_int_is_modulo true
-#endif
-#if __glibcpp_int_bits == 8
-#define __glibcpp_signed_int_min __glibcpp_s8_min
-#define __glibcpp_signed_int_max __glibcpp_s8_max
-#define __glibcpp_signed_int_digits __glibcpp_s8_digits
-#define __glibcpp_signed_int_digits10 __glibcpp_s8_digits10
-#define __glibcpp_unsigned_int_min __glibcpp_u8_min
-#define __glibcpp_unsigned_int_max __glibcpp_u8_max
-#define __glibcpp_unsigned_int_digits __glibcpp_u8_digits
-#define __glibcpp_unsigned_int_digits10 __glibcpp_u8_digits10
-#elif __glibcpp_int_bits == 16
-#define __glibcpp_signed_int_min __glibcpp_s16_min
-#define __glibcpp_signed_int_max __glibcpp_s16_max
-#define __glibcpp_signed_int_digits __glibcpp_s16_digits
-#define __glibcpp_signed_int_digits10 __glibcpp_s16_digits10
-#define __glibcpp_unsigned_int_min __glibcpp_u16_min
-#define __glibcpp_unsigned_int_max __glibcpp_u16_max
-#define __glibcpp_unsigned_int_digits __glibcpp_u16_digits
-#define __glibcpp_unsigned_int_digits10 __glibcpp_u16_digits10
-#elif __glibcpp_int_bits == 32
-#define __glibcpp_signed_int_min (int)__glibcpp_s32_min
-#define __glibcpp_signed_int_max (int)__glibcpp_s32_max
-#define __glibcpp_signed_int_digits __glibcpp_s32_digits
-#define __glibcpp_signed_int_digits10 __glibcpp_s32_digits10
-#define __glibcpp_unsigned_int_min (unsigned)__glibcpp_u32_min
-#define __glibcpp_unsigned_int_max (unsigned)__glibcpp_u32_max
-#define __glibcpp_unsigned_int_digits __glibcpp_u32_digits
-#define __glibcpp_unsigned_int_digits10 __glibcpp_u32_digits10
-#elif __glibcpp_int_bits == 64
-#define __glibcpp_signed_int_min (int)__glibcpp_s64_min
-#define __glibcpp_signed_int_max (int)__glibcpp_s64_max
-#define __glibcpp_signed_int_digits __glibcpp_s64_digits
-#define __glibcpp_signed_int_digits10 __glibcpp_s64_digits10
-#define __glibcpp_unsigned_int_min (unsigned)__glibcpp_u64_min
-#define __glibcpp_unsigned_int_max (unsigned)__glibcpp_u64_max
-#define __glibcpp_unsigned_int_digits __glibcpp_u64_digits
-#define __glibcpp_unsigned_int_digits10 __glibcpp_u64_digits10
-#else
-// You must define these macros in the configuration file.
-#endif
-
-// long
-
-#define __glibcpp_signed_long_traps true
-#define __glibcpp_unsigned_long_traps true
-#ifndef __glibcpp_signed_long_is_modulo
-#define __glibcpp_signed_long_is_modulo true
-#endif
-#if __glibcpp_long_bits == 8
-#define __glibcpp_signed_long_min __glibcpp_s8_min
-#define __glibcpp_signed_long_max __glibcpp_s8_max
-#define __glibcpp_signed_long_digits __glibcpp_s8_digits
-#define __glibcpp_signed_long_digits10 __glibcpp_s8_digits10
-#define __glibcpp_unsigned_long_min __glibcpp_u8_min
-#define __glibcpp_unsigned_long_max __glibcpp_u8_max
-#define __glibcpp_unsigned_long_digits __glibcpp_u8_digits
-#define __glibcpp_unsigned_long_digits10 __glibcpp_u8_digits10
-#elif __glibcpp_long_bits == 16
-#define __glibcpp_signed_long_min __glibcpp_s16_min
-#define __glibcpp_signed_long_max __glibcpp_s16_max
-#define __glibcpp_signed_long_digits __glibcpp_s16_digits
-#define __glibcpp_signed_long_digits10 __glibcpp_s16_digits10
-#define __glibcpp_unsigned_long_min __glibcpp_u16_min
-#define __glibcpp_unsigned_long_max __glibcpp_u16_max
-#define __glibcpp_unsigned_long_digits __glibcpp_u16_digits
-#define __glibcpp_unsigned_long_digits10 __glibcpp_u16_digits10
-#elif __glibcpp_long_bits == 32
-#define __glibcpp_signed_long_min __glibcpp_s32_min
-#define __glibcpp_signed_long_max __glibcpp_s32_max
-#define __glibcpp_signed_long_digits __glibcpp_s32_digits
-#define __glibcpp_signed_long_digits10 __glibcpp_s32_digits10
-#define __glibcpp_unsigned_long_min __glibcpp_u32_min
-#define __glibcpp_unsigned_long_max __glibcpp_u32_max
-#define __glibcpp_unsigned_long_digits __glibcpp_u32_digits
-#define __glibcpp_unsigned_long_digits10 __glibcpp_u32_digits10
-#elif __glibcpp_long_bits == 64
-#define __glibcpp_signed_long_min (long)__glibcpp_s64_min
-#define __glibcpp_signed_long_max (long)__glibcpp_s64_max
-#define __glibcpp_signed_long_digits __glibcpp_s64_digits
-#define __glibcpp_signed_long_digits10 __glibcpp_s64_digits10
-#define __glibcpp_unsigned_long_min (unsigned long)__glibcpp_u64_min
-#define __glibcpp_unsigned_long_max (unsigned long)__glibcpp_u64_max
-#define __glibcpp_unsigned_long_digits __glibcpp_u64_digits
-#define __glibcpp_unsigned_long_digits10 __glibcpp_u64_digits10
-#else
-// You must define these macros in the configuration file.
-#endif
-
-// long long
-
-#define __glibcpp_signed_long_long_traps true
-#define __glibcpp_signed_long_long_traps true
-#ifndef __glibcpp_signed_long_long_is_modulo
-#define __glibcpp_signed_long_long_is_modulo true
-#endif
-#if __glibcpp_long_long_bits == 8
-#define __glibcpp_signed_long_long_min __glibcpp_s8_min
-#define __glibcpp_signed_long_long_max __glibcpp_s8_max
-#define __glibcpp_signed_long_long_digits __glibcpp_s8_digits
-#define __glibcpp_signed_long_long_digits10 __glibcpp_s8_digits10
-#define __glibcpp_unsigned_long_long_min __glibcpp_u8_min
-#define __glibcpp_unsigned_long_long_max __glibcpp_u8_max
-#define __glibcpp_unsigned_long_long_digits __glibcpp_u8_digits
-#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u8_digits10
-#elif __glibcpp_long_long_bits == 16
-#define __glibcpp_signed_long_long_min __glibcpp_s16_min
-#define __glibcpp_signed_long_long_max __glibcpp_s16_max
-#define __glibcpp_signed_long_long_digits __glibcpp_s16_digits
-#define __glibcpp_signed_long_long_digits10 __glibcpp_s16_digits10
-#define __glibcpp_unsigned_long_long_min __glibcpp_u16_min
-#define __glibcpp_unsigned_long_long_max __glibcpp_u16_max
-#define __glibcpp_unsigned_long_long_digits __glibcpp_u16_digits
-#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u16_digits10
-#elif __glibcpp_long_long_bits == 32
-#define __glibcpp_signed_long_long_min __glibcpp_s32_min
-#define __glibcpp_signed_long_long_max __glibcpp_s32_max
-#define __glibcpp_signed_long_long_digits __glibcpp_s32_digits
-#define __glibcpp_signed_long_long_digits10 __glibcpp_s32_digits10
-#define __glibcpp_unsigned_long_long_min __glibcpp_u32_min
-#define __glibcpp_unsigned_long_long_max __glibcpp_u32_max
-#define __glibcpp_unsigned_long_long_digits __glibcpp_u32_digits
-#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u32_digits10
-#elif __glibcpp_long_long_bits == 64
-#define __glibcpp_signed_long_long_min __glibcpp_s64_min
-#define __glibcpp_signed_long_long_max __glibcpp_s64_max
-#define __glibcpp_signed_long_long_digits __glibcpp_s64_digits
-#define __glibcpp_signed_long_long_digits10 __glibcpp_s64_digits10
-#define __glibcpp_signed_long_long_traps true
-#define __glibcpp_unsigned_long_long_min __glibcpp_u64_min
-#define __glibcpp_unsigned_long_long_max __glibcpp_u64_max
-#define __glibcpp_unsigned_long_long_digits __glibcpp_u64_digits
-#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u64_digits10
-#define __glibcpp_unsigned_long_long_traps true
-#else
-// You must define these macros in the configuration file.
-#endif
-
-// wchar_t
-
-#define __glibcpp_wchar_t_traps true
-#ifndef __glibcpp_wchar_t_is_modulo
-#define __glibcpp_wchar_t_is_modulo true
-#endif
-#if __glibcpp_wchar_t_is_signed
-#if __glibcpp_wchar_t_bits == 8
-#define __glibcpp_wchar_t_min __glibcpp_s8_min
-#define __glibcpp_wchar_t_max __glibcpp_s8_max
-#define __glibcpp_wchar_t_digits __glibcpp_s8_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_s8_digits10
-#elif __glibcpp_wchar_t_bits == 16
-#define __glibcpp_wchar_t_min __glibcpp_s16_min
-#define __glibcpp_wchar_t_max __glibcpp_s16_max
-#define __glibcpp_wchar_t_digits __glibcpp_s16_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_s16_digits10
-#elif __glibcpp_wchar_t_bits == 32
-#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_s32_min
-#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_s32_max
-#define __glibcpp_wchar_t_digits __glibcpp_s32_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_s32_digits10
-#elif __glibcpp_wchar_t_bits == 64
-#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_s64_min
-#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_s64_max
-#define __glibcpp_wchar_t_digits __glibcpp_s64_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_s64_digits10
-#else
-// You must define these macros in the configuration file.
-#endif
-#else
-#if __glibcpp_wchar_t_bits == 8
-#define __glibcpp_wchar_t_min __glibcpp_u8_min
-#define __glibcpp_wchar_t_max __glibcpp_u8_max
-#define __glibcpp_wchar_t_digits __glibcpp_u8_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_u8_digits10
-#elif __glibcpp_wchar_t_bits == 16
-#define __glibcpp_wchar_t_min __glibcpp_u16_min
-#define __glibcpp_wchar_t_max __glibcpp_u16_max
-#define __glibcpp_wchar_t_digits __glibcpp_u16_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_u16_digits10
-#elif __glibcpp_wchar_t_bits == 32
-#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_u32_min
-#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_u32_max
-#define __glibcpp_wchar_t_digits __glibcpp_u32_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_u32_digits10
-#elif __glibcpp_wchar_t_bits == 64
-#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_u64_min
-#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_u64_max
-#define __glibcpp_wchar_t_digits __glibcpp_u64_digits
-#define __glibcpp_wchar_t_digits10 __glibcpp_u64_digits10
-#else
-// You must define these macros in the configuration file.
-#endif
+// GCC only intrinsicly supports modulo integral types. The only remaining
+// integral exceptional values is division by zero. Only targets that do not
+// signal division by zero in some "hard to ignore" way should use false.
+#ifndef __glibcpp_integral_traps
+# define __glibcpp_integral_traps true
#endif
// float
//
-#if __glibcpp_float_bits == 32
-#define __glibcpp_float_min __glibcpp_f32_min
-#define __glibcpp_float_max __glibcpp_f32_max
-#define __glibcpp_float_digits __glibcpp_f32_digits
-#define __glibcpp_float_digits10 __glibcpp_f32_digits10
-#define __glibcpp_float_radix __glibcpp_f32_radix
-#define __glibcpp_float_epsilon __glibcpp_f32_epsilon
-#define __glibcpp_float_round_error __glibcpp_f32_round_error
-#define __glibcpp_float_min_exponent __glibcpp_f32_min_exponent
-#define __glibcpp_float_min_exponent10 __glibcpp_f32_min_exponent10
-#define __glibcpp_float_max_exponent __glibcpp_f32_max_exponent
-#define __glibcpp_float_max_exponent10 __glibcpp_f32_max_exponent10
-#elif __glibcpp_float_bits == 64
-#define __glibcpp_float_min __glibcpp_f64_min
-#define __glibcpp_float_max __glibcpp_f64_max
-#define __glibcpp_float_digits __glibcpp_f64_digits
-#define __glibcpp_float_digits10 __glibcpp_f64_digits10
-#define __glibcpp_float_radix __glibcpp_f64_radix
-#define __glibcpp_float_epsilon __glibcpp_f64_epsilon
-#define __glibcpp_float_round_error __glibcpp_f64_round_error
-#define __glibcpp_float_min_exponent __glibcpp_f64_min_exponent
-#define __glibcpp_float_min_exponent10 __glibcpp_f64_min_exponent10
-#define __glibcpp_float_max_exponent __glibcpp_f64_max_exponent
-#define __glibcpp_float_max_exponent10 __glibcpp_f64_max_exponent10
-#elif __glibcpp_float_bits == 80
-#define __glibcpp_float_min __glibcpp_f80_min
-#define __glibcpp_float_max __glibcpp_f80_max
-#define __glibcpp_float_digits __glibcpp_f80_digits
-#define __glibcpp_float_digits10 __glibcpp_f80_digits10
-#define __glibcpp_float_radix __glibcpp_f80_radix
-#define __glibcpp_float_epsilon __glibcpp_f80_epsilon
-#define __glibcpp_float_round_error __glibcpp_f80_round_error
-#define __glibcpp_float_min_exponent __glibcpp_f80_min_exponent
-#define __glibcpp_float_min_exponent10 __glibcpp_f80_min_exponent10
-#define __glibcpp_float_max_exponent __glibcpp_f80_max_exponent
-#define __glibcpp_float_max_exponent10 __glibcpp_f80_max_exponent10
-#else
-// You must define these macros in the configuration file.
-#endif
-
-// FIXME: These are just stubs and inkorrect
-
-#ifndef __glibcpp_float_has_infinity
-#define __glibcpp_float_has_infinity false
-#endif
-
-#ifndef __glibcpp_float_has_quiet_NaN
-#define __glibcpp_float_has_quiet_NaN false
-#endif
-
-#ifndef __glibcpp_float_has_signaling_NaN
-#define __glibcpp_float_has_signaling_NaN false
-#endif
-
-#ifndef __glibcpp_float_has_denorm
-#define __glibcpp_float_has_denorm denorm_absent
-#endif
+// Default values. Should be overriden in configuration files if necessary.
#ifndef __glibcpp_float_has_denorm_loss
-#define __glibcpp_float_has_denorm_loss false
-#endif
-
-#ifndef __glibcpp_float_infinity
-#define __glibcpp_float_infinity 0.0F
-#endif
-
-#ifndef __glibcpp_float_quiet_NaN
-#define __glibcpp_float_quiet_NaN 0.0F
-#endif
-
-#ifndef __glibcpp_float_signaling_NaN
-#define __glibcpp_float_signaling_NaN 0.0F
-#endif
-
-#ifndef __glibcpp_float_denorm_min
-#define __glibcpp_float_denorm_min 0.0F
+# define __glibcpp_float_has_denorm_loss false
#endif
-
-#ifndef __glibcpp_float_is_iec559
-#define __glibcpp_float_is_iec559 false
-#endif
-
-#ifndef __glibcpp_float_is_bounded
-#define __glibcpp_float_is_bounded true
-#endif
-
-#ifndef __glibcpp_float_is_modulo
-#define __glibcpp_float_is_modulo false
-#endif
-
#ifndef __glibcpp_float_traps
-#define __glibcpp_float_traps false
+# define __glibcpp_float_traps false
#endif
-
#ifndef __glibcpp_float_tinyness_before
-#define __glibcpp_float_tinyness_before false
-#endif
-
-#ifndef __glibcpp_float_round_style
-#define __glibcpp_float_round_style round_toward_zero
+# define __glibcpp_float_tinyness_before false
#endif
// double
-#if __glibcpp_double_bits == 32
-#define __glibcpp_double_min __glibcpp_f32_min
-#define __glibcpp_double_max __glibcpp_f32_max
-#define __glibcpp_double_digits __glibcpp_f32_digits
-#define __glibcpp_double_digits10 __glibcpp_f32_digits10
-#define __glibcpp_double_radix __glibcpp_f32_radix
-#define __glibcpp_double_epsilon __glibcpp_f32_epsilon
-#define __glibcpp_double_round_error __glibcpp_f32_round_error
-#define __glibcpp_double_min_exponent __glibcpp_f32_min_exponent
-#define __glibcpp_double_min_exponent10 __glibcpp_f32_min_exponent10
-#define __glibcpp_double_max_exponent __glibcpp_f32_max_exponent
-#define __glibcpp_double_max_exponent10 __glibcpp_f32_max_exponent10
-#elif __glibcpp_double_bits == 64
-#define __glibcpp_double_min __glibcpp_f64_min
-#define __glibcpp_double_max __glibcpp_f64_max
-#define __glibcpp_double_digits __glibcpp_f64_digits
-#define __glibcpp_double_digits10 __glibcpp_f64_digits10
-#define __glibcpp_double_radix __glibcpp_f64_radix
-#define __glibcpp_double_epsilon __glibcpp_f64_epsilon
-#define __glibcpp_double_round_error __glibcpp_f64_round_error
-#define __glibcpp_double_min_exponent __glibcpp_f64_min_exponent
-#define __glibcpp_double_min_exponent10 __glibcpp_f64_min_exponent10
-#define __glibcpp_double_max_exponent __glibcpp_f64_max_exponent
-#define __glibcpp_double_max_exponent10 __glibcpp_f64_max_exponent10
-#elif __glibcpp_double_bits == 80
-#define __glibcpp_double_min __glibcpp_f80_min
-#define __glibcpp_double_max __glibcpp_f80_max
-#define __glibcpp_double_digits __glibcpp_f80_digits
-#define __glibcpp_double_digits10 __glibcpp_f80_digits10
-#define __glibcpp_double_radix __glibcpp_f80_radix
-#define __glibcpp_double_epsilon __glibcpp_f80_epsilon
-#define __glibcpp_double_round_error __glibcpp_f80_round_error
-#define __glibcpp_double_min_exponent __glibcpp_f80_min_exponent
-#define __glibcpp_double_min_exponent10 __glibcpp_f80_min_exponent10
-#define __glibcpp_double_max_exponent __glibcpp_f80_max_exponent
-#define __glibcpp_double_max_exponent10 __glibcpp_f80_max_exponent10
-#else
-// You must define these macros in the configuration file.
-#endif
-
-// FIXME: These are just stubs and inkorrect
-
-#ifndef __glibcpp_double_has_infinity
-#define __glibcpp_double_has_infinity false
-#endif
-
-#ifndef __glibcpp_double_has_quiet_NaN
-#define __glibcpp_double_has_quiet_NaN false
-#endif
-
-#ifndef __glibcpp_double_has_signaling_NaN
-#define __glibcpp_double_has_signaling_NaN false
-#endif
-
-#ifndef __glibcpp_double_has_denorm
-#define __glibcpp_double_has_denorm denorm_absent
-#endif
+// Default values. Should be overriden in configuration files if necessary.
#ifndef __glibcpp_double_has_denorm_loss
-#define __glibcpp_double_has_denorm_loss false
-#endif
-
-#ifndef __glibcpp_double_infinity
-#define __glibcpp_double_infinity 0.0
+# define __glibcpp_double_has_denorm_loss false
#endif
-
-#ifndef __glibcpp_double_quiet_NaN
-#define __glibcpp_double_quiet_NaN 0.0
-#endif
-
-#ifndef __glibcpp_double_signaling_NaN
-#define __glibcpp_double_signaling_NaN 0.0
-#endif
-
-#ifndef __glibcpp_double_denorm_min
-#define __glibcpp_double_denorm_min 0.0
-#endif
-
-#ifndef __glibcpp_double_is_iec559
-#define __glibcpp_double_is_iec559 false
-#endif
-
-#ifndef __glibcpp_double_is_bounded
-#define __glibcpp_double_is_bounded true
-#endif
-
-#ifndef __glibcpp_double_is_modulo
-#define __glibcpp_double_is_modulo false
-#endif
-
#ifndef __glibcpp_double_traps
-#define __glibcpp_double_traps false
+# define __glibcpp_double_traps false
#endif
-
#ifndef __glibcpp_double_tinyness_before
-#define __glibcpp_double_tinyness_before false
-#endif
-
-#ifndef __glibcpp_double_round_style
-#define __glibcpp_double_round_style round_toward_zero
+# define __glibcpp_double_tinyness_before false
#endif
// long double
-#if __glibcpp_long_double_bits == 32
-#define __glibcpp_long_double_min __glibcpp_f32_min
-#define __glibcpp_long_double_max __glibcpp_f32_max
-#define __glibcpp_long_double_digits __glibcpp_f32_digits
-#define __glibcpp_long_double_digits10 __glibcpp_f32_digits10
-#define __glibcpp_long_double_radix __glibcpp_f32_radix
-#define __glibcpp_long_double_epsilon __glibcpp_f32_epsilon
-#define __glibcpp_long_double_round_error __glibcpp_f32_round_error
-#define __glibcpp_long_double_min_exponent __glibcpp_f32_min_exponent
-#define __glibcpp_long_double_min_exponent10 __glibcpp_f32_min_exponent10
-#define __glibcpp_long_double_max_exponent __glibcpp_f32_max_exponent
-#define __glibcpp_long_double_max_exponent10 __glibcpp_f32_max_exponent10
-#elif __glibcpp_long_double_bits == 64
-#define __glibcpp_long_double_min __glibcpp_f64_min
-#define __glibcpp_long_double_max __glibcpp_f64_max
-#define __glibcpp_long_double_digits __glibcpp_f64_digits
-#define __glibcpp_long_double_digits10 __glibcpp_f64_digits10
-#define __glibcpp_long_double_radix __glibcpp_f64_radix
-#define __glibcpp_long_double_epsilon __glibcpp_f64_epsilon
-#define __glibcpp_long_double_round_error __glibcpp_f64_round_error
-#define __glibcpp_long_double_min_exponent __glibcpp_f64_min_exponent
-#define __glibcpp_long_double_min_exponent10 __glibcpp_f64_min_exponent10
-#define __glibcpp_long_double_max_exponent __glibcpp_f64_max_exponent
-#define __glibcpp_long_double_max_exponent10 __glibcpp_f64_max_exponent10
-#elif __glibcpp_long_double_bits == 80
-#define __glibcpp_long_double_min __glibcpp_f80_min
-#define __glibcpp_long_double_max __glibcpp_f80_max
-#define __glibcpp_long_double_digits __glibcpp_f80_digits
-#define __glibcpp_long_double_digits10 __glibcpp_f80_digits10
-#define __glibcpp_long_double_radix __glibcpp_f80_radix
-#define __glibcpp_long_double_epsilon __glibcpp_f80_epsilon
-#define __glibcpp_long_double_round_error __glibcpp_f80_round_error
-#define __glibcpp_long_double_min_exponent __glibcpp_f80_min_exponent
-#define __glibcpp_long_double_min_exponent10 __glibcpp_f80_min_exponent10
-#define __glibcpp_long_double_max_exponent __glibcpp_f80_max_exponent
-#define __glibcpp_long_double_max_exponent10 __glibcpp_f80_max_exponent10
-#elif __glibcpp_long_double_bits == 96
-#define __glibcpp_long_double_min __glibcpp_f96_min
-#define __glibcpp_long_double_max __glibcpp_f96_max
-#define __glibcpp_long_double_digits __glibcpp_f96_digits
-#define __glibcpp_long_double_digits10 __glibcpp_f96_digits10
-#define __glibcpp_long_double_radix __glibcpp_f96_radix
-#define __glibcpp_long_double_epsilon __glibcpp_f96_epsilon
-#define __glibcpp_long_double_round_error __glibcpp_f96_round_error
-#define __glibcpp_long_double_min_exponent __glibcpp_f96_min_exponent
-#define __glibcpp_long_double_min_exponent10 __glibcpp_f96_min_exponent10
-#define __glibcpp_long_double_max_exponent __glibcpp_f96_max_exponent
-#define __glibcpp_long_double_max_exponent10 __glibcpp_f96_max_exponent10
-#elif __glibcpp_long_double_bits == 128
-#define __glibcpp_long_double_min __glibcpp_f128_min
-#define __glibcpp_long_double_max __glibcpp_f128_max
-#define __glibcpp_long_double_digits __glibcpp_f128_digits
-#define __glibcpp_long_double_digits10 __glibcpp_f128_digits10
-#define __glibcpp_long_double_radix __glibcpp_f128_radix
-#define __glibcpp_long_double_epsilon __glibcpp_f128_epsilon
-#define __glibcpp_long_double_round_error __glibcpp_f128_round_error
-#define __glibcpp_long_double_min_exponent __glibcpp_f128_min_exponent
-#define __glibcpp_long_double_min_exponent10 __glibcpp_f128_min_exponent10
-#define __glibcpp_long_double_max_exponent __glibcpp_f128_max_exponent
-#define __glibcpp_long_double_max_exponent10 __glibcpp_f128_max_exponent10
-#else
-// You must define these macros in the configuration file.
-#endif
-
-// FIXME: These are just stubs and inkorrect
-
-#ifndef __glibcpp_long_double_has_infinity
-#define __glibcpp_long_double_has_infinity false
-#endif
-
-#ifndef __glibcpp_long_double_has_quiet_NaN
-#define __glibcpp_long_double_has_quiet_NaN false
-#endif
-
-#ifndef __glibcpp_long_double_has_signaling_NaN
-#define __glibcpp_long_double_has_signaling_NaN false
-#endif
-
-#ifndef __glibcpp_long_double_has_denorm
-#define __glibcpp_long_double_has_denorm denorm_absent
-#endif
+// Default values. Should be overriden in configuration files if necessary.
#ifndef __glibcpp_long_double_has_denorm_loss
-#define __glibcpp_long_double_has_denorm_loss false
-#endif
-
-#ifndef __glibcpp_long_double_infinity
-#define __glibcpp_long_double_infinity 0.0L
+# define __glibcpp_long_double_has_denorm_loss false
#endif
-
-#ifndef __glibcpp_long_double_quiet_NaN
-#define __glibcpp_long_double_quiet_NaN 0.0L
-#endif
-
-#ifndef __glibcpp_long_double_signaling_NaN
-#define __glibcpp_long_double_signaling_NaN 0.0L
+#ifndef __glibcpp_long_double_traps
+# define __glibcpp_long_double_traps false
#endif
-
-#ifndef __glibcpp_long_double_denorm_min
-#define __glibcpp_long_double_denorm_min 0.0L
+#ifndef __glibcpp_long_double_tinyness_before
+# define __glibcpp_long_double_tinyness_before false
#endif
-#ifndef __glibcpp_long_double_is_iec559
-#define __glibcpp_long_double_is_iec559 false
-#endif
+// You should not need to define any macros below this point.
-#ifndef __glibcpp_long_double_is_bounded
-#define __glibcpp_long_double_is_bounded true
-#endif
+#define __glibcpp_signed(T) ((T)(-1) < 0)
-#ifndef __glibcpp_long_double_is_modulo
-#define __glibcpp_long_double_is_modulo false
-#endif
+#define __glibcpp_min(T) \
+ (__glibcpp_signed (T) ? (T)1 << __glibcpp_digits (T) : (T)0)
-#ifndef __glibcpp_long_double_traps
-#define __glibcpp_long_double_traps false
-#endif
+#define __glibcpp_max(T) \
+ (__glibcpp_signed (T) ? ((T)1 << __glibcpp_digits (T)) - 1 : ~(T)0)
-#ifndef __glibcpp_long_double_tinyness_before
-#define __glibcpp_long_double_tinyness_before false
-#endif
+#define __glibcpp_digits(T) \
+ (sizeof(T) * __CHAR_BIT__ - __glibcpp_signed (T))
-#ifndef __glibcpp_long_double_round_style
-#define __glibcpp_long_double_round_style round_toward_zero
-#endif
+// The fraction 643/2136 approximates log10(2) to 7 significant digits.
+#define __glibcpp_digits10(T) \
+ (__glibcpp_digits (T) * 643 / 2136)
namespace std
{
- enum float_round_style
+ enum float_round_style
{
round_indeterminate = -1,
round_toward_zero = 0,
@@ -895,7 +158,7 @@ namespace std
round_toward_neg_infinity = 3
};
- enum float_denorm_style
+ enum float_denorm_style
{
denorm_indeterminate = -1,
denorm_absent = 0,
@@ -920,7 +183,7 @@ namespace std
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
-
+
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
@@ -936,8 +199,8 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
- template<typename _Tp>
- struct numeric_limits : public __numeric_limits_base
+ template<typename _Tp>
+ struct numeric_limits : public __numeric_limits_base
{
static _Tp min() throw() { return static_cast<_Tp>(0); }
static _Tp max() throw() { return static_cast<_Tp>(0); }
@@ -950,7 +213,7 @@ namespace std
};
// Now there follow 15 explicit specializations. Yes, 15. Make sure
- // you get the count right.
+ // you get the count right.
template<>
struct numeric_limits<bool>
{
@@ -958,11 +221,10 @@ namespace std
static bool min() throw()
{ return false; }
-
static bool max() throw()
{ return true; }
- static const int digits = __glibcpp_bool_digits;
+ static const int digits = 1;
static const int digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = true;
@@ -1000,34 +262,31 @@ namespace std
// It is not clear what it means for a boolean type to trap.
// This is a DR on the LWG issue list. Here, I use integer
// promotion semantics.
- static const bool traps = __glibcpp_signed_int_traps
- || __glibcpp_signed_long_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_bool_digits
-
template<>
struct numeric_limits<char>
{
static const bool is_specialized = true;
static char min() throw()
- { return __glibcpp_char_min; }
+ { return __glibcpp_min(char); }
static char max() throw()
- { return __glibcpp_char_max; }
+ { return __glibcpp_max(char); }
- static const int digits = __glibcpp_char_digits;
- static const int digits10 = __glibcpp_char_digits10;
- static const bool is_signed = __glibcpp_plain_char_is_signed;
+ static const int digits = __glibcpp_digits (char);
+ static const int digits10 = __glibcpp_digits10 (char);
+ static const bool is_signed = __glibcpp_signed (char);
static const bool is_integer = true;
static const bool is_exact = true;
static const int radix = 2;
static char epsilon() throw()
- { return char(); }
+ { return 0; }
static char round_error() throw()
- { return char(); }
+ { return 0; }
static const int min_exponent = 0;
static const int min_exponent10 = 0;
@@ -1051,35 +310,25 @@ namespace std
static const bool is_iec559 = false;
static const bool is_bounded = true;
- static const bool is_modulo = __glibcpp_char_is_modulo;
+ static const bool is_modulo = true;
- static const bool traps = __glibcpp_char_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_char_min
-#undef __glibcpp_char_max
-#undef __glibcpp_char_digits
-#undef __glibcpp_char_digits10
-#undef __glibcpp_char_is_signed
-#undef __glibcpp_char_is_modulo
-#undef __glibcpp_char_traps
-
-
-
template<>
struct numeric_limits<signed char>
{
static const bool is_specialized = true;
static signed char min() throw()
- { return __glibcpp_signed_char_min; }
+ { return -__SCHAR_MAX__ - 1; }
static signed char max() throw()
- { return __glibcpp_signed_char_max; }
+ { return __SCHAR_MAX__; }
- static const int digits = __glibcpp_signed_char_digits;
- static const int digits10 = __glibcpp_signed_char_digits10;
+ static const int digits = __glibcpp_digits (signed char);
+ static const int digits10 = __glibcpp_digits10 (signed char);
static const bool is_signed = true;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1111,20 +360,13 @@ namespace std
static const bool is_iec559 = false;
static const bool is_bounded = true;
- static const bool is_modulo = __glibcpp_signed_char_is_modulo;
+ static const bool is_modulo = true;
- static const bool traps = __glibcpp_signed_char_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_signed_char_min
-#undef __glibcpp_signed_char_max
-#undef __glibcpp_signed_char_digits
-#undef __glibcpp_signed_char_digits10
-#undef __glibcpp_signed_char_is_modulo
-#undef __glibcpp_signed_char_traps
-
template<>
struct numeric_limits<unsigned char>
{
@@ -1133,10 +375,10 @@ namespace std
static unsigned char min() throw()
{ return 0; }
static unsigned char max() throw()
- { return __glibcpp_unsigned_char_max; }
+ { return __SCHAR_MAX__ * 2U + 1; }
- static const int digits = __glibcpp_unsigned_char_digits;
- static const int digits10 = __glibcpp_unsigned_char_digits10;
+ static const int digits = __glibcpp_digits (unsigned char);
+ static const int digits10 = __glibcpp_digits10 (unsigned char);
static const bool is_signed = false;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1170,29 +412,24 @@ namespace std
static const bool is_bounded = true;
static const bool is_modulo = true;
- static const bool traps = __glibcpp_unsigned_char_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_unsigned_char_max
-#undef __glibcpp_unsigned_char_digits
-#undef __glibcpp_unsigned_char_digits10
-#undef __glibcpp_unsigned_char_traps
-
template<>
struct numeric_limits<wchar_t>
{
static const bool is_specialized = true;
static wchar_t min() throw()
- { return __glibcpp_wchar_t_min; }
+ { return __glibcpp_min (wchar_t); }
static wchar_t max() throw()
- { return __glibcpp_wchar_t_max; }
+ { return __glibcpp_max (wchar_t); }
- static const int digits = __glibcpp_wchar_t_digits;
- static const int digits10 = __glibcpp_wchar_t_digits10;
- static const bool is_signed = __glibcpp_wchar_t_is_signed;
+ static const int digits = __glibcpp_digits (wchar_t);
+ static const int digits10 = __glibcpp_digits10 (wchar_t);
+ static const bool is_signed = __glibcpp_signed (wchar_t);
static const bool is_integer = true;
static const bool is_exact = true;
static const int radix = 2;
@@ -1223,33 +460,25 @@ namespace std
static const bool is_iec559 = false;
static const bool is_bounded = true;
- static const bool is_modulo = __glibcpp_wchar_t_is_modulo;
+ static const bool is_modulo = true;
- static const bool traps = __glibcpp_wchar_t_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_wchar_t_min
-#undef __glibcpp_wchar_t_max
-#undef __glibcpp_wchar_t_digits
-#undef __glibcpp_wchar_t_digits10
-#undef __glibcpp_wchar_t_is_signed
-#undef __glibcpp_wchar_t_is_modulo
-#undef __glibcpp_wchar_t_traps
-
template<>
struct numeric_limits<short>
{
static const bool is_specialized = true;
static short min() throw()
- { return __glibcpp_signed_short_min; }
+ { return -__SHRT_MAX__ - 1; }
static short max() throw()
- { return __glibcpp_signed_short_max; }
+ { return __SHRT_MAX__; }
- static const int digits = __glibcpp_signed_short_digits;
- static const int digits10 = __glibcpp_signed_short_digits10;
+ static const int digits = __glibcpp_digits (short);
+ static const int digits10 = __glibcpp_digits10 (short);
static const bool is_signed = true;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1279,22 +508,15 @@ namespace std
static short denorm_min() throw()
{ return short(); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
- static const bool is_modulo = __glibcpp_signed_short_is_modulo;
+ static const bool is_modulo = true;
- static const bool traps = __glibcpp_signed_short_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_signed_short_min
-#undef __glibcpp_signed_short_max
-#undef __glibcpp_signed_short_digits
-#undef __glibcpp_signed_short_digits10
-#undef __glibcpp_signed_short_is_modulo
-#undef __glibcpp_signed_short_traps
-
template<>
struct numeric_limits<unsigned short>
{
@@ -1303,10 +525,10 @@ namespace std
static unsigned short min() throw()
{ return 0; }
static unsigned short max() throw()
- { return __glibcpp_unsigned_short_max; }
+ { return __SHRT_MAX__ * 2U + 1; }
- static const int digits = __glibcpp_unsigned_short_digits;
- static const int digits10 = __glibcpp_unsigned_short_digits10;
+ static const int digits = __glibcpp_digits (unsigned short);
+ static const int digits10 = __glibcpp_digits10 (unsigned short);
static const bool is_signed = false;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1336,32 +558,27 @@ namespace std
static unsigned short denorm_min() throw()
{ return static_cast<unsigned short>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
- static const bool traps = __glibcpp_unsigned_short_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_unsigned_short_max
-#undef __glibcpp_unsigned_short_digits
-#undef __glibcpp_unsigned_short_digits10
-#undef __glibcpp_unsigned_short_traps
-
template<>
struct numeric_limits<int>
{
static const bool is_specialized = true;
static int min() throw()
- { return __glibcpp_signed_int_min; }
+ { return -__INT_MAX__ - 1; }
static int max() throw()
- { return __glibcpp_signed_int_max; }
+ { return __INT_MAX__; }
- static const int digits = __glibcpp_signed_int_digits;
- static const int digits10 = __glibcpp_signed_int_digits10;
+ static const int digits = __glibcpp_digits (int);
+ static const int digits10 = __glibcpp_digits10 (int);
static const bool is_signed = true;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1391,22 +608,15 @@ namespace std
static int denorm_min() throw()
{ return static_cast<int>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
- static const bool is_modulo = __glibcpp_signed_int_is_modulo;
+ static const bool is_modulo = true;
- static const bool traps = __glibcpp_signed_int_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_signed_int_min
-#undef __glibcpp_signed_int_max
-#undef __glibcpp_signed_int_digits
-#undef __glibcpp_signed_int_digits10
-#undef __glibcpp_signed_int_is_modulo
-#undef __glibcpp_signed_int_traps
-
template<>
struct numeric_limits<unsigned int>
{
@@ -1414,11 +624,11 @@ namespace std
static unsigned int min() throw()
{ return 0; }
- static unsigned int max() throw()
- { return __glibcpp_unsigned_int_max; }
+ static unsigned int max() throw()
+ { return __INT_MAX__ * 2U + 1; }
- static const int digits = __glibcpp_unsigned_int_digits;
- static const int digits10 = __glibcpp_unsigned_int_digits10;
+ static const int digits = __glibcpp_digits (unsigned int);
+ static const int digits10 = __glibcpp_digits10 (unsigned int);
static const bool is_signed = false;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1448,32 +658,27 @@ namespace std
static unsigned int denorm_min() throw()
{ return static_cast<unsigned int>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
- static const bool traps = __glibcpp_unsigned_int_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_unsigned_int_max
-#undef __glibcpp_unsigned_int_digits
-#undef __glibcpp_unsigned_int_digits10
-#undef __glibcpp_unsigned_int_traps
-
template<>
struct numeric_limits<long>
{
static const bool is_specialized = true;
static long min() throw()
- { return __glibcpp_signed_long_min; }
+ { return -__LONG_MAX__ - 1; }
static long max() throw()
- { return __glibcpp_signed_long_max; }
+ { return __LONG_MAX__; }
- static const int digits = __glibcpp_signed_long_digits;
- static const int digits10 = __glibcpp_signed_long_digits10;
+ static const int digits = __glibcpp_digits (long);
+ static const int digits10 = __glibcpp_digits10 (long);
static const bool is_signed = true;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1503,22 +708,15 @@ namespace std
static long denorm_min() throw()
{ return static_cast<long>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
- static const bool is_modulo = __glibcpp_signed_long_is_modulo;
+ static const bool is_modulo = true;
- static const bool traps = __glibcpp_signed_long_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_signed_long_min
-#undef __glibcpp_signed_long_max
-#undef __glibcpp_signed_long_digits
-#undef __glibcpp_signed_long_digits10
-#undef __glibcpp_signed_long_is_modulo
-#undef __glibcpp_signed_long_traps
-
template<>
struct numeric_limits<unsigned long>
{
@@ -1527,10 +725,10 @@ namespace std
static unsigned long min() throw()
{ return 0; }
static unsigned long max() throw()
- { return __glibcpp_unsigned_long_max; }
+ { return __LONG_MAX__ * 2UL + 1; }
- static const int digits = __glibcpp_unsigned_long_digits;
- static const int digits10 = __glibcpp_unsigned_long_digits10;
+ static const int digits = __glibcpp_digits (unsigned long);
+ static const int digits10 = __glibcpp_digits10 (unsigned long);
static const bool is_signed = false;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1560,32 +758,27 @@ namespace std
static unsigned long denorm_min() throw()
{ return static_cast<unsigned long>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
- static const bool traps = __glibcpp_unsigned_long_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_unsigned_long_max
-#undef __glibcpp_unsigned_long_digits
-#undef __glibcpp_unsigned_long_digits10
-#undef __glibcpp_unsigned_long_traps
-
template<>
struct numeric_limits<long long>
{
static const bool is_specialized = true;
-
+
static long long min() throw()
- { return __glibcpp_signed_long_long_min; }
+ { return -__LONG_LONG_MAX__ - 1; }
static long long max() throw()
- { return __glibcpp_signed_long_long_max; }
-
- static const int digits = __glibcpp_signed_long_long_digits;
- static const int digits10 = __glibcpp_signed_long_long_digits10;
+ { return __LONG_LONG_MAX__; }
+
+ static const int digits = __glibcpp_digits (long long);
+ static const int digits10 = __glibcpp_digits10 (long long);
static const bool is_signed = true;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1594,18 +787,18 @@ namespace std
{ return 0; }
static long long round_error() throw()
{ return 0; }
-
+
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
-
+
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
-
+
static long long infinity() throw()
{ return static_cast<long long>(0); }
static long long quiet_NaN() throw()
@@ -1614,23 +807,16 @@ namespace std
{ return static_cast<long long>(0); }
static long long denorm_min() throw()
{ return static_cast<long long>(0); }
-
- static const bool is_iec559 = true;
+
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
- static const bool is_modulo = __glibcpp_signed_long_long_is_modulo;
+ static const bool is_modulo = true;
- static const bool traps = __glibcpp_signed_long_long_traps;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_signed_long_long_min
-#undef __glibcpp_signed_long_long_max
-#undef __glibcpp_signed_long_long_digits
-#undef __glibcpp_signed_long_long_digits10
-#undef __glibcpp_signed_long_long_is_modulo
-#undef __glibcpp_signed_long_long_traps
-
template<>
struct numeric_limits<unsigned long long>
{
@@ -1639,10 +825,10 @@ namespace std
static unsigned long long min() throw()
{ return 0; }
static unsigned long long max() throw()
- { return __glibcpp_unsigned_long_long_max; }
+ { return __LONG_LONG_MAX__ * 2ULL + 1; }
- static const int digits = __glibcpp_unsigned_long_long_digits;
- static const int digits10 = __glibcpp_unsigned_long_long_digits10;
+ static const int digits = __glibcpp_digits (unsigned long long);
+ static const int digits10 = __glibcpp_digits10 (unsigned long long);
static const bool is_signed = false;
static const bool is_integer = true;
static const bool is_exact = true;
@@ -1672,95 +858,72 @@ namespace std
static unsigned long long denorm_min() throw()
{ return static_cast<unsigned long long>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
- static const bool traps = true;
+ static const bool traps = __glibcpp_integral_traps;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
-#undef __glibcpp_unsigned_long_long_max
-#undef __glibcpp_unsigned_long_long_digits
-#undef __glibcpp_unsigned_long_long_digits10
-#undef __glibcpp_unsigned_long_long_traps
-
template<>
struct numeric_limits<float>
{
static const bool is_specialized = true;
static float min() throw()
- { return __glibcpp_float_min; }
+ { return __FLT_MIN__; }
static float max() throw()
- { return __glibcpp_float_max; }
+ { return __FLT_MAX__; }
- static const int digits = __glibcpp_float_digits;
- static const int digits10 = __glibcpp_float_digits10;
+ static const int digits = __FLT_MANT_DIG__;
+ static const int digits10 = __FLT_DIG__;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
- static const int radix = __glibcpp_float_radix;
+ static const int radix = __FLT_RADIX__;
static float epsilon() throw()
- { return __glibcpp_float_epsilon; }
+ { return __FLT_EPSILON__; }
static float round_error() throw()
- { return __glibcpp_float_round_error; }
-
- static const int min_exponent = __glibcpp_float_min_exponent;
- static const int min_exponent10 = __glibcpp_float_min_exponent10;
- static const int max_exponent = __glibcpp_float_max_exponent;
- static const int max_exponent10 = __glibcpp_float_max_exponent10;
-
- static const bool has_infinity = __glibcpp_float_has_infinity;
- static const bool has_quiet_NaN = __glibcpp_float_has_quiet_NaN;
- static const bool has_signaling_NaN = __glibcpp_float_has_signaling_NaN;
- static const float_denorm_style has_denorm = __glibcpp_float_has_denorm;
+ { return 0.5F; }
+
+ static const int min_exponent = __FLT_MIN_EXP__;
+ static const int min_exponent10 = __FLT_MIN_10_EXP__;
+ static const int max_exponent = __FLT_MAX_EXP__;
+ static const int max_exponent10 = __FLT_MAX_10_EXP__;
+
+ static const bool has_infinity
+ = __builtin_huge_valf () / 2 == __builtin_huge_valf ();
+ static const bool has_quiet_NaN
+ = __builtin_nanf ("") != __builtin_nanf ("");
+ static const bool has_signaling_NaN = has_quiet_NaN;
+ static const float_denorm_style has_denorm
+ = __FLT_DENORM_MIN__ ? denorm_present : denorm_absent;
static const bool has_denorm_loss = __glibcpp_float_has_denorm_loss;
static float infinity() throw()
- { return __glibcpp_float_infinity; }
+ { return __builtin_huge_valf (); }
static float quiet_NaN() throw()
- { return __glibcpp_float_quiet_NaN; }
+ { return __builtin_nanf (""); }
static float signaling_NaN() throw()
- { return __glibcpp_float_signaling_NaN; }
+ { return __builtin_nansf (""); }
static float denorm_min() throw()
- { return __glibcpp_float_denorm_min; }
+ { return __FLT_DENORM_MIN__; }
- static const bool is_iec559 = __glibcpp_float_is_iec559;
- static const bool is_bounded = __glibcpp_float_is_bounded;
- static const bool is_modulo = __glibcpp_float_is_modulo;
+ static const bool is_iec559
+ = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
+ static const bool is_bounded = true;
+ static const bool is_modulo = false;
static const bool traps = __glibcpp_float_traps;
static const bool tinyness_before = __glibcpp_float_tinyness_before;
- static const float_round_style round_style = __glibcpp_float_round_style;
+ static const float_round_style round_style = round_to_nearest;
};
-#undef __glibcpp_float_min
-#undef __glibcpp_float_max
-#undef __glibcpp_float_digits
-#undef __glibcpp_float_digits10
-#undef __glibcpp_float_radix
-#undef __glibcpp_float_round_error
-#undef __glibcpp_float_min_exponent
-#undef __glibcpp_float_min_exponent10
-#undef __glibcpp_float_max_exponent
-#undef __glibcpp_float_max_exponent10
-#undef __glibcpp_float_has_infinity
-#undef __glibcpp_float_has_quiet_NaN
-#undef __glibcpp_float_has_signaling_NaN
-#undef __glibcpp_float_has_denorm
#undef __glibcpp_float_has_denorm_loss
-#undef __glibcpp_float_infinity
-#undef __glibcpp_float_quiet_NaN
-#undef __glibcpp_float_signaling_NaN
-#undef __glibcpp_float_denorm_min
-#undef __glibcpp_float_is_iec559
-#undef __glibcpp_float_is_bounded
-#undef __glibcpp_float_is_modulo
#undef __glibcpp_float_traps
#undef __glibcpp_float_tinyness_before
-#undef __glibcpp_float_round_style
template<>
struct numeric_limits<double>
@@ -1768,159 +931,123 @@ namespace std
static const bool is_specialized = true;
static double min() throw()
- { return __glibcpp_double_min; }
+ { return __DBL_MIN__; }
static double max() throw()
- { return __glibcpp_double_max; }
+ { return __DBL_MAX__; }
- static const int digits = __glibcpp_double_digits;
- static const int digits10 = __glibcpp_double_digits10;
+ static const int digits = __DBL_MANT_DIG__;
+ static const int digits10 = __DBL_DIG__;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
- static const int radix = __glibcpp_double_radix;
+ static const int radix = __FLT_RADIX__;
static double epsilon() throw()
- { return __glibcpp_double_epsilon; }
+ { return __DBL_EPSILON__; }
static double round_error() throw()
- { return __glibcpp_double_round_error; }
-
- static const int min_exponent = __glibcpp_double_min_exponent;
- static const int min_exponent10 = __glibcpp_double_min_exponent10;
- static const int max_exponent = __glibcpp_double_max_exponent;
- static const int max_exponent10 = __glibcpp_double_max_exponent10;
-
- static const bool has_infinity = __glibcpp_double_has_infinity;
- static const bool has_quiet_NaN = __glibcpp_double_has_quiet_NaN;
- static const bool has_signaling_NaN = __glibcpp_double_has_signaling_NaN;
- static const float_denorm_style has_denorm =
- __glibcpp_double_has_denorm;
+ { return 0.5; }
+
+ static const int min_exponent = __DBL_MIN_EXP__;
+ static const int min_exponent10 = __DBL_MIN_10_EXP__;
+ static const int max_exponent = __DBL_MAX_EXP__;
+ static const int max_exponent10 = __DBL_MAX_10_EXP__;
+
+ static const bool has_infinity
+ = __builtin_huge_val () / 2 == __builtin_huge_val ();
+ static const bool has_quiet_NaN
+ = __builtin_nan ("") != __builtin_nan ("");
+ static const bool has_signaling_NaN = has_quiet_NaN;
+ static const float_denorm_style has_denorm
+ = __DBL_DENORM_MIN__ ? denorm_present : denorm_absent;
static const bool has_denorm_loss = __glibcpp_double_has_denorm_loss;
static double infinity() throw()
- { return __glibcpp_double_infinity; }
+ { return __builtin_huge_val(); }
static double quiet_NaN() throw()
- { return __glibcpp_double_quiet_NaN; }
+ { return __builtin_nan (""); }
static double signaling_NaN() throw()
- { return __glibcpp_double_signaling_NaN; }
+ { return __builtin_nans (""); }
static double denorm_min() throw()
- { return __glibcpp_double_denorm_min; }
+ { return __DBL_DENORM_MIN__; }
- static const bool is_iec559 = __glibcpp_double_is_iec559;
- static const bool is_bounded = __glibcpp_double_is_bounded;
- static const bool is_modulo = __glibcpp_double_is_modulo;
+ static const bool is_iec559
+ = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
+ static const bool is_bounded = true;
+ static const bool is_modulo = false;
static const bool traps = __glibcpp_double_traps;
static const bool tinyness_before = __glibcpp_double_tinyness_before;
- static const float_round_style round_style =
- __glibcpp_double_round_style;
+ static const float_round_style round_style = round_to_nearest;
};
-#undef __glibcpp_double_min
-#undef __glibcpp_double_max
-#undef __glibcpp_double_digits
-#undef __glibcpp_double_digits10
-#undef __glibcpp_double_radix
-#undef __glibcpp_double_round_error
-#undef __glibcpp_double_min_exponent
-#undef __glibcpp_double_min_exponent10
-#undef __glibcpp_double_max_exponent
-#undef __glibcpp_double_max_exponent10
-#undef __glibcpp_double_has_infinity
-#undef __glibcpp_double_has_quiet_NaN
-#undef __glibcpp_double_has_signaling_NaN
-#undef __glibcpp_double_has_denorm
#undef __glibcpp_double_has_denorm_loss
-#undef __glibcpp_double_infinity
-#undef __glibcpp_double_quiet_NaN
-#undef __glibcpp_double_signaling_NaN
-#undef __glibcpp_double_denorm_min
-#undef __glibcpp_double_is_iec559
-#undef __glibcpp_double_is_bounded
-#undef __glibcpp_double_is_modulo
#undef __glibcpp_double_traps
#undef __glibcpp_double_tinyness_before
-#undef __glibcpp_double_round_style
-
-
+
template<>
struct numeric_limits<long double>
{
static const bool is_specialized = true;
static long double min() throw()
- { return __glibcpp_long_double_min; }
+ { return __LDBL_MIN__; }
static long double max() throw()
- { return __glibcpp_long_double_max; }
+ { return __LDBL_MAX__; }
- static const int digits = __glibcpp_long_double_digits;
- static const int digits10 = __glibcpp_long_double_digits10;
+ static const int digits = __LDBL_MANT_DIG__;
+ static const int digits10 = __LDBL_DIG__;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
- static const int radix = __glibcpp_long_double_radix;
+ static const int radix = __FLT_RADIX__;
static long double epsilon() throw()
- { return __glibcpp_long_double_epsilon; }
+ { return __LDBL_EPSILON__; }
static long double round_error() throw()
- { return __glibcpp_long_double_round_error; }
-
- static const int min_exponent = __glibcpp_long_double_min_exponent;
- static const int min_exponent10 = __glibcpp_long_double_min_exponent10;
- static const int max_exponent = __glibcpp_long_double_max_exponent;
- static const int max_exponent10 = __glibcpp_long_double_max_exponent10;
-
- static const bool has_infinity = __glibcpp_long_double_has_infinity;
- static const bool has_quiet_NaN = __glibcpp_long_double_has_quiet_NaN;
- static const bool has_signaling_NaN =
- __glibcpp_long_double_has_signaling_NaN;
- static const float_denorm_style has_denorm =
- __glibcpp_long_double_has_denorm;
- static const bool has_denorm_loss =
- __glibcpp_long_double_has_denorm_loss;
+ { return 0.5L; }
+
+ static const int min_exponent = __LDBL_MIN_EXP__;
+ static const int min_exponent10 = __LDBL_MIN_10_EXP__;
+ static const int max_exponent = __LDBL_MAX_EXP__;
+ static const int max_exponent10 = __LDBL_MAX_10_EXP__;
+
+ static const bool has_infinity
+ = __builtin_huge_vall () / 2 == __builtin_huge_vall ();
+ static const bool has_quiet_NaN
+ = __builtin_nanl ("") != __builtin_nanl ("");
+ static const bool has_signaling_NaN = has_quiet_NaN;
+ static const float_denorm_style has_denorm
+ = __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent;
+ static const bool has_denorm_loss
+ = __glibcpp_long_double_has_denorm_loss;
static long double infinity() throw()
- { return __glibcpp_long_double_infinity; }
+ { return __builtin_huge_vall (); }
static long double quiet_NaN() throw()
- { return __glibcpp_long_double_quiet_NaN; }
+ { return __builtin_nanl (""); }
static long double signaling_NaN() throw()
- { return __glibcpp_long_double_signaling_NaN; }
+ { return __builtin_nansl (""); }
static long double denorm_min() throw()
- { return __glibcpp_long_double_denorm_min; }
+ { return __LDBL_DENORM_MIN__; }
- static const bool is_iec559 = __glibcpp_long_double_is_iec559;
- static const bool is_bounded = __glibcpp_long_double_is_bounded;
- static const bool is_modulo = __glibcpp_long_double_is_modulo;
+ static const bool is_iec559
+ = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
+ static const bool is_bounded = true;
+ static const bool is_modulo = false;
- static const bool traps = __glibcpp_long_double_traps;
+ static const bool traps = __glibcpp_long_double_traps;
static const bool tinyness_before = __glibcpp_long_double_tinyness_before;
- static const float_round_style round_style =
- __glibcpp_long_double_round_style;
+ static const float_round_style round_style = round_to_nearest;
};
-#undef __glibcpp_long_double_min
-#undef __glibcpp_long_double_max
-#undef __glibcpp_long_double_digits
-#undef __glibcpp_long_double_digits10
-#undef __glibcpp_long_double_radix
-#undef __glibcpp_long_double_round_error
-#undef __glibcpp_long_double_min_exponent
-#undef __glibcpp_long_double_min_exponent10
-#undef __glibcpp_long_double_max_exponent
-#undef __glibcpp_long_double_max_exponent10
-#undef __glibcpp_long_double_has_infinity
-#undef __glibcpp_long_double_has_quiet_NaN
-#undef __glibcpp_long_double_has_signaling_NaN
-#undef __glibcpp_long_double_has_denorm
#undef __glibcpp_long_double_has_denorm_loss
-#undef __glibcpp_long_double_infinity
-#undef __glibcpp_long_double_quiet_NaN
-#undef __glibcpp_long_double_signaling_NaN
-#undef __glibcpp_long_double_denorm_min
-#undef __glibcpp_long_double_is_iec559
-#undef __glibcpp_long_double_is_bounded
-#undef __glibcpp_long_double_is_modulo
#undef __glibcpp_long_double_traps
#undef __glibcpp_long_double_tinyness_before
-#undef __glibcpp_long_double_round_style
-
+
} // namespace std
+#undef __glibcpp_signed
+#undef __glibcpp_min
+#undef __glibcpp_max
+#undef __glibcpp_digits
+#undef __glibcpp_digits10
+
#endif // _CPP_NUMERIC_LIMITS
diff --git a/contrib/libstdc++/include/std/std_list.h b/contrib/libstdc++/include/std/std_list.h
index f32553b..84523ad 100644
--- a/contrib/libstdc++/include/std/std_list.h
+++ b/contrib/libstdc++/include/std/std_list.h
@@ -70,8 +70,9 @@
#include <bits/stl_uninitialized.h>
#include <bits/stl_list.h>
+#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
+# include <bits/list.tcc>
+#endif
+
#endif /* _CPP_LIST */
-// Local Variables:
-// mode:C++
-// End:
diff --git a/contrib/libstdc++/include/std/std_locale.h b/contrib/libstdc++/include/std/std_locale.h
index 9c46b96..2960256 100644
--- a/contrib/libstdc++/include/std/std_locale.h
+++ b/contrib/libstdc++/include/std/std_locale.h
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2002, 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
@@ -42,11 +42,8 @@
#pragma GCC system_header
#include <bits/localefwd.h>
+#include <bits/locale_classes.h>
#include <bits/locale_facets.h>
#include <bits/locale_facets.tcc>
#endif
-
-// Local Variables:
-// mode:c++
-// End:
diff --git a/contrib/libstdc++/include/std/std_memory.h b/contrib/libstdc++/include/std/std_memory.h
index 5850eb2..47c3ede 100644
--- a/contrib/libstdc++/include/std/std_memory.h
+++ b/contrib/libstdc++/include/std/std_memory.h
@@ -58,314 +58,301 @@
#include <bits/stl_uninitialized.h>
#include <bits/stl_raw_storage_iter.h>
-// Since this entire file is within namespace std, there's no reason to
-// waste two spaces along the left column. Thus the leading indentation is
-// slightly violated from here on.
namespace std
{
-/**
- * @if maint
- * This is a helper function. The unused second parameter exists to
- * permit the real get_temporary_buffer to use template parameter deduction.
- *
- * XXX This should perhaps use the pool.
- * @endif
-*/
-template <typename _Tp>
-pair<_Tp*, ptrdiff_t>
-__get_temporary_buffer(ptrdiff_t __len, _Tp*)
-{
- if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp)))
- __len = INT_MAX / sizeof(_Tp);
-
- while (__len > 0) {
- _Tp* __tmp = (_Tp*) std::malloc((std::size_t)__len * sizeof(_Tp));
- if (__tmp != 0)
- return pair<_Tp*, ptrdiff_t>(__tmp, __len);
- __len /= 2;
- }
-
- return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0);
-}
-
-/**
- * @brief This is a mostly-useless wrapper around malloc().
- * @param len The number of objects of type Tp.
- * @return See full description.
- *
- * Reinventing the wheel, but this time with prettier spokes!
- *
- * This function tries to obtain storage for @c len adjacent Tp objects.
- * The objects themselves are not constructed, of course. A pair<> is
- * returned containing "the buffer s address and capacity (in the units of
- * sizeof(Tp)), or a pair of 0 values if no storage can be obtained."
- * Note that the capacity obtained may be less than that requested if the
- * memory is unavailable; you should compare len with the .second return
- * value.
-*/
-template<typename _Tp>
- inline pair<_Tp*,ptrdiff_t>
- get_temporary_buffer(ptrdiff_t __len)
- {
- return __get_temporary_buffer(__len, (_Tp*) 0);
- }
-
-/**
- * @brief The companion to get_temporary_buffer().
- * @param p A buffer previously allocated by get_temporary_buffer.
- * @return None.
- *
- * Frees the memory pointed to by p.
- */
-template<typename _Tp>
- void
- return_temporary_buffer(_Tp* __p)
- {
- std::free(__p);
- }
-
-
-/**
- * A wrapper class to provide auto_ptr with reference semantics. For
- * example, an auto_ptr can be assigned (or constructed from) the result of
- * a function which returns an auto_ptr by value.
- *
- * All the auto_ptr_ref stuff should happen behind the scenes.
-*/
-template<typename _Tp1>
- struct auto_ptr_ref
-{
- _Tp1* _M_ptr;
-
- explicit
- auto_ptr_ref(_Tp1* __p)
- : _M_ptr(__p) {}
-};
-
-
-/**
- * @brief A simple smart pointer providing strict ownership semantics.
- *
- * The Standard says:
- * <pre>
- * An @c auto_ptr owns the object it holds a pointer to. Copying an
- * @c auto_ptr copies the pointer and transfers ownership to the destination.
- * If more than one @c auto_ptr owns the same object at the same time the
- * behavior of the program is undefined.
- *
- * The uses of @c auto_ptr include providing temporary exception-safety for
- * dynamically allocated memory, passing ownership of dynamically allocated
- * memory to a function, and returning dynamically allocated memory from a
- * function. @c auto_ptr does not meet the CopyConstructible and Assignable
- * requirements for Standard Library <a href="tables.html#65">container</a>
- * elements and thus instantiating a Standard Library container with an
- * @c auto_ptr results in undefined behavior.
- * </pre>
- * Quoted from [20.4.5]/3.
- *
- * Good examples of what can and cannot be done with auto_ptr can be found
- * in the libstdc++ testsuite.
- *
- * @if maint
- * _GLIBCPP_RESOLVE_LIB_DEFECTS
- * 127. auto_ptr<> conversion issues
- * These resolutions have all been incorporated.
- * @endif
-*/
-template<typename _Tp>
- class auto_ptr
-{
-private:
- _Tp* _M_ptr;
-
-public:
- /// The pointed-to type.
- typedef _Tp element_type;
-
/**
- * @brief An %auto_ptr is usually constructed from a raw pointer.
- * @param p A pointer (defaults to NULL).
- *
- * This object now @e owns the object pointed to by @a p.
- */
- explicit
- auto_ptr(element_type* __p = 0) throw()
- : _M_ptr(__p) { }
-
- /**
- * @brief An %auto_ptr can be constructed from another %auto_ptr.
- * @param a Another %auto_ptr of the same type.
- *
- * This object now @e owns the object previously owned by @a a, which has
- * given up ownsership.
- */
- auto_ptr(auto_ptr& __a) throw()
- : _M_ptr(__a.release()) { }
-
- /**
- * @brief An %auto_ptr can be constructed from another %auto_ptr.
- * @param a Another %auto_ptr of a different but related type.
- *
- * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type.
- *
- * This object now @e owns the object previously owned by @a a, which has
- * given up ownsership.
- */
- template<typename _Tp1>
- auto_ptr(auto_ptr<_Tp1>& __a) throw()
- : _M_ptr(__a.release()) { }
-
- /**
- * @brief %auto_ptr assignment operator.
- * @param a Another %auto_ptr of the same type.
+ * @if maint
+ * This is a helper function. The unused second parameter exists to
+ * permit the real get_temporary_buffer to use template parameter deduction.
*
- * This object now @e owns the object previously owned by @a a, which has
- * given up ownsership. The object that this one @e used to own and
- * track has been deleted.
- */
- auto_ptr&
- operator=(auto_ptr& __a) throw()
+ * XXX This should perhaps use the pool.
+ * @endif
+ */
+ template<typename _Tp>
+ pair<_Tp*, ptrdiff_t>
+ __get_temporary_buffer(ptrdiff_t __len, _Tp*)
{
- reset(__a.release());
- return *this;
+ if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp)))
+ __len = INT_MAX / sizeof(_Tp);
+
+ while (__len > 0)
+ {
+ _Tp* __tmp = (_Tp*) std::malloc((std::size_t)__len * sizeof(_Tp));
+ if (__tmp != 0)
+ return pair<_Tp*, ptrdiff_t>(__tmp, __len);
+ __len /= 2;
+ }
+ return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0);
}
/**
- * @brief %auto_ptr assignment operator.
- * @param a Another %auto_ptr of a different but related type.
+ * @brief This is a mostly-useless wrapper around malloc().
+ * @param len The number of objects of type Tp.
+ * @return See full description.
*
- * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type.
+ * Reinventing the wheel, but this time with prettier spokes!
*
- * This object now @e owns the object previously owned by @a a, which has
- * given up ownsership. The object that this one @e used to own and
- * track has been deleted.
- */
- template <typename _Tp1>
- auto_ptr&
- operator=(auto_ptr<_Tp1>& __a) throw()
- {
- reset(__a.release());
- return *this;
- }
+ * This function tries to obtain storage for @c len adjacent Tp objects.
+ * The objects themselves are not constructed, of course. A pair<> is
+ * returned containing "the buffer s address and capacity (in the units of
+ * sizeof(Tp)), or a pair of 0 values if no storage can be obtained."
+ * Note that the capacity obtained may be less than that requested if the
+ * memory is unavailable; you should compare len with the .second return
+ * value.
+ */
+ template<typename _Tp>
+ inline pair<_Tp*,ptrdiff_t>
+ get_temporary_buffer(ptrdiff_t __len)
+ { return __get_temporary_buffer(__len, (_Tp*) 0); }
/**
- * When the %auto_ptr goes out of scope, the object it owns is deleted.
- * If it no longer owns anything (i.e., @c get() is @c NULL), then this
- * has no effect.
+ * @brief The companion to get_temporary_buffer().
+ * @param p A buffer previously allocated by get_temporary_buffer.
+ * @return None.
*
- * @if maint
- * The C++ standard says there is supposed to be an empty throw
- * specification here, but omitting it is standard conforming. Its
- * presence can be detected only if _Tp::~_Tp() throws, but this is
- * prohibited. [17.4.3.6]/2
- * @end maint
- */
- ~auto_ptr() { delete _M_ptr; }
+ * Frees the memory pointed to by p.
+ */
+ template<typename _Tp>
+ void
+ return_temporary_buffer(_Tp* __p)
+ { std::free(__p); }
/**
- * @brief Smart pointer dereferencing.
+ * A wrapper class to provide auto_ptr with reference semantics. For
+ * example, an auto_ptr can be assigned (or constructed from) the result of
+ * a function which returns an auto_ptr by value.
*
- * If this %auto_ptr no longer owns anything, then this operation will
- * crash. (For a smart pointer, "no longer owns anything" is the same as
- * being a null pointer, and you know what happens when you dereference
- * one of those...)
- */
- element_type&
- operator*() const throw() { return *_M_ptr; }
+ * All the auto_ptr_ref stuff should happen behind the scenes.
+ */
+ template<typename _Tp1>
+ struct auto_ptr_ref
+ {
+ _Tp1* _M_ptr;
+
+ explicit
+ auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { }
+ };
- /**
- * @brief Smart pointer dereferencing.
- *
- * This returns the pointer itself, which the language then will
- * automatically cause to be dereferenced.
- */
- element_type*
- operator->() const throw() { return _M_ptr; }
/**
- * @brief Bypassing the smart pointer.
- * @return The raw pointer being managed.
+ * @brief A simple smart pointer providing strict ownership semantics.
*
- * You can get a copy of the pointer that this object owns, for
- * situations such as passing to a function which only accepts a raw
- * pointer.
+ * The Standard says:
+ * <pre>
+ * An @c auto_ptr owns the object it holds a pointer to. Copying an
+ * @c auto_ptr copies the pointer and transfers ownership to the destination.
+ * If more than one @c auto_ptr owns the same object at the same time the
+ * behavior of the program is undefined.
*
- * @note This %auto_ptr still owns the memory.
- */
- element_type*
- get() const throw() { return _M_ptr; }
-
- /**
- * @brief Bypassing the smart pointer.
- * @return The raw pointer being managed.
+ * The uses of @c auto_ptr include providing temporary exception-safety for
+ * dynamically allocated memory, passing ownership of dynamically allocated
+ * memory to a function, and returning dynamically allocated memory from a
+ * function. @c auto_ptr does not meet the CopyConstructible and Assignable
+ * requirements for Standard Library <a href="tables.html#65">container</a>
+ * elements and thus instantiating a Standard Library container with an
+ * @c auto_ptr results in undefined behavior.
+ * </pre>
+ * Quoted from [20.4.5]/3.
*
- * You can get a copy of the pointer that this object owns, for
- * situations such as passing to a function which only accepts a raw
- * pointer.
+ * Good examples of what can and cannot be done with auto_ptr can be found
+ * in the libstdc++ testsuite.
*
- * @note This %auto_ptr no longer owns the memory. When this object
- * goes out of scope, nothing will happen.
- */
- element_type*
- release() throw()
- {
- element_type* __tmp = _M_ptr;
- _M_ptr = 0;
- return __tmp;
- }
-
- /**
- * @brief Forcibly deletes the managed object.
- * @param p A pointer (defaults to NULL).
- *
- * This object now @e owns the object pointed to by @a p. The previous
- * object has been deleted.
- */
- void
- reset(element_type* __p = 0) throw()
- {
- if (__p != _M_ptr)
- {
- delete _M_ptr;
- _M_ptr = __p;
- }
- }
-
- /** @{
- * @brief Automatic conversions
- *
- * These operations convert an %auto_ptr into and from an auto_ptr_ref
- * automatically as needed. This allows constructs such as
- * @code
- * auto_ptr<Derived> func_returning_auto_ptr(.....);
- * ...
- * auto_ptr<Base> ptr = func_returning_auto_ptr(.....);
- * @endcode
- */
- auto_ptr(auto_ptr_ref<element_type> __ref) throw()
- : _M_ptr(__ref._M_ptr) {}
-
- auto_ptr&
- operator=(auto_ptr_ref<element_type> __ref) throw()
+ * @if maint
+ * _GLIBCPP_RESOLVE_LIB_DEFECTS
+ * 127. auto_ptr<> conversion issues
+ * These resolutions have all been incorporated.
+ * @endif
+ */
+ template<typename _Tp>
+ class auto_ptr
{
- if (__ref._M_ptr != this->get())
+ private:
+ _Tp* _M_ptr;
+
+ public:
+ /// The pointed-to type.
+ typedef _Tp element_type;
+
+ /**
+ * @brief An %auto_ptr is usually constructed from a raw pointer.
+ * @param p A pointer (defaults to NULL).
+ *
+ * This object now @e owns the object pointed to by @a p.
+ */
+ explicit
+ auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
+
+ /**
+ * @brief An %auto_ptr can be constructed from another %auto_ptr.
+ * @param a Another %auto_ptr of the same type.
+ *
+ * This object now @e owns the object previously owned by @a a,
+ * which has given up ownsership.
+ */
+ auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
+
+ /**
+ * @brief An %auto_ptr can be constructed from another %auto_ptr.
+ * @param a Another %auto_ptr of a different but related type.
+ *
+ * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type.
+ *
+ * This object now @e owns the object previously owned by @a a,
+ * which has given up ownsership.
+ */
+ template<typename _Tp1>
+ auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { }
+
+ /**
+ * @brief %auto_ptr assignment operator.
+ * @param a Another %auto_ptr of the same type.
+ *
+ * This object now @e owns the object previously owned by @a a,
+ * which has given up ownsership. The object that this one @e
+ * used to own and track has been deleted.
+ */
+ auto_ptr&
+ operator=(auto_ptr& __a) throw()
+ {
+ reset(__a.release());
+ return *this;
+ }
+
+ /**
+ * @brief %auto_ptr assignment operator.
+ * @param a Another %auto_ptr of a different but related type.
+ *
+ * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type.
+ *
+ * This object now @e owns the object previously owned by @a a,
+ * which has given up ownsership. The object that this one @e
+ * used to own and track has been deleted.
+ */
+ template<typename _Tp1>
+ auto_ptr&
+ operator=(auto_ptr<_Tp1>& __a) throw()
{
- delete _M_ptr;
- _M_ptr = __ref._M_ptr;
- }
- return *this;
- }
-
- template<typename _Tp1>
- operator auto_ptr_ref<_Tp1>() throw()
- { return auto_ptr_ref<_Tp1>(this->release()); }
-
- template<typename _Tp1>
- operator auto_ptr<_Tp1>() throw()
- { return auto_ptr<_Tp1>(this->release()); }
- /** @} */
-};
-
+ reset(__a.release());
+ return *this;
+ }
+
+ /**
+ * When the %auto_ptr goes out of scope, the object it owns is deleted.
+ * If it no longer owns anything (i.e., @c get() is @c NULL), then this
+ * has no effect.
+ *
+ * @if maint
+ * The C++ standard says there is supposed to be an empty throw
+ * specification here, but omitting it is standard conforming. Its
+ * presence can be detected only if _Tp::~_Tp() throws, but this is
+ * prohibited. [17.4.3.6]/2
+ * @end maint
+ */
+ ~auto_ptr() { delete _M_ptr; }
+
+ /**
+ * @brief Smart pointer dereferencing.
+ *
+ * If this %auto_ptr no longer owns anything, then this
+ * operation will crash. (For a smart pointer, "no longer owns
+ * anything" is the same as being a null pointer, and you know
+ * what happens when you dereference one of those...)
+ */
+ element_type&
+ operator*() const throw() { return *_M_ptr; }
+
+ /**
+ * @brief Smart pointer dereferencing.
+ *
+ * This returns the pointer itself, which the language then will
+ * automatically cause to be dereferenced.
+ */
+ element_type*
+ operator->() const throw() { return _M_ptr; }
+
+ /**
+ * @brief Bypassing the smart pointer.
+ * @return The raw pointer being managed.
+ *
+ * You can get a copy of the pointer that this object owns, for
+ * situations such as passing to a function which only accepts a raw
+ * pointer.
+ *
+ * @note This %auto_ptr still owns the memory.
+ */
+ element_type*
+ get() const throw() { return _M_ptr; }
+
+ /**
+ * @brief Bypassing the smart pointer.
+ * @return The raw pointer being managed.
+ *
+ * You can get a copy of the pointer that this object owns, for
+ * situations such as passing to a function which only accepts a raw
+ * pointer.
+ *
+ * @note This %auto_ptr no longer owns the memory. When this object
+ * goes out of scope, nothing will happen.
+ */
+ element_type*
+ release() throw()
+ {
+ element_type* __tmp = _M_ptr;
+ _M_ptr = 0;
+ return __tmp;
+ }
+
+ /**
+ * @brief Forcibly deletes the managed object.
+ * @param p A pointer (defaults to NULL).
+ *
+ * This object now @e owns the object pointed to by @a p. The previous
+ * object has been deleted.
+ */
+ void
+ reset(element_type* __p = 0) throw()
+ {
+ if (__p != _M_ptr)
+ {
+ delete _M_ptr;
+ _M_ptr = __p;
+ }
+ }
+
+ /** @{
+ * @brief Automatic conversions
+ *
+ * These operations convert an %auto_ptr into and from an auto_ptr_ref
+ * automatically as needed. This allows constructs such as
+ * @code
+ * auto_ptr<Derived> func_returning_auto_ptr(.....);
+ * ...
+ * auto_ptr<Base> ptr = func_returning_auto_ptr(.....);
+ * @endcode
+ */
+ auto_ptr(auto_ptr_ref<element_type> __ref) throw()
+ : _M_ptr(__ref._M_ptr) { }
+
+ auto_ptr&
+ operator=(auto_ptr_ref<element_type> __ref) throw()
+ {
+ if (__ref._M_ptr != this->get())
+ {
+ delete _M_ptr;
+ _M_ptr = __ref._M_ptr;
+ }
+ return *this;
+ }
+
+ template<typename _Tp1>
+ operator auto_ptr_ref<_Tp1>() throw()
+ { return auto_ptr_ref<_Tp1>(this->release()); }
+
+ template<typename _Tp1>
+ operator auto_ptr<_Tp1>() throw()
+ { return auto_ptr<_Tp1>(this->release()); }
+ /** @} */
+ };
} // namespace std
-#endif /* _CPP_MEMORY */
+#endif
diff --git a/contrib/libstdc++/include/std/std_ostream.h b/contrib/libstdc++/include/std/std_ostream.h
index eff4bb5..82f8a28 100644
--- a/contrib/libstdc++/include/std/std_ostream.h
+++ b/contrib/libstdc++/include/std/std_ostream.h
@@ -46,7 +46,14 @@
namespace std
{
- // 27.6.2.1 Template class basic_ostream
+ // [27.6.2.1] Template class basic_ostream
+ /**
+ * @brief Controlling output.
+ *
+ * This is the base class for all output streams. It provides text
+ * formatting of all builtin types, and communicates with any class
+ * derived from basic_streambuf to do the actual output.
+ */
template<typename _CharT, typename _Traits>
class basic_ostream : virtual public basic_ios<_CharT, _Traits>
{
@@ -66,20 +73,60 @@ namespace std
typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
typedef ctype<_CharT> __ctype_type;
- // 27.6.2.2 Constructor/destructor:
+ template<typename _CharT2, typename _Traits2>
+ friend basic_ostream<_CharT2, _Traits2>&
+ operator<<(basic_ostream<_CharT2, _Traits2>&, _CharT2);
+
+ template<typename _Traits2>
+ friend basic_ostream<char, _Traits2>&
+ operator<<(basic_ostream<char, _Traits2>&, char);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_ostream<_CharT2, _Traits2>&
+ operator<<(basic_ostream<_CharT2, _Traits2>&, const _CharT2*);
+
+ template<typename _Traits2>
+ friend basic_ostream<char, _Traits2>&
+ operator<<(basic_ostream<char, _Traits2>&, const char*);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_ostream<_CharT2, _Traits2>&
+ operator<<(basic_ostream<_CharT2, _Traits2>&, const char*);
+
+ // [27.6.2.2] constructor/destructor
+ /**
+ * @brief Base constructor.
+ *
+ * This ctor is almost never called by the user directly, rather from
+ * derived classes' initialization lists, which pass a pointer to
+ * their own stream buffer.
+ */
explicit
basic_ostream(__streambuf_type* __sb)
{ this->init(__sb); }
+ /**
+ * @brief Base destructor.
+ *
+ * This does very little apart from providing a virtual base dtor.
+ */
virtual
~basic_ostream() { }
- // 27.6.2.3 Prefix/suffix:
+ // [27.6.2.3] prefix/suffix
class sentry;
friend class sentry;
- // 27.6.2.5 Formatted output:
- // 27.6.2.5.3 basic_ostream::operator<<
+ // [27.6.2.5] formatted output
+ // [27.6.2.5.3] basic_ostream::operator<<
+ //@{
+ /**
+ * @brief Interface for manipulators.
+ *
+ * Manuipulators such as @c std::endl and @c std::hex use these
+ * functions in constructs like "std::cout << std::endl". For more
+ * information, see the iomanip header.
+ */
__ostream_type&
operator<<(__ostream_type& (*__pf)(__ostream_type&));
@@ -88,8 +135,35 @@ namespace std
__ostream_type&
operator<<(ios_base& (*__pf) (ios_base&));
-
- // 27.6.2.5.2 Arithmetic Inserters
+ //@}
+
+ // [27.6.2.5.2] arithmetic inserters
+ /**
+ * @name Arithmetic Inserters
+ *
+ * All the @c operator<< functions (aka <em>formatted output
+ * functions</em>) have some common behavior. Each starts by
+ * constructing a temporary object of type std::basic_ostream::sentry.
+ * This can have several effects, concluding with the setting of a
+ * status flag; see the sentry documentation for more.
+ *
+ * If the sentry status is good, the function tries to generate
+ * whatever data is appropriate for the type of the argument.
+ *
+ * If an exception is thrown during insertion, ios_base::badbit
+ * will be turned on in the stream's error state without causing an
+ * ios_base::failure to be thrown. The original exception will then
+ * be rethrown.
+ */
+ //@{
+ /**
+ * @brief Basic arithmetic inserters
+ * @param A variable of builtin type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to perform numeric formatting.
+ */
__ostream_type&
operator<<(long __n);
@@ -150,31 +224,140 @@ namespace std
__ostream_type&
operator<<(const void* __p);
+ /**
+ * @brief Extracting from another streambuf.
+ * @param sb A pointer to a streambuf
+ *
+ * This function behaves like one of the basic arithmetic extractors,
+ * in that it also constructs a sentry onject and has the same error
+ * handling behavior.
+ *
+ * If @a sb is NULL, the stream will set failbit in its error state.
+ *
+ * Characters are extracted from @a sb and inserted into @c *this
+ * until one of the following occurs:
+ *
+ * - the input stream reaches end-of-file,
+ * - insertion into the output sequence fails (in this case, the
+ * character that would have been inserted is not extracted), or
+ * - an exception occurs while getting a character from @a sb, which
+ * sets failbit in the error state
+ *
+ * If the function inserts no characters, failbit is set.
+ */
__ostream_type&
operator<<(__streambuf_type* __sb);
-
- // Unformatted output:
+ //@}
+
+ // [27.6.2.6] unformatted output functions
+ /**
+ * @name Unformatted Output Functions
+ *
+ * All the unformatted output functions have some common behavior.
+ * Each starts by constructing a temporary object of type
+ * std::basic_ostream::sentry. This has several effects, concluding
+ * with the setting of a status flag; see the sentry documentation
+ * for more.
+ *
+ * If the sentry status is good, the function tries to generate
+ * whatever data is appropriate for the type of the argument.
+ *
+ * If an exception is thrown during insertion, ios_base::badbit
+ * will be turned on in the stream's error state. If badbit is on in
+ * the stream's exceptions mask, the exception will be rethrown
+ * without completing its actions.
+ */
+ //@{
+ /**
+ * @brief Simple insertion.
+ * @param c The character to insert.
+ * @return *this
+ *
+ * Tries to insert @a c.
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
__ostream_type&
put(char_type __c);
+ /**
+ * @brief Character string insertion.
+ * @param s The array to insert.
+ * @param n Maximum number of characters to insert.
+ * @return *this
+ *
+ * Characters are copied from @a s and inserted into the stream until
+ * one of the following happens:
+ *
+ * - @a n characters are inserted
+ * - inserting into the output sequence fails (in this case, badbit
+ * will be set in the stream's error state)
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
__ostream_type&
write(const char_type* __s, streamsize __n);
-
+ //@}
+
+ /**
+ * @brief Synchronizing the stream buffer.
+ * @return *this
+ *
+ * If @c rdbuf() is a null pointer, changes nothing.
+ *
+ * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
+ * sets badbit.
+ */
__ostream_type&
flush();
- // Seeks:
+ // [27.6.2.4] seek members
+ /**
+ * @brief Getting the current write position.
+ * @return A file position object.
+ *
+ * If @c fail() is not false, returns @c pos_type(-1) to indicate
+ * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,out).
+ */
pos_type
tellp();
+ /**
+ * @brief Changing the current write position.
+ * @param pos A file position object.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If
+ * that function fails, sets failbit.
+ */
__ostream_type&
seekp(pos_type);
- __ostream_type&
+ /**
+ * @brief Changing the current write position.
+ * @param off A file offset object.
+ * @param dir The direction in which to seek.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
+ * If that function fails, sets failbit.
+ */
+ __ostream_type&
seekp(off_type, ios_base::seekdir);
};
- // 27.6.2.3 Class basic_ostream::sentry
+ /**
+ * @brief Performs setup work for output streams.
+ *
+ * Objects of this class are created before all of the standard
+ * inserters are run. It is responsible for "exception-safe prefix and
+ * suffix operations." Additional actions may be added by the
+ * implementation, and we list them in
+ * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5
+ * under [27.6] notes.
+ */
template <typename _CharT, typename _Traits>
class basic_ostream<_CharT, _Traits>::sentry
{
@@ -183,9 +366,27 @@ namespace std
basic_ostream<_CharT,_Traits>& _M_os;
public:
+ /**
+ * @brief The constructor performs preparatory work.
+ * @param os The output stream to guard.
+ *
+ * If the stream state is good (@a os.good() is true), then if the
+ * stream is tied to another output stream, @c is.tie()->flush()
+ * is called to synchronize the output sequences.
+ *
+ * If the stream state is still good, then the sentry state becomes
+ * true ("okay").
+ */
explicit
sentry(basic_ostream<_CharT,_Traits>& __os);
+ /**
+ * @brief Possibly flushes the stream.
+ *
+ * If @c ios_base::unitbuf is set in @c os.flags(), and
+ * @c std::uncaught_exception() is true, the sentry destructor calls
+ * @c flush() on the output stream.
+ */
~sentry()
{
// XXX MT
@@ -197,10 +398,34 @@ namespace std
}
}
+ /**
+ * @brief Quick status checking.
+ * @return The sentry state.
+ *
+ * For ease of use, sentries may be converted to booleans. The
+ * return value is that of the sentry state (true == okay).
+ */
operator bool()
{ return _M_ok; }
};
+ // [27.6.2.5.4] character insertion templates
+ //@{
+ /**
+ * @brief Character inserters
+ * @param out An output stream.
+ * @param c A character.
+ * @return out
+ *
+ * Behaves like one of the formatted arithmetic inserters described in
+ * std::basic_ostream. After constructing a sentry object with good
+ * status, this function inserts a single character and any required
+ * padding (as determined by [22.2.2.2.2]). @c out.width(0) is then
+ * called.
+ *
+ * If @a c is of type @c char and the character type of the stream is not
+ * @c char, the character is widened before insertion.
+ */
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c);
@@ -225,7 +450,22 @@ namespace std
basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
{ return (__out << static_cast<char>(__c)); }
+ //@}
+ //@{
+ /**
+ * @brief String inserters
+ * @param out An output stream.
+ * @param s A character string.
+ * @return out
+ * @pre @a s must be a non-NULL pointer
+ *
+ * Behaves like one of the formatted arithmetic inserters described in
+ * std::basic_ostream. After constructing a sentry object with good
+ * status, this function inserts @c traits::length(s) characters starting
+ * at @a s, widened if necessary, followed by any required padding (as
+ * determined by [22.2.2.2.2]). @c out.width(0) is then called.
+ */
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s);
@@ -249,18 +489,38 @@ namespace std
basic_ostream<char, _Traits> &
operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
{ return (__out << reinterpret_cast<const char*>(__s)); }
-
- // 27.6.2.7 Standard basic_ostream manipulators
+ //@}
+
+ // [27.6.2.7] standard basic_ostream manipulators
+ /**
+ * @brief Write a newline and flush the stream.
+ *
+ * This manipulator is often mistakenly used when a simple newline is
+ * desired, leading to poor buffering performance. See
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for more
+ * on this subject.
+ */
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
endl(basic_ostream<_CharT, _Traits>& __os)
{ return flush(__os.put(__os.widen('\n'))); }
+ /**
+ * @brief Write a null character into the output sequence.
+ *
+ * "Null character" is @c CharT() by definition. For CharT of @c char,
+ * this correctly writes the ASCII @c NUL character string terminator.
+ */
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
ends(basic_ostream<_CharT, _Traits>& __os)
{ return __os.put(_CharT()); }
+ /**
+ * @brief Flushes the output stream.
+ *
+ * This manipulator simply calls the stream's @c flush() member function.
+ */
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
flush(basic_ostream<_CharT, _Traits>& __os)
diff --git a/contrib/libstdc++/include/std/std_queue.h b/contrib/libstdc++/include/std/std_queue.h
index 6be3551..60636e6 100644
--- a/contrib/libstdc++/include/std/std_queue.h
+++ b/contrib/libstdc++/include/std/std_queue.h
@@ -74,8 +74,9 @@
#include <bits/stl_function.h>
#include <bits/stl_queue.h>
-#endif /* _CPP_QUEUE */
+#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
+# include <bits/deque.tcc>
+# include <bits/vector.tcc>
+#endif
-// Local Variables:
-// mode:C++
-// End:
+#endif /* _CPP_QUEUE */
diff --git a/contrib/libstdc++/include/std/std_sstream.h b/contrib/libstdc++/include/std/std_sstream.h
index 6ee7505..0940e60 100644
--- a/contrib/libstdc++/include/std/std_sstream.h
+++ b/contrib/libstdc++/include/std/std_sstream.h
@@ -1,6 +1,6 @@
// String based streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2002, 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
@@ -46,6 +46,18 @@
namespace std
{
+ // [27.7.1] template class basic_stringbuf
+ /**
+ * @brief The actual work of input and output (for std::string).
+ *
+ * This class associates either or both of its input and output sequences
+ * with a sequence of characters, which can be initialized from, or made
+ * available as, a @c std::basic_string. (Paraphrased from [27.7.1]/1.)
+ *
+ * For this class, open modes (of type @c ios_base::openmode) have
+ * @c in set if the input sequence can be read, and @c out set if the
+ * output sequence can be written.
+ */
template<typename _CharT, typename _Traits, typename _Alloc>
class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
{
@@ -61,22 +73,48 @@ namespace std
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
- // Non-standard Types:
+ //@{
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
typedef basic_streambuf<char_type, traits_type> __streambuf_type;
typedef basic_string<char_type, _Traits, _Alloc> __string_type;
typedef typename __string_type::size_type __size_type;
+ //@}
protected:
// Data Members:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__string_type _M_string;
public:
// Constructors:
+ /**
+ * @brief Starts with an empty string buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * The default constructor initializes the parent class using its
+ * own default ctor.
+ */
explicit
basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out)
: __streambuf_type(), _M_string()
{ _M_stringbuf_init(__mode); }
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param str A string to copy as a starting buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * This constructor initializes the parent class using its
+ * own default ctor.
+ */
explicit
basic_stringbuf(const __string_type& __str,
ios_base::openmode __mode = ios_base::in | ios_base::out)
@@ -84,6 +122,14 @@ namespace std
{ _M_stringbuf_init(__mode); }
// Get and set:
+ /**
+ * @brief Copying out the string buffer.
+ * @return A copy of one of the underlying sequences.
+ *
+ * "If the buffer is only created in input mode, the underlying
+ * character sequence is equal to the input sequence; otherwise, it
+ * is equal to the output sequence." [27.7.1.2]/1
+ */
__string_type
str() const
{
@@ -94,7 +140,7 @@ namespace std
// _M_string, and may not be the correct size of the
// current stringbuf internal buffer.
__size_type __len = _M_string.size();
- if (_M_out_cur > _M_out_beg)
+ if (_M_out_end > _M_out_beg)
__len = max(__size_type(_M_out_end - _M_out_beg), __len);
return __string_type(_M_out_beg, _M_out_beg + __len);
}
@@ -102,6 +148,13 @@ namespace std
return _M_string;
}
+ /**
+ * @brief Setting a new buffer.
+ * @param s The string to use as a new sequence.
+ *
+ * Deallocates any previous stored sequence, then copies @a s to
+ * use as a new one.
+ */
void
str(const __string_type& __s)
{
@@ -112,6 +165,11 @@ namespace std
protected:
// Common initialization code for both ctors goes here.
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
void
_M_stringbuf_init(ios_base::openmode __mode)
{
@@ -135,6 +193,7 @@ namespace std
}
// Overridden virtual functions:
+ // [documentation is inherited]
virtual int_type
underflow()
{
@@ -144,12 +203,25 @@ namespace std
return traits_type::eof();
}
+ // [documentation is inherited]
virtual int_type
pbackfail(int_type __c = traits_type::eof());
+ // [documentation is inherited]
virtual int_type
overflow(int_type __c = traits_type::eof());
+ /**
+ * @brief Manipulates the buffer.
+ * @param s Pointer to a buffer area.
+ * @param n Size of @a s.
+ * @return @c this
+ *
+ * If no buffer has already been created, and both @a s and @a n are
+ * non-zero, then @c s is used as a buffer; see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2
+ * for more.
+ */
virtual __streambuf_type*
setbuf(char_type* __s, streamsize __n)
{
@@ -161,10 +233,12 @@ namespace std
return this;
}
+ // [documentation is inherited]
virtual pos_type
seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __mode = ios_base::in | ios_base::out);
+ // [documentation is inherited]
virtual pos_type
seekpos(pos_type __sp,
ios_base::openmode __mode = ios_base::in | ios_base::out);
@@ -175,6 +249,11 @@ namespace std
// Assumes: contents of _M_string and internal buffer match exactly.
// __i == _M_in_cur - _M_in_beg
// __o == _M_out_cur - _M_out_beg
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
virtual int
_M_really_sync(__size_type __i, __size_type __o)
{
@@ -196,7 +275,15 @@ namespace std
};
- // 27.7.2 Template class basic_istringstream
+ // [27.7.2] Template class basic_istringstream
+ /**
+ * @brief Controlling input for std::string.
+ *
+ * This class supports reading from objects of type std::basic_string,
+ * using the inherited functions from std::basic_istream. To control
+ * the associated sequence, an instance of std::basic_stringbuf is used,
+ * which this page refers to as @c sb.
+ */
template<typename _CharT, typename _Traits, typename _Alloc>
class basic_istringstream : public basic_istream<_CharT, _Traits>
{
@@ -218,40 +305,104 @@ namespace std
typedef basic_istream<char_type, traits_type> __istream_type;
private:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__stringbuf_type _M_stringbuf;
public:
// Constructors:
+ /**
+ * @brief Default constructor starts with an empty string buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::in is automatically included in @a mode.
+ *
+ * Initializes @c sb using @c mode|in, and passes @c &sb to the base
+ * class initializer. Does not allocate any buffer.
+ *
+ * @if maint
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ * @endif
+ */
explicit
basic_istringstream(ios_base::openmode __mode = ios_base::in)
: __istream_type(NULL), _M_stringbuf(__mode | ios_base::in)
{ this->init(&_M_stringbuf); }
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param str A string to copy as a starting buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::in is automatically included in @a mode.
+ *
+ * Initializes @c sb using @a str and @c mode|in, and passes @c &sb
+ * to the base class initializer.
+ *
+ * @if maint
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ * @endif
+ */
explicit
basic_istringstream(const __string_type& __str,
ios_base::openmode __mode = ios_base::in)
: __istream_type(NULL), _M_stringbuf(__str, __mode | ios_base::in)
{ this->init(&_M_stringbuf); }
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The buffer is deallocated by the stringbuf object, not the
+ * formatting stream.
+ */
~basic_istringstream()
{ }
// Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_stringbuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
__stringbuf_type*
rdbuf() const
{ return const_cast<__stringbuf_type*>(&_M_stringbuf); }
+ /**
+ * @brief Copying out the string buffer.
+ * @return @c rdbuf()->str()
+ */
__string_type
str() const
{ return _M_stringbuf.str(); }
+ /**
+ * @brief Setting a new buffer.
+ * @param s The string to use as a new sequence.
+ *
+ * Calls @c rdbuf()->str(s).
+ */
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
};
- // 27.7.3 Template class basic_ostringstream
+ // [27.7.3] Template class basic_ostringstream
+ /**
+ * @brief Controlling output for std::string.
+ *
+ * This class supports writing to objects of type std::basic_string,
+ * using the inherited functions from std::basic_ostream. To control
+ * the associated sequence, an instance of std::basic_stringbuf is used,
+ * which this page refers to as @c sb.
+ */
template <typename _CharT, typename _Traits, typename _Alloc>
class basic_ostringstream : public basic_ostream<_CharT, _Traits>
{
@@ -273,40 +424,104 @@ namespace std
typedef basic_ostream<char_type, traits_type> __ostream_type;
private:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__stringbuf_type _M_stringbuf;
public:
- // Constructors/destructor:
+ // Constructors/destructor:
+ /**
+ * @brief Default constructor starts with an empty string buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::out is automatically included in @a mode.
+ *
+ * Initializes @c sb using @c mode|out, and passes @c &sb to the base
+ * class initializer. Does not allocate any buffer.
+ *
+ * @if maint
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ * @endif
+ */
explicit
basic_ostringstream(ios_base::openmode __mode = ios_base::out)
: __ostream_type(NULL), _M_stringbuf(__mode | ios_base::out)
{ this->init(&_M_stringbuf); }
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param str A string to copy as a starting buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::out is automatically included in @a mode.
+ *
+ * Initializes @c sb using @a str and @c mode|out, and passes @c &sb
+ * to the base class initializer.
+ *
+ * @if maint
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ * @endif
+ */
explicit
basic_ostringstream(const __string_type& __str,
ios_base::openmode __mode = ios_base::out)
: __ostream_type(NULL), _M_stringbuf(__str, __mode | ios_base::out)
{ this->init(&_M_stringbuf); }
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The buffer is deallocated by the stringbuf object, not the
+ * formatting stream.
+ */
~basic_ostringstream()
{ }
// Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_stringbuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
__stringbuf_type*
rdbuf() const
{ return const_cast<__stringbuf_type*>(&_M_stringbuf); }
+ /**
+ * @brief Copying out the string buffer.
+ * @return @c rdbuf()->str()
+ */
__string_type
str() const
{ return _M_stringbuf.str(); }
+ /**
+ * @brief Setting a new buffer.
+ * @param s The string to use as a new sequence.
+ *
+ * Calls @c rdbuf()->str(s).
+ */
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
};
- // 27.7.4 Template class basic_stringstream
+ // [27.7.4] Template class basic_stringstream
+ /**
+ * @brief Controlling input and output for std::string.
+ *
+ * This class supports reading from and writing to objects of type
+ * std::basic_string, using the inherited functions from
+ * std::basic_iostream. To control the associated sequence, an instance
+ * of std::basic_stringbuf is used, which this page refers to as @c sb.
+ */
template <typename _CharT, typename _Traits, typename _Alloc>
class basic_stringstream : public basic_iostream<_CharT, _Traits>
{
@@ -328,33 +543,85 @@ namespace std
typedef basic_iostream<char_type, traits_type> __iostream_type;
private:
+ /**
+ * @if maint
+ * @doctodo
+ * @endif
+ */
__stringbuf_type _M_stringbuf;
public:
// Constructors/destructors
+ /**
+ * @brief Default constructor starts with an empty string buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * Initializes @c sb using @c mode, and passes @c &sb to the base
+ * class initializer. Does not allocate any buffer.
+ *
+ * @if maint
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ * @endif
+ */
explicit
basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in)
: __iostream_type(NULL), _M_stringbuf(__m)
{ this->init(&_M_stringbuf); }
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param str A string to copy as a starting buffer.
+ * @param mode Whether the buffer can read, or write, or both.
+ *
+ * Initializes @c sb using @a str and @c mode, and passes @c &sb
+ * to the base class initializer.
+ *
+ * @if maint
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ * @endif
+ */
explicit
basic_stringstream(const __string_type& __str,
ios_base::openmode __m = ios_base::out | ios_base::in)
: __iostream_type(NULL), _M_stringbuf(__str, __m)
{ this->init(&_M_stringbuf); }
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The buffer is deallocated by the stringbuf object, not the
+ * formatting stream.
+ */
~basic_stringstream()
{ }
// Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_stringbuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
__stringbuf_type*
rdbuf() const
{ return const_cast<__stringbuf_type*>(&_M_stringbuf); }
+ /**
+ * @brief Copying out the string buffer.
+ * @return @c rdbuf()->str()
+ */
__string_type
str() const
{ return _M_stringbuf.str(); }
+ /**
+ * @brief Setting a new buffer.
+ * @param s The string to use as a new sequence.
+ *
+ * Calls @c rdbuf()->str(s).
+ */
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
diff --git a/contrib/libstdc++/include/std/std_stack.h b/contrib/libstdc++/include/std/std_stack.h
index e517c42..ddae7e7 100644
--- a/contrib/libstdc++/include/std/std_stack.h
+++ b/contrib/libstdc++/include/std/std_stack.h
@@ -70,8 +70,8 @@
#include <bits/stl_deque.h>
#include <bits/stl_stack.h>
-#endif /* _CPP_STACK */
+#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
+# include <bits/deque.tcc>
+#endif
-// Local Variables:
-// mode:C++
-// End:
+#endif /* _CPP_STACK */
diff --git a/contrib/libstdc++/include/std/std_streambuf.h b/contrib/libstdc++/include/std/std_streambuf.h
index db36ed3..a1958c1 100644
--- a/contrib/libstdc++/include/std/std_streambuf.h
+++ b/contrib/libstdc++/include/std/std_streambuf.h
@@ -50,28 +50,104 @@
namespace std
{
+ /**
+ * @if maint
+ * Does stuff.
+ * @endif
+ */
template<typename _CharT, typename _Traits>
streamsize
__copy_streambufs(basic_ios<_CharT, _Traits>& _ios,
basic_streambuf<_CharT, _Traits>* __sbin,
basic_streambuf<_CharT, _Traits>* __sbout);
- // 27.5.2 Template class basic_streambuf<_CharT, _Traits>
+ /**
+ * @brief The actual work of input and output (interface).
+ *
+ * This is a base class. Derived stream buffers each control a
+ * pair of character sequences: one for input, and one for output.
+ *
+ * Section [27.5.1] of the standard describes the requirements and
+ * behavior of stream buffer classes. That section (three paragraphs)
+ * is reproduced here, for simplicity and accuracy.
+ *
+ * -# Stream buffers can impose various constraints on the sequences
+ * they control. Some constraints are:
+ * - The controlled input sequence can be not readable.
+ * - The controlled output sequence can be not writable.
+ * - The controlled sequences can be associated with the contents of
+ * other representations for character sequences, such as external
+ * files.
+ * - The controlled sequences can support operations @e directly to or
+ * from associated sequences.
+ * - The controlled sequences can impose limitations on how the
+ * program can read characters from a sequence, write characters to
+ * a sequence, put characters back into an input sequence, or alter
+ * the stream position.
+ * .
+ * -# Each sequence is characterized by three pointers which, if non-null,
+ * all point into the same @c charT array object. The array object
+ * represents, at any moment, a (sub)sequence of characters from the
+ * sequence. Operations performed on a sequence alter the values
+ * stored in these pointers, perform reads and writes directly to or
+ * from associated sequences, and alter "the stream position" and
+ * conversion state as needed to maintain this subsequence relationship.
+ * The three pointers are:
+ * - the <em>beginning pointer</em>, or lowest element address in the
+ * array (called @e xbeg here);
+ * - the <em>next pointer</em>, or next element address that is a
+ * current candidate for reading or writing (called @e xnext here);
+ * - the <em>end pointer</em>, or first element address beyond the
+ * end of the array (called @e xend here).
+ * .
+ * -# The following semantic constraints shall always apply for any set
+ * of three pointers for a sequence, using the pointer names given
+ * immediately above:
+ * - If @e xnext is not a null pointer, then @e xbeg and @e xend shall
+ * also be non-null pointers into the same @c charT array, as
+ * described above; otherwise, @e xbeg and @e xend shall also be null.
+ * - If @e xnext is not a null pointer and @e xnext < @e xend for an
+ * output sequence, then a <em>write position</em> is available.
+ * In this case, @e *xnext shall be assignable as the next element
+ * to write (to put, or to store a character value, into the sequence).
+ * - If @e xnext is not a null pointer and @e xbeg < @e xnext for an
+ * input sequence, then a <em>putback position</em> is available.
+ * In this case, @e xnext[-1] shall have a defined value and is the
+ * next (preceding) element to store a character that is put back
+ * into the input sequence.
+ * - If @e xnext is not a null pointer and @e xnext< @e xend for an
+ * input sequence, then a <em>read position</em> is available.
+ * In this case, @e *xnext shall have a defined value and is the
+ * next element to read (to get, or to obtain a character value,
+ * from the sequence).
+ */
template<typename _CharT, typename _Traits>
class basic_streambuf
{
public:
- // Types:
+ //@{
+ /**
+ * These are standard types. They permit a standardized way of
+ * referring to names of (or names dependant on) the template
+ * parameters, which are specific to the implementation.
+ */
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
-
- // Non-standard Types:
+ //@}
+
+ //@{
+ /**
+ * @if maint
+ * These are non-standard types.
+ * @endif
+ */
typedef ctype<char_type> __ctype_type;
typedef basic_streambuf<char_type, traits_type> __streambuf_type;
typedef typename traits_type::state_type __state_type;
+ //@}
friend class basic_ios<char_type, traits_type>;
friend class basic_istream<char_type, traits_type>;
@@ -84,56 +160,100 @@ namespace std
__streambuf_type* __sbin,__streambuf_type* __sbout);
protected:
- // Pointer to the beginning of internally-allocated
- // space. Filebuf manually allocates/deallocates this, whereas
- // stringstreams attempt to use the built-in intelligence of the
- // string class. If you are managing memory, set this. If not,
- // leave it NULL.
+ /**
+ * @if maint
+ * Pointer to the beginning of internally-allocated space. Filebuf
+ * manually allocates/deallocates this, whereas stringstreams attempt
+ * to use the built-in intelligence of the string class. If you are
+ * managing memory, set this. If not, leave it NULL.
+ * @endif
+ */
char_type* _M_buf;
- // Actual size of allocated internal buffer, in bytes.
+ /**
+ * @if maint
+ * Actual size of allocated internal buffer, in bytes.
+ * @endif
+ */
size_t _M_buf_size;
- // Optimal or preferred size of internal buffer, in bytes.
+ /**
+ * @if maint
+ * Optimal or preferred size of internal buffer, in bytes.
+ * @endif
+ */
size_t _M_buf_size_opt;
- // True iff _M_in_* and _M_out_* buffers should always point to
- // the same place. True for fstreams, false for sstreams.
+ /**
+ * @if maint
+ * True iff _M_in_* and _M_out_* buffers should always point to
+ * the same place. True for fstreams, false for sstreams.
+ * @endif
+ */
bool _M_buf_unified;
- // This is based on _IO_FILE, just reordered to be more
- // consistent, and is intended to be the most minimal abstraction
- // for an internal buffer.
- // get == input == read
- // put == output == write
+ //@{
+ /**
+ * @if maint
+ * This is based on _IO_FILE, just reordered to be more consistent,
+ * and is intended to be the most minimal abstraction for an
+ * internal buffer.
+ * - get == input == read
+ * - put == output == write
+ * @endif
+ */
char_type* _M_in_beg; // Start of get area.
char_type* _M_in_cur; // Current read area.
char_type* _M_in_end; // End of get area.
char_type* _M_out_beg; // Start of put area.
char_type* _M_out_cur; // Current put area.
char_type* _M_out_end; // End of put area.
+ //@}
- // Place to stash in || out || in | out settings for current streambuf.
+ /**
+ * @if maint
+ * Place to stash in || out || in | out settings for current streambuf.
+ * @endif
+ */
ios_base::openmode _M_mode;
- // Current locale setting.
+ /**
+ * @if maint
+ * Current locale setting.
+ * @endif
+ */
locale _M_buf_locale;
- // True iff locale is initialized.
+ /**
+ * @if maint
+ * True iff locale is initialized.
+ * @endif
+ */
bool _M_buf_locale_init;
- // Necessary bits for putback buffer management. Only used in
- // the basic_filebuf class, as necessary for the standard
- // requirements. The only basic_streambuf member function that
- // needs access to these data members is in_avail...
- // NB: pbacks of over one character are not currently supported.
+ //@{
+ /**
+ * @if maint
+ * Necessary bits for putback buffer management. Only used in
+ * the basic_filebuf class, as necessary for the standard
+ * requirements. The only basic_streambuf member function that
+ * needs access to these data members is in_avail...
+ *
+ * @note pbacks of over one character are not currently supported.
+ * @endif
+ */
static const size_t _S_pback_size = 1;
char_type _M_pback[_S_pback_size];
char_type* _M_pback_cur_save;
char_type* _M_pback_end_save;
bool _M_pback_init;
+ //@}
- // Yet unused.
+ /**
+ * @if maint
+ * Yet unused.
+ * @endif
+ */
fpos<__state_type> _M_pos;
// Initializes pback buffers, and moves normal buffers to safety.
@@ -158,7 +278,7 @@ namespace std
// Assumptions:
// The pback buffer has only moved forward.
void
- _M_pback_destroy()
+ _M_pback_destroy() throw()
{
if (_M_pback_init)
{
@@ -236,6 +356,7 @@ namespace std
}
public:
+ /// Destructor deallocates no buffer space.
virtual
~basic_streambuf()
{
@@ -245,7 +366,14 @@ namespace std
_M_mode = ios_base::openmode(0);
}
- // Locales:
+ // [27.5.2.2.1] locales
+ /**
+ * @brief Entry point for imbue().
+ * @param loc The new locale.
+ * @return The previous locale.
+ *
+ * Calls the derived imbue(loc).
+ */
locale
pubimbue(const locale &__loc)
{
@@ -254,11 +382,27 @@ namespace std
return __tmp;
}
+ /**
+ * @brief Locale access.
+ * @return The current locale in effect.
+ *
+ * If pubimbue(loc) has been called, then the most recent @c loc
+ * is returned. Otherwise the global locale in effect at the time
+ * of construction is returned.
+ */
locale
getloc() const
{ return _M_buf_locale; }
- // Buffer and positioning:
+ // [27.5.2.2.2] buffer management and positioning
+ //@{
+ /**
+ * @brief Entry points for derived buffer functions.
+ *
+ * The public versions of @c pubfoo dispatch to the protected
+ * derived @c foo member functions, passing the arguments (if any)
+ * and returning the result unchanged.
+ */
__streambuf_type*
pubsetbuf(char_type* __s, streamsize __n)
{ return this->setbuf(__s, __n); }
@@ -275,9 +419,17 @@ namespace std
int
pubsync() { return this->sync(); }
-
- // Get and put areas:
- // Get area:
+ //@}
+
+ // [27.5.2.2.3] get area
+ /**
+ * @brief Looking ahead into the stream.
+ * @return The number of characters available.
+ *
+ * If a read position is available, returns the number of characters
+ * available for reading before the buffer must be refilled.
+ * Otherwise returns the derived @c showmanyc().
+ */
streamsize
in_avail()
{
@@ -298,6 +450,13 @@ namespace std
return __ret;
}
+ /**
+ * @brief Getting the next character.
+ * @return The next character, or eof.
+ *
+ * Calls @c sbumpc(), and if that function returns
+ * @c traits::eof(), so does this function. Otherwise, @c sgetc().
+ */
int_type
snextc()
{
@@ -306,9 +465,25 @@ namespace std
? __eof : this->sgetc());
}
+ /**
+ * @brief Getting the next character.
+ * @return The next character, or eof.
+ *
+ * If the input read position is available, returns that character
+ * and increments the read pointer, otherwise calls and returns
+ * @c uflow().
+ */
int_type
sbumpc();
+ /**
+ * @brief Getting the next character.
+ * @return The next character, or eof.
+ *
+ * If the input read position is available, returns that character,
+ * otherwise calls and returns @c underflow(). Does not move the
+ * read position after fetching the character.
+ */
int_type
sgetc()
{
@@ -320,26 +495,84 @@ namespace std
return __ret;
}
+ /**
+ * @brief Entry point for xsgetn.
+ * @param s A buffer area.
+ * @param n A count.
+ *
+ * Returns xsgetn(s,n). The effect is to fill @a s[0] through
+ * @a s[n-1] with characters from the input sequence, if possible.
+ */
streamsize
sgetn(char_type* __s, streamsize __n)
{ return this->xsgetn(__s, __n); }
- // Putback:
+ // [27.5.2.2.4] putback
+ /**
+ * @brief Pushing characters back into the input stream.
+ * @param c The character to push back.
+ * @return The previous character, if possible.
+ *
+ * Similar to sungetc(), but @a c is pushed onto the stream instead
+ * of "the previous character". If successful, the next character
+ * fetched from the input stream will be @a c.
+ */
int_type
sputbackc(char_type __c);
+ /**
+ * @brief Moving backwards in the input stream.
+ * @return The previous character, if possible.
+ *
+ * If a putback position is available, this function decrements the
+ * input pointer and returns that character. Otherwise, calls and
+ * returns pbackfail(). The effect is to "unget" the last character
+ * "gotten".
+ */
int_type
sungetc();
- // Put area:
+ // [27.5.2.2.5] put area
+ /**
+ * @brief Entry point for all single-character output functions.
+ * @param c A character to output.
+ * @return @a c, if possible.
+ *
+ * One of two public output functions.
+ *
+ * If a write position is available for the output sequence (i.e.,
+ * the buffer is not full), stores @a c in that position, increments
+ * the position, and returns @c traits::to_int_type(c). If a write
+ * position is not available, returns @c overflow(c).
+ */
int_type
sputc(char_type __c);
+ /**
+ * @brief Entry point for all single-character output functions.
+ * @param s A buffer read area.
+ * @param n A count.
+ *
+ * One of two public output functions.
+ *
+ *
+ * Returns xsputn(s,n). The effect is to write @a s[0] through
+ * @a s[n-1] to the output sequence, if possible.
+ */
streamsize
sputn(const char_type* __s, streamsize __n)
{ return this->xsputn(__s, __n); }
protected:
+ /**
+ * @brief Base constructor.
+ *
+ * Only called from derived constructors, and sets up all the
+ * buffer data to zero, including the pointers described in the
+ * basic_streambuf class description. Note that, as a result,
+ * - the class starts with no read nor write positions available,
+ * - this is not an error
+ */
basic_streambuf()
: _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(BUFSIZ),
_M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
@@ -349,7 +582,18 @@ namespace std
_M_pback_init(false)
{ }
- // Get area:
+ // [27.5.2.3.1] get area access
+ //@{
+ /**
+ * @brief Access to the get area.
+ *
+ * These functions are only available to other protected functions,
+ * including derived classes.
+ *
+ * - eback() returns the beginning pointer for the input sequence
+ * - gptr() returns the next pointer for the input sequence
+ * - egptr() returns the end pointer for the input sequence
+ */
char_type*
eback() const { return _M_in_beg; }
@@ -358,10 +602,25 @@ namespace std
char_type*
egptr() const { return _M_in_end; }
-
+ //@}
+
+ /**
+ * @brief Moving the read position.
+ * @param n The delta by which to move.
+ *
+ * This just advances the read position without returning any data.
+ */
void
gbump(int __n) { _M_in_cur += __n; }
+ /**
+ * @brief Setting the three read area pointers.
+ * @param gbeg A pointer.
+ * @param gnext A pointer.
+ * @param gend A pointer.
+ * @post @a gbeg == @c eback(), @a gnext == @c gptr(), and
+ * @a gend == @c egptr()
+ */
void
setg(char_type* __gbeg, char_type* __gnext, char_type* __gend)
{
@@ -372,7 +631,18 @@ namespace std
_M_mode = _M_mode | ios_base::in;
}
- // Put area:
+ // [27.5.2.3.2] put area access
+ //@{
+ /**
+ * @brief Access to the put area.
+ *
+ * These functions are only available to other protected functions,
+ * including derived classes.
+ *
+ * - pbase() returns the beginning pointer for the output sequence
+ * - pptr() returns the next pointer for the output sequence
+ * - epptr() returns the end pointer for the output sequence
+ */
char_type*
pbase() const { return _M_out_beg; }
@@ -381,10 +651,24 @@ namespace std
char_type*
epptr() const { return _M_out_end; }
-
+ //@}
+
+ /**
+ * @brief Moving the write position.
+ * @param n The delta by which to move.
+ *
+ * This just advances the write position without returning any data.
+ */
void
pbump(int __n) { _M_out_cur += __n; }
+ /**
+ * @brief Setting the three write area pointers.
+ * @param pbeg A pointer.
+ * @param pend A pointer.
+ * @post @a pbeg == @c pbase(), @a pbeg == @c pptr(), and
+ * @a pend == @c epptr()
+ */
void
setp(char_type* __pbeg, char_type* __pend)
{
@@ -394,8 +678,19 @@ namespace std
_M_mode = _M_mode | ios_base::out;
}
- // Virtual functions:
- // Locales:
+ // [27.5.2.4] virtual functions
+ // [27.5.2.4.1] locales
+ /**
+ * @brief Changes translations.
+ * @param loc A new locale.
+ *
+ * Translations done during I/O which depend on the current locale
+ * are changed by this call. The standard adds, "Between invocations
+ * of this function a class derived from streambuf can safely cache
+ * results of calls to locale functions and to members of facets
+ * so obtained." This function simply stores the new locale for use
+ * by derived classes.
+ */
virtual void
imbue(const locale& __loc)
{
@@ -403,35 +698,126 @@ namespace std
_M_buf_locale = __loc;
}
- // Buffer management and positioning:
+ // [27.5.2.4.2] buffer management and positioning
+ /**
+ * @brief Maniuplates the buffer.
+ *
+ * Each derived class provides its own appropriate behavior. See
+ * the next-to-last paragraph of
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for
+ * more on this function.
+ *
+ * @note Base class version does nothing, returns @c this.
+ */
virtual basic_streambuf<char_type,_Traits>*
setbuf(char_type*, streamsize)
{ return this; }
+ /**
+ * @brief Alters the stream positions.
+ *
+ * Each derived class provides its own appropriate behavior.
+ * @note Base class version does nothing, returns a @c pos_type
+ * that represents an invalid stream position.
+ */
virtual pos_type
seekoff(off_type, ios_base::seekdir,
ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
{ return pos_type(off_type(-1)); }
+ /**
+ * @brief Alters the stream positions.
+ *
+ * Each derived class provides its own appropriate behavior.
+ * @note Base class version does nothing, returns a @c pos_type
+ * that represents an invalid stream position.
+ */
virtual pos_type
seekpos(pos_type,
ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
{ return pos_type(off_type(-1)); }
+ /**
+ * @brief Synchronizes the buffer arrays with the controlled sequences.
+ * @return -1 on failure.
+ *
+ * Each derived class provides its own appropriate behavior,
+ * including the definition of "failure".
+ * @note Base class version does nothing, returns zero.
+ */
virtual int
sync() { return 0; }
- // Get area:
+ // [27.5.2.4.3] get area
+ /**
+ * @brief Investigating the data available.
+ * @return An estimate of the number of characters available in the
+ * input sequence, or -1.
+ *
+ * "If it returns a positive value, then successive calls to
+ * @c underflow() will not return @c traits::eof() until at least that
+ * number of characters have been supplied. If @c showmanyc()
+ * returns -1, then calls to @c underflow() or @c uflow() will fail."
+ * [27.5.2.4.3]/1
+ *
+ * @note Base class version does nothing, returns zero.
+ * @note The standard adds that "the intention is not only that the
+ * calls [to underflow or uflow] will not return @c eof() but
+ * that they will return "immediately".
+ * @note The standard adds that "the morphemes of @c showmanyc are
+ * "es-how-many-see", not "show-manic".
+ */
virtual streamsize
showmanyc() { return 0; }
+ /**
+ * @brief Multiple character extraction.
+ * @param s A buffer area.
+ * @param n Maximum number of characters to assign.
+ * @return The number of characters assigned.
+ *
+ * Fills @a s[0] through @a s[n-1] with characters from the input
+ * sequence, as if by @c sbumpc(). Stops when either @a n characters
+ * have been copied, or when @c traits::eof() would be copied.
+ *
+ * It is expected that derived classes provide a more efficient
+ * implementation by overriding this definition.
+ */
virtual streamsize
xsgetn(char_type* __s, streamsize __n);
+ /**
+ * @brief Fetches more data from the controlled sequence.
+ * @return The first character from the <em>pending sequence</em>.
+ *
+ * Informally, this function is called when the input buffer is
+ * exhausted (or does not exist, as buffering need not actually be
+ * done). If a buffer exists, it is "refilled". In either case, the
+ * next available character is returned, or @c traits::eof() to
+ * indicate a null pending sequence.
+ *
+ * For a formal definiton of the pending sequence, see a good text
+ * such as Langer & Kreft, or [27.5.2.4.3]/7-14.
+ *
+ * A functioning input streambuf can be created by overriding only
+ * this function (no buffer area will be used). For an example, see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#6
+ *
+ * @note Base class version does nothing, returns eof().
+ */
virtual int_type
underflow()
{ return traits_type::eof(); }
+ /**
+ * @brief Fetches more data from the controlled sequence.
+ * @return The first character from the <em>pending sequence</em>.
+ *
+ * Informally, this function does the same thing as @c underflow(),
+ * and in fact is required to call that function. It also returns
+ * the new character, like @c underflow() does. However, this
+ * function also moves the read position forward by one.
+ */
virtual int_type
uflow()
{
@@ -448,21 +834,78 @@ namespace std
return __ret;
}
- // Putback:
+ // [27.5.2.4.4] putback
+ /**
+ * @brief Tries to back up the input sequence.
+ * @param c The character to be inserted back into the sequence.
+ * @return eof() on failure, "some other value" on success
+ * @post The constraints of @c gptr(), @c eback(), and @c pptr()
+ * are the same as for @c underflow().
+ *
+ * @note Base class version does nothing, returns eof().
+ */
virtual int_type
pbackfail(int_type /* __c */ = traits_type::eof())
{ return traits_type::eof(); }
// Put area:
+ /**
+ * @brief Multiple character insertion.
+ * @param s A buffer area.
+ * @param n Maximum number of characters to write.
+ * @return The number of characters written.
+ *
+ * Writes @a s[0] through @a s[n-1] to the output sequence, as if
+ * by @c sputc(). Stops when either @a n characters have been
+ * copied, or when @c sputc() would return @c traits::eof().
+ *
+ * It is expected that derived classes provide a more efficient
+ * implementation by overriding this definition.
+ */
virtual streamsize
xsputn(const char_type* __s, streamsize __n);
+ /**
+ * @brief Consumes data from the buffer; writes to the
+ * controlled sequence.
+ * @param c An additional character to consume.
+ * @return eof() to indicate failure, something else (usually
+ * @a c, or not_eof())
+ *
+ * Informally, this function is called when the output buffer is full
+ * (or does not exist, as buffering need not actually be done). If a
+ * buffer exists, it is "consumed", with "some effect" on the
+ * controlled sequence. (Typically, the buffer is written out to the
+ * sequence verbatim.) In either case, the character @a c is also
+ * written out, if @a c is not @c eof().
+ *
+ * For a formal definiton of this function, see a good text
+ * such as Langer & Kreft, or [27.5.2.4.5]/3-7.
+ *
+ * A functioning output streambuf can be created by overriding only
+ * this function (no buffer area will be used).
+ *
+ * @note Base class version does nothing, returns eof().
+ */
virtual int_type
overflow(int_type /* __c */ = traits_type::eof())
{ return traits_type::eof(); }
#ifdef _GLIBCPP_DEPRECATED
+ // Annex D.6
public:
+ /**
+ * @brief Tosses a character.
+ *
+ * Advances the read pointer, ignoring the character that would have
+ * been read.
+ *
+ * See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html
+ *
+ * @note This function has been deprecated by the standard. You
+ * must define @c _GLIBCPP_DEPRECATED to make this visible; see
+ * c++config.h.
+ */
void
stossc()
{
diff --git a/contrib/libstdc++/include/std/std_valarray.h b/contrib/libstdc++/include/std/std_valarray.h
index 3957d7f..b4de5df 100644
--- a/contrib/libstdc++/include/std/std_valarray.h
+++ b/contrib/libstdc++/include/std/std_valarray.h
@@ -45,48 +45,47 @@
#include <cmath>
#include <cstdlib>
#include <numeric>
-#include <functional>
#include <algorithm>
namespace std
{
- template<class _Clos, typename _Tp> class _Expr;
+ template<class _Clos, typename _Tp>
+ class _Expr;
- template<typename _Tp1, typename _Tp2> class _ValArray;
+ template<typename _Tp1, typename _Tp2>
+ class _ValArray;
- template<template<class> class _Oper,
- template<class, class> class _Meta, class _Dom> struct _UnClos;
+ template<class _Oper, template<class, class> class _Meta, class _Dom>
+ struct _UnClos;
- template<template<class> class _Oper,
+ template<class _Oper,
template<class, class> class _Meta1,
template<class, class> class _Meta2,
- class _Dom1, class _Dom2> class _BinClos;
+ class _Dom1, class _Dom2>
+ class _BinClos;
- template<template<class, class> class _Meta, class _Dom> class _SClos;
+ template<template<class, class> class _Meta, class _Dom>
+ class _SClos;
- template<template<class, class> class _Meta, class _Dom> class _GClos;
+ template<template<class, class> class _Meta, class _Dom>
+ class _GClos;
- template<template<class, class> class _Meta, class _Dom> class _IClos;
+ template<template<class, class> class _Meta, class _Dom>
+ class _IClos;
- template<template<class, class> class _Meta, class _Dom> class _ValFunClos;
-
- template<template<class, class> class _Meta, class _Dom> class _RefFunClos;
-
- template<class _Tp> struct _Unary_plus;
- template<class _Tp> struct _Bitwise_and;
- template<class _Tp> struct _Bitwise_or;
- template<class _Tp> struct _Bitwise_xor;
- template<class _Tp> struct _Bitwise_not;
- template<class _Tp> struct _Shift_left;
- template<class _Tp> struct _Shift_right;
+ template<template<class, class> class _Meta, class _Dom>
+ class _ValFunClos;
- template<class _Tp> class valarray; // An array of type _Tp
- class slice; // BLAS-like slice out of an array
- template<class _Tp> class slice_array;
- class gslice; // generalized slice out of an array
- template<class _Tp> class gslice_array;
- template<class _Tp> class mask_array; // masked array
- template<class _Tp> class indirect_array; // indirected array
+ template<template<class, class> class _Meta, class _Dom>
+ class _RefFunClos;
+
+ template<class _Tp> class valarray; // An array of type _Tp
+ class slice; // BLAS-like slice out of an array
+ template<class _Tp> class slice_array;
+ class gslice; // generalized slice out of an array
+ template<class _Tp> class gslice_array;
+ template<class _Tp> class mask_array; // masked array
+ template<class _Tp> class indirect_array; // indirected array
} // namespace std
@@ -95,12 +94,19 @@ namespace std
namespace std
{
- template<class _Tp> class valarray
- {
- public:
+ template<class _Tp>
+ class valarray
+ {
+ template<class _Op>
+ struct _UnaryOp
+ {
+ typedef typename __fun<_Op, _Tp>::result_type __rt;
+ typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt;
+ };
+ public:
typedef _Tp value_type;
-
- // _lib.valarray.cons_ construct/destroy:
+
+ // _lib.valarray.cons_ construct/destroy:
valarray();
explicit valarray(size_t);
valarray(const _Tp&, size_t);
@@ -111,8 +117,8 @@ namespace std
valarray(const mask_array<_Tp>&);
valarray(const indirect_array<_Tp>&);
template<class _Dom>
- valarray(const _Expr<_Dom,_Tp>& __e);
- ~valarray();
+ valarray(const _Expr<_Dom,_Tp>& __e);
+ ~valarray();
// _lib.valarray.assign_ assignment:
valarray<_Tp>& operator=(const valarray<_Tp>&);
@@ -123,7 +129,7 @@ namespace std
valarray<_Tp>& operator=(const indirect_array<_Tp>&);
template<class _Dom> valarray<_Tp>&
- operator= (const _Expr<_Dom,_Tp>&);
+ operator= (const _Expr<_Dom,_Tp>&);
// _lib.valarray.access_ element access:
// XXX: LWG to be resolved.
@@ -137,67 +143,67 @@ namespace std
valarray<_Tp> operator[](const valarray<bool>&) const;
mask_array<_Tp> operator[](const valarray<bool>&);
_Expr<_IClos<_ValArray, _Tp>, _Tp>
- operator[](const valarray<size_t>&) const;
+ operator[](const valarray<size_t>&) const;
indirect_array<_Tp> operator[](const valarray<size_t>&);
// _lib.valarray.unary_ unary operators:
- _Expr<_UnClos<_Unary_plus,_ValArray,_Tp>,_Tp> operator+ () const;
- _Expr<_UnClos<negate,_ValArray,_Tp>,_Tp> operator- () const;
- _Expr<_UnClos<_Bitwise_not,_ValArray,_Tp>,_Tp> operator~ () const;
- _Expr<_UnClos<logical_not,_ValArray,_Tp>,bool> operator! () const;
-
+ typename _UnaryOp<__unary_plus>::_Rt operator+() const;
+ typename _UnaryOp<__negate>::_Rt operator-() const;
+ typename _UnaryOp<__bitwise_not>::_Rt operator~() const;
+ typename _UnaryOp<__logical_not>::_Rt operator!() const;
+
// _lib.valarray.cassign_ computed assignment:
- valarray<_Tp>& operator*= (const _Tp&);
- valarray<_Tp>& operator/= (const _Tp&);
- valarray<_Tp>& operator%= (const _Tp&);
- valarray<_Tp>& operator+= (const _Tp&);
- valarray<_Tp>& operator-= (const _Tp&);
- valarray<_Tp>& operator^= (const _Tp&);
- valarray<_Tp>& operator&= (const _Tp&);
- valarray<_Tp>& operator|= (const _Tp&);
+ valarray<_Tp>& operator*=(const _Tp&);
+ valarray<_Tp>& operator/=(const _Tp&);
+ valarray<_Tp>& operator%=(const _Tp&);
+ valarray<_Tp>& operator+=(const _Tp&);
+ valarray<_Tp>& operator-=(const _Tp&);
+ valarray<_Tp>& operator^=(const _Tp&);
+ valarray<_Tp>& operator&=(const _Tp&);
+ valarray<_Tp>& operator|=(const _Tp&);
valarray<_Tp>& operator<<=(const _Tp&);
valarray<_Tp>& operator>>=(const _Tp&);
- valarray<_Tp>& operator*= (const valarray<_Tp>&);
- valarray<_Tp>& operator/= (const valarray<_Tp>&);
- valarray<_Tp>& operator%= (const valarray<_Tp>&);
- valarray<_Tp>& operator+= (const valarray<_Tp>&);
- valarray<_Tp>& operator-= (const valarray<_Tp>&);
- valarray<_Tp>& operator^= (const valarray<_Tp>&);
- valarray<_Tp>& operator|= (const valarray<_Tp>&);
- valarray<_Tp>& operator&= (const valarray<_Tp>&);
+ valarray<_Tp>& operator*=(const valarray<_Tp>&);
+ valarray<_Tp>& operator/=(const valarray<_Tp>&);
+ valarray<_Tp>& operator%=(const valarray<_Tp>&);
+ valarray<_Tp>& operator+=(const valarray<_Tp>&);
+ valarray<_Tp>& operator-=(const valarray<_Tp>&);
+ valarray<_Tp>& operator^=(const valarray<_Tp>&);
+ valarray<_Tp>& operator|=(const valarray<_Tp>&);
+ valarray<_Tp>& operator&=(const valarray<_Tp>&);
valarray<_Tp>& operator<<=(const valarray<_Tp>&);
valarray<_Tp>& operator>>=(const valarray<_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator*= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator*=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator/= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator/=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator%= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator%=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator+= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator+=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator-= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator-=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator^= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator^=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator|= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator|=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator&= (const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator&=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
+
-
// _lib.valarray.members_ member functions:
size_t size() const;
_Tp sum() const;
_Tp min() const;
_Tp max() const;
-// // FIXME: Extension
-// _Tp product () const;
+ // // FIXME: Extension
+ // _Tp product () const;
valarray<_Tp> shift (int) const;
valarray<_Tp> cshift(int) const;
@@ -205,56 +211,25 @@ namespace std
_Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
void resize(size_t __size, _Tp __c = _Tp());
- private:
+ private:
size_t _M_size;
_Tp* __restrict__ _M_data;
-
+
friend class _Array<_Tp>;
- };
-
-
- template<typename _Tp> struct _Unary_plus : unary_function<_Tp,_Tp> {
- _Tp operator() (const _Tp& __t) const { return __t; }
- };
-
- template<typename _Tp> struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> {
- _Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; }
- };
-
- template<typename _Tp> struct _Bitwise_or : binary_function<_Tp,_Tp,_Tp> {
- _Tp operator() (_Tp __x, _Tp __y) const { return __x | __y; }
- };
-
- template<typename _Tp> struct _Bitwise_xor : binary_function<_Tp,_Tp,_Tp> {
- _Tp operator() (_Tp __x, _Tp __y) const { return __x ^ __y; }
- };
-
- template<typename _Tp> struct _Bitwise_not : unary_function<_Tp,_Tp> {
- _Tp operator() (_Tp __t) const { return ~__t; }
- };
-
- template<typename _Tp> struct _Shift_left : unary_function<_Tp,_Tp> {
- _Tp operator() (_Tp __x, _Tp __y) const { return __x << __y; }
- };
-
- template<typename _Tp> struct _Shift_right : unary_function<_Tp,_Tp> {
- _Tp operator() (_Tp __x, _Tp __y) const { return __x >> __y; }
- };
-
+ };
template<typename _Tp>
- inline const _Tp&
- valarray<_Tp>::operator[] (size_t __i) const
- { return _M_data[__i]; }
+ inline const _Tp&
+ valarray<_Tp>::operator[](size_t __i) const
+ { return _M_data[__i]; }
template<typename _Tp>
- inline _Tp&
- valarray<_Tp>::operator[] (size_t __i)
- { return _M_data[__i]; }
+ inline _Tp&
+ valarray<_Tp>::operator[](size_t __i)
+ { return _M_data[__i]; }
} // std::
-#include <bits/slice.h>
#include <bits/slice_array.h>
#include <bits/gslice.h>
#include <bits/gslice_array.h>
@@ -264,214 +239,227 @@ namespace std
namespace std
{
template<typename _Tp>
- inline valarray<_Tp>::valarray () : _M_size (0), _M_data (0) {}
+ inline
+ valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {}
template<typename _Tp>
- inline valarray<_Tp>::valarray (size_t __n)
- : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
- { __valarray_default_construct(_M_data, _M_data + __n); }
+ inline
+ valarray<_Tp>::valarray(size_t __n)
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ { __valarray_default_construct(_M_data, _M_data + __n); }
template<typename _Tp>
- inline valarray<_Tp>::valarray (const _Tp& __t, size_t __n)
- : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
- { __valarray_fill_construct (_M_data, _M_data + __n, __t); }
+ inline
+ valarray<_Tp>::valarray(const _Tp& __t, size_t __n)
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ { __valarray_fill_construct(_M_data, _M_data + __n, __t); }
template<typename _Tp>
- inline valarray<_Tp>::valarray (const _Tp* __restrict__ __p, size_t __n)
- : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
- { __valarray_copy_construct (__p, __p + __n, _M_data); }
+ inline
+ valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ { __valarray_copy_construct(__p, __p + __n, _M_data); }
template<typename _Tp>
- inline valarray<_Tp>::valarray (const valarray<_Tp>& __v)
- : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
- { __valarray_copy_construct (__v._M_data, __v._M_data + _M_size, _M_data); }
+ inline
+ valarray<_Tp>::valarray(const valarray<_Tp>& __v)
+ : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
+ { __valarray_copy_construct(__v._M_data, __v._M_data + _M_size, _M_data); }
template<typename _Tp>
- inline valarray<_Tp>::valarray (const slice_array<_Tp>& __sa)
- : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
- {
- __valarray_copy
- (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
- }
+ inline
+ valarray<_Tp>::valarray(const slice_array<_Tp>& __sa)
+ : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
+ {
+ __valarray_copy
+ (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
+ }
template<typename _Tp>
- inline valarray<_Tp>::valarray (const gslice_array<_Tp>& __ga)
- : _M_size(__ga._M_index.size()),
- _M_data(__valarray_get_storage<_Tp>(_M_size))
- {
- __valarray_copy
- (__ga._M_array, _Array<size_t>(__ga._M_index),
- _Array<_Tp>(_M_data), _M_size);
- }
+ inline
+ valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga)
+ : _M_size(__ga._M_index.size()),
+ _M_data(__valarray_get_storage<_Tp>(_M_size))
+ {
+ __valarray_copy
+ (__ga._M_array, _Array<size_t>(__ga._M_index),
+ _Array<_Tp>(_M_data), _M_size);
+ }
template<typename _Tp>
- inline valarray<_Tp>::valarray (const mask_array<_Tp>& __ma)
- : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
- {
- __valarray_copy
- (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
- }
+ inline
+ valarray<_Tp>::valarray(const mask_array<_Tp>& __ma)
+ : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
+ {
+ __valarray_copy
+ (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
+ }
template<typename _Tp>
- inline valarray<_Tp>::valarray (const indirect_array<_Tp>& __ia)
- : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
- {
- __valarray_copy
- (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
- }
+ inline
+ valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia)
+ : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
+ {
+ __valarray_copy
+ (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
+ }
template<typename _Tp> template<class _Dom>
- inline valarray<_Tp>::valarray (const _Expr<_Dom, _Tp>& __e)
- : _M_size(__e.size ()), _M_data(__valarray_get_storage<_Tp>(_M_size))
- { __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); }
+ inline
+ valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e)
+ : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
+ { __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); }
template<typename _Tp>
- inline valarray<_Tp>::~valarray ()
- {
+ inline
+ valarray<_Tp>::~valarray()
+ {
__valarray_destroy_elements(_M_data, _M_data + _M_size);
__valarray_release_memory(_M_data);
- }
+ }
template<typename _Tp>
- inline valarray<_Tp>&
- valarray<_Tp>::operator= (const valarray<_Tp>& __v)
- {
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const valarray<_Tp>& __v)
+ {
__valarray_copy(__v._M_data, _M_size, _M_data);
return *this;
- }
+ }
template<typename _Tp>
- inline valarray<_Tp>&
- valarray<_Tp>::operator= (const _Tp& __t)
- {
- __valarray_fill (_M_data, _M_size, __t);
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const _Tp& __t)
+ {
+ __valarray_fill(_M_data, _M_size, __t);
return *this;
- }
+ }
template<typename _Tp>
- inline valarray<_Tp>&
- valarray<_Tp>::operator= (const slice_array<_Tp>& __sa)
- {
- __valarray_copy (__sa._M_array, __sa._M_sz,
- __sa._M_stride, _Array<_Tp>(_M_data));
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const slice_array<_Tp>& __sa)
+ {
+ __valarray_copy(__sa._M_array, __sa._M_sz,
+ __sa._M_stride, _Array<_Tp>(_M_data));
return *this;
- }
+ }
template<typename _Tp>
- inline valarray<_Tp>&
- valarray<_Tp>::operator= (const gslice_array<_Tp>& __ga)
- {
- __valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
- _Array<_Tp>(_M_data), _M_size);
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga)
+ {
+ __valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index),
+ _Array<_Tp>(_M_data), _M_size);
return *this;
- }
+ }
template<typename _Tp>
- inline valarray<_Tp>&
- valarray<_Tp>::operator= (const mask_array<_Tp>& __ma)
- {
- __valarray_copy (__ma._M_array, __ma._M_mask,
- _Array<_Tp>(_M_data), _M_size);
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const mask_array<_Tp>& __ma)
+ {
+ __valarray_copy(__ma._M_array, __ma._M_mask,
+ _Array<_Tp>(_M_data), _M_size);
return *this;
- }
+ }
template<typename _Tp>
- inline valarray<_Tp>&
- valarray<_Tp>::operator= (const indirect_array<_Tp>& __ia)
- {
- __valarray_copy (__ia._M_array, __ia._M_index,
- _Array<_Tp>(_M_data), _M_size);
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia)
+ {
+ __valarray_copy(__ia._M_array, __ia._M_index,
+ _Array<_Tp>(_M_data), _M_size);
return *this;
- }
+ }
template<typename _Tp> template<class _Dom>
- inline valarray<_Tp>&
- valarray<_Tp>::operator= (const _Expr<_Dom, _Tp>& __e)
- {
- __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data));
- return *this;
- }
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
+ {
+ __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
+ return *this;
+ }
template<typename _Tp>
- inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
- valarray<_Tp>::operator[] (slice __s) const
- {
+ inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
+ valarray<_Tp>::operator[](slice __s) const
+ {
typedef _SClos<_ValArray,_Tp> _Closure;
- return _Expr<_Closure, _Tp> (_Closure (_Array<_Tp>(_M_data), __s));
- }
+ return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s));
+ }
template<typename _Tp>
- inline slice_array<_Tp>
- valarray<_Tp>::operator[] (slice __s)
- {
- return slice_array<_Tp> (_Array<_Tp>(_M_data), __s);
- }
+ inline slice_array<_Tp>
+ valarray<_Tp>::operator[](slice __s)
+ {
+ return slice_array<_Tp>(_Array<_Tp>(_M_data), __s);
+ }
template<typename _Tp>
- inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
- valarray<_Tp>::operator[] (const gslice& __gs) const
- {
+ inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
+ valarray<_Tp>::operator[](const gslice& __gs) const
+ {
typedef _GClos<_ValArray,_Tp> _Closure;
return _Expr<_Closure, _Tp>
- (_Closure (_Array<_Tp>(_M_data), __gs._M_index->_M_index));
- }
+ (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index));
+ }
template<typename _Tp>
- inline gslice_array<_Tp>
- valarray<_Tp>::operator[] (const gslice& __gs)
- {
+ inline gslice_array<_Tp>
+ valarray<_Tp>::operator[](const gslice& __gs)
+ {
return gslice_array<_Tp>
- (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
- }
+ (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
+ }
template<typename _Tp>
- inline valarray<_Tp>
- valarray<_Tp>::operator[] (const valarray<bool>& __m) const
- {
- size_t __s (0);
- size_t __e (__m.size ());
+ inline valarray<_Tp>
+ valarray<_Tp>::operator[](const valarray<bool>& __m) const
+ {
+ size_t __s = 0;
+ size_t __e = __m.size();
for (size_t __i=0; __i<__e; ++__i)
- if (__m[__i]) ++__s;
- return valarray<_Tp> (mask_array<_Tp> (_Array<_Tp>(_M_data), __s,
- _Array<bool> (__m)));
- }
+ if (__m[__i]) ++__s;
+ return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s,
+ _Array<bool> (__m)));
+ }
template<typename _Tp>
- inline mask_array<_Tp>
- valarray<_Tp>::operator[] (const valarray<bool>& __m)
- {
- size_t __s (0);
- size_t __e (__m.size ());
+ inline mask_array<_Tp>
+ valarray<_Tp>::operator[](const valarray<bool>& __m)
+ {
+ size_t __s = 0;
+ size_t __e = __m.size();
for (size_t __i=0; __i<__e; ++__i)
- if (__m[__i]) ++__s;
- return mask_array<_Tp> (_Array<_Tp>(_M_data), __s, _Array<bool> (__m));
- }
+ if (__m[__i]) ++__s;
+ return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array<bool>(__m));
+ }
template<typename _Tp>
- inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
- valarray<_Tp>::operator[] (const valarray<size_t>& __i) const
- {
+ inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
+ valarray<_Tp>::operator[](const valarray<size_t>& __i) const
+ {
typedef _IClos<_ValArray,_Tp> _Closure;
- return _Expr<_Closure, _Tp> (_Closure (*this, __i));
- }
+ return _Expr<_Closure, _Tp>(_Closure(*this, __i));
+ }
template<typename _Tp>
- inline indirect_array<_Tp>
- valarray<_Tp>::operator[] (const valarray<size_t>& __i)
- {
- return indirect_array<_Tp> (_Array<_Tp>(_M_data), __i.size(),
- _Array<size_t> (__i));
- }
+ inline indirect_array<_Tp>
+ valarray<_Tp>::operator[](const valarray<size_t>& __i)
+ {
+ return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(),
+ _Array<size_t>(__i));
+ }
template<class _Tp>
- inline size_t valarray<_Tp>::size () const { return _M_size; }
+ inline size_t
+ valarray<_Tp>::size() const
+ { return _M_size; }
template<class _Tp>
- inline _Tp
- valarray<_Tp>::sum () const
- {
+ inline _Tp
+ valarray<_Tp>::sum() const
+ {
return __valarray_sum(_M_data, _M_data + _M_size);
- }
+ }
// template<typename _Tp>
// inline _Tp
@@ -530,209 +518,172 @@ namespace std
}
template <class _Tp>
- inline void
- valarray<_Tp>::resize (size_t __n, _Tp __c)
- {
- // This complication is so to make valarray<valarray<T> > work
- // even though it is not required by the standard. Nobody should
- // be saying valarray<valarray<T> > anyway. See the specs.
- __valarray_destroy_elements(_M_data, _M_data + _M_size);
- if (_M_size != __n)
- {
- __valarray_release_memory(_M_data);
- _M_size = __n;
- _M_data = __valarray_get_storage<_Tp>(__n);
- }
- __valarray_fill_construct(_M_data, _M_data + __n, __c);
- }
+ inline void
+ valarray<_Tp>::resize (size_t __n, _Tp __c)
+ {
+ // This complication is so to make valarray<valarray<T> > work
+ // even though it is not required by the standard. Nobody should
+ // be saying valarray<valarray<T> > anyway. See the specs.
+ __valarray_destroy_elements(_M_data, _M_data + _M_size);
+ if (_M_size != __n)
+ {
+ __valarray_release_memory(_M_data);
+ _M_size = __n;
+ _M_data = __valarray_get_storage<_Tp>(__n);
+ }
+ __valarray_fill_construct(_M_data, _M_data + __n, __c);
+ }
template<typename _Tp>
- inline _Tp
- valarray<_Tp>::min() const
- {
+ inline _Tp
+ valarray<_Tp>::min() const
+ {
return *min_element (_M_data, _M_data+_M_size);
- }
+ }
template<typename _Tp>
- inline _Tp
- valarray<_Tp>::max() const
- {
+ inline _Tp
+ valarray<_Tp>::max() const
+ {
return *max_element (_M_data, _M_data+_M_size);
- }
+ }
template<class _Tp>
- inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp>
- valarray<_Tp>::apply (_Tp func (_Tp)) const
- {
+ inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp>
+ valarray<_Tp>::apply(_Tp func(_Tp)) const
+ {
typedef _ValFunClos<_ValArray,_Tp> _Closure;
- return _Expr<_Closure,_Tp> (_Closure (*this, func));
- }
+ return _Expr<_Closure,_Tp>(_Closure(*this, func));
+ }
template<class _Tp>
- inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp>
- valarray<_Tp>::apply (_Tp func (const _Tp &)) const
- {
+ inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp>
+ valarray<_Tp>::apply(_Tp func(const _Tp &)) const
+ {
typedef _RefFunClos<_ValArray,_Tp> _Closure;
- return _Expr<_Closure,_Tp> (_Closure (*this, func));
- }
+ return _Expr<_Closure,_Tp>(_Closure(*this, func));
+ }
#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
- inline _Expr<_UnClos<_Name,_ValArray,_Tp>, _Tp> \
+ inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
valarray<_Tp>::operator _Op() const \
{ \
- typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
- return _Expr<_Closure, _Tp> (_Closure (*this)); \
+ typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(*this)); \
}
- _DEFINE_VALARRAY_UNARY_OPERATOR(+, _Unary_plus)
- _DEFINE_VALARRAY_UNARY_OPERATOR(-, negate)
- _DEFINE_VALARRAY_UNARY_OPERATOR(~, _Bitwise_not)
+ _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus)
+ _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate)
+ _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not)
+ _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not)
#undef _DEFINE_VALARRAY_UNARY_OPERATOR
-
- template<typename _Tp>
- inline _Expr<_UnClos<logical_not,_ValArray,_Tp>, bool>
- valarray<_Tp>::operator!() const
- {
- typedef _UnClos<logical_not,_ValArray,_Tp> _Closure;
- return _Expr<_Closure, bool> (_Closure (*this));
- }
#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
template<class _Tp> \
- inline valarray<_Tp> & \
- valarray<_Tp>::operator _Op##= (const _Tp &__t) \
- { \
- _Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, __t); \
+ inline valarray<_Tp>& \
+ valarray<_Tp>::operator _Op##=(const _Tp &__t) \
+ { \
+ _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, __t); \
return *this; \
- } \
+ } \
\
template<class _Tp> \
- inline valarray<_Tp> & \
- valarray<_Tp>::operator _Op##= (const valarray<_Tp> &__v) \
- { \
- _Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, \
- _Array<_Tp>(__v._M_data)); \
+ inline valarray<_Tp>& \
+ valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \
+ { \
+ _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \
+ _Array<_Tp>(__v._M_data)); \
return *this; \
- }
-
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, plus)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, minus)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, multiplies)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, divides)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, modulus)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, xor)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, and)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, or)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, shift_left)
-_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, shift_right)
+ }
+
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, __plus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, __minus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, __multiplies)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, __divides)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, __modulus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, __shift_left)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT
-
-} // std::
-
-
-namespace std
-{
-
#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
template<class _Tp> template<class _Dom> \
- inline valarray<_Tp> & \
- valarray<_Tp>::operator _Op##= (const _Expr<_Dom,_Tp> &__e) \
- { \
- _Array_augmented_##_Name (_Array<_Tp>(_M_data), __e, _M_size); \
+ inline valarray<_Tp>& \
+ valarray<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) \
+ { \
+ _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \
return *this; \
- }
-
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, plus)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, minus)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, multiplies)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, divides)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, modulus)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, xor)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, and)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, or)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, shift_left)
-_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, shift_right)
+ }
+
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, __plus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, __minus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, __multiplies)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, __divides)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, __modulus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT
#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
- operator _Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
- { \
+ inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
+ { \
typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
- return _Expr<_Closure, _Tp> (_Closure (__v, __w)); \
- } \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \
+ } \
\
template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,_Tp> \
- operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \
+ inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \
{ \
- typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
- return _Expr<_Closure, _Tp> (_Closure (__v, __t)); \
+ typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \
} \
\
template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,_Tp> \
- operator _Op (const _Tp &__t, const valarray<_Tp> &__v) \
- { \
- typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
- return _Expr<_Closure, _Tp> (_Closure (__t, __v)); \
- }
-
-_DEFINE_BINARY_OPERATOR(+, plus)
-_DEFINE_BINARY_OPERATOR(-, minus)
-_DEFINE_BINARY_OPERATOR(*, multiplies)
-_DEFINE_BINARY_OPERATOR(/, divides)
-_DEFINE_BINARY_OPERATOR(%, modulus)
-_DEFINE_BINARY_OPERATOR(^, _Bitwise_xor)
-_DEFINE_BINARY_OPERATOR(&, _Bitwise_and)
-_DEFINE_BINARY_OPERATOR(|, _Bitwise_or)
-_DEFINE_BINARY_OPERATOR(<<, _Shift_left)
-_DEFINE_BINARY_OPERATOR(>>, _Shift_right)
-
-#undef _DEFINE_BINARY_OPERATOR
-
-#define _DEFINE_LOGICAL_OPERATOR(_Op, _Name) \
- template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>,bool> \
- operator _Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
- { \
- typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
- return _Expr<_Closure, bool> (_Closure (__v, __w)); \
- } \
- \
- template<class _Tp> \
- inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,bool> \
- operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \
+ inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \
{ \
- typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
- return _Expr<_Closure, bool> (_Closure (__v, __t)); \
- } \
- \
- template<class _Tp> \
- inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,bool> \
- operator _Op (const _Tp &__t, const valarray<_Tp> &__v) \
- { \
- typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
- return _Expr<_Closure, bool> (_Closure (__t, __v)); \
- }
-
-_DEFINE_LOGICAL_OPERATOR(&&, logical_and)
-_DEFINE_LOGICAL_OPERATOR(||, logical_or)
-_DEFINE_LOGICAL_OPERATOR(==, equal_to)
-_DEFINE_LOGICAL_OPERATOR(!=, not_equal_to)
-_DEFINE_LOGICAL_OPERATOR(<, less)
-_DEFINE_LOGICAL_OPERATOR(>, greater)
-_DEFINE_LOGICAL_OPERATOR(<=, less_equal)
-_DEFINE_LOGICAL_OPERATOR(>=, greater_equal)
-
-#undef _DEFINE_LOGICAL_OPERATOR
+ typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
+ }
+
+_DEFINE_BINARY_OPERATOR(+, __plus)
+_DEFINE_BINARY_OPERATOR(-, __minus)
+_DEFINE_BINARY_OPERATOR(*, __multiplies)
+_DEFINE_BINARY_OPERATOR(/, __divides)
+_DEFINE_BINARY_OPERATOR(%, __modulus)
+_DEFINE_BINARY_OPERATOR(^, __bitwise_xor)
+_DEFINE_BINARY_OPERATOR(&, __bitwise_and)
+_DEFINE_BINARY_OPERATOR(|, __bitwise_or)
+_DEFINE_BINARY_OPERATOR(<<, __shift_left)
+_DEFINE_BINARY_OPERATOR(>>, __shift_right)
+_DEFINE_BINARY_OPERATOR(&&, __logical_and)
+_DEFINE_BINARY_OPERATOR(||, __logical_or)
+_DEFINE_BINARY_OPERATOR(==, __equal_to)
+_DEFINE_BINARY_OPERATOR(!=, __not_equal_to)
+_DEFINE_BINARY_OPERATOR(<, __less)
+_DEFINE_BINARY_OPERATOR(>, __greater)
+_DEFINE_BINARY_OPERATOR(<=, __less_equal)
+_DEFINE_BINARY_OPERATOR(>=, __greater_equal)
} // namespace std
diff --git a/contrib/libstdc++/include/std/std_vector.h b/contrib/libstdc++/include/std/std_vector.h
index 4120aa9..5738ef7 100644
--- a/contrib/libstdc++/include/std/std_vector.h
+++ b/contrib/libstdc++/include/std/std_vector.h
@@ -71,8 +71,9 @@
#include <bits/stl_vector.h>
#include <bits/stl_bvector.h>
+#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
+# include <bits/vector.tcc>
+#endif
+
#endif /* _CPP_VECTOR */
-// Local Variables:
-// mode:C++
-// End:
OpenPOWER on IntegriCloud