From: Mark Mitchell Date: Mon, 5 Feb 2001 01:38:47 +0000 (+0000) Subject: Remove V2 C++ library. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22fdd65e5971ec8f15368ba77046ce8c6c3cb329;p=gcc.git Remove V2 C++ library. * configure.in: Remove --enable-libstdcxx_v3 support. * Makefile.in (site.exp): Always set HAVE_LIBSTDCXX_V3. * configure.in: Remove --enable-libstdcxx_v3 support. * configure: Regenerated. From-SVN: r39445 --- diff --git a/ChangeLog b/ChangeLog index 5206aa19550..ba716508744 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-02-04 Mark Mitchell + + Remove V2 C++ library. + * configure.in: Remove --enable-libstdcxx_v3 support. + 2001-01-31 Bryce McKinlay * include/demangle.h: Add prototype for java_demangle_v3. diff --git a/configure.in b/configure.in index a93e6f1d61c..de8c60b4c0d 100644 --- a/configure.in +++ b/configure.in @@ -48,15 +48,9 @@ if [ "${enable_gdbgui}" = "yes" ] ; then host_libs="${host_libs} libgui" fi -# Set up configure/Makefile variables if libstdc++-v3 is to be built. -if [ "${enable_libstdcxx_v3}" = "yes" ] && test -d $srcdir/libstdc++-v3; then - libstdcxx_version="target-libstdc++-v3" - # Don't use libstdc++-v3's flags to configure/build itself. - libstdcxx_flags='`case $$dir in libstdc++-v3) ;; *) cat $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/libstdc++.INC 2>/dev/null || : ;; esac` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs' -else - libstdcxx_version="target-libio target-libstdc++" - libstdcxx_flags='-isystem $$s/libstdc++ -isystem $$s/libstdc++/std -isystem $$s/libstdc++/stl -isystem $$s/libio -isystem $$r/$(TARGET_SUBDIR)/libio -L$$r/$(TARGET_SUBDIR)/libstdc++' -fi +libstdcxx_version="target-libstdc++-v3" +# Don't use libstdc++-v3's flags to configure/build itself. +libstdcxx_flags='`case $$dir in libstdc++-v3) ;; *) cat $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/libstdc++.INC 2>/dev/null || : ;; esac` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs' # these tools are built for the host environment # Note, the powerpc-eabi build depends on sim occurring before gdb in order to diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3a77f7c2f1e..4a35cb02137 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2001-02-04 Mark Mitchell + + * Makefile.in (site.exp): Always set HAVE_LIBSTDCXX_V3. + * configure.in: Remove --enable-libstdcxx_v3 support. + * configure: Regenerated. + Sun Feb 4 15:52:44 2001 Richard Kenner * diagnostic.h (set_internal_error_function): Renamed. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 17255c79b18..4e9edaab4c3 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2740,7 +2740,7 @@ site.exp: ./config.status Makefile # CFLAGS is set even though it's empty to show we reserve the right to set it. @echo "set CFLAGS \"\"" >> ./tmp0 @echo "set CXXFLAGS \"-I$(objdir)/../$(target_subdir)libio -I\$$srcdir/../libg++/src -I\$$srcdir/../libio -I\$$srcdir/../libstdc++ -I\$$srcdir/../libstdc++/stl -L$(objdir)/../$(target_subdir)libg++ -L$(objdir)/../$(target_subdir)libstdc++\"" >> ./tmp0 - @echo "set HAVE_LIBSTDCXX_V3 @HAVE_LIBSTDCXX_V3@" >> ./tmp0 + @echo "set HAVE_LIBSTDCXX_V3 1" >> ./tmp0 # If newlib has been configured, we need to pass -B to gcc so it can find # newlib's crt0.o if it exists. This will cause a "path prefix not used" # message if it doesn't, but the testsuite is supposed to ignore the message - diff --git a/gcc/configure b/gcc/configure index 38960b77685..0e491b671e0 100755 --- a/gcc/configure +++ b/gcc/configure @@ -25,9 +25,6 @@ ac_help="$ac_help --with-elf arrange to use ELF instead of host debug format." ac_help="$ac_help --with-local-prefix=DIR specifies directory to put local include." -ac_help="$ac_help - --enable-libstdcxx-v3 - enable libstdc++-v3 for building and installation" ac_help="$ac_help --with-gxx-include-dir=DIR specifies directory to put g++ header files." @@ -615,7 +612,7 @@ copy=cp # - two terminals occur directly after each other # - the path contains an element with a dot in it echo $ac_n "checking LIBRARY_PATH variable""... $ac_c" 1>&6 -echo "configure:619: checking LIBRARY_PATH variable" >&5 +echo "configure:616: checking LIBRARY_PATH variable" >&5 case ${LIBRARY_PATH} in [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* ) library_path_setting="contains current directory" @@ -640,7 +637,7 @@ fi # - two terminals occur directly after each other # - the path contains an element with a dot in it echo $ac_n "checking GCC_EXEC_PREFIX variable""... $ac_c" 1>&6 -echo "configure:644: checking GCC_EXEC_PREFIX variable" >&5 +echo "configure:641: checking GCC_EXEC_PREFIX variable" >&5 case ${GCC_EXEC_PREFIX} in [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* ) gcc_exec_prefix_setting="contains current directory" @@ -754,28 +751,6 @@ if test x$local_prefix = x; then local_prefix=/usr/local fi -# Build a new-libstdc++ system (ie libstdc++-v3) -echo $ac_n "checking for libstdc++ to install""... $ac_c" 1>&6 -echo "configure:760: checking for libstdc++ to install" >&5 -# Check whether --enable-libstdcxx-v3 or --disable-libstdcxx-v3 was given. -if test "${enable_libstdcxx_v3+set}" = set; then - enableval="$enable_libstdcxx_v3" - enable_libstdcxx_v3="$enableval" -else - enable_libstdcxx_v3=yes -fi - - -if test x$enable_libstdcxx_v3 = xyes; then - echo "$ac_t""v3" 1>&6 - HAVE_LIBSTDCXX_V3=1 - ac_esn=1 -else - echo "$ac_t""v2" 1>&6 - HAVE_LIBSTDCXX_V3=0 - ac_esn=0 -fi - # Don't set gcc_gxx_include_dir to gxx_include_dir since that's only # passed in by the toplevel make and thus we'd get different behavior # depending on where we built the sources. @@ -1013,7 +988,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:1017: checking host system type" >&5 +echo "configure:992: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -1034,7 +1009,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:1038: checking target system type" >&5 +echo "configure:1013: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -1052,7 +1027,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1056: checking build system type" >&5 +echo "configure:1031: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -1079,7 +1054,7 @@ test "$host_alias" != "$target_alias" && # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1083: checking for $ac_word" >&5 +echo "configure:1058: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1109,7 +1084,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1113: checking for $ac_word" >&5 +echo "configure:1088: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1160,7 +1135,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1164: checking for $ac_word" >&5 +echo "configure:1139: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1192,7 +1167,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1196: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1171: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1203,12 +1178,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1207 "configure" +#line 1182 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1234,12 +1209,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1238: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1213: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1243: checking whether we are using GNU C" >&5 +echo "configure:1218: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1248,7 +1223,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1252: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1227: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1267,7 +1242,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1271: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1246: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1300,10 +1275,10 @@ fi if test "x$CC" != xcc; then echo $ac_n "checking whether $CC and cc understand -c and -o together""... $ac_c" 1>&6 -echo "configure:1304: checking whether $CC and cc understand -c and -o together" >&5 +echo "configure:1279: checking whether $CC and cc understand -c and -o together" >&5 else echo $ac_n "checking whether cc understands -c and -o together""... $ac_c" 1>&6 -echo "configure:1307: checking whether cc understands -c and -o together" >&5 +echo "configure:1282: checking whether cc understands -c and -o together" >&5 fi set dummy $CC; ac_cc="`echo $2 | sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`" @@ -1315,16 +1290,16 @@ else # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&5' -if { (eval echo configure:1319: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && - test -f conftest.o && { (eval echo configure:1320: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; +if { (eval echo configure:1294: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && + test -f conftest.o && { (eval echo configure:1295: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. - if { ac_try='cc -c conftest.c 1>&5'; { (eval echo configure:1325: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + if { ac_try='cc -c conftest.c 1>&5'; { (eval echo configure:1300: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then ac_try='cc -c conftest.c -o conftest.o 1>&5' - if { (eval echo configure:1327: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && - test -f conftest.o && { (eval echo configure:1328: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; + if { (eval echo configure:1302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && + test -f conftest.o && { (eval echo configure:1303: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; then # cc works too. : @@ -1360,7 +1335,7 @@ fi echo $ac_n "checking for long double""... $ac_c" 1>&6 -echo "configure:1364: checking for long double" >&5 +echo "configure:1339: checking for long double" >&5 if eval "test \"`echo '$''{'gcc_cv_c_long_double'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1368,7 +1343,7 @@ else gcc_cv_c_long_double=yes else cat > conftest.$ac_ext <= sizeof(double)):; ; return 0; } EOF -if { (eval echo configure:1382: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1357: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_c_long_double=yes else @@ -1401,21 +1376,21 @@ fi echo $ac_n "checking whether ${CC-cc} accepts -Wno-long-long""... $ac_c" 1>&6 -echo "configure:1405: checking whether ${CC-cc} accepts -Wno-long-long" >&5 +echo "configure:1380: checking whether ${CC-cc} accepts -Wno-long-long" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_no_long_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else save_CFLAGS="$CFLAGS" CFLAGS="-Wno-long-long" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1394: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_prog_cc_no_long_long=yes else @@ -1459,7 +1434,7 @@ esac echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1463: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:1438: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1487,7 +1462,7 @@ fi echo $ac_n "checking whether a default assembler was specified""... $ac_c" 1>&6 -echo "configure:1491: checking whether a default assembler was specified" >&5 +echo "configure:1466: checking whether a default assembler was specified" >&5 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then if test x"$gas_flag" = x"no"; then echo "$ac_t""yes ($DEFAULT_ASSEMBLER)" 1>&6 @@ -1499,7 +1474,7 @@ else fi echo $ac_n "checking whether a default linker was specified""... $ac_c" 1>&6 -echo "configure:1503: checking whether a default linker was specified" >&5 +echo "configure:1478: checking whether a default linker was specified" >&5 if test x"${DEFAULT_LINKER+set}" = x"set"; then if test x"$gnu_ld_flag" = x"no"; then echo "$ac_t""yes ($DEFAULT_LINKER)" 1>&6 @@ -1511,12 +1486,12 @@ else fi echo $ac_n "checking for GNU C library""... $ac_c" 1>&6 -echo "configure:1515: checking for GNU C library" >&5 +echo "configure:1490: checking for GNU C library" >&5 if eval "test \"`echo '$''{'gcc_cv_glibc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { @@ -1526,7 +1501,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1530: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1505: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_glibc=yes else @@ -1547,21 +1522,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1551: checking for inline" >&5 +echo "configure:1526: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1540: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -1588,12 +1563,12 @@ esac # Find some useful tools -for ac_prog in mawk gawk nawk awk +for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1597: checking for $ac_word" >&5 +echo "configure:1572: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1623,7 +1598,7 @@ test -n "$AWK" && break done echo $ac_n "checking whether ln works""... $ac_c" 1>&6 -echo "configure:1627: checking whether ln works" >&5 +echo "configure:1602: checking whether ln works" >&5 if eval "test \"`echo '$''{'gcc_cv_prog_LN'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1655,7 +1630,7 @@ else fi echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1659: checking whether ln -s works" >&5 +echo "configure:1634: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'gcc_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1687,19 +1662,19 @@ else fi echo $ac_n "checking for volatile""... $ac_c" 1>&6 -echo "configure:1691: checking for volatile" >&5 +echo "configure:1666: checking for volatile" >&5 if eval "test \"`echo '$''{'gcc_cv_c_volatile'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1678: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_c_volatile=yes else @@ -1722,7 +1697,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1726: checking for $ac_word" >&5 +echo "configure:1701: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1760,7 +1735,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1764: checking for a BSD compatible install" >&5 +echo "configure:1739: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1811,7 +1786,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1815: checking how to run the C preprocessor" >&5 +echo "configure:1790: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1826,13 +1801,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1836: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1843,13 +1818,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1828: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1860,13 +1835,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1845: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1891,12 +1866,12 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1895: checking for ANSI C header files" >&5 +echo "configure:1870: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1904,7 +1879,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1883: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1921,7 +1896,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1939,7 +1914,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1960,7 +1935,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1971,7 +1946,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1995,12 +1970,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1999: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:1974: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2009,7 +1984,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:2013: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1988: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -2030,12 +2005,12 @@ EOF fi echo $ac_n "checking whether string.h and strings.h may both be included""... $ac_c" 1>&6 -echo "configure:2034: checking whether string.h and strings.h may both be included" >&5 +echo "configure:2009: checking whether string.h and strings.h may both be included" >&5 if eval "test \"`echo '$''{'gcc_cv_header_string'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2043,7 +2018,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2047: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2022: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_header_string=yes else @@ -2064,12 +2039,12 @@ EOF fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:2068: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:2043: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2085,7 +2060,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:2089: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2064: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -2112,17 +2087,17 @@ for ac_hdr in limits.h stddef.h string.h strings.h stdlib.h time.h \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2116: checking for $ac_hdr" >&5 +echo "configure:2091: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2126: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2101: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2152,17 +2127,17 @@ done # Check for thread headers. ac_safe=`echo "thread.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for thread.h""... $ac_c" 1>&6 -echo "configure:2156: checking for thread.h" >&5 +echo "configure:2131: checking for thread.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2166: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2186,17 +2161,17 @@ fi ac_safe=`echo "pthread.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for pthread.h""... $ac_c" 1>&6 -echo "configure:2190: checking for pthread.h" >&5 +echo "configure:2165: checking for pthread.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2200: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2175: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2223,7 +2198,7 @@ fi # Extract the first word of "gnatbind", so it can be a program name with args. set dummy gnatbind; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2227: checking for $ac_word" >&5 +echo "configure:2202: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gnat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2255,7 +2230,7 @@ fi # Extract the first word of "mktemp", so it can be a program name with args. set dummy mktemp; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2259: checking for $ac_word" >&5 +echo "configure:2234: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_have_mktemp_command'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2294,7 +2269,7 @@ else # Extract the first word of "makeinfo", so it can be a program name with args. set dummy makeinfo; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2298: checking for $ac_word" >&5 +echo "configure:2273: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2323,13 +2298,13 @@ fi if test -n "$MAKEINFO"; then # Found it, now check the version. echo $ac_n "checking for modern makeinfo""... $ac_c" 1>&6 -echo "configure:2327: checking for modern makeinfo" >&5 +echo "configure:2302: checking for modern makeinfo" >&5 if eval "test \"`echo '$''{'gcc_cv_prog_makeinfo_modern'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_prog_version=`$MAKEINFO --version 2>&1 | sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'` - echo "configure:2333: version of makeinfo is $ac_prog_version" >&5 + echo "configure:2308: version of makeinfo is $ac_prog_version" >&5 case $ac_prog_version in '') gcc_cv_prog_makeinfo_modern=no;; 4.*) @@ -2357,7 +2332,7 @@ fi # Is pod2man recent enough to regenerate manpages? echo $ac_n "checking for recent Pod::Man""... $ac_c" 1>&6 -echo "configure:2361: checking for recent Pod::Man" >&5 +echo "configure:2336: checking for recent Pod::Man" >&5 if perl -e 'use 1.10 Pod::Man' >/dev/null 2>&1; then echo "$ac_t""yes" 1>&6 GENERATED_MANPAGES=generated-manpages @@ -2373,7 +2348,7 @@ else # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2377: checking for $ac_word" >&5 +echo "configure:2352: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_FLEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2410,7 +2385,7 @@ else # Extract the first word of "bison", so it can be a program name with args. set dummy bison; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2414: checking for $ac_word" >&5 +echo "configure:2389: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_BISON'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2444,12 +2419,12 @@ fi echo $ac_n "checking for preprocessor stringizing operator""... $ac_c" 1>&6 -echo "configure:2448: checking for preprocessor stringizing operator" >&5 +echo "configure:2423: checking for preprocessor stringizing operator" >&5 if eval "test \"`echo '$''{'ac_cv_c_stringize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 # Use only if it exists, # doesn't clash with , and declares intmax_t. echo $ac_n "checking for inttypes.h""... $ac_c" 1>&6 -echo "configure:2486: checking for inttypes.h" >&5 +echo "configure:2461: checking for inttypes.h" >&5 if eval "test \"`echo '$''{'gcc_cv_header_inttypes_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2495,7 +2470,7 @@ int main() { intmax_t i = -1; ; return 0; } EOF -if { (eval echo configure:2499: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2474: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_header_inttypes_h=yes else @@ -2520,7 +2495,7 @@ fi # be either signed or unsigned. # echo $ac_n "checking for unsigned enumerated bitfields""... $ac_c" 1>&6 -echo "configure:2524: checking for unsigned enumerated bitfields" >&5 +echo "configure:2499: checking for unsigned enumerated bitfields" >&5 if eval "test \"`echo '$''{'gcc_cv_enum_bf_unsigned'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2528,7 +2503,7 @@ else gcc_cv_enum_bf_unsigned=yes else cat > conftest.$ac_ext < enum t { BLAH = 128 } ; @@ -2541,7 +2516,7 @@ int main(void) } EOF -if { (eval echo configure:2545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then gcc_cv_enum_bf_unsigned=yes else @@ -2569,12 +2544,12 @@ for ac_func in strtoul bsearch putenv popen bcopy \ fputs_unlocked getrusage iconv nl_langinfo do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2573: checking for $ac_func" >&5 +echo "configure:2548: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2623,12 +2598,12 @@ done echo $ac_n "checking for ssize_t""... $ac_c" 1>&6 -echo "configure:2627: checking for ssize_t" >&5 +echo "configure:2602: checking for ssize_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2659,12 +2634,12 @@ fi # Try to determine the array type of the second argument of getgroups # for the target system (int or gid_t). echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:2663: checking for uid_t in sys/types.h" >&5 +echo "configure:2638: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -2693,7 +2668,7 @@ EOF fi echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6 -echo "configure:2697: checking type of array argument to getgroups" >&5 +echo "configure:2672: checking type of array argument to getgroups" >&5 if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2701,7 +2676,7 @@ else ac_cv_type_getgroups=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_type_getgroups=gid_t else @@ -2740,7 +2715,7 @@ fi if test $ac_cv_type_getgroups = cross; then cat > conftest.$ac_ext < EOF @@ -2781,12 +2756,12 @@ fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:2785: checking for vprintf" >&5 +echo "configure:2760: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -2833,12 +2808,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:2837: checking for _doprnt" >&5 +echo "configure:2812: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -2899,12 +2874,12 @@ fi for ac_func in strstr do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2903: checking for $ac_func" >&5 +echo "configure:2878: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2954,7 +2929,7 @@ done echo $ac_n "checking whether the printf functions support %p""... $ac_c" 1>&6 -echo "configure:2958: checking whether the printf functions support %p" >&5 +echo "configure:2933: checking whether the printf functions support %p" >&5 if eval "test \"`echo '$''{'gcc_cv_func_printf_ptr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2962,7 +2937,7 @@ else gcc_cv_func_printf_ptr=no else cat > conftest.$ac_ext < @@ -2975,7 +2950,7 @@ int main() return (p != q); } EOF -if { (eval echo configure:2979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then gcc_cv_func_printf_ptr=yes else @@ -3007,12 +2982,12 @@ case "${host}" in ;; esac echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:3011: checking for pid_t" >&5 +echo "configure:2986: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3041,17 +3016,17 @@ fi ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for vfork.h""... $ac_c" 1>&6 -echo "configure:3045: checking for vfork.h" >&5 +echo "configure:3020: checking for vfork.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3055: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3030: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3076,18 +3051,18 @@ else fi echo $ac_n "checking for working vfork""... $ac_c" 1>&6 -echo "configure:3080: checking for working vfork" >&5 +echo "configure:3055: checking for working vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then echo $ac_n "checking for vfork""... $ac_c" 1>&6 -echo "configure:3086: checking for vfork" >&5 +echo "configure:3061: checking for vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vfork=yes" else @@ -3132,7 +3107,7 @@ fi ac_cv_func_vfork_works=$ac_cv_func_vfork else cat > conftest.$ac_ext < @@ -3227,7 +3202,7 @@ main() { } } EOF -if { (eval echo configure:3231: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_vfork_works=yes else @@ -3252,12 +3227,12 @@ fi for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3256: checking for $ac_func" >&5 +echo "configure:3231: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3551,7 +3526,7 @@ main () EOF echo $ac_n "checking for working mmap from /dev/zero""... $ac_c" 1>&6 -echo "configure:3555: checking for working mmap from /dev/zero" >&5 +echo "configure:3530: checking for working mmap from /dev/zero" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_dev_zero'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3567,11 +3542,11 @@ else esac else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_dev_zero=yes else @@ -3598,7 +3573,7 @@ EOF fi echo $ac_n "checking for working mmap with MAP_ANON(YMOUS)""... $ac_c" 1>&6 -echo "configure:3602: checking for working mmap with MAP_ANON(YMOUS)" >&5 +echo "configure:3577: checking for working mmap with MAP_ANON(YMOUS)" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_anon'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3608,12 +3583,12 @@ else ac_cv_func_mmap_anon=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_anon=yes else @@ -3641,7 +3616,7 @@ fi rm -f ct-mmap.inc echo $ac_n "checking for working mmap of a file""... $ac_c" 1>&6 -echo "configure:3645: checking for working mmap of a file" >&5 +echo "configure:3620: checking for working mmap of a file" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_file'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3656,7 +3631,7 @@ if test "$cross_compiling" = yes; then ac_cv_func_mmap_file=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_file=yes else @@ -3726,12 +3701,12 @@ for ac_func in bcopy \ do ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` echo $ac_n "checking whether $ac_func is declared""... $ac_c" 1>&6 -echo "configure:3730: checking whether $ac_func is declared" >&5 +echo "configure:3705: checking whether $ac_func is declared" >&5 if eval "test \"`echo '$''{'gcc_cv_have_decl_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3721: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_have_decl_$ac_func=yes" else @@ -3835,12 +3810,12 @@ for ac_func in getrlimit setrlimit getrusage do ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` echo $ac_n "checking whether $ac_func is declared""... $ac_c" 1>&6 -echo "configure:3839: checking whether $ac_func is declared" >&5 +echo "configure:3814: checking whether $ac_func is declared" >&5 if eval "test \"`echo '$''{'gcc_cv_have_decl_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3834: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_have_decl_$ac_func=yes" else @@ -3898,12 +3873,12 @@ CFLAGS="$saved_CFLAGS" # mkdir takes a single argument on some systems. echo $ac_n "checking if mkdir takes one argument""... $ac_c" 1>&6 -echo "configure:3902: checking if mkdir takes one argument" >&5 +echo "configure:3877: checking if mkdir takes one argument" >&5 if eval "test \"`echo '$''{'gcc_cv_mkdir_takes_one_arg'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -3920,7 +3895,7 @@ int main() { mkdir ("foo", 0); ; return 0; } EOF -if { (eval echo configure:3924: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3899: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_mkdir_takes_one_arg=no else @@ -4231,7 +4206,7 @@ fi echo $ac_n "checking for strerror in -lcposix""... $ac_c" 1>&6 -echo "configure:4235: checking for strerror in -lcposix" >&5 +echo "configure:4210: checking for strerror in -lcposix" >&5 ac_lib_var=`echo cposix'_'strerror | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4239,7 +4214,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4273,12 +4248,12 @@ fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:4277: checking for working const" >&5 +echo "configure:4252: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4306: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -4348,12 +4323,12 @@ EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:4352: checking for off_t" >&5 +echo "configure:4327: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -4381,12 +4356,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:4385: checking for size_t" >&5 +echo "configure:4360: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -4416,19 +4391,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:4420: checking for working alloca.h" >&5 +echo "configure:4395: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:4432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -4449,12 +4424,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:4453: checking for alloca" >&5 +echo "configure:4428: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4461: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -4514,12 +4489,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:4518: checking whether alloca needs Cray hooks" >&5 +echo "configure:4493: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4548: checking for $ac_func" >&5 +echo "configure:4523: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4599,7 +4574,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:4603: checking stack direction for C alloca" >&5 +echo "configure:4578: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4607,7 +4582,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -4653,17 +4628,17 @@ unistd.h sys/param.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4657: checking for $ac_hdr" >&5 +echo "configure:4632: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4667: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4642: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4693,12 +4668,12 @@ done strdup __argz_count __argz_stringify __argz_next do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4697: checking for $ac_func" >&5 +echo "configure:4672: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4750,12 +4725,12 @@ done for ac_func in stpcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4754: checking for $ac_func" >&5 +echo "configure:4729: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4812,19 +4787,19 @@ EOF if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:4816: checking for LC_MESSAGES" >&5 +echo "configure:4791: checking for LC_MESSAGES" >&5 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:4828: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_val_LC_MESSAGES=yes else @@ -4845,7 +4820,7 @@ EOF fi fi echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:4849: checking whether NLS is requested" >&5 +echo "configure:4824: checking whether NLS is requested" >&5 # Check whether --enable-nls or --disable-nls was given. if test "${enable_nls+set}" = set; then enableval="$enable_nls" @@ -4865,7 +4840,7 @@ fi EOF echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 -echo "configure:4869: checking whether included gettext is requested" >&5 +echo "configure:4844: checking whether included gettext is requested" >&5 # Check whether --with-included-gettext or --without-included-gettext was given. if test "${with_included_gettext+set}" = set; then withval="$with_included_gettext" @@ -4884,17 +4859,17 @@ fi ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for libintl.h""... $ac_c" 1>&6 -echo "configure:4888: checking for libintl.h" >&5 +echo "configure:4863: checking for libintl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4898: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4873: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4911,19 +4886,19 @@ fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6 -echo "configure:4915: checking for gettext in libc" >&5 +echo "configure:4890: checking for gettext in libc" >&5 if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return (int) gettext ("") ; return 0; } EOF -if { (eval echo configure:4927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gt_cv_func_gettext_libc=yes else @@ -4939,7 +4914,7 @@ echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6 if test "$gt_cv_func_gettext_libc" != "yes"; then echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6 -echo "configure:4943: checking for bindtextdomain in -lintl" >&5 +echo "configure:4918: checking for bindtextdomain in -lintl" >&5 ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4947,7 +4922,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4974,12 +4949,12 @@ fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6 -echo "configure:4978: checking for gettext in libintl" >&5 +echo "configure:4953: checking for gettext in libintl" >&5 if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo $ac_n "checking for gettext in -lintl""... $ac_c" 1>&6 -echo "configure:4983: checking for gettext in -lintl" >&5 +echo "configure:4958: checking for gettext in -lintl" >&5 ac_lib_var=`echo intl'_'gettext | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4987,7 +4962,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5041,7 +5016,7 @@ EOF # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5045: checking for $ac_word" >&5 +echo "configure:5020: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5075,12 +5050,12 @@ fi for ac_func in dcgettext do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5079: checking for $ac_func" >&5 +echo "configure:5054: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5130,7 +5105,7 @@ done # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5134: checking for $ac_word" >&5 +echo "configure:5109: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5166,7 +5141,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5170: checking for $ac_word" >&5 +echo "configure:5145: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5198,7 +5173,7 @@ else fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* CATOBJEXT=.gmo DATADIRNAME=share @@ -5231,7 +5206,7 @@ fi if test "$CATOBJEXT" = "NONE"; then echo $ac_n "checking whether catgets can be used""... $ac_c" 1>&6 -echo "configure:5235: checking whether catgets can be used" >&5 +echo "configure:5210: checking whether catgets can be used" >&5 # Check whether --with-catgets or --without-catgets was given. if test "${with_catgets+set}" = set; then withval="$with_catgets" @@ -5244,7 +5219,7 @@ fi if test "$nls_cv_use_catgets" = "yes"; then echo $ac_n "checking for main in -li""... $ac_c" 1>&6 -echo "configure:5248: checking for main in -li" >&5 +echo "configure:5223: checking for main in -li" >&5 ac_lib_var=`echo i'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5252,14 +5227,14 @@ else ac_save_LIBS="$LIBS" LIBS="-li $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5287,12 +5262,12 @@ else fi echo $ac_n "checking for catgets""... $ac_c" 1>&6 -echo "configure:5291: checking for catgets" >&5 +echo "configure:5266: checking for catgets" >&5 if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5294: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_catgets=yes" else @@ -5337,7 +5312,7 @@ EOF # Extract the first word of "gencat", so it can be a program name with args. set dummy gencat; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5341: checking for $ac_word" >&5 +echo "configure:5316: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_GENCAT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5373,7 +5348,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5377: checking for $ac_word" >&5 +echo "configure:5352: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5410,7 +5385,7 @@ fi # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5414: checking for $ac_word" >&5 +echo "configure:5389: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5448,7 +5423,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5452: checking for $ac_word" >&5 +echo "configure:5427: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5506,7 +5481,7 @@ fi # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5510: checking for $ac_word" >&5 +echo "configure:5485: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5540,7 +5515,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5544: checking for $ac_word" >&5 +echo "configure:5519: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5579,7 +5554,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5583: checking for $ac_word" >&5 +echo "configure:5558: checking for $ac_word" >&5 if eval "test \"`echo '$''{'gcc_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5678,7 +5653,7 @@ fi LINGUAS= else echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6 -echo "configure:5682: checking for catalogs to be installed" >&5 +echo "configure:5657: checking for catalogs to be installed" >&5 if test "x$LINGUAS" = "x"; then LINGUAS=$ALL_LINGUAS else @@ -5710,17 +5685,17 @@ echo "configure:5682: checking for catalogs to be installed" >&5 if test "$CATOBJEXT" = ".cat"; then ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6 -echo "configure:5714: checking for linux/version.h" >&5 +echo "configure:5689: checking for linux/version.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5724: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5699: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5795,7 +5770,7 @@ fi echo $ac_n "checking whether windows registry support is requested""... $ac_c" 1>&6 -echo "configure:5799: checking whether windows registry support is requested" >&5 +echo "configure:5774: checking whether windows registry support is requested" >&5 if test x$enable_win32_registry != xno; then cat >> confdefs.h <<\EOF #define ENABLE_WIN32_REGISTRY 1 @@ -5824,7 +5799,7 @@ esac if test x$enable_win32_registry != xno; then echo $ac_n "checking registry key on windows hosts""... $ac_c" 1>&6 -echo "configure:5828: checking registry key on windows hosts" >&5 +echo "configure:5803: checking registry key on windows hosts" >&5 cat >> confdefs.h <&6 -echo "configure:6008: checking what assembler to use" >&5 +echo "configure:5983: checking what assembler to use" >&5 gcc_cv_as= gcc_cv_gas_major_version= gcc_cv_gas_minor_version= @@ -6089,7 +6064,7 @@ fi # Figure out what nm we will be using. echo $ac_n "checking what nm to use""... $ac_c" 1>&6 -echo "configure:6093: checking what nm to use" >&5 +echo "configure:6068: checking what nm to use" >&5 if test -x nm$host_exeext; then gcc_cv_nm=./nm$host_exeext elif test x$host = x$target; then @@ -6100,7 +6075,7 @@ echo "$ac_t""$gcc_cv_nm" 1>&6 # Figure out what assembler alignment features are present. echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6 -echo "configure:6104: checking assembler alignment features" >&5 +echo "configure:6079: checking assembler alignment features" >&5 gcc_cv_as_alignment_features=none if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then # Gas version 2.6 and later support for .balign and .p2align. @@ -6148,7 +6123,7 @@ fi echo "$ac_t""$gcc_cv_as_alignment_features" 1>&6 echo $ac_n "checking assembler subsection support""... $ac_c" 1>&6 -echo "configure:6152: checking assembler subsection support" >&5 +echo "configure:6127: checking assembler subsection support" >&5 gcc_cv_as_subsections=no if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 9 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then @@ -6188,7 +6163,7 @@ fi echo "$ac_t""$gcc_cv_as_subsections" 1>&6 echo $ac_n "checking assembler weak support""... $ac_c" 1>&6 -echo "configure:6192: checking assembler weak support" >&5 +echo "configure:6167: checking assembler weak support" >&5 gcc_cv_as_weak=no if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 2 -o "$gcc_cv_gas_major_version" -gt 2; then @@ -6211,7 +6186,7 @@ fi echo "$ac_t""$gcc_cv_as_weak" 1>&6 echo $ac_n "checking assembler hidden support""... $ac_c" 1>&6 -echo "configure:6215: checking assembler hidden support" >&5 +echo "configure:6190: checking assembler hidden support" >&5 gcc_cv_as_hidden=no if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 10 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then @@ -6237,7 +6212,7 @@ echo "$ac_t""$gcc_cv_as_hidden" 1>&6 case "$target" in sparc*-*-*) echo $ac_n "checking assembler .register pseudo-op support""... $ac_c" 1>&6 -echo "configure:6241: checking assembler .register pseudo-op support" >&5 +echo "configure:6216: checking assembler .register pseudo-op support" >&5 if eval "test \"`echo '$''{'gcc_cv_as_register_pseudo_op'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6265,7 +6240,7 @@ EOF fi echo $ac_n "checking assembler supports -relax""... $ac_c" 1>&6 -echo "configure:6269: checking assembler supports -relax" >&5 +echo "configure:6244: checking assembler supports -relax" >&5 if eval "test \"`echo '$''{'gcc_cv_as_relax_opt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6295,7 +6270,7 @@ EOF case "$tm_file" in *64*) echo $ac_n "checking for 64 bit support in assembler ($gcc_cv_as)""... $ac_c" 1>&6 -echo "configure:6299: checking for 64 bit support in assembler ($gcc_cv_as)" >&5 +echo "configure:6274: checking for 64 bit support in assembler ($gcc_cv_as)" >&5 if eval "test \"`echo '$''{'gcc_cv_as_flags64'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6340,7 +6315,7 @@ EOF if test "x$gcc_cv_as_flags64" != xno; then echo $ac_n "checking for assembler offsetable %lo() support""... $ac_c" 1>&6 -echo "configure:6344: checking for assembler offsetable %lo() support" >&5 +echo "configure:6319: checking for assembler offsetable %lo() support" >&5 if eval "test \"`echo '$''{'gcc_cv_as_offsetable_lo10'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6379,7 +6354,7 @@ EOF i[34567]86-*-*) echo $ac_n "checking assembler instructions""... $ac_c" 1>&6 -echo "configure:6383: checking assembler instructions" >&5 +echo "configure:6358: checking assembler instructions" >&5 gcc_cv_as_instructions= if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 9 -o "$gcc_cv_gas_major_version" -gt 2; then @@ -6408,7 +6383,7 @@ EOF esac echo $ac_n "checking assembler dwarf2 debug_line support""... $ac_c" 1>&6 -echo "configure:6412: checking assembler dwarf2 debug_line support" >&5 +echo "configure:6387: checking assembler dwarf2 debug_line support" >&5 gcc_cv_as_dwarf2_debug_line=no # ??? Not all targets support dwarf2 debug_line, even within a version # of gas. Moreover, we need to emit a valid instruction to trigger any @@ -6569,14 +6544,13 @@ fi cat >> confdefs.h <&6 -echo "configure:6580: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:6554: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -7103,7 +7077,6 @@ s%@GGC@%$GGC%g s%@zlibdir@%$zlibdir%g s%@zlibinc@%$zlibinc%g s%@GXX_ABI_FLAG@%$GXX_ABI_FLAG%g -s%@HAVE_LIBSTDCXX_V3@%$HAVE_LIBSTDCXX_V3%g s%@MAINT@%$MAINT%g s%@build_canonical@%$build_canonical%g s%@host_canonical@%$host_canonical%g diff --git a/gcc/configure.in b/gcc/configure.in index ac39b4ff2c2..73be99e1ab0 100644 --- a/gcc/configure.in +++ b/gcc/configure.in @@ -151,23 +151,6 @@ if test x$local_prefix = x; then local_prefix=/usr/local fi -# Build a new-libstdc++ system (ie libstdc++-v3) -AC_MSG_CHECKING([for libstdc++ to install]) -AC_ARG_ENABLE(libstdcxx-v3, -[ --enable-libstdcxx-v3 - enable libstdc++-v3 for building and installation], - [enable_libstdcxx_v3="$enableval"], [enable_libstdcxx_v3=yes]) - -if test x$enable_libstdcxx_v3 = xyes; then - AC_MSG_RESULT(v3) - HAVE_LIBSTDCXX_V3=1 - ac_esn=1 -else - AC_MSG_RESULT(v2) - HAVE_LIBSTDCXX_V3=0 - ac_esn=0 -fi - # Don't set gcc_gxx_include_dir to gxx_include_dir since that's only # passed in by the toplevel make and thus we'd get different behavior # depending on where we built the sources. @@ -1599,9 +1582,8 @@ else fi AC_SUBST(GXX_ABI_FLAG) -AC_DEFINE_UNQUOTED(ENABLE_STD_NAMESPACE, $ac_esn, +AC_DEFINE_UNQUOTED(ENABLE_STD_NAMESPACE, 1, [Define to 1 if you want to enable namespaces (-fhonor-std) by default.]) -AC_SUBST(HAVE_LIBSTDCXX_V3) dnl Very limited version of automake's enable-maintainer-mode diff --git a/libstdc++/ChangeLog b/libstdc++/ChangeLog deleted file mode 100644 index 9fc67ea02ca..00000000000 --- a/libstdc++/ChangeLog +++ /dev/null @@ -1,1539 +0,0 @@ -2001-01-23 Chris Demetriou - - * exception.cc (__terminate_func): Remove declaration. - (__terminate_func_ptr): New typedef. - (__terminate, __terminate_set_func): New extern function - prototypes. - (std::terminate): Use __terminate function. - (std::set_terminate): Use __terminate_set_func function. - -2000-11-24 Magnus Fromreide - - * sstream: Backport libstdc++-V3 sstream to V2. - -2000-10-23 Gabriel Dos Reis - - * std/std_valarray.h (valarray::valarray): Use __valarray_copy, - not __valarray_copy_construct. - -2000-10-08 Philipp Thomas - - * Makefile.in (piclist): Fix sed command to also accept - numbers in filenames. - -2000-10-07 Richard Henderson - - * del_op.cc, del_opnt.cc, del_opv.cc, del_opvnt.cc: New files. - * exception.cc, new_handler.cc, new_op.cc, new_opnt.cc: New files. - * new_opv.cc, new_opvnt.cc, tinfo.cc, tinfo2.cc, vec.cc: New files. - * cxxabi.h, exception, new, new.h, typeinfo, pure.c: New files. - * tinfo.hP: New file. - - * Makefile.in (OBJS, HEADERS): Add new files. - * configure.in (XCXXINCLUDES): Add ../include and ../gcc. - -2000-09-19 David Edelsohn - - * configure.in: Add AIX multithread support fragment. - * config/aix.mt: Define _PTHREADS in MT_CFLAGS if -pthread - commandline option present. - -2000-08-14 Zack Weinberg - - * configure.in: Accept *-*-linux* not just *-*-linux-gnu*. - Honor --disable-threads. - -2000-08-11 Jason Merrill - - * std/straits.h (is_del): Boolify with !!. - -2000-08-11 "Axel Habermann" - - * std/bastring.cc (compare to charT*): Add rlen==n check. - * std/bastring.h (Rep::grab): Add x86 atomic version. - -2000-8-4 David E O'Brien - - * std/mask_array.h (mask_array): Rename template type - parameter to avoid conflicts with ctype.h on BSD systems. - * std/slice_array.h (slice_array): Likewise. - -2000-07-17 Gabriel Dos Reis - - * std/valarray_array.h(__valarray_sum): Make inline. - -2000-07-15 Gabriel Dos Reis - - * std/valarray_array.h (__valarray_get_memory, - __valarray_get_storage, __valarray_release_storage): New - functions. - (_Array_default_ctor, _Array_init_ctor, _Array_copy_ctor, - _Array_copier): New traits classes. - (__valarray_default_construct): New function. Implements valarray - default construction. - (__valarray_fill_construct): New function. Implements valarray - construction with initializer. - (__valarray_copy_construct): New function. Implements valarray - copy construction. - (__valarray_destroy_elements): New function. - (__valarray_copy, __valarray_fill): Tweak. - (__valarray_sum, __valarray_product): New helper functions. - (_Array<>::free_data): Remove. - (_Array<>::_Array): Tweak. - - * std/std_valarray.h (valarray<>::product): Remove. - (valarray<>::valarray): Use __valarray_get_storage. - (valarray<>::shift, valarray<>::cshift, valarray<>::resize): - Tweak. - - * std/cpp_type_traits.h: New file. - - * valarray.cc (multiplies<>, accumulate, valarray<>::product): - Remove explicit instantiation. - (__valarray_product): New function. - (_Indexer::_Indexer): Use. - -2000-07-14 Jean-Francois Panisset - - * std/bastring.h (basic_string<>::clear): Add function. - -2000-07-06 Zack Weinberg - - * std/gslice_array.h, std/indirect_array.h, std/mask_array.h, - std/slice_array.h, std/std_valarray.h, std/valarray_meta.h: - Do not paste anything after 'operator' keyword. - -2000-05-15 David Edelsohn - - * Makefile.in: Change "pic" to depend on $(PICFLAG), not - on $(enable_shared). - * config/aix.ml: Build AIX-style shared library. - -2000-05-10 Jakub Jelinek - - * configure.in: Use mh-sparcpic for sparc*-*-*. - -2000-04-24 Magnus Fromreide - - * sstream: New file. - * Makefile.in (HEADERS): Add it. - -2000-03-29 Jason Merrill - - * configure.in: -linux-gnu*, not -linux-gnu. - -2000-03-10 Gabriel Dos Reis - - * std/bastring.h (basic_string<>::push_back): Was missing. - -2000-01-12 Fred Fish - - * Makefile.in (SHOPT): New macro, flag to ld to create - shared library. Defaults to "-shared". - (SHLIB): Use new SHOPT rather than hardcoded "-shared". - * configure.in: While configuring for *-*-beos*, if - --enable-shared is given, add beos.ml to list of makefile - frags. - * config/beos.ml: New file. - -1999-12-15 Jason Merrill - - * Makefile.in (MYCXXFLAGS): Include $(CXXFLAGS). - (MYCFLAGS): Include $(CFLAGS). - -1999-12-14 Martin v. Löwis - - * std/bastring.h (basic_string::basic_string): Rename parameters - to avoid shadow warnings. - * std/bastring.cc (alloc): Likewise. - -1999-12-13 Jakub Jelinek - - * std/bastring.h (class basic_string::Rep): Use proper defines - for sparc v9 and fix asm for sparc64. - -1999-11-19 Gabriel Dos Reis - - * std/valarray_meta.h (_DEFINE_EXPR_UNARY_FUNCTION): Don't forget - to define tanh. - -Sun Nov 14 09:47:51 1999 H.J. Lu - - * Makefile.in ($(OBJS)): Depend on stamp-picdir. - -1999-11-05 Gabriel Dos Reis - - * std/valarray_meta.h (_DEFINE_EXPR_UNARY_FUNCTION): When - building meta-expressions don't forget to take the contained - closures. - -1999-10-19 Gabriel Dos Reis - - * std/valarray_meta.h: (_BinClos::_BinClos): Fix typo. - -1999-090-17 Gabriel Dos Reis - - * std/valarray_array.h (__valarray_copy): Fix typo. - -1999-09-17 Gabriel Dos Reis - - * std/complext.cc (pow): Don't expect floating point promotion - in presence of template argument deduction. There is no such - thing. - -1999-09-01 Andreas Schwab - - * configure.in: Move *-*-gnu* pattern below *-*-linux*. - -Wed Aug 25 01:31:11 1999 "David O'Brien" - - * configure.in: Alphabetize selection of .ml fragments. - -Thu Aug 5 02:00:13 1999 Loren Rittle - - * Makefile.in (MARLINK, MSHLINK): Handle library version - number components with more than one numeric digit. - -Sat Jul 17 23:51:58 1999 Jeffrey A Law (law@cygnus.com) - - * Makefile.in (INTERFACE): Bump to 3. - -1999-07-16 Markus Gyger (mgyger@gmu.edu) - - * stdexcepti.cc (__out_of_range): Use std:: qualifier for names - in std. - (__length_error): Likewise. - -Fri Jul 9 01:20:23 1999 Jeffrey A Law (law@cygnus.com) - - * Makefile.in (VERSION): Bump to 2.10.0. - -Tue Jun 8 00:21:11 1999 Jeffrey A Law (law@cygnus.com) - - * configure.in (*-*-freebsd2*): Add missing '*' at end of configure - string. - -1999-06-05 Gabriel Dos Reis - - * std/std_valarray.h: Don't #include unconditionally - -1999-06-05 Gabriel Dos Reis - - * std/std_valarray.h: New file. - * std/slice.h: New file. - * std/slice_array.h: New file. - * std/gslice.h: New file. - * std/gslice_array.h: New file. - * std/mask_array.h: New file. - * std/indirect_array.h: New file. - * std/valarray_array.h: New file. - * std/valarray_array.tcc: New file. - * std/valarray_meta.h: New file. - * valarray.cc: New file. - * valarray: New file - - * Makefile.in (OBJS): add valarray.o - (HEADERS): add valarray - (valarray.o): define dependency on valarray.cc - (install): make it possible to install valarray file. - -Wed Jun 2 00:21:54 1999 Robert Lipe - - * std/bastring.h (class basic_string:Rep): Encode xlock opcode - as .bytes instead of mnemonics. - -1999-05-20 Angela Marie Thomas - - * configure.in: Test for ${compiler_name}.exe as well. - -1999-05-15 Mark Kettenis - - * configure.in: Add shared library support for the Hurd - (*-*-gnu*). - * config/gnu.ml: New file. - -1999-05-12 Jason Merrill - - * configure.in (compiler_name): Don't do the skip-this-dir thing - if we're reconfiguring. - -1999-05-07 Ulrich Drepper - - * std/bastring.h (class basic_string::Rep): Make release member - function thread-safe for ix86 (x>=4) and UltraSPARC. - - * stlinst.cc: Make it possible to compile with __USE_MALLOC. - -Mon Apr 26 02:24:47 1999 "Loren J. Rittle" - - * config/freebsd.ml (LIBS): Add ARLINK. - * config/openbsd.ml (LIBS): Add ARLINK. - -Fri Apr 2 15:12:14 1999 H.J. Lu (hjl@gnu.org) - - * libstdc++/configure.in (gxx_include_dir): Handle it. - * libstdc++/Makefile.in: Likewise. - -Wed Mar 24 22:36:45 1999 Mumit Khan - - * configure.in (EXEEXT): Define. - (compiler_name): Use. - -Thu Mar 11 01:07:55 1999 Franz Sirl - - * configure.in: Add mh-*pic handling for alpha, arm, powerpc - -Fri Mar 5 02:16:39 1999 Doug Rabson - - * configure.in: Support shared libs on FreeBSD 3.x and 4.x - * config/freebsd.ml: A copy of config/linux.ml since they are both - ELF and both have a shared libm. - -1999-02-24 Jason Merrill - - * configure.in: Fix INSTALLDIR sed pattern for Solaris sed. - -Sat Feb 20 13:17:17 1999 Jeffrey A Law (law@cygnus.com) - - * string, std/straits.h, std/bastring.h: Revert recent change. Needs - some libiberty support before it can be re-enabled. - -Thu Feb 18 19:53:17 1999 Marc Espie - - * configure.in: Handle OpenBSD with and without threads. - * config/openbsd.ml: New file. - * config/openbsd.mt: New file. - -1999-02-04 Ulrich Drepper - - * configure.in: Recognize --enable-threads=posix for all - platforms. - * config/posix.mt: New file. - - * configure.in: Add fragments for Solaris defining macro specifying - thread library to be used. - * config/sol2pth.mt: New file - * config/sol2solth.mt: New file. - * stl/stl_alloc.h: Add support for Solaris thread library. - * stl/stl_config.h: Recognize _SOLTHREADS and define internal macros - appropriately. - -1999-01-28 Baron Roberts - - * string: Uncomment wstring declaration. - - * std/straits.h: Remove #if 0/#endif from around - struct string_char_traits . - #include . - Add missing definition for wchar_t move method. - Add empty() method for trait-based empty string return. - - * std/bastring.h (c_str): Change return of "" to return of - traits::empty() call so that proper empty string is returned - based on the character type (i.e. "" or L""). - -1999-02-07 Jason Merrill - - * Makefile.in (stuff2): Tweak. - -1999-02-04 Ulrich Drepper - - * configure.in: Recognize --enable-threads=posix for all - platforms. - * config/posix.mt: New file. - - * configure.in: Add fragments for Solaris defining macro specifying - thread library to be used. - * config/sol2pth.mt: New file - * config/sol2solth.mt: New file. - * stl/stl_alloc.h: Add support for Solaris thread library. - * stl/stl_config.h: Recognize _SOLTHREADS and define internal macros - appropriately. - -Sat Jan 30 08:05:46 1999 Mumit Khan - - * config/x86-interix.ml: New file. - * configure.in (i[3456]86-*-interix*): Add shared library support. - -1999-01-13 Ulrich Drepper - - * configure.in: Test for "ln -s" and set LN_S in generated Makefile. - * Makefile.in: Use $(LN_S) instead of explicitly ln -s. - -Sun Jan 03 03:16:02 1999 Robert Lipe - - * configure.in: (*-*-sysv5, *-*-*udk*): Treat like sysv4. - -Tue Dec 8 00:59:09 1998 Marc Espie - - * Makefile.in: Be more selective about what files to install. - -1998-11-30 Ulrich Drepper - - * std/bastring.cc (operator>>): Correct cast in last patch. - (getline): Likewise. - -1998-11-27 Alexandre Oliva - - * Makefile.in (HEADERS): Install bitset. - -1998-11-26 Manfred Hollstein - - * configure.in (compiler_name): Add check to detect if this - language's compiler has been built. - -1998-11-23 Ulrich Drepper - - * std/bastring.cc (operator>>): Cast new character to char before - adding to string. - (getline): Likewise. - -Thu Sep 17 01:29:46 1998 H.J. Lu (hjl@gnu.org) - - * Makefile.in ($(ARLINK), $(SHLINK)): Don't rely on 'ln -f'. - - * Makefile.in (install): Don't rely on 'ln -f'. - -1998-09-09 Manfred Hollstein - - * Makefile.in (install): Initialize RELINSTALLDIR correctly - even for multilib and cross configurations. - - * configure.in (INSTALLDIR): Don't change INSTALLDIR's init - value if --enable-version-specific-runtime-libs has been specified. - -Wed Sep 2 21:11:15 1998 H.J. Lu (hjl@gnu.org) - - * Makefile.in (RELINSTALLDIR): New. Use it to make symlinks. - - * configure.in: Fix INSTALLDIR replacement for cross-compile. - -Sun Aug 30 22:17:41 1998 H.J. Lu (hjl@gnu.org) - - * Makefile.in (INTERFACE): New, set to 2. - (ARLIB): Set to libstdc++.a.$(VERSION) - (ARLINK, MARLINK): New macros. - (LIBS): Add $(ARLINK). - ($(ARLINK), marlink): New targets. - (install): Don't check $(libsubdir). Handle versioned libraries. - - * config/linux.ml (ARLIB, MARLINK, SHLIB, MSHLINK): New macros. - (LIBS): Add marlink $(ARLINK). - - * config/aix.ml (ARLIB): Set to libstdc++-ar.a.$(VERSION) - (ARLINK): New macros. - (BUILD_LIBS): Add $(ARLINK). - - * config/dec-osf.ml (LIBS): Add $(ARLINK). - * config/elf.ml (LIBS): Likewise. - * config/elfshlibm.ml (LIBS): Likewise. - * config/hpux.ml (LIBS): Likewise. - * config/iris5.ml (LIBS): Likewise. - * config/sol2shm.ml (LIBS): Likewise. - * config/sunos4.ml (LIBS): Likewise. - - * configure.in: Use ${topsrcdir}/config.if to put - LIBSTDCXX_INTERFACE, CXX_INTERFACE, LIBC_INTERFACE in - ${package_makefile_frag}. - -1998-08-25 Martin von Löwis - - * stdexcept: Remove __HONOR_STD. - -1998-08-23 Mark Mitchell - - * sinst.cc: Don't explicitly instantiation string_char_traits. - * cinst.cc: Likewiwse, for complex, complex, - complex. - -1998-08-17 Mark Mitchell - - * stdexcept: Put things in the std namespace, if appropriate. - -1998-07-12 Jason Merrill - - * Makefile.in (VERSION): Bump to 2.9.0. - -1998-07-12 Lars Albertsson - - * std/bastring.cc (find_last_of): Fix. - (find_last_not_of): Likewise. - -1998-07-06 Manfred Hollstein - - * configure.in (INSTALLDIR): Make sed pattern failsafe. - -1998-07-06 Ulrich Drepper - - * std/bastring.h (class basic_string): Correct iterator return - values in insert member functions. - -1998-07-02 Ulrich Drepper - - * std/bastring.h (class basic_string): Return correct iterators in - erase member functions. - -1998-06-24 Manfred Hollstein - - * Makefile.in (INSTALLDIR): Add comment to document the fact, - this macro will be properly initialized at make's runtime. - (install): Add initialization of INSTALLDIR depending on $(libsubdir) - and ${enable_version_specific_runtime_libs}; use $${INSTALLDIR} shell - variable instead of the $(INSTALLDIR) make macro. - -Tue Mar 24 10:13:07 1998 Jason Merrill - - * std/bastring.cc (basic_string::copy): Mark const here, too. - -1998-03-23 15:59 Ulrich Drepper - - * std/bastring.h (basic_string::copy): Mark copy function as const. - Reported by Scott Schurr . - -Thu Mar 5 09:23:28 1998 Manfred Hollstein - - * configure.in: Make locating frag files failsafe even for the - special case if configuring and building in srcdir. - -1998-03-04 12:37 Ulrich Drepper - - * cinst.cc [INSERT] (operator<<): Correct type of numeric argument. - -Fri Feb 6 01:36:21 1998 Manfred Hollstein - - * Makefile.in (piclist): Check value of enable_shared, not PICFLAG. - (stmp-string, ...): Dito. - (bigstmp-string, ...): Dito. - -Sun Feb 1 13:38:07 1998 H.J. Lu (hjl@gnu.org) - - * config/linux.mt: Don't define _PTHREADS, but define - _IO_MTSAFE_IO. - -Wed Jan 28 10:27:11 1998 Manfred Hollstein - - * tests/configure.in, testsuite/configure.in: Update with yesterday's - toplevel configure.in changes. - -Tue Jan 27 23:27:32 1998 Manfred Hollstein - - * configure.in (package_makefile_rules_frag): New variable - which is used in the call to config.shared; redirect file descriptor 2 - to ${package_makefile_rules_frag}. - -Tue Jan 27 10:11:27 1998 Jason Merrill - - * Makefile.in (install): Remove the shared library symlink even if - we aren't installing it. - -Tue Jan 27 10:29:44 1998 H.J. Lu (hjl@gnu.org) - - * configure.in (topsrcdir): New. - (configdirs): Check ${topsrcdir}/gcc instead. - (config-ml.in): Use ${topsrcdir}/config-ml.in. - - * tests/configure.in (topsrcdir): New. - (check): Check ${topsrcdir}/gcc instead. - -Sun Jan 25 14:01:50 1998 Jason Merrill - - * std/bastring.h (unique): We only need length bytes. - (c_str): Avoid writing over random memory. - #include . - Lose _G_ALLOC_CONTROL. - * std/bastring.cc: Likewise. - (nilRep): Add initializer for selfish. - * sinst.cc: Just #include . - -Tue Jan 13 21:23:05 1998 H.J. Lu (hjl@gnu.org) - - * configure.in (configdirs): Include testsuite only if - ${srcdir}/../gcc exists. - - * tests/configure.in (check): Set to ${CHECK} if - ${srcdir}/../../gcc doesn't exists. - -1998-01-05 Brendan Kehoe - - * std/bastring.cc (basic_string::Rep::operator delete): Don't claim - to return from deallocate, since this is a void method. - -Sat Jan 3 12:15:41 1998 Franz Sirl - - * configure.in: Finalize support for {alpha|powerpc}*-*-linux-gnulibc1 - -Sun Dec 7 02:34:40 1997 Jody Goldberg - - * libstdc++/std/bastring.h : Move closer to the draft standard - implementation of basic_string by adding 3 paramter 'Allocator'. - NOTE: this still differs from the standard in not offering per - instance allocators. - * libstdc++/std/bastring.cc : Likewise. - * libstdc++/stlinst.cc : Handle thread safe allocators if they are the - default. - -Sun Dec 7 02:32:20 1997 Jason Merrill - - * iosfwd: New header. - * Makefile.in (HEADERS): Add it. - -Sun Dec 7 02:32:20 1997 Gregory L. Galloway (gregg@eoeml.gtri.gatech.edu) - - * Makefile.in (HEADERS): Modified list of headers to - install to include all of SGI STL headers especially hash_set and - hash_map, and added ANSI C++ style wrappers for fstream, iomanip, - iostream, and strstream. - - * fstream, iomanip, iostream, strstream: New forwarding headers - added. - -Thu Nov 27 01:33:55 1997 Jeffrey A Law (law@cygnus.com) - - * Makefile.in (install): Change gxx_includedir to gxx_include_dir. - -Tue Nov 25 23:16:44 1997 Jason Merrill - - London changes to string: - * std/bastring.cc (check_realloc): Don't be selfish anymore. - * std/bastring.h (non-const operator[]): Be selfish. - (iterator forms of insert and erase): Stay selfish. - -Tue Nov 25 14:03:43 1997 H.J. Lu (hjl@gnu.org) - - * Makefile.in (stmp-complex, bigstmp-complex): Changed to - xxxx-complx. - -Mon Nov 24 14:41:33 1997 Jeffrey A Law (law@cygnus.com) - - * Makefile.in: Use ln -f -s, not ln -s -f. - -Fri Nov 21 12:56:24 1997 Manfred Hollstein - - * Makefile.in (bigstmp-complex): Name changed to bigstmp-complx to - cope with filesystem not capable to handle names longer than - 14 characters. - -Sun Nov 16 22:41:55 1997 Jeffrey A Law (law@cygnus.com) - - * Makefile.in (SHLIB): Build with CC instead of CXX. - -Sun Nov 2 23:34:09 1997 Manfred Hollstein - - * configure.in: Use delta.mt for m68k-motorola-sysv. - * config/delta.mt: New makefile fragment. - -Sun Nov 2 12:14:37 1997 Jason Merrill - - * Makefile.in (install): Some of HEADERS come from the stl dir now. - * algorithm, deque, functional, iterator, list, map, memory, numeric, - queue, set, stack, utility, vector: Now in stl dir. - -Fri Oct 10 00:40:00 1997 Jason Merrill - - * std/bastring.h: Use ibegin internally. Return passed iterator - instead of recalculating it where appropriate. - * std/bastring.cc: Adjust for erase. - - From Yotam Medini: - * std/bastring.h: Replace remove with erase. - -Thu Oct 9 23:24:36 1997 Jason Merrill - - * stdexcepti.cc (__out_of_range): New fn. - (__length_error): New fn. - - * std/bastring.h (OUTOFRANGE): Fix logic. Use throwing functions. - (LENGTHERROR): Likewise. - Revert Oct 2 changes. - * string: Revert Oct 2 changes. - -Tue Oct 7 00:51:51 1997 Jason Merrill - - * std/{f,d,ld}complex.h: Replace guiding fns if not -ansi. - -Thu Oct 2 00:08:18 1997 Jason Merrill - - * std/bastring.h: Move exception stuff after definition of string. - Move typedef of string here. - * string: From here. - -Sat Sep 27 16:48:00 1997 Jason Merrill - - * std/complext.h: Lose injection decls. - * std/fcomplex.h: Likewise. - * std/dcomplex.h: Likewise. - * std/ldcomplex.h: Likewise. - -Sat Sep 27 16:47:35 1997 Mark Mitchell - - * std/complext.h: Declare templates before making them - friends. Use new friend <> syntax. - * std/complext.cc: Don't rely on guiding declarations. - * std/fcomplex.h: Use new friend <> syntax. - * std/dcomplex.h: Likewise. - * std/ldcomplex.h: Likewise. - -Thu Sep 25 19:55:56 1997 Jason Merrill - - * std/bastring.h: Enable exceptions. - (assign, append, insert, replace): Implement member template versions. - -1997-09-15 02:37 Ulrich Drepper - - * config/linux.mt: New file. Make sure _PTHREADS is defined - if necessary. - * configure.in: Find linux.mt file. - -Thu Sep 11 15:03:20 1997 Jason Merrill - - * std/bastring.h (class basic_string): Add global scope to - use of reverse_iterator. - -Tue Sep 9 19:47:07 1997 Jason Merrill - - * std/bastring.h: Adjust use of reverse_iterator template. - -Wed Aug 27 00:04:33 1997 Alexandre Oliva (oliva@dcc.unicamp.br) - - * Makefile.in: Create correct multiple links to - shared libstdc++. - -Tue Aug 26 12:24:01 1997 H.J. Lu (hjl@gnu.ai.mit.edu) - - * testsuite/Makefile.in (check): Don't depend on site.exp. - (just-check): Depend on site.exp. - -Mon Aug 25 14:26:45 1997 Jason Merrill - - * Makefile.in (CXXFLAGS): Add -Weffc++. - -Sat Aug 23 21:25:37 1997 Mark Mitchell - - * bastring.h: Enable reverse_iterator and its ilk. - - * bastring.h: Provide specializations of member function templates - for const_iterator. - -Wed Jul 30 10:59:00 1997 Benjamin Kosnik - - * stlinst.cc: Add instantiation file for - __default_alloc_template and - __malloc_alloc_template<0> - -Sun Jun 1 17:03:40 1997 Jason Merrill - - * std/bastring.cc (find_last_of): Correct handling of POS. - (find_last_not_of): Likewise. - -Thu May 1 17:37:10 1997 Jason Merrill - - * Makefile.in ($(SHLIB)): Add $(LIBCXXFLAGS). - -Wed Apr 30 12:06:23 1997 Jason Merrill - - * Makefile.in (IO_DIR): Remove $(MULTIBUILDTOP). - (LIBIBERTY_DIR): Likewise. - * configure.in: Don't turn on multilib here. - -Fri Apr 25 16:09:15 1997 Bob Manson - - * testsuite/libstdc++.tests/test.exp, testsuite/lib/libstdc++.exp, - testsuite/configure.in, testsuite/Makefile.in, - testsuite/config/default.exp, testsuite/ChangeLog: New files. - - * configure.in: Add new testsuite directory to be configured. - -Tue Apr 22 19:03:39 1997 Alexandre Oliva - - * Makefile.in (install): Fix handling of mshlink. - -Fri Apr 4 03:25:13 1997 Ulrich Drepper - - * Makefile.in (IO_DIR): Prepend $(MULTIBUILDTOP) to - support multilib build. - (LIBIBERTY_DIR): Likewise. - - * configure.in: Enable multilibing by default. - Update multilib template to read config-ml.in. - -Wed Mar 12 16:09:34 1997 Jason Merrill - - * configure.in (XCXXINCLUDES): Add the STL directory. - -Thu Jan 23 08:08:43 1997 Brendan Kehoe - - * stdexcept: Delete dtors for all of the error classes, to match - their removal in the Apr 1995 WP. - (class overflow_error): Define missing class, added in May 1996 WP. - -Mon Nov 18 16:57:25 1996 Jason Merrill - - * Makefile.in (stuff[12]): More rules for my own evil purposes. - (CXXFLAGS, CFLAGS): Use -O instead of -O3 so debugging works. - -Wed Oct 16 13:47:45 1996 Jason Merrill - - * config/irix5.ml: Do link against the math library. - * configure.in: Support shared libs on Irix 6. - -Fri Oct 11 18:06:09 1996 Jason Merrill - - * config/linux.ml: Lose version overrides. - - * Makefile.in (MSHLINK): Defaults to .so.2.x - (mshlink): Indirect rule for making it. - -Tue Sep 24 17:58:31 1996 Jason Merrill - - * Remove new, typeinfo, exception, stddef*. - * Move public headers from std/*.h to *. - -Sun Sep 22 05:35:55 1996 Jason Merrill - - * Makefile.in: Remove new, exception, typeinfo handling. - * exceptioni.cc, newi.cc, typeinfoi.cc, std/exception.h, std/new.h, - std/typeinfo.h, new.h: Remove. - * typeinfo, new, exception: Refer to the files with .h in gcc. - -Fri Sep 20 14:39:19 1996 Jason Merrill - - * Makefile.in: Remove references to stl.list. - * configure.in (configdirs): Remove stl. - -Sat Sep 14 09:42:08 1996 Jason Merrill - - * Makefile.in (stuff): Convenience for me. - - * std/bastring.h: Remove kludge obsoleted by new overloading code. - -Fri Sep 6 16:43:21 1996 Jason Merrill - - * typeinfoi.cc (__dynamic_cast): Fix static_cast. - (__rtti_si): Likewise. - (dcast): Likewise. - -Thu Aug 29 17:06:23 1996 Michael Meissner - - * configure.in (i[345]86-*-*): Recognize i686 for pentium pro. - -Tue Jul 23 14:27:44 1996 Mike Stump - - * Makefile.in (exceptioni.o): Use -fexceptions now. - -Mon Jun 17 13:57:24 1996 Per Bothner - - * std/bastring.h (class basic_string::remove): Add casts. - - * configure.in: Use EXTRA_DISTCLEAN rather than DISTCLEAN. - -Fri Jun 7 14:09:20 1996 Jason Merrill - - * typeinfoi.cc (BUILTIN): Align typeinfo object like a pointer. - -Wed May 29 16:48:35 1996 Mike Stump - - * exceptioni.cc (__throw_bad_exception): Add. - * std/exception.h (bad_exception): Add. - * std/typeinfo.h: Remove leftovers of bad_cast_object. - -Mon May 6 14:04:42 1996 Jason Merrill - - * std/complext.h: s/FLOAT/_FLT/g. - -Thu May 2 17:26:24 1996 Mike Stump - - * exceptioni.cc (uncaught_exception): New routine. - * std/exception.h: Declare it. - -Thu Apr 25 13:20:57 1996 Jason Merrill - - * Makefile.in (typeinfoi.o, stdexcepti.o): Use default rule. - -Wed Apr 24 18:38:24 1996 Mike Stump - - * exceptioni.cc: Add #pragma implementation. - * std/exception.h: Add #pragma interface. Moved exception from - stdexcept. - * std/stdexcept.h: Moved exception to exception. Fix all constructor - arguments to take strings to match ANSI. Moved bad_cast and bad_typeid - to typeinfo. - * std/typeinfo.h: Moved bad_cast and bad_typeid from stdexcept. - -Wed Apr 24 10:43:07 1996 Doug Evans - - * Makefile.in (newi.o,cstringi.o,stddefi.o,cstdlibi.o,cmathi.o): Add - rules for SunOS VPATH. - -Fri Apr 19 17:24:51 1996 Jason Merrill - - * Version 2.8.0b3. - -Wed Apr 10 14:38:05 1996 Jason Merrill - - * typeinfoi.cc (base_info): Pack the latter three fields into 32 bits. - -Tue Apr 9 15:49:38 1996 Jason Merrill - - * typeinfoi.cc: Add 'const'. - (__class_type_info): Now just one pointer to an array of structs, - rather than four pointers to arrays. - - * typeinfoi.cc (__throw_type_match_rtti): Check for conversion to - void* before conversion to base*. - (dcast): Handle downcasting to X* given other X subobjects in - the most derived type. Ack. - -Mon Apr 8 15:20:32 1996 Ian Lance Taylor - - * configure.in: Permit --enable-shared to specify a list of - directories. - -Sun Apr 7 22:50:53 1996 Jason Merrill - - * typeinfoi.cc (__rtti_array): New entry point. - -Sat Apr 6 14:41:18 1996 Jason Merrill - - * exceptioni.cc (__throw_bad_cast): New entry point for compiler. - * typeinfoi.cc: Remove __bad_cast_object. - - * typeinfoi.cc: Add nodes for unsigned builtins. - -Fri Apr 5 18:16:22 1996 Jason Merrill - - * typeinfoi.cc, std/typeinfo.h: Total overhaul. Move most - everything out of the header, move name field into type_info, add - single-inheritance case, rewrite pointer handling, add new - compiler interface. Compare addresses to check for equality. - -Wed Mar 27 11:54:08 1996 Jason Merrill - - * Version 2.8.0b2. - -Fri Mar 8 13:56:18 1996 Jason Merrill - - * std/[cs]inst.h: Remove. - -Thu Mar 7 07:29:00 1996 Lee Iverson - - * Makefile.in (install): Restore deleted chdir to stl subdir. - -Thu Mar 7 15:02:58 1996 Jason Merrill - - * std/complext.h: Fix __attribute__ usage. - -Wed Feb 28 10:00:24 1996 Jason Merrill - - * Version 2.8.0b1. - -Mon Feb 26 17:26:26 1996 Jason Merrill - - * std/cstring.h: New approach to changing signatures of string - manipulation functions. Still disabled. - -Tue Feb 20 18:29:30 1996 Jason Merrill - - * std/complext.h (__doapl, __doami, __doaml, __doadv): Helper - templates to implement +=, -=, *= and /=, respectively, since - member function templates do not apply to class specializations. - * std/{f,d,ld}complex.h, std/complext.cc, cinst.cc: Adjust. - - * std/bastring.h: The representation class is now a nested class. - * std/bastring.cc: Add templates for static data members. - * sinst.cc: Don't provide specializations for static data members. - * std/string.h: Use default template parameters. - - * Makefile.in (CXXFLAGS): Remove -pedantic -ansi. - (CFLAGS): Ditto. - -Wed Feb 14 14:39:07 1996 Jason Merrill - - * std/bastring.cc (check_realloc): Fix for sizeof (charT) > 1. - From John Hickin . - -Wed Jan 10 11:05:04 1996 Jason Merrill - - * std/bastring.h (insert): Fix iterator handling. - From Joe Buck . - -Mon Jan 8 11:48:03 1996 Jason Merrill - - * std/bastring.h (max_size): Fix for sizeof (charT) > 1. - * std/bastring.cc (replace): Use it. - - * std/bastring.cc (rfind): Fix for n > length (). - -Tue Dec 19 15:13:08 1995 Jason Merrill - - * config/aix.ml (SHFLAGS): Add -Wl,-unix. - -Mon Dec 18 12:48:25 1995 Mike Stump - - * Makefile.in (exceptioni.o): Compile with -fhandle-exceptions, so - we can unwind through unexpected on machines that don't have a - working __unwind_function. - -Sun Dec 17 00:28:31 1995 Jeffrey A Law (law@cygnus.com) - - * Makefile.in (install): Make sure shared libraries - are installed with mode 555. - -Mon Nov 27 15:01:56 1995 Jason Merrill - - * Makefile.in (install): Make shared library links relative. - (install): Break up -sf into -s -f. - ({M,}SHLINK): Ditto. - -Sun Nov 26 22:48:06 1995 Jason Merrill - - * queue: Include instead of . - -Sat Nov 25 11:33:13 1995 Doug Evans - - * Makefile.in (install): Fix setting of rootme. - -Tue Nov 21 14:20:34 1995 Ian Lance Taylor - - * configure.in: Check ${with_cross_host} rather than comparing - ${host} and ${target}. - -Tue Nov 14 01:50:52 1995 Doug Evans - - * Makefile.in (IO_DIR): Delete MULTITOP, MULTISUBDIR. - (LIBIBERTY_DIR): Likewise. - (INSTALLDIR): Delete MULTISUBDIR. - * configure.in: Delete call to cfg-ml-com.in. Call config-ml.in - instead of cfg-ml-pos.in. - (XCXXINCLUDES): Delete MULTITOP. - * stl/configure.in (XCXXINCLUDES): Delete MULTITOP. - (config-ml.in): Call instead of cfg-ml-pos.in. - -Sun Nov 12 16:44:25 1995 Per Bothner - - * Makefile.in (VERSION): Set to 2.7.1. - -Thu Nov 9 17:39:28 1995 Jason Merrill - - * config/{aix,dec-osf,irix5,linux,sol2shm}.ml: Remove LDLIBS defn; - no longer needed now that make check sets LD_LIBRARY_PATH. - -Wed Nov 8 19:46:35 1995 Brendan Kehoe - - * std/bastring.h: Wrap with #ifndef/#define/#endif. - * std/cassert.h: Likewise. - * std/cinst.h: Likewise. - * std/complext.h: Likewise. - * std/dcomplex.h: Likewise. - * std/fcomplex.h: Likewise. - * std/ldcomplex.h: Likewise. - * std/sinst.h: Likewise. - -Wed Nov 8 16:15:48 1995 Jason Merrill - - * std/bastring.cc (getline): Update to September 95 WP. Now we - don't set failbit when reading an empty line. - -Tue Nov 7 16:09:04 1995 Jason Merrill - - * std/bastring.cc (new): Fix for sizeof (charT) != 1. - -Sat Nov 4 17:37:16 1995 Jason Merrill - - * std/complext.cc (operator / (FLOAT, const complex&)): - Reimplement along the lines of the other operator / templates. - From John Eaton . - -Sat Nov 4 13:33:50 1995 Per Bothner - - * configure.in (DISTCLEAN): New, to add target-mkfrag. - -Tue Oct 31 13:59:32 1995 Jason Merrill - - * std/bastring.h: Use size_t for the reference count. - * std/bastring.cc (create): Set selfish. - From Joe Buck (jbuck@synopsys.com). - -Mon Oct 30 23:09:48 1995 Per Bothner - - * configure.in: Don't bother changing LIBIBERTY for cross, - now that we are using target-libiberty instead. - * Makefile.in (LIBIBERTY_DIR): Simplify. - (LIBIBERTY): Remove. - -Wed Oct 11 14:56:49 1995 Brendan Kehoe - - * config/sol2shm.ml: New files with -rpath. - * configure (*-*-solaris*): Use sol2shm.ml. - -Thu Sep 28 09:26:52 1995 Jason Merrill - - * std/straits.h (compare, copy, move, set): Fix for non-char charT's. - * std/bastring.h (basic_string::remove): Fix for non-char charT's. - -Tue Sep 26 15:22:56 1995 Jason Merrill - - * config/irix5.ml: Pass -rpath to links. - -Fri Sep 15 00:17:47 1995 Jason Merrill - - * config/linux.ml: Conform to Linux shared library numbering - scheme. - * Makefile.in: Ditto. - -Tue Sep 12 00:28:56 1995 Mike Stump - - * typeinfoi.cc: (__pointer_type_info::__rtti_match): Moved from - the headerfile, include all sorts of pointer conversions from 15.3 - para 2. - * std/typeinfo.h (__pointer_type_info::__rtti_match): Moved from here. - -Mon Sep 11 23:27:59 1995 Mike Stump - - * std/typeinfo.h (__pointer_type_info::__rtti_match): We no longer - have to dereference the object pointer, as the pointer is always - passed directly. - -Mon Sep 11 19:29:51 1995 Mike Stump - - * std/typeinfo.h (__pointer_type_info::__rtti_match): Define so - that pointer conversions can happen on catch type matching. - * typeinfoi.cc (__throw_type_match_rtti): Arrange for __rtti_match - to be used on pointers. - -Tue Sep 5 14:49:19 1995 Jason Merrill - - * string.h: Remove for now. - -Thu Aug 31 14:14:01 1995 Jason Merrill - - * std/bastring.cc (operator>>): Simplify and fix. - (resize): Fix order of arguments to append. - (getline): Simplify and fix. - -Thu Aug 24 17:44:09 1995 Jason Merrill - - * std/cstdlib.h (abs): Provide default implementation for peons - without labs. - -Tue Aug 22 08:43:07 1995 Jason Merrill - - * std/cstdlib.h: Comment out definition of div(long,long) for now, - since not all targets have ldiv. - -Mon Aug 21 11:46:03 1995 Jason Merrill - - * std/cmath.h: Wrap abs(double) with #if ! _G_MATH_H_INLINES. - - * stl.h: Add, for compatibility with ObjectSpace STL. - - * std/complext.cc (operator /): Use abs instead of fabs. - - * std/bastring.h (replace): Update single-character replace method - as per my proposal. - - * std/cmath.h: Add abs(float), abs(double) and abs(long double). - Add commented-out declarations for other float and long double - math functions. - - * std/cstdlib.h: Add abs(long) and div(long,long). - - * Makefile.in (install): Make shared library executable and - non-writable. Tidy. - (OBJS): Add cstdlibi.o and cmathi.o. - - * Rename implementation files to have different basenames. - -Mon Aug 21 00:57:03 1995 Jeffrey A. Law - - * Makefile.in (install): Use "cd stl"; no need for $(srcdir) - prefix because we're already in $(srcdir). - -Tue Jul 25 18:41:29 1995 Per Bothner - - * std/stddef.h: Remove obsolete definition of enum capacity. - -Sat Jul 22 13:37:01 1995 Doug Evans - - * Makefile.in (IO_DIR): Add multilib support. - (LIBIBERTY, LIBIBERTY_OBJS, INSTALLDIR, stdlist): Likewise. - (libiberty.a, install): Likewise. - * configure.in: Likewise. - (XCXXINCLUDES): Likewise. - * stl/configure.in: Likewise. - (XCXXINCLUDES): Likewise. - -Mon Jul 17 09:29:31 1995 Brendan Kehoe - - * Makefile.in (typeinfo.o, stdexcept.o): Put an else for the if - stmt checking PICFLAG. - (stmp-string, bigstmp-string, stmp-complex, bigstmp-complex): Likewise. - -Wed Jun 28 17:05:29 1995 Jason Merrill - - * std/*.h: Wrap with extern "C++". - - * std/ciso646.h: Don't worry about #undefing the keywords. - -Mon Jun 26 19:05:38 1995 Jason Merrill - - * std/bastring.h (operator!=): If they've included the STL - function.h, don't overload the operator templates that it defines. - -Fri Jun 23 16:54:17 1995 Jason Merrill - - * Makefile.in (SHLINK): Force link. - (install): Ditto. - - * std/bastring.h (terminate): Never reallocate. - (alloc): No longer const. - - * std/bastring.cc (create): Always allocate an extra byte. - (check_realloc): Always leave room for an extra byte. - (*find*): Add missing 'const'. - - * Makefile.in (SHARLIB): Provide a default value. - -Tue Jun 20 16:29:52 1995 Jason Merrill - - * std/cstring.h: Don't bother tweaking prototypes for now. When - we do, we will use new-style casts. - -Fri Jun 16 13:57:53 1995 Jason Merrill - - * Makefile.in (VERSION): Update to 2.7.0. - - * config/aix.ml: Build both shared and archive libraries. - -Wed Jun 14 21:44:21 1995 Jason Merrill - - * configure.in (frags): Use linux.ml for Linux/ELF. - * config/linux.ml: New file. - -Wed Jun 14 17:56:23 1995 Niclas Andersson - - * configure.in: Use xiberty when building cross-compiler. - -Wed Jun 14 12:57:47 1995 Jason Merrill - - * std/*complex*, std/cinst.h, cinst.cc: Pass by reference to const - rather than by value. - * std/*complex*: Add member functions real() and imag(). - -Sat Jun 10 12:14:38 1995 Jason Merrill - - * Makefile.in (bigstmp-string): Call main string object cstrmain.o - instead of cstring.o. - -Wed Jun 7 11:15:15 1995 Jason Merrill - - * std/cstring.h: Use #include_next to pick up . - - * string.h: New file. - - * Makefile.in (MOSTLYCLEAN_JUNK): Remove piclist. - - * configure.in (MOSTLYCLEAN): Remove stamp-picdir. - -Mon Jun 5 18:36:39 1995 Jason Merrill - - * config/*.ml: Build both shared and archive libraries. - - * configure.in (MOSTLYCLEAN): Remove pic. - (frags): Use toplevel pic frags. - - * Makefile.in (piclist): New rule. - (SHLIB): Use it. - (stl.list): Removed. - (typeinfo.o): Also build pic version. - (stdexcept.o): Ditto. - (*stmp-*): Ditto. - -Tue May 30 12:01:14 1995 Jason Merrill - - * std/{complext,{f,d,ld}complex}.h: To declare specializations, - use friend declarations in the class body... - * std/cinst.h: ...rather than macro hackery. - - * Makefile.in (stdlist): Renamed from list. - - * cstdarg: Don't define __CSTDARG__. - * complex.h: Similarly. - -Tue May 9 19:31:20 1995 Jason Merrill - - * std/bastring.cc (operator>>): Use an int to store the return value - of streambuf::sbumpc. - (getline): Ditto. - * std/bastring.* (replace): Reverse size_t and charT arguments. - - * configure.in (enable_shared): Support enable_shared under AIX. - - * Makefile.in (SHARLIB): New variable and rule for building an - archive library containing a single shared object (for AIX). - -Mon May 8 01:43:19 1995 Jason Merrill - - * std/bastring.h (remove): Forgot one. - (empty): And this. - Disable copy-on-write if someone takes an iterator. - - * std/bastring.cc (getline): Avoid resizing down if unnecessary. - (operator>>): Don't use private methods. - -Sun May 7 02:39:56 1995 Jason Merrill - - * std/bastring.h (insert, replace): Fix. - * std/bastring.cc (find_*_of): Fix. - -Fri May 5 01:45:10 1995 Jason Merrill - - * std/bastring.h: Add iterator remove fn. Remove evil default - arguments. - - * std/*complex*, std/cinst.h, cinst.cc: s/__complex/complex/g. - complex is now specialized. Lose _*_complex in favor of - 'explicit' constructors. - * std/complex.h: Lose typedef of complex. - * std/fcomplex.h: New file. - * std/complext.cc (operator<<): Accept more input forms. - - * std/bastring.h: Add iterator insert fns. - -Thu May 4 02:30:04 1995 Jason Merrill - - * std/bastring.*: Update to current draft. - - * std/bastring.*: Reorganize so that the pointer in a string - object points to the data rather than the bsrep object, for - debugging. - -Tue Apr 25 17:15:09 1995 Jason Merrill - - * configure.in: Update to stay in sync with config.shared. - -Mon Apr 24 13:08:46 1995 Jason Merrill - - * std/complext.h: Declare hypot. Declare appropriate functions const. - -Wed Apr 12 15:26:25 1995 Jason Merrill - - * Makefile.in (typeinfo.o): Don't use $<. - (stdexcept.o): Ditto. - -Sat Apr 8 15:35:00 1995 Mike Stump - - * std/typeinfo.h: Move bad_cast, bad_typeid and __bad_cast_object - from here to stdexcept. - * std/stdexcept.h: Ditto. - * Makefile.in (stdexcept.o): Added rule to build typeinfo.o with - -frtti to support matching of thrown objects with rtti info for - bad_cast. - -Mon Apr 3 18:13:14 1995 Jason Merrill - - * typeinfo: New file. - - * Makefile.in (HEADERS): Add typeinfo. - -Mon Apr 3 15:06:58 1995 Mike Stump - - * Makefile.in (typeinfo.o): Added rule to build typeinfo.o with - -frtti to support matching of thrown objects with rtti info for - bad_cast. - -Wed Mar 29 15:56:06 1995 Mike Stump - - * typeinfo.cc: (__throw_type_match_rtti): Added to support - matching of thrown objects with rtti info. - -Thu Mar 23 18:42:30 1995 Jason Merrill - - * Makefile.in (HEADERS): Add stdexcept. - -Sun Mar 12 01:25:27 1995 Jason Merrill - - * std/typeinfo.h: Add return statements to dummy methods. - -Wed Mar 8 16:09:50 1995 Jason Merrill - - * config/dec-osf.ml: Use -rpath flag. - -Fri Feb 17 18:16:46 1995 Jason Merrill - - * std/typeinfo.h: Add copyright header. - - * Makefile.in (CXXFLAGS): Add a bunch of warning options to keep - me honest. - -Thu Feb 16 00:04:49 1995 Jason Merrill - - * Makefile.in, config/*.ml: Generate shared library on most hosts - as libstdc++.so.$(VERSION), with a symlink to libstdc++.so, so that - multiple versions can coexist. - -Fri Feb 10 02:59:39 1995 Jason Merrill - - * std/exception.h: {set_,}{terminate,unexpected} have C++ linkage. - - * Makefile.in: Allow string and complex to be split up either by - individual function or into I/O and non-I/O. Default to the - latter. - -Wed Feb 8 02:39:47 1995 Jason Merrill - - * std/bastring.h: Start thinking about throwing exceptions. - - * typeinfo.cc: Remove private functions; defining them to call - abort () just delays errors until runtime. Define - __bad_cast_object. - - * std/exception.h: Standard exceptions are now defined in - stdexcept.h. This header now contains declarations of terminate() - et al. - * exception.cc: Move code from libg++/src/except.c here. - * std/typeinfo.h: Define RTTI-related exceptions here. - * stdexcept{,.cc},std/stdexcept.h: New files. - -Mon Feb 6 18:51:31 1995 Jason Merrill - - * Makefile.in (HEADERS): Resurrect, add new STL header names. - (install): Install extensionless headers again. - * extensionless headers: Resurrect, add new STL headers. - Currently only forward to std/whatever or stl/whatever. - -Mon Jan 30 13:53:22 1995 Jason Merrill - - * std/bastring.h (basic_string (charT, size_t)): Mark explicit. - - * Makefile.in (install): Set rootme when installing stl headers. - Only install *.* from std. - -Wed Jan 25 02:29:30 1995 Jason Merrill - - * std/bastring.h (operator=): grab before releasing. - -Mon Jan 23 19:54:02 1995 Ronald F. Guilmette - - * Makefile.in (install): Also install STL headers. - -Mon Jan 23 04:09:35 1995 Jason Merrill - - * Makefile.in (list): Set $rootme before calling make. - -Wed Jan 11 19:24:47 1995 Jason Merrill - - * typeinfo.cc (__rtti_match): Don't try to do pointer arithmetic - with a void *. - - * move all headers into std subdirectory and update files accordingly. - -Thu Jan 5 01:51:49 1995 Jason Merrill - - * bastring.ccI (basic_string (size_t, capacity)): s/reserve/::reserve/. - -Wed Jan 4 17:27:32 1995 Jason Merrill - - * exception: s/string/__string/g. - - * configure.in (MOSTLYCLEAN): Add so_locations. - - * bastring.ccI (basic_string (size_t, capacity)): Fix thinko. - (various find functions): Ditto. - -Fri Dec 30 18:04:00 1994 Mike Stump - - * typeinfo.h: Add support for the built-in type bool. - -Fri Dec 30 14:57:02 1994 Mike Stump - - * typeinfo.{cc, h}: Guard against multiple inclusions, and add #p i/i. - -Fri Dec 2 17:56:05 1994 Mike Stump - - * libg++ 2.6.2 released. - - * typeinfo.{cc, h} (__rtti_match): Change interface to compiler - for dynamic_casting to gear up for exception handling's use of - rtti for argument matching. - -Tue Nov 29 16:49:32 1994 Per Bothner - - * configure.in (configdirs): Add stl. - * Makefile.in: Build stl, and merge .o files from it. - -Thu Nov 17 15:30:57 1994 Jason Merrill - - * bastring.hI: Add iterator, const_iterator, begin() and end() to - basic_string. - -Mon Nov 7 16:50:33 1994 Jason Merrill - - * Makefile.in, configure.in, config/*.ml, tests/Makefile.in, - tests/configure.in: Various changes to handle --enable-shared. - -Fri Nov 4 19:13:33 1994 Mike Stump - - * exception{,.cc}: Added to support catching bad_cast's. - -Thu Nov 3 17:42:13 1994 Mike Stump - - * typeinfo.h (type_info::{name, before}): Add to match draft. - -Thu Nov 3 00:56:34 1994 Jason Merrill (jason@phydeaux.cygnus.com) - - * Makefile.in (LIBIBERTY_OBJS): Add strerror.o. - -Mon Oct 31 15:33:06 1994 Kung Hsu (kung@mexican.cygnus.com) - - * typeinfo.cc: Fix a bug in the final return. - * typeinfo.cc: Fix the ANSI header version number. - * typeinfo.h: ditto. - -Fri Oct 28 14:23:12 1994 Mike Stump - - * type_info.{cc,h}: Rename to typeinfo to better match current draft. - -Wed Oct 26 11:13:53 1994 Kung Hsu (kung@mexican.cygnus.com) - - * type_info.h: new header file for rtti. - * type_info.cc: new code file for rtti. - * Makefile.in: change to include type_info.o in libstdc++ for rtti. - -Sat Oct 15 16:09:51 1994 Jason Merrill (jason@phydeaux.cygnus.com) - - * libg++ 2.6.1 released. - - * cinst.hI: Also declare instantiations of out-of-line functions. - -Fri Oct 14 15:00:09 1994 Jason Merrill (jason@phydeaux.cygnus.com) - - * configure.in (CXXINCLUDES): Use {} to wrap variable name. - * tests/configure.in (CXXINCLUDES): Ditto. - - * cinst.hI: Declare instantiations of two-argument functions so - overload resolution will work. - * complext.hI: Always include cinst.hI. - - * bastring.ccI (operator>>): Tweak. - -Tue Oct 11 17:07:49 1994 Jason Merrill (jason@phydeaux.cygnus.com) - - * stddef*: Do the #pragma i/i thang. - - * bastring.hI (basic_string::put_at): Use operator[]. - (basic_string::terminate): Don't necessarily copy the rep. - - * bastring.ccI (operator>>): Avoid shrinking and then re-expanding - the string. - - * bastring.*I, sinst.cc: Only allow allocation policy control if - _G_ALLOC_CONTROL is defined. - - * Makefile.in (libstdc++.a): Depend on iostream.list and libiberty.a. - (../libio/iostream.list): New rule. - (../libiberty/libiberty.a): New rule. - (OBJS): Add stddef.o. - -Sat Oct 8 23:59:45 1994 Jason Merrill (jason@phydeaux.cygnus.com) - - * *: First checkin. diff --git a/libstdc++/Makefile.in b/libstdc++/Makefile.in deleted file mode 100644 index fa6fe008108..00000000000 --- a/libstdc++/Makefile.in +++ /dev/null @@ -1,411 +0,0 @@ -# Copyright (C) 1994, 1995, 1999, 2000 Free Software Foundation - -# This file is part of the GNU ANSI 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. - -VERSION = 2.10.0 -INTERFACE = 3 - -gxx_include_dir=${includedir}/g++ - -OBJS = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.o valarray.o \ - del_op.o del_opnt.o del_opv.o del_opvnt.o exception.o new_handler.o \ - new_op.o new_opnt.o new_opv.o new_opvnt.o tinfo.o tinfo2.o vec.o \ - pure.o - -SUBLIBS = $(STAMP)-string $(STAMP)-complx - -# C++ headers with no extension -HEADERS= cassert cctype cerrno cfloat ciso646 climits clocale cmath complex \ - csetjmp csignal cstdarg cstddef cstdio cstdlib cstring ctime \ - cwchar cwctype string stdexcept \ - algorithm deque functional hash_map hash_set iterator list map \ - memory numeric pthread_alloc queue rope set slist stack utility \ - vector fstream iomanip iostream strstream iosfwd bitset valarray \ - sstream exception new typeinfo - -ARLIB = libstdc++.a.$(VERSION) -ARLINK = libstdc++.a -MARLINK = libstdc++.a.`echo $(VERSION) | sed 's/\([0-9]*[.][0-9]*\).*/\1/'` -SHLIB = libstdc++.so.$(VERSION) -SHARLIB = libstdc++-sh.a -SHLINK = libstdc++.so -MSHLINK = libstdc++.so.`echo $(VERSION) | sed 's/\([0-9]*[.][0-9]*\).*/\1/'` -SHFLAGS = -SHDEPS = -SHOPT = -shared - -STAMP = bigstmp - -LIBS = $(ARLIB) $(ARLINK) - -#### package, host, target, and site dependent Makefile fragments come in here. -## - -IO_DIR = ../libio -LIBIBERTY_DIR = ../libiberty - -LIBIBERTY_OBJS = `cat $(LIBIBERTY_DIR)/needed-list` strerror.o - -tooldir = $(exec_prefix)/$(target) -# This is where the libraries will be installed; note, it will be set -# at make runtime now. See below at target install. -INSTALLDIR = $(libdir) - -MOSTLYCLEAN_JUNK = *stmp-* tlib*.a *.s *.ii stdlist piclist -CLEAN_JUNK = $(LIBS) - -.PHONY: libs -libs: $(LIBS) - -# The "pic" subdir must be created before we can put any object -# files into it. -$(OBJS): stamp-picdir - -stdlist: $(IO_DIR)/iostream.list $(OBJS) $(SUBLIBS) $(LIBIBERTY_DIR)/libiberty.a - -rm -f tlist - touch tlist - echo *.o >> tlist - for f in `cat $(IO_DIR)/iostream.list` ; do \ - echo "$(IO_DIR)/$$f" >> tlist ; \ - done - for f in $(LIBIBERTY_OBJS) ; do \ - echo "$(LIBIBERTY_DIR)/$$f" >> tlist ; \ - done - mv tlist stdlist - -piclist: stdlist - -rm -f tlist - cp stdlist tlist - if [ x"$(PICFLAG)" != x ]; then \ - sed 's,\([A-Za-z_0-9]*\.o\),pic/\1,g' tlist > tlist2 ; \ - mv tlist2 tlist ; \ - else true ; fi - mv tlist piclist - -$(ARLIB): stdlist - -rm -f t$(ARLIB) - $(AR) $(AR_FLAGS) t$(ARLIB) `cat stdlist` - mv t$(ARLIB) $(ARLIB) - $(RANLIB) $(ARLIB) - -$(ARLINK): - -rm -f $(ARLINK) - $(LN_S) $(ARLIB) $(ARLINK) || cp $(ARLIB) $(ARLINK) - -marlink: - @$(MAKE) $(MARLINK) "ARLINK=$(MARLINK)" - -$(SHLIB): piclist - $(CC) $(LIBCXXFLAGS) $(SHFLAGS) $(SHOPT) -o $(SHLIB) `cat piclist` $(SHDEPS) - -$(SHARLIB): $(SHLIB) - -rm -f t$(SHARLIB) - $(AR) $(AR_FLAGS) t$(SHARLIB) $(SHLIB) - mv t$(SHARLIB) $(SHARLIB) - $(RANLIB) $(SHARLIB) - -$(SHLINK): - -rm -f $(SHLINK) - $(LN_S) $(SHLIB) $(SHLINK) || cp $(ARLIB) $(ARLINK) - -mshlink: - @$(MAKE) $(MSHLINK) "SHLINK=$(MSHLINK)" - -$(IO_DIR)/iostream.list: force - cd $(IO_DIR) ; $(MAKE) $(FLAGS_TO_PASS) iostream.list - -$(LIBIBERTY_DIR)/libiberty.a: - cd $(LIBIBERTY_DIR) ; $(MAKE) $(FLAGS_TO_PASS) - -STRFUNCS = REP MAIN TRAITS ADDSS ADDPS ADDCS ADDSP ADDSC \ - EQSS EQPS EQSP NESS NEPS NESP LTSS LTPS LTSP GTSS GTPS GTSP \ - LESS LEPS LESP GESS GEPS GESP -STRIO = EXTRACT INSERT GETLINE - -# These are here for SunOS VPATH. -cinst.o: cinst.cc -cmathi.o: cmathi.cc -cstdlibi.o: cstdlibi.cc -cstringi.o: cstringi.cc -del_op.o: del_op.cc new -del_opnt.o: del_opnt.cc new -del_opv.o: del_opv.cc new -del_opvnt.o: del_opvnt.cc new -exception.o: exception.cc typeinfo $(srcdir)/../gcc/gansidecl.h \ - $(srcdir)/../include/ansidecl.h $(srcdir)/../gcc/eh-common.h -new_handler.o: new_handler.cc new -new_op.o: new_op.cc new -new_opnt.o: new_opnt.cc new -new_opv.o: new_opv.cc new -new_opvnt.o: new_opvnt.cc new -sinst.o: sinst.cc -stdexcepti.o: stdexcepti.cc -stlinst.o: stlinst.cc -tinfo.o: tinfo.cc tinfo.hP typeinfo new -tinfo2.o: tinfo2.cc tinfo.hP typeinfo new -valarray.o: valarray.cc -vec.o: vec.cc -pure.o: pure.c - -# Later do wide strings, too. -stmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \ - ${srcdir}/std/bastring.cc ${srcdir}/std/straits.h - for name in $(STRFUNCS) $(STRIO); do \ - echo c$${name}; \ - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DC -D$${name} ${srcdir}/sinst.cc \ - -o pic/c$${name}.o; \ - else true ; fi; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - $(COMPILE.cc) -DC -D$${name} ${srcdir}/sinst.cc -o c$${name}.o; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - done - touch stmp-string - -bigstmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \ - ${srcdir}/std/bastring.cc ${srcdir}/std/straits.h - echo cstring - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DC \ - `for N in $(STRFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/sinst.cc -o pic/cstrmain.o; \ - else true ; fi - $(COMPILE.cc) -DC `for N in $(STRFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/sinst.cc -o cstrmain.o - echo cstrio - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DC \ - `for N in $(STRIO); do echo " -D$${N}"; done` \ - $(srcdir)/sinst.cc -o pic/cstrio.o; \ - else true ; fi - $(COMPILE.cc) -DC `for N in $(STRIO); do echo " -D$${N}"; done` \ - $(srcdir)/sinst.cc -o cstrio.o - touch bigstmp-string - -COMFUNCS = MAIN ADDCC ADDCF ADDFC SUBCC SUBCF SUBFC MULCC MULCF MULFC DIVCC \ - DIVCF DIVFC PLUS MINUS EQCC EQCF EQFC NECC NECF NEFC ABS ARG POLAR \ - CONJ NORM COS COSH EXP LOG POWCC POWCF POWCI POWFC SIN SINH SQRT -COMIO = EXTRACT INSERT - -stmp-complx: ${srcdir}/cinst.cc ${srcdir}/std/complext.h \ - ${srcdir}/std/complext.cc ${srcdir}/std/dcomplex.h \ - ${srcdir}/std/ldcomplex.h - for N in $(COMFUNCS) $(COMIO); do \ - echo f$${N}; \ - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DF -D$${N} $(srcdir)/cinst.cc \ - -o pic/f$${N}.o; \ - else true ; fi; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - $(COMPILE.cc) -DF -D$${N} ${srcdir}/cinst.cc -o f$${N}.o; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - echo d$${N}; \ - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DD -D$${N} $(srcdir)/cinst.cc \ - -o pic/d$${N}.o; \ - else true ; fi; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - $(COMPILE.cc) -DD -D$${N} ${srcdir}/cinst.cc -o d$${N}.o; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - echo ld$${N}; \ - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DLD -D$${N} $(srcdir)/cinst.cc \ - -o pic/ld$${N}.o; \ - else true ; fi; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - $(COMPILE.cc) -DLD -D$${N} ${srcdir}/cinst.cc -o ld$${N}.o; \ - if [ $$? -eq 0 ]; then true; else exit 1; fi; \ - done - touch stmp-complx - -bigstmp-complx: ${srcdir}/cinst.cc ${srcdir}/std/complext.h \ - ${srcdir}/std/complext.cc ${srcdir}/std/dcomplex.h \ - ${srcdir}/std/ldcomplex.h - echo fcomplex - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DF \ - `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o pic/fcomplex.o; \ - else true ; fi - $(COMPILE.cc) -DF `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o fcomplex.o - echo fcomio - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DF \ - `for N in $(COMIO); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o pic/fcomio.o; \ - else true ; fi - $(COMPILE.cc) -DF `for N in $(COMIO); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o fcomio.o - echo dcomplex - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DD \ - `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o pic/dcomplex.o; \ - else true ; fi - $(COMPILE.cc) -DD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o dcomplex.o - echo dcomio - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DD \ - `for N in $(COMIO); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o pic/dcomio.o; \ - else true ; fi - $(COMPILE.cc) -DD `for N in $(COMIO); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o dcomio.o - echo ldcomplex - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DLD \ - `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o pic/ldcomplex.o; \ - else true ; fi - $(COMPILE.cc) -DLD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o ldcomplex.o - echo ldcomio - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.cc) $(PICFLAG) -DLD \ - `for N in $(COMIO); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o pic/ldcomio.o; \ - else true ; fi - $(COMPILE.cc) -DLD `for N in $(COMIO); do echo " -D$${N}"; done` \ - $(srcdir)/cinst.cc -o ldcomio.o - touch bigstmp-complx - -.PHONY: install -install: - rootme=`pwd`/ ; export rootme ; \ - if [ -z "$(MULTISUBDIR)" ]; then \ - cd $(srcdir); \ - for FILE in $(HEADERS); do \ - rm -f $(gxx_include_dir)/$$FILE ; \ - if [ -f stl/$$FILE ]; then \ - $(INSTALL_DATA) stl/$$FILE $(gxx_include_dir)/$$FILE ; \ - else \ - $(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \ - fi ; \ - chmod a-x $(gxx_include_dir)/$$FILE ; \ - done ; \ - for FILE in *.h std/*.h std/*.cc std/*.tcc; do \ - rm -f $(gxx_include_dir)/$$FILE ; \ - $(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \ - chmod a-x $(gxx_include_dir)/$$FILE ; \ - done ; \ - cd stl; \ - for FILE in *.h; do \ - rm -f $(gxx_include_dir)/$$FILE ; \ - $(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \ - chmod a-x $(gxx_include_dir)/$$FILE ; \ - done ; \ - else true ; \ - fi - rootme=`pwd`/ ; export rootme ; \ - if [ x$(enable_version_specific_runtime_libs) != xyes ]; then \ - INSTALLDIR=$(libdir); \ - else \ - INSTALLDIR=$(libsubdir); \ - fi; \ - INSTALLLINKDIR=$(libsubdir); \ - if [ $${INSTALLLINKDIR}$(MULTISUBDIR) = $${INSTALLDIR}$(MULTISUBDIR) ]; then \ - RELINSTALLDIR=; \ - elif [ x$(MULTISUBDIR) = x ]; then \ - if [ $(build_alias) = $(target_alias) ]; then \ - RELINSTALLDIR=../../../; \ - else \ - RELINSTALLDIR=../../../../$(target_alias)/lib/; \ - fi; \ - else \ - if [ $(build_alias) = $(target_alias) ]; then \ - RELINSTALLDIR=../../..`echo $(MULTISUBDIR) | sed -e 's,/[^/]*,/..,g'`$(MULTISUBDIR)/; \ - else \ - RELINSTALLDIR=../../../..`echo $(MULTISUBDIR) | sed -e 's,/[^/]*,/..,g'`/$(target_alias)/lib$(MULTISUBDIR)/; \ - fi; \ - fi; \ - if [ $(build_alias) != $(target_alias) ]; then \ - case $$RELINSTALLDIR in \ - ../../../|../../../../) \ - RELINSTALLDIR=../$${RELINSTALLDIR}$(target_alias)/lib/;; \ - esac; \ - fi; \ - rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$(SHLINK) ; \ - rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$(ARLINK) ; \ - for FILE in $(LIBS) ; do \ - rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - if [ $$FILE = $(SHLINK) ] ; then \ - if [ -f $${INSTALLDIR}/$(MSHLINK) ]; then \ - rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - $(LN_S) $${RELINSTALLDIR}$(MSHLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \ - || cp $${RELINSTALLDIR}$(MSHLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - else \ - rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - $(LN_S) $${RELINSTALLDIR}$(SHLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \ - || cp $${RELINSTALLDIR}$(SHLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - fi; \ - elif [ $$FILE = $(ARLINK) ] ; then \ - if [ -f $${INSTALLDIR}/$(MARLINK) ]; then \ - rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - $(LN_S) $${RELINSTALLDIR}$(MARLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \ - || cp $${RELINSTALLDIR}$(MARLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - else \ - rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - $(LN_S) $${RELINSTALLDIR}$(ARLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \ - || cp $${RELINSTALLDIR}$(ARLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \ - fi; \ - elif [ $$FILE = mshlink ]; then \ - for FILE in $(MSHLINK) ; do \ - rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - $(LN_S) $(SHLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE \ - || cp $(SHLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - done; \ - elif [ $$FILE = marlink ]; then \ - for FILE in $(MARLINK) ; do \ - rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - $(LN_S) $(ARLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE \ - || cp $(ARLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - done; \ - elif [ $$FILE = $(SHLIB) ]; then \ - $(INSTALL_PROGRAM) $$FILE $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - : On the HP, shared libraries must be mode 555. ;\ - chmod 555 $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - else \ - $(INSTALL_DATA) $$FILE $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - $(RANLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - chmod a-x $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \ - fi ; \ - done - @rootme=`pwd`/ ; export rootme ; \ - $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install - -.PHONY: force -force: - -MYCXXFLAGS = $(CXXFLAGS) -g -O2 -Wpointer-arith -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -Winline -Wwrite-strings -pedantic -Wno-long-long -MYCFLAGS = $(CFLAGS) -g -O2 -Wpointer-arith -Wnested-externs - -.PHONY: stuff -stuff: - $(MAKE) stuff1 - $(MAKE) stuff2 - -stuff1: - $(MAKE) clean - $(MAKE) -C ../libio c++clean - rm -f ../../gcc/cplib2.txt - -stuff2: - $(MAKE) -C ../../gcc/ LANGUAGES='c c++' libgcc.a - $(MAKE) CXXFLAGS="$(MYCXXFLAGS)" CFLAGS="$(MYCFLAGS)" - -$(MAKE) check - -$(MAKE) -C ../libio check - -$(MAKE) -C ../../gcc check-g++ diff --git a/libstdc++/NEWS b/libstdc++/NEWS deleted file mode 100644 index 89e866e7d3f..00000000000 --- a/libstdc++/NEWS +++ /dev/null @@ -1,9 +0,0 @@ -SUMMARY OF RECENT MAJOR CHANGES to LIBSTDC++. -(Also check ../libio/NEWS.) - -*** Noteworthy changes in libstdc++ for EGCS - -* EGCS includes the SGI STL implementation without changes. - -* As a result of these and other changes, libstc++ for EGCS is not binary - compatible with previous releases of libstdc++. diff --git a/libstdc++/cassert b/libstdc++/cassert deleted file mode 100644 index b4165bfae7f..00000000000 --- a/libstdc++/cassert +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CASSERT__ -#define __CASSERT__ -#include -#endif diff --git a/libstdc++/cctype b/libstdc++/cctype deleted file mode 100644 index e2765aed50a..00000000000 --- a/libstdc++/cctype +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- character type header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CCTYPE__ -#define __CCTYPE__ -#include -#endif diff --git a/libstdc++/cerrno b/libstdc++/cerrno deleted file mode 100644 index ce493469597..00000000000 --- a/libstdc++/cerrno +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- error number header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CERRNO__ -#define __CERRNO__ -#include -#endif diff --git a/libstdc++/cfloat b/libstdc++/cfloat deleted file mode 100644 index cf59eadfb79..00000000000 --- a/libstdc++/cfloat +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CFLOAT__ -#define __CFLOAT__ -#include -#endif diff --git a/libstdc++/cinst.cc b/libstdc++/cinst.cc deleted file mode 100644 index 983e8a9caa7..00000000000 --- a/libstdc++/cinst.cc +++ /dev/null @@ -1,154 +0,0 @@ -// Instantiation file for the -*- C++ -*- complex number classes. -// Copyright (C) 1994 Free Software Foundation - -#ifdef F -typedef float f; -#endif -#ifdef D -typedef double f; -#endif -#ifdef LD -typedef long double f; -#endif - -#if defined (MAIN) && defined (__GNUG__) -#ifdef F -#pragma implementation "fcomplex" -#endif -#ifdef D -#pragma implementation "dcomplex" -#endif -#ifdef LD -#pragma implementation "ldcomplex" -#endif -#endif - -#if 0 -#define _G_NO_EXTERN_TEMPLATES -#endif -#include - -typedef complex c; -typedef const c& ccr; - -#ifdef MAIN -template c& __doapl (c*, ccr); -template c& __doaml (c*, ccr); -template c& __doami (c*, ccr); -template c& __doadv (c*, ccr); -#endif - -#ifdef ADDCC -template c operator+ (ccr, ccr); -#endif -#ifdef ADDCF -template c operator+ (ccr, f); -#endif -#ifdef ADDFC -template c operator+ (f, ccr); -#endif -#ifdef SUBCC -template c operator- (ccr, ccr); -#endif -#ifdef SUBCF -template c operator- (ccr, f); -#endif -#ifdef SUBFC -template c operator- (f, ccr); -#endif -#ifdef MULCC -template c operator* (ccr, ccr); -#endif -#ifdef MULCF -template c operator* (ccr, f); -#endif -#ifdef MULFC -template c operator* (f, ccr); -#endif -#ifdef DIVCC -template c operator/ (ccr, ccr); -#endif -#ifdef DIVCF -template c operator/ (ccr, f); -#endif -#ifdef DIVFC -template c operator/ (f, ccr); -#endif -#ifdef PLUS -template c operator+ (ccr); -#endif -#ifdef MINUS -template c operator- (ccr); -#endif -#ifdef EQCC -template bool operator== (ccr, ccr); -#endif -#ifdef EQCF -template bool operator== (ccr, f); -#endif -#ifdef EQFC -template bool operator== (f, ccr); -#endif -#ifdef NECC -template bool operator!= (ccr, ccr); -#endif -#ifdef NECF -template bool operator!= (ccr, f); -#endif -#ifdef NEFC -template bool operator!= (f, ccr); -#endif -#ifdef ABS -template f abs (ccr); -#endif -#ifdef ARG -template f arg (ccr); -#endif -#ifdef POLAR -template c polar (f, f); -#endif -#ifdef CONJ -template c conj (ccr); -#endif -#ifdef NORM -template f norm (ccr); -#endif -#ifdef COS -template c cos (ccr); -#endif -#ifdef COSH -template c cosh (ccr); -#endif -#ifdef EXP -template c exp (ccr); -#endif -#ifdef LOG -template c log (ccr); -#endif -#ifdef POWCC -template c pow (ccr, ccr); -#endif -#ifdef POWCF -template c pow (ccr, f); -#endif -#ifdef POWCI -template c pow (ccr, int); -#endif -#ifdef POWFC -template c pow (f, ccr); -#endif -#ifdef SIN -template c sin (ccr); -#endif -#ifdef SINH -template c sinh (ccr); -#endif -#ifdef SQRT -template c sqrt (ccr); -#endif -#ifdef EXTRACT -template istream& operator>> (istream&, complex&); -#endif -#ifdef INSERT -template ostream& operator<< (ostream&, const complex&); -#endif diff --git a/libstdc++/ciso646 b/libstdc++/ciso646 deleted file mode 100644 index 4d8200d73dc..00000000000 --- a/libstdc++/ciso646 +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CISO646__ -#define __CISO646__ -#include -#endif diff --git a/libstdc++/climits b/libstdc++/climits deleted file mode 100644 index 1b29b3af01e..00000000000 --- a/libstdc++/climits +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CLIMITS__ -#define __CLIMITS__ -#include -#endif diff --git a/libstdc++/clocale b/libstdc++/clocale deleted file mode 100644 index b67cf31c9d2..00000000000 --- a/libstdc++/clocale +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- locale support header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CLOCALE__ -#define __CLOCALE__ -#include -#endif diff --git a/libstdc++/cmath b/libstdc++/cmath deleted file mode 100644 index b18ea0b428c..00000000000 --- a/libstdc++/cmath +++ /dev/null @@ -1,76 +0,0 @@ -// The -*- C++ -*- math functions header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CMATH__ -#define __CMATH__ -#include <_G_config.h> -#include - -#ifdef __GNUG__ -#pragma interface "cmath" -#endif - -extern "C++" { -#if 0 -float acos (float); -float asin (float); -float atan (float); -float atan2(float, float); -float ceil (float); -float cos (float); -float cosh (float); -float exp (float); -float fabs (float); -float floor(float); -float fmod (float, float); -float frexp(float, int*); -float modf (float, float*); -float ldexp(float, int); -float log (float); -float log10(float); -float pow (float, float); -float pow (float, int); -float sin (float); -float sinh (float); -float sqrt (float); -float tan (float); -float tanh (float); -#endif - -inline float abs (float x) { return fabs (x); } -#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */ -inline double abs (double x) { return fabs (x); } -#endif - -#if 0 -double pow(double, int); - -long double acos (long double); -long double asin (long double); -long double atan (long double); -long double atan2(long double, long double); -long double ceil (long double); -long double cos (long double); -long double cosh (long double); -long double exp (long double); -long double fabs (long double); -long double floor(long double); -long double frexp(long double, int*); -long double fmod (long double, long double); -long double frexp(long double, int*); -long double log (long double); -long double log10(long double); -long double modf (long double, long double*); -long double pow (long double, long double); -long double pow (long double, int); -long double sin (long double); -long double sinh (long double); -long double sqrt (long double); -long double tan (long double); -long double tanh (long double); -#endif -inline long double abs (long double x) { return fabs (x); } - -} // extern "C++" - -#endif diff --git a/libstdc++/cmathi.cc b/libstdc++/cmathi.cc deleted file mode 100644 index afd740f013e..00000000000 --- a/libstdc++/cmathi.cc +++ /dev/null @@ -1,7 +0,0 @@ -// Implementation file for the -*- C++ -*- math functions header. -// This file is part of the GNU ANSI C++ Library. - -#ifdef __GNUG__ -#pragma implementation "cmath" -#endif -#include diff --git a/libstdc++/complex b/libstdc++/complex deleted file mode 100644 index bfdd352b462..00000000000 --- a/libstdc++/complex +++ /dev/null @@ -1,18 +0,0 @@ -// Main header for the -*- C++ -*- complex number classes. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __COMPLEX__ -#define __COMPLEX__ - -#include - -extern "C++" { -#define __STD_COMPLEX - -// ANSI complex types -typedef complex float_complex; -typedef complex double_complex; -typedef complex long_double_complex; -} - -#endif diff --git a/libstdc++/complex.h b/libstdc++/complex.h deleted file mode 100644 index 2e88de854a6..00000000000 --- a/libstdc++/complex.h +++ /dev/null @@ -1,6 +0,0 @@ -// -*- C++ -*- backward compatiblity header. -// Copyright (C) 1994 Free Software Foundation - -#ifndef __COMPLEX_H__ -#include -#endif diff --git a/libstdc++/config/aix.ml b/libstdc++/config/aix.ml deleted file mode 100644 index 5d6b6b245eb..00000000000 --- a/libstdc++/config/aix.ml +++ /dev/null @@ -1,30 +0,0 @@ -# AIX has weird shared/non-shared libraries. - -ARLIB = -ARLINK = - -# Build shared object with interface versioning in name. -# Archive resulting shared object in a library. -AIXLINK = libstdc++.a -AIXLIB = libstdc++-$(VERSION).a -AIXSHLIB = shr$(LIBSTDCXX_INTERFACE)$(CXX_INTERFACE).o -SHFLAGS = -Wl,-bexpall -SHDEPS = -lm -SHOPT = -shared - -LIBS = $(AIXLIB) $(AIXLINK) - -$(AIXSHLIB): stdlist - $(CC) $(LIBCXXFLAGS) $(SHFLAGS) $(SHOPT) -o $(AIXSHLIB) `cat stdlist` $(SHDEPS) - -# Delete $(AIXSHLIB) so that it is not included in stdlist if rebuilding. -$(AIXLIB): $(AIXSHLIB) - -rm -f t$(AIXLIB) - $(AR) $(AR_FLAGS) t$(AIXLIB) $(AIXSHLIB) - mv t$(AIXLIB) $(AIXLIB) - -rm -f $(AIXSHLIB) - -$(AIXLINK): - -rm -f $(AIXLINK) - $(LN_S) $(AIXLIB) $(AIXLINK) || cp $(AIXLIB) $(AIXLINK) - diff --git a/libstdc++/config/aix.mt b/libstdc++/config/aix.mt deleted file mode 100644 index d24e14fe83e..00000000000 --- a/libstdc++/config/aix.mt +++ /dev/null @@ -1 +0,0 @@ -MT_CFLAGS = `case "$(CXXFLAGS)" in *-pthread* ) echo -D_PTHREADS ;; esac` diff --git a/libstdc++/config/beos.ml b/libstdc++/config/beos.ml deleted file mode 100644 index f90b0b02357..00000000000 --- a/libstdc++/config/beos.ml +++ /dev/null @@ -1,4 +0,0 @@ -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) mshlink $(SHLINK) -SHFLAGS = -Wl,-soname,$(MSHLINK) -DEPLIBS = ../$(SHLIB) -SHOPT = -nostart diff --git a/libstdc++/config/dec-osf.ml b/libstdc++/config/dec-osf.ml deleted file mode 100644 index a11f373d84c..00000000000 --- a/libstdc++/config/dec-osf.ml +++ /dev/null @@ -1,6 +0,0 @@ -# We don't need -fpic on the alpha, so let's install both the shared and -# non-shared versions. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) -DEPLIBS = ../$(SHLIB) -SHDEPS = -lm diff --git a/libstdc++/config/delta.mt b/libstdc++/config/delta.mt deleted file mode 100644 index b0b36db1062..00000000000 --- a/libstdc++/config/delta.mt +++ /dev/null @@ -1,2 +0,0 @@ -# If FPU instructions are generated by default, we have to use a special libm.a -MLDLIBS = $(LDLIBS) `case "$(CXXFLAGS)" in *-m68000* | *-mc68000* | *-msoft-float* ) echo -lm ;; * ) echo -lm881 ;; esac` diff --git a/libstdc++/config/elf.ml b/libstdc++/config/elf.ml deleted file mode 100644 index bd711debf83..00000000000 --- a/libstdc++/config/elf.ml +++ /dev/null @@ -1,8 +0,0 @@ -# Elf without shared libm -- we have to link with the archive library, even -# for programs that don't use complex. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) -SHFLAGS = -h $(SHLIB) -DEPLIBS = ../$(SHLIB) -LDLIBS = -L.. -lstdc++ -lm -MLDLIBS = -L.. -lstdc++ -lm diff --git a/libstdc++/config/elfshlibm.ml b/libstdc++/config/elfshlibm.ml deleted file mode 100644 index 826f0bc0917..00000000000 --- a/libstdc++/config/elfshlibm.ml +++ /dev/null @@ -1,6 +0,0 @@ -# Elf with shared libm, so we can link it into the shared libstdc++. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) -SHFLAGS = -h $(SHLIB) -SHDEPS = -lm -DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/freebsd.ml b/libstdc++/config/freebsd.ml deleted file mode 100644 index 3ee682690ad..00000000000 --- a/libstdc++/config/freebsd.ml +++ /dev/null @@ -1,6 +0,0 @@ -# Elf with shared libm, so we can link it into the shared libstdc++. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) mshlink -SHFLAGS = -Wl,-soname,$(MSHLINK) -SHDEPS = -lm -DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/gnu.ml b/libstdc++/config/gnu.ml deleted file mode 100644 index 2a0380327f7..00000000000 --- a/libstdc++/config/gnu.ml +++ /dev/null @@ -1,6 +0,0 @@ -# Elf with shared libm, so we can link it into the shared libstdc++. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) -SHFLAGS = -Wl,-soname,$(SHLIB) -SHDEPS = -lm -DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/hpux.ml b/libstdc++/config/hpux.ml deleted file mode 100644 index a39602a6403..00000000000 --- a/libstdc++/config/hpux.ml +++ /dev/null @@ -1,6 +0,0 @@ -# HPUX uses the .sl suffix for shared libraries. - -SHLIB = libstdc++.sl -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) -DEPLIBS = ../$(SHLIB) -SHFLAGS = $(PICFLAG) diff --git a/libstdc++/config/irix5.ml b/libstdc++/config/irix5.ml deleted file mode 100644 index 055c832c26e..00000000000 --- a/libstdc++/config/irix5.ml +++ /dev/null @@ -1,6 +0,0 @@ -# We don't need -fpic on IRIX, so let's install both the shared and -# non-shared versions. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) -DEPLIBS = ../$(SHLIB) -SHDEPS = -lm diff --git a/libstdc++/config/linux.ml b/libstdc++/config/linux.ml deleted file mode 100644 index 14dcb45b79d..00000000000 --- a/libstdc++/config/linux.ml +++ /dev/null @@ -1,11 +0,0 @@ -# Elf with shared libm, so we can link it into the shared libstdc++. - -ARLIB = libstdc++-$(LIBSTDCXX_INTERFACE)$(LIBC_INTERFACE)$(CXX_INTERFACE)-$(VERSION).a -MARLINK = libstdc++$(LIBC_INTERFACE)$(CXX_INTERFACE).a.$(LIBSTDCXX_INTERFACE) -SHLIB = libstdc++-$(LIBSTDCXX_INTERFACE)$(LIBC_INTERFACE)$(CXX_INTERFACE)-$(VERSION).so -MSHLINK = libstdc++$(LIBC_INTERFACE)$(CXX_INTERFACE).so.$(LIBSTDCXX_INTERFACE) - -LIBS = $(ARLIB) marlink $(ARLINK) $(SHLIB) mshlink $(SHLINK) -SHFLAGS = -Wl,-soname,$(MSHLINK) -SHDEPS = -lm -DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/linux.mt b/libstdc++/config/linux.mt deleted file mode 100644 index 5848851be8a..00000000000 --- a/libstdc++/config/linux.mt +++ /dev/null @@ -1,2 +0,0 @@ -# tell we want the mt-safe version -MT_CFLAGS = -D_IO_MTSAFE_IO diff --git a/libstdc++/config/openbsd.ml b/libstdc++/config/openbsd.ml deleted file mode 100644 index 09c40235adf..00000000000 --- a/libstdc++/config/openbsd.ml +++ /dev/null @@ -1,7 +0,0 @@ -# Base shared lib for OpenBSD i386 - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) mshlink -SHFLAGS = -nostdlib -Wl,-Bshareable,-Bforcearchive -SHDEPS = -lm -DEPLIBS = ../$(SHLIB) - diff --git a/libstdc++/config/openbsd.mt b/libstdc++/config/openbsd.mt deleted file mode 100644 index 29da11cf454..00000000000 --- a/libstdc++/config/openbsd.mt +++ /dev/null @@ -1,3 +0,0 @@ -# tell we want the mt-safe version -MT_CFLAGS = -D_IO_MTSAFE_IO -D_PTHREADS - diff --git a/libstdc++/config/posix.mt b/libstdc++/config/posix.mt deleted file mode 100644 index 6afe1e514d9..00000000000 --- a/libstdc++/config/posix.mt +++ /dev/null @@ -1 +0,0 @@ -MT_CFLAGS = -D_PTHREADS diff --git a/libstdc++/config/sol2pth.mt b/libstdc++/config/sol2pth.mt deleted file mode 100644 index 6afe1e514d9..00000000000 --- a/libstdc++/config/sol2pth.mt +++ /dev/null @@ -1 +0,0 @@ -MT_CFLAGS = -D_PTHREADS diff --git a/libstdc++/config/sol2shm.ml b/libstdc++/config/sol2shm.ml deleted file mode 100644 index e87f079e46c..00000000000 --- a/libstdc++/config/sol2shm.ml +++ /dev/null @@ -1,6 +0,0 @@ -# Solaris2 with shared libm, so we can link it into the shared libstdc++. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) -SHFLAGS = -h $(SHLIB) -SHDEPS = -lm -DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/sol2solth.mt b/libstdc++/config/sol2solth.mt deleted file mode 100644 index f809d0ace86..00000000000 --- a/libstdc++/config/sol2solth.mt +++ /dev/null @@ -1 +0,0 @@ -MT_CFLAGS = -D_SOLTHREADS diff --git a/libstdc++/config/sunos4.ml b/libstdc++/config/sunos4.ml deleted file mode 100644 index 3c5de27ab50..00000000000 --- a/libstdc++/config/sunos4.ml +++ /dev/null @@ -1,9 +0,0 @@ -# SunOS doesn't provide a shared libm, so we have to link with the archive -# library, even for programs that don't use complex. -# SunOS requires a version number in shared library filenames. - -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) -SHFLAGS = $(PICFLAG) -DEPLIBS = ../$(SHLIB) -LDLIBS = -L.. -lstdc++ -lm -MLDLIBS = -L.. -lstdc++ -lm diff --git a/libstdc++/config/x86-interix.ml b/libstdc++/config/x86-interix.ml deleted file mode 100644 index 8b8774e3a7a..00000000000 --- a/libstdc++/config/x86-interix.ml +++ /dev/null @@ -1,9 +0,0 @@ -# x86 Interix. SHLINK is defined to be .dummy to avoid running into -# the lack of symbolic links. - -SHLINK = .dummy -SHLIB = libstdc++.so -LIBS = $(ARLIB) $(SHLIB) -DEPLIBS = ../$(SHLIB) -SHFLAGS = $(PICFLAG) - diff --git a/libstdc++/configure.in b/libstdc++/configure.in deleted file mode 100644 index 54483d2d451..00000000000 --- a/libstdc++/configure.in +++ /dev/null @@ -1,209 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../configure. - -# If the language specific compiler does not exist, but the "gcc" directory -# does, we do not build anything. Note, $r is set by the top-level Makefile. -# Note that when we look for the compiler, we search both with and without -# extension to handle cross and canadian cross builds. -# Note that if $norecursion is set we're being called from config.status, -# so don't check for the compiler; we might be doing a make clean. -compiler_name=cc1plus -rm -f skip-this-dir -if test -n "$r" && [ -z "$norecursion" ] ; then - if test -d "$r"/gcc; then - if test -f "$r"/gcc/$compiler_name \ - || test -f "$r"/gcc/$compiler_name.exe; then - true - else - echo "rm -f multilib.out" > skip-this-dir - fi - fi -fi - -if [ "${srcdir}" = "." ] ; then - if [ "${with_target_subdir}" != "." ] ; then - topsrcdir=${with_multisrctop}../.. - else - topsrcdir=${with_multisrctop}.. - fi -else - topsrcdir=${srcdir}/.. -fi - -if [ -d ${topsrcdir}/gcc ] ; then - configdirs="tests testsuite" -else - configdirs="tests" -fi -srctrigger=sinst.cc -srcname="ANSI C++ library" -package_makefile_frag=Make.pack -package_makefile_rules_frag=Make.pack.r - -# per-host: - -# per-target: - -echo "# Warning: this fragment is automatically generated" > temp.mt -frags= - -# If they didn't specify --enable-shared, don't generate shared libs. -case "${enable_shared}" in - yes) shared=yes ;; - no) shared=no ;; - *libstdc++*) shared=yes ;; - *) shared=no ;; -esac - -if [ "${shared}" = "yes" ]; then - case "${target}" in - alpha*-*-linux*) frags=../../config/mh-elfalphapic ;; - arm*-*-*) frags=../../config/mh-armpic ;; - hppa*-*-*) frags=../../config/mh-papic ;; - i[3456]86-*-*) frags=../../config/mh-x86pic ;; - powerpc*-*-aix*) ;; - powerpc*-*-*) frags=../../config/mh-ppcpic ;; - sparc*-*-*) frags=../../config/mh-sparcpic ;; - *-*-*) frags=../../config/mh-${target_cpu}pic ;; - esac - case "${target}" in - *-*-aix*) frags="${frags} aix.ml" ;; - *-*-beos*) frags="${frags} beos.ml" ;; - *-dec-osf*) frags="${frags} dec-osf.ml";; - *-*-freebsd2*) ;; - *-*-freebsd*) frags="${frags} freebsd.ml" ;; - *-*-hpux*) frags="${frags} hpux.ml" ;; - *-*-irix[56]*) frags="${frags} irix5.ml" ;; - *-*-linux*aout*) ;; - *-*-linux*) frags="${frags} linux.ml" ;; - # This must come after *-*-linux* - *-*-gnu*) frags="${frags} gnu.ml" ;; - *-*-openbsd*) frags="${frags} openbsd.ml" ;; - *-*-sysv[45]*|*-*-udk*) frags="${frags} elf.ml" ;; - *-*-solaris*) frags="${frags} sol2shm.ml" ;; - *-*-sunos4*) frags="${frags} sunos4.ml" ;; - i[3456]86-*-interix*) frags="${frags} x86-interix.ml" ;; - esac -fi - -# Make sure the right flags are defined for multi-threading. -case "${target}" in - *-*-aix*) - frags="${frags} aix.mt" ;; - *-*-linux*) - case "x${enable_threads}" in - xyes|xposix) frags="${frags} linux.mt" ;; - esac;; - *-*-openbsd*) - case "x${enable_threads}" in - xyes|xposix) frags="${frags} openbsd.mt" ;; - esac;; - m68k-motorola-sysv) frags="${frags} delta.mt" ;; - *-*-solaris*) - case "x${enable_threads}" in - xposix) frags="${frags} sol2pth.mt" ;; - xsolaris) frags="${frags} sol2solth.mt" ;; - esac ;; - *) - case "x${enable_threads}" in - xposix) frags="${frags} posix.mt" ;; - esac ;; -esac - -for frag in ${frags}; do - case ${frag} in - ../* ) - if [ ${srcdir} = . ]; then - [ -n "${with_target_subdir}" ] && frag=../${frag} - [ -n "${with_multisrctop}" ] && frag=${with_multisrctop}${frag} - fi - ;; - esac - frag=${srcdir}/config/$frag - if [ -f ${frag} ]; then - echo "Appending ${frag} to target-mkfrag" - echo "# Following fragment copied from ${frag}" >> temp.mt - cat ${frag} >> temp.mt - fi -done - -target_makefile_frag=target-mkfrag -${moveifchange} temp.mt target-mkfrag - -LIBDIR=yes -TO_TOPDIR=../ -ALL='libs' -XCXXINCLUDES="-I${srcdir} -I${srcdir}/stl -I${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}include -I${srcdir}/${TO_TOPDIR}gcc" -MOSTLYCLEAN='*.o pic stamp-picdir core so_locations $(MOSTLYCLEAN_JUNK)' -CLEAN='$(CLEAN_JUNK)' -EXTRA_DISTCLEAN='target-mkfrag' - -(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} 2>${package_makefile_rules_frag} - -. ${topsrcdir}/config.if -echo " -LIBSTDCXX_INTERFACE=${libstdcxx_interface} -CXX_INTERFACE=${cxx_interface} -LIBC_INTERFACE=${libc_interface} -" >> ${package_makefile_frag} - -# This duplicated the AC_PROG_LN_S macro in GNU autoconf. -rm -f conttestdata -if ln -s X conftestdata 2>/dev/null -then - rm -f conftestdata - LN_S="ln -s" -else - LN_S=ln -fi -echo " -LN_S=$LN_S -" >> ${package_makefile_frag} - -# post-target: - -# If cross-compiling, we install in $(tooldir)/lib or in $(libsubdir) -# depending on --enable-version-specific-runtime-libs. -if [ -n "${with_cross_host}" ] ; then - rm -f Makefile.tem - sed \ - -e 's|^\([ ]*INSTALLDIR[ ]*=[ ]*\)\$(libdir)|\1$(tooldir)/lib|' \ - Makefile >Makefile.tem - mv -f Makefile.tem Makefile -fi - -# enable multilib-ing by default. -if [ -z "${enable_multilib}" ]; then - enable_multilib=yes -fi - -. ${topsrcdir}/config-ml.in - -gxx_include_dir= -# Specify the g++ header file directory -# Check whether --with-gxx-include-dir or --without-gxx-include-dir was given. -if test "${with_gxx_include_dir+set}" = set; then - withval="$with_gxx_include_dir" - case "${withval}" in - yes) - echo "configure.in: error: bad value ${withval} given for g++ include directory" 1>&2 - exit 1 - ;; - no) ;; - *) gxx_include_dir=$with_gxx_include_dir ;; - esac -fi - -if test x${gxx_include_dir} = x; then - if test x${enable_version_specific_runtime_libs} = xyes; then - gxx_include_dir='${libsubdir}/include/g++' - else - gxx_include_dir='${prefix}/include/g++'-${libstdcxx_interface} - fi -fi - -rm -f Makefile.tem -sed -e "s%^gxx_include_dir[ ]*=.*$%gxx_include_dir=${gxx_include_dir}%" \ - Makefile >Makefile.tem -mv -f Makefile.tem Makefile diff --git a/libstdc++/csetjmp b/libstdc++/csetjmp deleted file mode 100644 index 4bba048dcb5..00000000000 --- a/libstdc++/csetjmp +++ /dev/null @@ -1,8 +0,0 @@ -// The -*- C++ -*- setjmp/longjmp header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CSETJMP__ -#define __CSETJMP__ -#include -#endif - diff --git a/libstdc++/csignal b/libstdc++/csignal deleted file mode 100644 index 6febfb7b2ed..00000000000 --- a/libstdc++/csignal +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- signal handling header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CSIGNAL__ -#define __CSIGNAL__ -#include -#endif diff --git a/libstdc++/cstdarg b/libstdc++/cstdarg deleted file mode 100644 index 324f5a1c19b..00000000000 --- a/libstdc++/cstdarg +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CSTDARG__ -#define __CSTDARG__ -#include -#endif diff --git a/libstdc++/cstddef b/libstdc++/cstddef deleted file mode 100644 index db5cbe40037..00000000000 --- a/libstdc++/cstddef +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CSTDDEF__ -#define __CSTDDEF__ -#include -#endif diff --git a/libstdc++/cstdio b/libstdc++/cstdio deleted file mode 100644 index 1fe1456b5bd..00000000000 --- a/libstdc++/cstdio +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- standard I/O header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CSTDIO__ -#define __CSTDIO__ -#include -#endif diff --git a/libstdc++/cstdlib b/libstdc++/cstdlib deleted file mode 100644 index e7c1a5160a5..00000000000 --- a/libstdc++/cstdlib +++ /dev/null @@ -1,23 +0,0 @@ -// The -*- C++ -*- standard library header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CSTDLIB__ -#define __CSTDLIB__ -#include - -#ifdef __GNUG__ -#pragma interface "cstdlib" -#endif - -extern "C++" { - -#if _G_HAS_LABS -inline long abs(long x) { return labs (x); } -#else -inline long abs(long x) { return x >= 0 ? x : -x; } -#endif -//inline ldiv_t div(long x, long y) { return ldiv (x, y); } - -} // extern "C++" - -#endif diff --git a/libstdc++/cstdlibi.cc b/libstdc++/cstdlibi.cc deleted file mode 100644 index abbfa03464a..00000000000 --- a/libstdc++/cstdlibi.cc +++ /dev/null @@ -1,7 +0,0 @@ -// Implementation file for the -*- C++ -*- standard library header. -// This file is part of the GNU ANSI C++ Library. - -#ifdef __GNUG__ -#pragma implementation "cstdlib" -#endif -#include diff --git a/libstdc++/cstring b/libstdc++/cstring deleted file mode 100644 index d8d03a765b6..00000000000 --- a/libstdc++/cstring +++ /dev/null @@ -1,96 +0,0 @@ -// The -*- C++ -*- null-terminated string header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CSTRING__ -#define __CSTRING__ - -#include - -#if 0 // Let's not bother with this just yet. -#include - -#ifdef __GNUG__ -#pragma interface "cstring" -#endif - -// The ANSI C prototypes for these functions have a const argument type and -// non-const return type, so we can't use them. - -extern "C++" { -extern inline const char * -_G_strchr (const char *s, int c) -{ - return strchr (s, c); -} - -extern inline char * -_G_strchr (char *s, int c) -{ - return const_cast (strchr (s, c)); -} - -extern inline const char * -_G_strpbrk (const char *s1, const char *s2) -{ - return strpbrk (s1, s2); -} - -extern inline char * -_G_strpbrk (char *s1, const char *s2) -{ - return const_cast (strpbrk (s1, s2)); -} - -extern inline const char * -_G_strrchr (const char *s, int c) -{ - return strrchr (s, c); -} - -extern inline char * -_G_strrchr (char *s, int c) -{ - return const_cast (strrchr (s, c)); -} - -extern inline const char * -_G_strstr (const char *s1, const char *s2) -{ - return strstr (s1, s2); -} - -extern inline char * -_G_strstr (char *s1, const char *s2) -{ - return const_cast (strstr (s1, s2)); -} - -extern inline const void * -_G_memchr (const void *s, int c, size_t n) -{ - return memchr (s, c, n); -} - -extern inline void * -_G_memchr (void *s, int c, size_t n) -{ - return const_cast (memchr (s, c, n)); -} -} // extern "C++" - -// Lose any vendor macros for these functions. -#undef strchr -#undef strpbrk -#undef strrchr -#undef strstr -#undef memchr - -// Ewww, namespace pollution. Anyone have a better idea? -#define strchr _G_strchr -#define strpbrk _G_strpbrk -#define strrchr _G_strrchr -#define strstr _G_strstr -#define memchr _G_memchr -#endif // 0 - -#endif // !defined (__CSTRING__) diff --git a/libstdc++/cstringi.cc b/libstdc++/cstringi.cc deleted file mode 100644 index 2676febc9b0..00000000000 --- a/libstdc++/cstringi.cc +++ /dev/null @@ -1,7 +0,0 @@ -// Implementation file for the -*- C++ -*- null-terminated string header. -// This file is part of the GNU ANSI C++ Library. - -#ifdef __GNUG__ -#pragma implementation "cstring" -#endif -#include diff --git a/libstdc++/ctime b/libstdc++/ctime deleted file mode 100644 index 0184da5929f..00000000000 --- a/libstdc++/ctime +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- time header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CTIME__ -#define __CTIME__ -#include -#endif diff --git a/libstdc++/cwchar b/libstdc++/cwchar deleted file mode 100644 index 1674c12b61f..00000000000 --- a/libstdc++/cwchar +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- wide character header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CWCHAR__ -#define __CWCHAR__ -#include -#endif diff --git a/libstdc++/cwctype b/libstdc++/cwctype deleted file mode 100644 index 81122012bd0..00000000000 --- a/libstdc++/cwctype +++ /dev/null @@ -1,7 +0,0 @@ -// The -*- C++ -*- wide character type header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __CWCTYPE__ -#define __CWCTYPE__ -#include -#endif diff --git a/libstdc++/cxxabi.h b/libstdc++/cxxabi.h deleted file mode 100644 index 908d7c467fe..00000000000 --- a/libstdc++/cxxabi.h +++ /dev/null @@ -1,519 +0,0 @@ -/* new abi support -*- C++ -*- - Copyright (C) 2000 - Free Software Foundation, Inc. - Written by Nathan Sidwell, Codesourcery LLC, */ - -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -/* This file declares the new abi entry points into the runtime. It is not - normally necessary for user programs to include this header, or use the - entry points directly. However, this header is available should that be - needed. - - Some of the entry points are intended for both C and C++, thus this header - is includable from both C and C++. Though the C++ specific parts are not - available in C, naturally enough. */ - -#ifndef __CXXABI_H -#define __CXXABI_H 1 - -#if defined(__cplusplus) && (!defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100) -/* These structures only make sense when targeting the new abi, catch a - bonehead error early rather than let the user get very confused. */ -#error "Not targetting the new abi, supply -fnew-abi" -#endif - -#ifdef __cplusplus - -// We use the compiler builtins __SIZE_TYPE__ and __PTRDIFF_TYPE__ instead of -// std::size_t and std::ptrdiff_t respectively. This makes us independant of -// the conformance level of and whether -fhonor-std was supplied. -// is not currently available during compiler building anyway. -// Including would be wrong, as that would rudely place size_t in -// the global namespace. - -#include - -namespace __cxxabiv1 -{ - -/* type information for int, float etc */ -class __fundamental_type_info - : public std::type_info -{ -public: - virtual ~__fundamental_type_info (); -public: - explicit __fundamental_type_info (const char *__n) - : std::type_info (__n) - { } -}; - -/* type information for array objects */ -class __array_type_info - : public std::type_info -{ -/* abi defined member functions */ -protected: - virtual ~__array_type_info (); -public: - explicit __array_type_info (const char *__n) - : std::type_info (__n) - { } -}; - -/* type information for functions (both member and non-member) */ -class __function_type_info - : public std::type_info -{ -/* abi defined member functions */ -public: - virtual ~__function_type_info (); -public: - explicit __function_type_info (const char *__n) - : std::type_info (__n) - { } - -/* implementation defined member functions */ -protected: - virtual bool __is_function_p () const; -}; - -/* type information for enumerations */ -class __enum_type_info - : public std::type_info -{ -/* abi defined member functions */ -public: - virtual ~__enum_type_info (); -public: - explicit __enum_type_info (const char *__n) - : std::type_info (__n) - { } -}; - -/* common type information for simple pointers and pointers to member */ -class __pbase_type_info - : public std::type_info -{ -/* abi defined member variables */ -public: - unsigned int __qualifier_flags; /* qualification of the target object */ - const std::type_info *__pointee; /* type of pointed to object */ - -/* abi defined member functions */ -public: - virtual ~__pbase_type_info (); -public: - explicit __pbase_type_info (const char *__n, - int __quals, - const std::type_info *__type) - : std::type_info (__n), __qualifier_flags (__quals), __pointee (__type) - { } - -/* implementation defined types */ -public: - enum __qualifier_masks { - __const_mask = 0x1, - __volatile_mask = 0x2, - __restrict_mask = 0x4, - __incomplete_mask = 0x8, - __incomplete_class_mask = 0x10 - }; - -/* implementation defined member functions */ -protected: - virtual bool __do_catch (const std::type_info *__thr_type, - void **__thr_obj, - unsigned __outer) const; -protected: - inline virtual bool __pointer_catch (const __pbase_type_info *__thr_type, - void **__thr_obj, - unsigned __outer) const; -}; - -/* type information for simple pointers */ -class __pointer_type_info - : public __pbase_type_info -{ -/* abi defined member functions */ -public: - virtual ~__pointer_type_info (); -public: - explicit __pointer_type_info (const char *__n, - int __quals, - const std::type_info *__type) - : __pbase_type_info (__n, __quals, __type) - { } - -/* implementation defined member functions */ -protected: - virtual bool __is_pointer_p () const; - -protected: - virtual bool __pointer_catch (const __pbase_type_info *__thr_type, - void **__thr_obj, - unsigned __outer) const; -}; - -/* type information for a pointer to member variable */ -class __pointer_to_member_type_info - : public __pbase_type_info -{ -/* abi defined member variables */ -public: - __class_type_info *__context_class; /* class of the member */ - -/* abi defined member functions */ -public: - virtual ~__pointer_to_member_type_info (); -public: - explicit __pointer_to_member_type_info (const char *__n, - int __quals, - const std::type_info *__type, - __class_type_info *__klass) - : __pbase_type_info (__n, __quals, __type), __context_class (__klass) - { } - -/* implementation defined member functions */ -protected: - virtual bool __pointer_catch (const __pbase_type_info *__thr_type, - void **__thr_obj, - unsigned __outer) const; -}; - -class __class_type_info; - -/* helper class for __vmi_class_type */ -class __base_class_info -{ -/* abi defined member variables */ -public: - const __class_type_info *__base; /* base class type */ - long __offset_flags; /* offset and info */ - -/* implementation defined types */ -public: - enum __offset_flags_masks { - __virtual_mask = 0x1, - __public_mask = 0x2, - hwm_bit = 2, - offset_shift = 8 /* bits to shift offset by */ - }; - -/* implementation defined member functions */ -public: - bool __is_virtual_p () const - { return __offset_flags & __virtual_mask; } - bool __is_public_p () const - { return __offset_flags & __public_mask; } - __PTRDIFF_TYPE__ __offset () const - { - // This shift, being of a signed type, is implementation defined. GCC - // implements such shifts as arithmetic, which is what we want. - return static_cast<__PTRDIFF_TYPE__> (__offset_flags) >> offset_shift; - } -}; - -/* type information for a class */ -class __class_type_info - : public std::type_info -{ -/* abi defined member functions */ -public: - virtual ~__class_type_info (); -public: - explicit __class_type_info (const char *__n) - : type_info (__n) - { } - -/* implementation defined types */ -public: - /* sub_kind tells us about how a base object is contained within a derived - object. We often do this lazily, hence the UNKNOWN value. At other times - we may use NOT_CONTAINED to mean not publicly contained. */ - enum __sub_kind - { - __unknown = 0, /* we have no idea */ - __not_contained, /* not contained within us (in some */ - /* circumstances this might mean not contained */ - /* publicly) */ - __contained_ambig, /* contained ambiguously */ - - __contained_virtual_mask = __base_class_info::__virtual_mask, /* via a virtual path */ - __contained_public_mask = __base_class_info::__public_mask, /* via a public path */ - __contained_mask = 1 << __base_class_info::hwm_bit, /* contained within us */ - - __contained_private = __contained_mask, - __contained_public = __contained_mask | __contained_public_mask - }; - -public: - struct __upcast_result; - struct __dyncast_result; - -/* implementation defined member functions */ -protected: - virtual bool __do_upcast (const __class_type_info *__dst_type, void **__obj_ptr) const; - -protected: - virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj, - unsigned __outer) const; - - -public: - /* Helper for upcast. See if DST is us, or one of our bases. */ - /* Return false if not found, true if found. */ - virtual bool __do_upcast (const __class_type_info *__dst, - const void *__obj, - __upcast_result &__restrict __result) const; - -public: - /* Indicate whether SRC_PTR of type SRC_TYPE is contained publicly within - OBJ_PTR. OBJ_PTR points to a base object of our type, which is the - destination type. SRC2DST indicates how SRC objects might be contained - within this type. If SRC_PTR is one of our SRC_TYPE bases, indicate the - virtuality. Returns not_contained for non containment or private - containment. */ - inline __sub_kind __find_public_src (__PTRDIFF_TYPE__ __src2dst, - const void *__obj_ptr, - const __class_type_info *__src_type, - const void *__src_ptr) const; - -public: - /* dynamic cast helper. ACCESS_PATH gives the access from the most derived - object to this base. DST_TYPE indicates the desired type we want. OBJ_PTR - points to a base of our type within the complete object. SRC_TYPE - indicates the static type started from and SRC_PTR points to that base - within the most derived object. Fill in RESULT with what we find. Return - true if we have located an ambiguous match. */ - virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst, - __sub_kind __access_path, - const __class_type_info *__dst_type, - const void *__obj_ptr, - const __class_type_info *__src_type, - const void *__src_ptr, - __dyncast_result &__result) const; -public: - /* Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE bases are - inherited by the type started from -- which is not necessarily the - current type. The current type will be a base of the destination type. - OBJ_PTR points to the current base. */ - virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst, - const void *__obj_ptr, - const __class_type_info *__src_type, - const void *__src_ptr) const; -}; - -/* type information for a class with a single non-virtual base */ -class __si_class_type_info - : public __class_type_info -{ -/* abi defined member variables */ -public: - const __class_type_info *__base_type; - -/* abi defined member functions */ -public: - virtual ~__si_class_type_info (); -public: - explicit __si_class_type_info (const char *__n, - const __class_type_info *__base) - : __class_type_info (__n), __base_type (__base) - { } - -/* implementation defined member functions */ -protected: - virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst, - __sub_kind __access_path, - const __class_type_info *__dst_type, - const void *__obj_ptr, - const __class_type_info *__src_type, - const void *__src_ptr, - __dyncast_result &__result) const; - virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst, - const void *__obj_ptr, - const __class_type_info *__src_type, - const void *__sub_ptr) const; - virtual bool __do_upcast (const __class_type_info *__dst, - const void *__obj, - __upcast_result &__restrict __result) const; -}; - -/* type information for a class with multiple and/or virtual bases */ -class __vmi_class_type_info : public __class_type_info { -/* abi defined member variables */ -public: - unsigned int __flags; /* details about the class heirarchy */ - unsigned int __base_count; /* number of direct bases */ - __base_class_info const __base_info[1]; /* array of bases */ - /* The array of bases uses the trailing array struct hack - so this class is not constructable with a normal constructor. It is - internally generated by the compiler. */ - -/* abi defined member functions */ -public: - virtual ~__vmi_class_type_info (); -public: - explicit __vmi_class_type_info (const char *__n, - int ___flags) - : __class_type_info (__n), __flags (___flags), __base_count (0) - { } - -/* implementation defined types */ -public: - enum __flags_masks { - __non_diamond_repeat_mask = 0x1, /* distinct instance of repeated base */ - __diamond_shaped_mask = 0x2, /* diamond shaped multiple inheritance */ - non_public_base_mask = 0x4, /* has non-public direct or indirect base */ - public_base_mask = 0x8, /* has public base (direct) */ - - __flags_unknown_mask = 0x10 - }; - -/* implementation defined member functions */ -protected: - virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst, - __sub_kind __access_path, - const __class_type_info *__dst_type, - const void *__obj_ptr, - const __class_type_info *__src_type, - const void *__src_ptr, - __dyncast_result &__result) const; - virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst, - const void *__obj_ptr, - const __class_type_info *__src_type, - const void *__src_ptr) const; - virtual bool __do_upcast (const __class_type_info *__dst, - const void *__obj, - __upcast_result &__restrict __result) const; -}; - -/* dynamic cast runtime */ -extern "C" -void *__dynamic_cast (const void *__src_ptr, /* object started from */ - const __class_type_info *__src_type, /* static type of object */ - const __class_type_info *__dst_type, /* desired target type */ - __PTRDIFF_TYPE__ __src2dst); /* how src and dst are related */ - - /* src2dst has the following possible values - >= 0: src_type is a unique public non-virtual base of dst_type - dst_ptr + src2dst == src_ptr - -1: unspecified relationship - -2: src_type is not a public base of dst_type - -3: src_type is a multiple public non-virtual base of dst_type */ - -/* array ctor/dtor routines */ - -/* allocate and construct array */ -extern "C" -void *__cxa_vec_new (__SIZE_TYPE__ __element_count, - __SIZE_TYPE__ __element_size, - __SIZE_TYPE__ __padding_size, - void (*__constructor) (void *), - void (*__destructor) (void *)); - -extern "C" -void *__cxa_vec_new2 (__SIZE_TYPE__ __element_count, - __SIZE_TYPE__ __element_size, - __SIZE_TYPE__ __padding_size, - void (*__constructor) (void *), - void (*__destructor) (void *), - void *(*__alloc) (__SIZE_TYPE__), - void (*__dealloc) (void *)); - -extern "C" -void *__cxa_vec_new3 (__SIZE_TYPE__ __element_count, - __SIZE_TYPE__ __element_size, - __SIZE_TYPE__ __padding_size, - void (*__constructor) (void *), - void (*__destructor) (void *), - void *(*__alloc) (__SIZE_TYPE__), - void (*__dealloc) (void *, __SIZE_TYPE__)); - -/* construct array */ -extern "C" -void __cxa_vec_ctor (void *__array_address, - __SIZE_TYPE__ __element_count, - __SIZE_TYPE__ __element_size, - void (*__constructor) (void *), - void (*__destructor) (void *)); - -extern "C" -void __cxa_vec_cctor (void *dest_array, - void *src_array, - __SIZE_TYPE__ element_count, - __SIZE_TYPE__ element_size, - void (*constructor) (void *, void *), - void (*destructor) (void *)); - -/* destruct array */ -extern "C" -void __cxa_vec_dtor (void *__array_address, - __SIZE_TYPE__ __element_count, - __SIZE_TYPE__ __element_size, - void (*__destructor) (void *)); - -/* destruct and release array */ -extern "C" -void __cxa_vec_delete (void *__array_address, - __SIZE_TYPE__ __element_size, - __SIZE_TYPE__ __padding_size, - void (*__destructor) (void *)); - -extern "C" -void __cxa_vec_delete2 (void *__array_address, - __SIZE_TYPE__ __element_size, - __SIZE_TYPE__ __padding_size, - void (*__destructor) (void *), - void (*__dealloc) (void *)); - -extern "C" -void __cxa_vec_delete3 (void *__array_address, - __SIZE_TYPE__ __element_size, - __SIZE_TYPE__ __padding_size, - void (*__destructor) (void *), - void (*__dealloc) (void *, __SIZE_TYPE__)); - -/* demangling routines */ - -extern "C" -char *__cxa_demangle (const char *__mangled_name, - char *__output_buffer, - __SIZE_TYPE__ *__length, - int *__status); - -} /* namespace __cxxabiv1 */ - -/* User programs should use the alias `abi'. */ -namespace abi = __cxxabiv1; - -#else -#endif /* __cplusplus */ - - -#endif /* __CXXABI_H */ diff --git a/libstdc++/del_op.cc b/libstdc++/del_op.cc deleted file mode 100644 index c009a1637c6..00000000000 --- a/libstdc++/del_op.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Boilerplate support routines for -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" - -extern "C" void free (void *); - -void -operator delete (void *ptr) throw () -{ - if (ptr) - free (ptr); -} diff --git a/libstdc++/del_opnt.cc b/libstdc++/del_opnt.cc deleted file mode 100644 index d5d619e803d..00000000000 --- a/libstdc++/del_opnt.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Boilerplate support routines for -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" - -extern "C" void free (void *); - -void -operator delete (void *ptr, const std::nothrow_t&) throw () -{ - if (ptr) - free (ptr); -} diff --git a/libstdc++/del_opv.cc b/libstdc++/del_opv.cc deleted file mode 100644 index b43d45a35a1..00000000000 --- a/libstdc++/del_opv.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Boilerplate support routines for -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" - -void -operator delete[] (void *ptr) throw () -{ - ::operator delete (ptr); -} diff --git a/libstdc++/del_opvnt.cc b/libstdc++/del_opvnt.cc deleted file mode 100644 index e91096c4af6..00000000000 --- a/libstdc++/del_opvnt.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Boilerplate support routines for -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" - -void -operator delete[] (void *ptr, const std::nothrow_t&) throw () -{ - ::operator delete (ptr); -} diff --git a/libstdc++/exception b/libstdc++/exception deleted file mode 100644 index 4d35c56c405..00000000000 --- a/libstdc++/exception +++ /dev/null @@ -1,65 +0,0 @@ -// Exception Handling support header for -*- C++ -*- -// Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation - -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -#ifndef __EXCEPTION__ -#define __EXCEPTION__ - -#pragma interface "exception" - -extern "C++" { - -namespace std { - -class exception { -public: - exception () { } - virtual ~exception () { } - virtual const char* what () const; -}; - -class bad_exception : public exception { -public: - bad_exception () { } - virtual ~bad_exception () { } -}; - -typedef void (*terminate_handler) (); -typedef void (*unexpected_handler) (); - -terminate_handler set_terminate (terminate_handler); -void terminate () __attribute__ ((__noreturn__)); -unexpected_handler set_unexpected (unexpected_handler); -void unexpected () __attribute__ ((__noreturn__)); -bool uncaught_exception (); - -} // namespace std - -} // extern "C++" - -#endif diff --git a/libstdc++/exception.cc b/libstdc++/exception.cc deleted file mode 100644 index c27b8ff9603..00000000000 --- a/libstdc++/exception.cc +++ /dev/null @@ -1,404 +0,0 @@ -// Functions for Exception Support for -*- C++ -*- -// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation - -// This file is part of GNU CC. - -// GNU CC 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. - -// GNU CC 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 GNU CC; 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. - -#pragma implementation "exception" - -#include "typeinfo" -#include "exception" -#include -#include "gansidecl.h" /* Needed to support macros used in eh-common.h. */ -#include "eh-common.h" - -/* Define terminate, unexpected, set_terminate, set_unexpected as - well as the default terminate func and default unexpected func. */ - -/* __terminate and __terminate_set_func, defined in libgcc2. */ -typedef void (*__terminate_func_ptr)(void) __attribute__ ((__noreturn__)); -extern "C" void __terminate (void) __attribute__ ((__noreturn__)); -extern "C" __terminate_func_ptr __terminate_set_func (__terminate_func_ptr); - -using std::terminate; - -void -std::terminate () -{ - __terminate (); -} - -void -__default_unexpected () -{ - terminate (); -} - -static std::unexpected_handler __unexpected_func __attribute__((__noreturn__)) - = __default_unexpected; - -std::terminate_handler -std::set_terminate (std::terminate_handler func) -{ - return __terminate_set_func (func); -} - -std::unexpected_handler -std::set_unexpected (std::unexpected_handler func) -{ - std::unexpected_handler old = __unexpected_func; - - __unexpected_func = func; - return old; -} - -void -std::unexpected () -{ - __unexpected_func (); -} - -/* The type of a function called to clean up an exception object. - (These will be destructors.) Under the old ABI, these take a - second argument (the `in-charge' argument), that indicates whether - or not do delete the object, and whether or not to destroy virtual - bases. Under the new ABI, there is no second argument. */ -#if !defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -typedef void (*cleanup_fn)(void *, int); -/* The `2' is the value for the in-charge parameter that indicates - that virtual bases should be destroyed. */ -#define CALL_CLEANUP(FN, THIS) FN (THIS, 2) -#else -typedef void (*cleanup_fn)(void *); -#define CALL_CLEANUP(FN, THIS) FN (THIS) -#endif - -/* C++-specific state about the current exception. - This must match init_exception_processing(). - - Note that handlers and caught are not redundant; when rethrown, an - exception can have multiple active handlers and still be considered - uncaught. */ - -struct cp_eh_info -{ - __eh_info eh_info; - void *value; - void *type; - cleanup_fn cleanup; - bool caught; - cp_eh_info *next; - long handlers; - void *original_value; -}; - -/* Language-specific EH info pointer, defined in libgcc2. */ - -extern "C" cp_eh_info **__get_eh_info (); // actually void ** - -/* Exception allocate and free, defined in libgcc2. */ -extern "C" void *__eh_alloc(size_t); -extern "C" void __eh_free(void *); - -/* Is P the type_info node for a pointer of some kind? */ - -extern bool __is_pointer (void *); - - -/* OLD Compiler hook to return a pointer to the info for the current exception. - Used by get_eh_info (). This fudges the actualy returned value to - point to the beginning of what USE to be the cp_eh_info structure. - THis is so that old code that dereferences this pointer will find - things where it expects it to be.*/ -extern "C" void * -__cp_exception_info (void) -{ - return &((*__get_eh_info ())->value); -} - -#define CP_EH_INFO ((cp_eh_info *) *__get_eh_info ()) - -/* Old Compiler hook to return a pointer to the info for the current exception. - Used by get_eh_info (). */ - -extern "C" cp_eh_info * -__cp_eh_info (void) -{ - cp_eh_info *p = CP_EH_INFO; - return p; -} - -/* Compiler hook to return a pointer to the info for the current exception, - Set the caught bit, and increment the number of handlers that are - looking at this exception. This makes handlers smaller. */ - -extern "C" cp_eh_info * -__start_cp_handler (void) -{ - cp_eh_info *p = CP_EH_INFO; - p->caught = 1; - p->handlers++; - return p; -} - -extern "C" int __throw_type_match_rtti_2 (const void *, const void *, - void *, void **); - -extern "C" void * -__cplus_type_matcher (__eh_info *info_, void *match_info, - exception_descriptor *exception_table) -{ - cp_eh_info *info = (cp_eh_info *)info_; - - /* No exception table implies the old style mechanism, so don't check. */ - if (exception_table != NULL - && exception_table->lang.language != EH_LANG_C_plus_plus) - return NULL; - - if (match_info == CATCH_ALL_TYPE) - return (void *)1; - - /* we don't worry about version info yet, there is only one version! */ - - void *match_type = match_info; - -#if !defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 - match_type = ((void *(*)())match_type) (); -#endif - - if (__throw_type_match_rtti_2 (match_type, info->type, - info->original_value, &info->value)) - // Arbitrary non-null pointer. - return (void *)1; - else - return NULL; -} - -/* Compiler hook to push a new exception onto the stack. - Used by expand_throw(). */ - -extern "C" void -__cp_push_exception (void *value, void *type, cleanup_fn cleanup) -{ - cp_eh_info *p = (cp_eh_info *) __eh_alloc (sizeof (cp_eh_info)); - - p->value = value; - p->type = type; - p->cleanup = cleanup; - p->handlers = 0; - p->caught = false; - p->original_value = value; - - p->eh_info.match_function = __cplus_type_matcher; - p->eh_info.language = EH_LANG_C_plus_plus; - p->eh_info.version = 1; - - cp_eh_info **q = __get_eh_info (); - - p->next = *q; - *q = p; -} - -/* Compiler hook to pop an exception that has been finalized. Used by - push_eh_cleanup(). P is the info for the exception caught by the - current catch block. */ - -extern "C" void -__cp_pop_exception (cp_eh_info *p) -{ - cp_eh_info **stack = __get_eh_info (); - cp_eh_info **q = stack; - - --p->handlers; - - /* Do nothing if our exception is being rethrown (i.e. if the active - exception is our exception and it is uncaught). */ - if (p == *q && !p->caught) - return; - - /* Don't really pop if there are still active handlers for our exception; - rather, push it down past any uncaught exceptions. */ - if (p->handlers != 0) - { - if (p == *q && p->next && !p->next->caught) - { - q = &(p->next); - while (1) - { - if (*q == 0 || (*q)->caught) - break; - - q = &((*q)->next); - } - *stack = p->next; - p->next = *q; - *q = p; - } - return; - } - - for (; *q; q = &((*q)->next)) - if (*q == p) - break; - - if (! *q) - terminate (); - - *q = p->next; - - if (p->cleanup) - // value may have been adjusted. - CALL_CLEANUP (p->cleanup, p->original_value); - - if (! __is_pointer (p->type)) - __eh_free (p->original_value); // value may have been adjusted. - - __eh_free (p); -} - -/* We're doing a rethrow. Find the currently handled exception, mark it - uncaught, and move it to the top of the EH stack. */ - -extern "C" void -__uncatch_exception (void) -{ - cp_eh_info **stack = __get_eh_info (); - cp_eh_info **q = stack; - cp_eh_info *p; - - while (1) - { - p = *q; - - if (p == 0) - terminate (); - if (p->caught) - break; - - q = &(p->next); - } - - if (q != stack) - { - *q = p->next; - p->next = *stack; - *stack = p; - } - - p->caught = false; -} - -/* As per [except.unexpected]: - If an exception is thrown, we check it against the spec. If it doesn't - match, we call unexpected (). If unexpected () throws, we check that - exception against the spec. If it doesn't match, if the spec allows - bad_exception we throw that; otherwise we call terminate (). - - The compiler treats an exception spec as a try block with a generic - handler that just calls this function with a list of the allowed - exception types, so we have an active exception that can be rethrown. - - This function does not return. */ - -extern "C" void -__check_eh_spec (int n, const void **spec) -{ - cp_eh_info *p = CP_EH_INFO; - void *d; - - for (int i = 0; i < n; ++i) - { - if (__throw_type_match_rtti_2 (spec[i], p->type, p->value, &d)) - throw; - } - - try - { - std::unexpected (); - } - catch (...) - { - // __exception_info is an artificial var pushed into each catch block. - if (p != __exception_info) - { - p = __exception_info; - for (int i = 0; i < n; ++i) - { - if (__throw_type_match_rtti_2 (spec[i], p->type, p->value, &d)) - throw; - } - } - - const std::type_info &bad_exc = typeid (std::bad_exception); - for (int i = 0; i < n; ++i) - { - if (__throw_type_match_rtti_2 (spec[i], &bad_exc, p->value, &d)) - throw std::bad_exception (); - } - - terminate (); - } -} - -/* Special case of the above for throw() specs. */ - -extern "C" void -__check_null_eh_spec (void) -{ - __check_eh_spec (0, 0); -} - -// Helpers for rtti. Although these don't return, we give them return types so -// that the type system is not broken. - -extern "C" void * -__throw_bad_cast () -{ - throw std::bad_cast (); - return 0; -} - -extern "C" std::type_info const & -__throw_bad_typeid () -{ - throw std::bad_typeid (); - return typeid (void); -} - -/* Has the current exception been caught? */ - -bool -std::uncaught_exception () -{ - cp_eh_info *p = CP_EH_INFO; - return p && ! p->caught; -} - -const char * std::exception:: -what () const -{ - return typeid (*this).name (); -} diff --git a/libstdc++/fstream b/libstdc++/fstream deleted file mode 100644 index 2c35ca92b03..00000000000 --- a/libstdc++/fstream +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __FSTREAM__ -#define __FSTREAM__ -#include -#endif diff --git a/libstdc++/iomanip b/libstdc++/iomanip deleted file mode 100644 index 817948579ce..00000000000 --- a/libstdc++/iomanip +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __IOMANIP__ -#define __IOMANIP__ -#include -#endif diff --git a/libstdc++/iosfwd b/libstdc++/iosfwd deleted file mode 100644 index 8314cf7b73f..00000000000 --- a/libstdc++/iosfwd +++ /dev/null @@ -1,15 +0,0 @@ -// -*- C++ -*- I/O forward declaration header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __IOSFWD__ -#define __IOSFWD__ -class ios; -class streambuf; -class istream; -class ostream; -class iostream; -class filebuf; -class ifstream; -class ofstream; -class fstream; -#endif diff --git a/libstdc++/iostream b/libstdc++/iostream deleted file mode 100644 index 7ecba6e8daf..00000000000 --- a/libstdc++/iostream +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __IOSTREAM__ -#define __IOSTREAM__ -#include -#endif diff --git a/libstdc++/new b/libstdc++/new deleted file mode 100644 index cbb8d107acf..00000000000 --- a/libstdc++/new +++ /dev/null @@ -1,68 +0,0 @@ -// The -*- C++ -*- dynamic memory management header. -// Copyright (C) 1994, 1996, 1997, 1998, 2000 Free Software Foundation - -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -#ifndef __NEW__ -#define __NEW__ - -#pragma interface "new" -#include -#include - -extern "C++" { - -namespace std { - - class bad_alloc : public exception { - public: - virtual const char* what() const throw() { return "bad_alloc"; } - }; - - struct nothrow_t {}; - extern const nothrow_t nothrow; - typedef void (*new_handler)(); - new_handler set_new_handler (new_handler); - -} // namespace std - -// replaceable signatures -void *operator new (size_t) throw (std::bad_alloc); -void *operator new[] (size_t) throw (std::bad_alloc); -void operator delete (void *) throw(); -void operator delete[] (void *) throw(); -void *operator new (size_t, const std::nothrow_t&) throw(); -void *operator new[] (size_t, const std::nothrow_t&) throw(); -void operator delete (void *, const std::nothrow_t&) throw(); -void operator delete[] (void *, const std::nothrow_t&) throw(); - -// default placement versions of operator new -inline void *operator new(size_t, void *place) throw() { return place; } -inline void *operator new[](size_t, void *place) throw() { return place; } -} // extern "C++" - -#endif diff --git a/libstdc++/new.h b/libstdc++/new.h deleted file mode 100644 index cb1fa4cb5ca..00000000000 --- a/libstdc++/new.h +++ /dev/null @@ -1,38 +0,0 @@ -// -*- C++ -*- forwarding header. -// Copyright (C) 2000 Free Software Foundation - -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -#ifndef __NEW_H__ -#define __NEW_H__ - -#include - -using std::new_handler; -using std::set_new_handler; - -#endif // __NEW_H__ diff --git a/libstdc++/new_handler.cc b/libstdc++/new_handler.cc deleted file mode 100644 index 183d1b29882..00000000000 --- a/libstdc++/new_handler.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Implementation file for the -*- C++ -*- dynamic memory management header. -// Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#pragma implementation "new" -#include "new" - -const std::nothrow_t std::nothrow = { }; - -using std::new_handler; -new_handler __new_handler; - -new_handler -std::set_new_handler (new_handler handler) -{ - new_handler prev_handler = __new_handler; - __new_handler = handler; - return prev_handler; -} diff --git a/libstdc++/new_op.cc b/libstdc++/new_op.cc deleted file mode 100644 index 92577e2f6c8..00000000000 --- a/libstdc++/new_op.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Support routines for the -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" -using std::new_handler; -using std::bad_alloc; - -extern "C" void *malloc (size_t); -extern new_handler __new_handler; - -void * -operator new (size_t sz) throw (std::bad_alloc) -{ - void *p; - - /* malloc (0) is unpredictable; avoid it. */ - if (sz == 0) - sz = 1; - p = (void *) malloc (sz); - while (p == 0) - { - new_handler handler = __new_handler; - if (! handler) - throw bad_alloc (); - handler (); - p = (void *) malloc (sz); - } - - return p; -} diff --git a/libstdc++/new_opnt.cc b/libstdc++/new_opnt.cc deleted file mode 100644 index 27a9283f165..00000000000 --- a/libstdc++/new_opnt.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Support routines for the -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" -using std::new_handler; -using std::bad_alloc; - -extern "C" void *malloc (size_t); -extern new_handler __new_handler; - -void * -operator new (size_t sz, const std::nothrow_t&) throw() -{ - void *p; - - /* malloc (0) is unpredictable; avoid it. */ - if (sz == 0) - sz = 1; - p = (void *) malloc (sz); - while (p == 0) - { - new_handler handler = __new_handler; - if (! handler) - return 0; - try - { - handler (); - } - catch (bad_alloc &) - { - return 0; - } - - p = (void *) malloc (sz); - } - - return p; -} diff --git a/libstdc++/new_opv.cc b/libstdc++/new_opv.cc deleted file mode 100644 index 1e14ca81cf6..00000000000 --- a/libstdc++/new_opv.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Boilerplate support routines for -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" - -void * -operator new[] (size_t sz) throw (std::bad_alloc) -{ - return ::operator new(sz); -} diff --git a/libstdc++/new_opvnt.cc b/libstdc++/new_opvnt.cc deleted file mode 100644 index dde0a7c3cf9..00000000000 --- a/libstdc++/new_opvnt.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Boilerplate support routines for -*- C++ -*- dynamic memory management. -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -#include "new" - -void * -operator new[] (size_t sz, const std::nothrow_t& nothrow) throw() -{ - return ::operator new(sz, nothrow); -} diff --git a/libstdc++/pure.c b/libstdc++/pure.c deleted file mode 100644 index abaed59177f..00000000000 --- a/libstdc++/pure.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#ifdef __GNU_LIBRARY__ - /* Avoid forcing the library's meaning of `write' on the user program - by using the "internal" name (for use within the library) */ -#define write(fd, buf, n) __write((fd), (buf), (n)) -#endif - -#define MESSAGE "pure virtual method called\n" - -void -__pure_virtual (void) -{ - write (2, MESSAGE, sizeof (MESSAGE) - 1); - __terminate (); -} diff --git a/libstdc++/sinst.cc b/libstdc++/sinst.cc deleted file mode 100644 index 0b3617ece62..00000000000 --- a/libstdc++/sinst.cc +++ /dev/null @@ -1,135 +0,0 @@ -// Instantiation file for the -*- C++ -*- string classes. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification by Takanori Adachi -// in ANSI X3J16/94-0013R2. - -#ifdef __GNUG__ -#ifdef TRAITS -#ifdef C -#pragma implementation "std/straits.h" -#endif -#endif -#endif - -#include - -#ifdef C -typedef char c; -#endif -#ifdef W -typedef wchar_t c; -#endif - -#if defined(TRAITS) && !defined(C) -template class string_char_traits ; -#else -/* string_char_traits is already explicitly specialized in - std/straits.h. */ -#endif - -typedef basic_string s; - -#ifdef MAIN -template class basic_string ; -#endif - -#ifdef ADDSS -template s operator+ (const s&, const s&); -#endif -#ifdef ADDPS -template s operator+ (const c*, const s&); -#endif -#ifdef ADDCS -template s operator+ (c, const s&); -#endif -#ifdef ADDSP -template s operator+ (const s&, const c*); -#endif -#ifdef ADDSC -template s operator+ (const s&, c); -#endif -#ifdef EQSS -template bool operator== (const s&, const s&); -#endif -#ifdef EQPS -template bool operator== (const c*, const s&); -#endif -#ifdef EQSP -template bool operator== (const s&, const c*); -#endif -#ifdef NESS -template bool operator!= (const s&, const s&); -#endif -#ifdef NEPS -template bool operator!= (const c*, const s&); -#endif -#ifdef NESP -template bool operator!= (const s&, const c*); -#endif -#ifdef LTSS -template bool operator< (const s&, const s&); -#endif -#ifdef LTPS -template bool operator< (const c*, const s&); -#endif -#ifdef LTSP -template bool operator< (const s&, const c*); -#endif -#ifdef GTSS -template bool operator> (const s&, const s&); -#endif -#ifdef GTPS -template bool operator> (const c*, const s&); -#endif -#ifdef GTSP -template bool operator> (const s&, const c*); -#endif -#ifdef LESS -template bool operator<= (const s&, const s&); -#endif -#ifdef LEPS -template bool operator<= (const c*, const s&); -#endif -#ifdef LESP -template bool operator<= (const s&, const c*); -#endif -#ifdef GESS -template bool operator>= (const s&, const s&); -#endif -#ifdef GEPS -template bool operator>= (const c*, const s&); -#endif -#ifdef GESP -template bool operator>= (const s&, const c*); -#endif -#ifdef EXTRACT -template istream& operator>> (istream&, s&); -#endif // EXTRACT -#ifdef INSERT -template ostream& operator<< (ostream&, const s&); -#endif // INSERT -#ifdef GETLINE -template istream& getline (istream&, s&, c); -#endif diff --git a/libstdc++/sstream b/libstdc++/sstream deleted file mode 100644 index 45393b14761..00000000000 --- a/libstdc++/sstream +++ /dev/null @@ -1,343 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 2000 Free Software Foundation - -This file is part of the GNU IO 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, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not 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. */ - -/* Written by Magnus Fromreide (magfr@lysator.liu.se). */ -/* seekoff and ideas for overflow is largely borrowed from libstdc++-v3 */ - -#ifndef __SSTREAM__ -#define __SSTREAM__ - -#include -#include -#include - -namespace std -{ - class stringbuf : public streambuf - { - public: - typedef char char_type; - typedef int int_type; - typedef streampos pos_type; - typedef streamoff off_type; - - explicit - stringbuf(int which=ios::in|ios::out) - : streambuf(), mode(static_cast(which)), - stream(NULL), stream_len(0) - { - stringbuf_init(); - } - - explicit - stringbuf(const string &str, int which=ios::in|ios::out) - : streambuf(), mode(static_cast(which)), - stream(NULL), stream_len(0) - { - if (mode & (ios::in|ios::out)) - { - stream_len = str.size(); - stream = new char_type[stream_len]; - str.copy(stream, stream_len); - } - stringbuf_init(); - } - - virtual - ~stringbuf() - { - delete[] stream; - } - - string - str() const - { - if (pbase() != 0) - return string(stream, pptr()-pbase()); - else - return string(); - } - - void - str(const string& str) - { - delete[] stream; - stream_len = str.size(); - stream = new char_type[stream_len]; - str.copy(stream, stream_len); - stringbuf_init(); - } - - protected: - // The buffer is already in gptr, so if it ends then it is out of data. - virtual int - underflow() - { - return EOF; - } - - virtual int - overflow(int c = EOF) - { - int res; - if (mode & ios::out) - { - if (c != EOF) - { - streamsize old_stream_len = stream_len; - stream_len += 1; - char_type* new_stream = new char_type[stream_len]; - memcpy(new_stream, stream, old_stream_len); - delete[] stream; - stream = new_stream; - stringbuf_sync(gptr()-eback(), pptr()-pbase()); - sputc(c); - res = c; - } - else - res = EOF; - } - else - res = 0; - return res; - } - - virtual streambuf* - setbuf(char_type* s, streamsize n) - { - if (n != 0) - { - delete[] stream; - stream = new char_type[n]; - memcpy(stream, s, n); - stream_len = n; - stringbuf_sync(0, 0); - } - return this; - } - - virtual pos_type - seekoff(off_type off, ios::seek_dir way, int which = ios::in | ios::out) - { - pos_type ret = pos_type(off_type(-1)); - bool testin = which & ios::in && mode & ios::in; - bool testout = which & ios::out && mode & ios::out; - bool testboth = testin && testout && way != ios::cur; - - if (stream_len && ((testin != testout) || testboth)) - { - char_type* beg = stream; - char_type* curi = NULL; - char_type* curo = NULL; - char_type* endi = NULL; - char_type* endo = NULL; - - if (testin) - { - curi = gptr(); - endi = egptr(); - } - if (testout) - { - curo = pptr(); - endo = epptr(); - } - - off_type newoffi = 0; - off_type newoffo = 0; - if (way == ios::beg) - { - newoffi = beg - curi; - newoffo = beg - curo; - } - else if (way == ios::end) - { - newoffi = endi - curi; - newoffo = endo - curo; - } - - if (testin && newoffi + off + curi - beg >= 0 && - endi - beg >= newoffi + off + curi - beg) - { - gbump(newoffi + off); - ret = pos_type(newoffi + off + curi); - } - if (testout && newoffo + off + curo - beg >= 0 && - endo - beg >= newoffo + off + curo - beg) - { - pbump(newoffo + off); - ret = pos_type(newoffo + off + curo); - } - } - return ret; - } - - virtual pos_type - seekpos(pos_type sp, int which = ios::in | ios::out) - { - pos_type ret = seekoff(sp, ios::beg, which); - return ret; - } - - private: - void - stringbuf_sync(streamsize i, streamsize o) - { - if (mode & ios::in) - setg(stream, stream + i, stream + stream_len); - if (mode & ios::out) - { - setp(stream, stream + stream_len); - pbump(o); - } - } - void - stringbuf_init() - { - if (mode & ios::ate) - stringbuf_sync(0, stream_len); - else - stringbuf_sync(0, 0); - } - - private: - ios::open_mode mode; - char_type* stream; - streamsize stream_len; - }; - - class istringstream : public istream { - public: - typedef char char_type; - typedef int int_type; - typedef streampos pos_type; - typedef streamoff off_type; - - explicit - istringstream(int which=ios::in) - : istream(&sb), sb(which | ios::in) - { } - - explicit - istringstream(const string& str, int which=ios::in) - : istream(&sb), sb(str, which | ios::in) - { } - - stringbuf* - rdbuf() const - { - return const_cast(&sb); - } - - string - str() const - { - return rdbuf()->str(); - } - void - str(const string& s) - { - rdbuf()->str(s); - } - private: - stringbuf sb; - }; - - class ostringstream : public ostream { - public: - typedef char char_type; - typedef int int_type; - typedef streampos pos_type; - typedef streamoff off_type; - - explicit - ostringstream(int which=ios::out) - : ostream(&sb), sb(which | ios::out) - { } - - explicit - ostringstream(const string& str, int which=ios::out) - : ostream(&sb), sb(str, which | ios::out) - { } - - stringbuf* - rdbuf() const - { - return const_cast(&sb); - } - - string - str() const - { - return rdbuf()->str(); - } - - void str(const string& s) - { - rdbuf()->str(s); - } - private: - stringbuf sb; - }; - - class stringstream : public iostream { - public: - typedef char char_type; - typedef int int_type; - typedef streampos pos_type; - typedef streamoff off_type; - - explicit - stringstream(int which=ios::out|ios::in) - : iostream(&sb), sb(which) - { } - - explicit - stringstream(const string& str, int which=ios::out|ios::in) - : iostream(&sb), sb(str, which) - { } - - stringbuf* - rdbuf() const - { - return const_cast(&sb); - } - - string - str() const - { - return rdbuf()->str(); - } - - void - str(const string& s) - { - rdbuf()->str(s); - } - private: - stringbuf sb; - }; -}; - -#endif /* not __STRSTREAM__ */ diff --git a/libstdc++/std/bastring.cc b/libstdc++/std/bastring.cc deleted file mode 100644 index b8fec4fa7db..00000000000 --- a/libstdc++/std/bastring.cc +++ /dev/null @@ -1,526 +0,0 @@ -// Member templates for the -*- C++ -*- string classes. -// Copyright (C) 1994, 1999, 2000 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification by Takanori Adachi -// in ANSI X3J16/94-0013R2. - -extern "C++" { -template -inline void * basic_string ::Rep:: -operator new (size_t s, size_t extra) -{ - return Allocator::allocate(s + extra * sizeof (charT)); -} - -template -inline void basic_string ::Rep:: -operator delete (void * ptr) -{ - Allocator::deallocate(ptr, sizeof(Rep) + - reinterpret_cast(ptr)->res * - sizeof (charT)); -} - -template -inline size_t basic_string ::Rep:: -frob_size (size_t s) -{ - size_t i = 16; - while (i < s) i *= 2; - return i; -} - -template -inline basic_string ::Rep * -basic_string ::Rep:: -create (size_t extra) -{ - extra = frob_size (extra + 1); - Rep *p = new (extra) Rep; - p->res = extra; - p->ref = 1; - p->selfish = false; - return p; -} - -template -charT * basic_string ::Rep:: -clone () -{ - Rep *p = Rep::create (len); - p->copy (0, data (), len); - p->len = len; - return p->data (); -} - -template -inline bool basic_string ::Rep:: -excess_slop (size_t s, size_t r) -{ - return 2 * (s <= 16 ? 16 : s) < r; -} - -template -inline bool basic_string :: -check_realloc (basic_string::size_type s) const -{ - s += sizeof (charT); - rep ()->selfish = false; - return (rep ()->ref > 1 - || s > capacity () - || Rep::excess_slop (s, capacity ())); -} - -template -void basic_string :: -alloc (basic_string::size_type __size, bool __save) -{ - if (! check_realloc (__size)) - return; - - Rep *p = Rep::create (__size); - - if (__save) - { - p->copy (0, data (), length ()); - p->len = length (); - } - else - p->len = 0; - - repup (p); -} - -template -basic_string & -basic_string :: -replace (size_type pos1, size_type n1, - const basic_string& str, size_type pos2, size_type n2) -{ - const size_t len2 = str.length (); - - if (pos1 == 0 && n1 >= length () && pos2 == 0 && n2 >= len2) - return operator= (str); - - OUTOFRANGE (pos2 > len2); - - if (n2 > len2 - pos2) - n2 = len2 - pos2; - - return replace (pos1, n1, str.data () + pos2, n2); -} - -template -inline void basic_string ::Rep:: -copy (size_t pos, const charT *s, size_t n) -{ - if (n) - traits::copy (data () + pos, s, n); -} - -template -inline void basic_string ::Rep:: -move (size_t pos, const charT *s, size_t n) -{ - if (n) - traits::move (data () + pos, s, n); -} - -template -basic_string & -basic_string :: -replace (size_type pos, size_type n1, const charT* s, size_type n2) -{ - const size_type len = length (); - OUTOFRANGE (pos > len); - if (n1 > len - pos) - n1 = len - pos; - LENGTHERROR (len - n1 > max_size () - n2); - size_t newlen = len - n1 + n2; - - if (check_realloc (newlen)) - { - Rep *p = Rep::create (newlen); - p->copy (0, data (), pos); - p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); - p->copy (pos, s, n2); - repup (p); - } - else - { - rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); - rep ()->copy (pos, s, n2); - } - rep ()->len = newlen; - - return *this; -} - -template -inline void basic_string ::Rep:: -set (size_t pos, const charT c, size_t n) -{ - traits::set (data () + pos, c, n); -} - -template -basic_string & basic_string :: -replace (size_type pos, size_type n1, size_type n2, charT c) -{ - const size_t len = length (); - OUTOFRANGE (pos > len); - if (n1 > len - pos) - n1 = len - pos; - LENGTHERROR (len - n1 > max_size () - n2); - size_t newlen = len - n1 + n2; - - if (check_realloc (newlen)) - { - Rep *p = Rep::create (newlen); - p->copy (0, data (), pos); - p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); - p->set (pos, c, n2); - repup (p); - } - else - { - rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); - rep ()->set (pos, c, n2); - } - rep ()->len = newlen; - - return *this; -} - -template -void basic_string :: -resize (size_type n, charT c) -{ - LENGTHERROR (n > max_size ()); - - if (n > length ()) - append (n - length (), c); - else - erase (n); -} - -template -basic_string ::size_type -basic_string :: -copy (charT* s, size_type n, size_type pos) const -{ - OUTOFRANGE (pos > length ()); - - if (n > length () - pos) - n = length () - pos; - - traits::copy (s, data () + pos, n); - return n; -} - -template -basic_string ::size_type -basic_string :: -find (const charT* s, size_type pos, size_type n) const -{ - size_t xpos = pos; - for (; xpos + n <= length (); ++xpos) - if (traits::eq (data () [xpos], *s) - && traits::compare (data () + xpos, s, n) == 0) - return xpos; - return npos; -} - -template -inline basic_string ::size_type -basic_string :: -_find (const charT* ptr, charT c, size_type xpos, size_type len) -{ - for (; xpos < len; ++xpos) - if (traits::eq (ptr [xpos], c)) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -find (charT c, size_type pos) const -{ - return _find (data (), c, pos, length ()); -} - -template -basic_string ::size_type -basic_string :: -rfind (const charT* s, size_type pos, size_type n) const -{ - if (n > length ()) - return npos; - - size_t xpos = length () - n; - if (xpos > pos) - xpos = pos; - - for (++xpos; xpos-- > 0; ) - if (traits::eq (data () [xpos], *s) - && traits::compare (data () + xpos, s, n) == 0) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -rfind (charT c, size_type pos) const -{ - if (1 > length ()) - return npos; - - size_t xpos = length () - 1; - if (xpos > pos) - xpos = pos; - - for (++xpos; xpos-- > 0; ) - if (traits::eq (data () [xpos], c)) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -find_first_of (const charT* s, size_type pos, size_type n) const -{ - size_t xpos = pos; - for (; xpos < length (); ++xpos) - if (_find (s, data () [xpos], 0, n) != npos) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -find_last_of (const charT* s, size_type pos, size_type n) const -{ - if (length() == 0) - return npos; - size_t xpos = length () - 1; - if (xpos > pos) - xpos = pos; - for (++xpos; xpos-- > 0;) - if (_find (s, data () [xpos], 0, n) != npos) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -find_first_not_of (const charT* s, size_type pos, size_type n) const -{ - size_t xpos = pos; - for (; xpos < length (); ++xpos) - if (_find (s, data () [xpos], 0, n) == npos) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -find_first_not_of (charT c, size_type pos) const -{ - size_t xpos = pos; - for (; xpos < length (); ++xpos) - if (traits::ne (data () [xpos], c)) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -find_last_not_of (const charT* s, size_type pos, size_type n) const -{ - if (length() == 0) - return npos; - size_t xpos = length () - 1; - if (xpos > pos) - xpos = pos; - for (++xpos; xpos-- > 0;) - if (_find (s, data () [xpos], 0, n) == npos) - return xpos; - return npos; -} - -template -basic_string ::size_type -basic_string :: -find_last_not_of (charT c, size_type pos) const -{ - if (length() == 0) - return npos; - size_t xpos = length () - 1; - if (xpos > pos) - xpos = pos; - for (++xpos; xpos-- > 0;) - if (traits::ne (data () [xpos], c)) - return xpos; - return npos; -} - -template -int basic_string :: -compare (const basic_string& str, size_type pos, size_type n) const -{ - OUTOFRANGE (pos > length ()); - - size_t rlen = length () - pos; - if (rlen > n) - rlen = n; - if (rlen > str.length ()) - rlen = str.length (); - int r = traits::compare (data () + pos, str.data (), rlen); - if (r != 0) - return r; - if (rlen == n) - return 0; - return (length () - pos) - str.length (); -} - -template -int basic_string :: -compare (const charT* s, size_type pos, size_type n) const -{ - OUTOFRANGE (pos > length ()); - - size_t rlen = length () - pos; - if (rlen > n) - rlen = n; - int r = traits::compare (data () + pos, s, rlen); - if (r != 0) - return r; - if (rlen == n) - return 0; - return (length () - pos) - n; -} - -#include - -template -istream & -operator>> (istream &is, basic_string &s) -{ - int w = is.width (0); - if (is.ipfx0 ()) - { - register streambuf *sb = is.rdbuf (); - s.resize (0); - while (1) - { - int ch = sb->sbumpc (); - if (ch == EOF) - { - is.setstate (ios::eofbit); - break; - } - else if (traits::is_del (ch)) - { - sb->sungetc (); - break; - } - s += static_cast (ch); - if (--w == 1) - break; - } - } - - is.isfx (); - if (s.length () == 0) - is.setstate (ios::failbit); - - return is; -} - -template -ostream & -operator<< (ostream &o, const basic_string & s) -{ - return o.write (s.data (), s.length ()); -} - -template -istream& -getline (istream &is, basic_string & s, charT delim) -{ - if (is.ipfx1 ()) - { - _IO_size_t count = 0; - streambuf *sb = is.rdbuf (); - s.resize (0); - - while (1) - { - int ch = sb->sbumpc (); - if (ch == EOF) - { - is.setstate (count == 0 - ? (ios::failbit|ios::eofbit) - : ios::eofbit); - break; - } - - ++count; - - if (ch == delim) - break; - - s += static_cast (ch); - - if (s.length () == s.npos - 1) - { - is.setstate (ios::failbit); - break; - } - } - } - - // We need to be friends with istream to do this. - // is._gcount = count; - is.isfx (); - - return is; -} - -template -basic_string ::Rep -basic_string::nilRep = { 0, 0, 1, false }; - -template -const basic_string ::size_type -basic_string ::npos; - -} // extern "C++" diff --git a/libstdc++/std/bastring.h b/libstdc++/std/bastring.h deleted file mode 100644 index 5551ec1fe47..00000000000 --- a/libstdc++/std/bastring.h +++ /dev/null @@ -1,671 +0,0 @@ -// Main templates for the -*- C++ -*- string classes. -// Copyright (C) 1994, 1995, 1999 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification by Takanori Adachi -// in ANSI X3J16/94-0013R2. - -#ifndef __BASTRING__ -#define __BASTRING__ - -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include - -// NOTE : This does NOT conform to the draft standard and is likely to change -#include - -extern "C++" { -class istream; class ostream; - -#include - -#ifdef __STL_USE_EXCEPTIONS - -extern void __out_of_range (const char *); -extern void __length_error (const char *); - -#define OUTOFRANGE(cond) \ - do { if (cond) __out_of_range (#cond); } while (0) -#define LENGTHERROR(cond) \ - do { if (cond) __length_error (#cond); } while (0) - -#else - -#include -#define OUTOFRANGE(cond) assert (!(cond)) -#define LENGTHERROR(cond) assert (!(cond)) - -#endif - -template , - class Allocator = alloc > -class basic_string -{ -private: - struct Rep { - size_t len, res, ref; - bool selfish; - - charT* data () { return reinterpret_cast(this + 1); } - charT& operator[] (size_t s) { return data () [s]; } -#if defined __i486__ || defined __i586__ || defined __i686__ - charT* grab () { if (selfish) return clone (); - asm ("lock; addl %0, (%1)" - : : "a" (1), "d" (&ref) - : "memory"); - return data (); } - - void release () - { - size_t __val; - // This opcode exists as a .byte instead of as a mnemonic for the - // benefit of SCO OpenServer 5. The system assembler (which is - // essentially required on this target) can't assemble xaddl in - //COFF mode. - asm (".byte 0xf0, 0x0f, 0xc1, 0x02" // lock; xaddl %eax, (%edx) - : "=a" (__val) - : "0" (-1), "m" (ref), "d" (&ref) - : "memory"); - - if (__val == 1) - delete this; - } -#elif defined __sparc_v9__ - charT* grab () { if (selfish) return clone (); ++ref; return data (); } - void release () - { - size_t __newval, __oldval = ref; - do - { - __newval = __oldval - 1; - __asm__ ( -#ifdef __arch64__ - "casx [%4], %2, %0" -#else - "cas [%4], %2, %0" -#endif - : "=r" (__oldval), "=m" (ref) - : "r" (__oldval), "m" (ref), "r"(&(ref)), "0" (__newval)); - } - while (__newval != __oldval); - - if (__oldval == 0) - delete this; - } -#else - charT* grab () { if (selfish) return clone (); ++ref; return data (); } - void release () { if (--ref == 0) delete this; } -#endif - - inline static void * operator new (size_t, size_t); - inline static void operator delete (void *); - inline static Rep* create (size_t); - charT* clone (); - - inline void copy (size_t, const charT *, size_t); - inline void move (size_t, const charT *, size_t); - inline void set (size_t, const charT, size_t); - - inline static bool excess_slop (size_t, size_t); - inline static size_t frob_size (size_t); - - private: - Rep &operator= (const Rep &); - }; - -public: -// types: - typedef traits traits_type; - typedef typename traits::char_type value_type; - typedef Allocator allocator_type; - - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef charT& reference; - typedef const charT& const_reference; - typedef charT* pointer; - typedef const charT* const_pointer; - typedef pointer iterator; - typedef const_pointer const_iterator; - typedef ::reverse_iterator reverse_iterator; - typedef ::reverse_iterator const_reverse_iterator; - static const size_type npos = static_cast(-1); - -private: - Rep *rep () const { return reinterpret_cast(dat) - 1; } - void repup (Rep *p) { rep ()->release (); dat = p->data (); } - -public: - const charT* data () const - { return rep ()->data(); } - size_type length () const - { return rep ()->len; } - size_type size () const - { return rep ()->len; } - size_type capacity () const - { return rep ()->res; } - size_type max_size () const - { return (npos - 1)/sizeof (charT); } // XXX - bool empty () const - { return size () == 0; } - -// _lib.string.cons_ construct/copy/destroy: - basic_string& operator= (const basic_string& str) - { - if (&str != this) { rep ()->release (); dat = str.rep ()->grab (); } - return *this; - } - - explicit basic_string (): dat (nilRep.grab ()) { } - basic_string (const basic_string& str): dat (str.rep ()->grab ()) { } - basic_string (const basic_string& str, size_type pos, size_type n = npos) - : dat (nilRep.grab ()) { assign (str, pos, n); } - basic_string (const charT* s, size_type n) - : dat (nilRep.grab ()) { assign (s, n); } - basic_string (const charT* s) - : dat (nilRep.grab ()) { assign (s); } - basic_string (size_type n, charT c) - : dat (nilRep.grab ()) { assign (n, c); } -#ifdef __STL_MEMBER_TEMPLATES - template - basic_string(InputIterator __begin, InputIterator __end) -#else - basic_string(const_iterator __begin, const_iterator __end) -#endif - : dat (nilRep.grab ()) { assign (__begin, __end); } - - ~basic_string () - { rep ()->release (); } - - void swap (basic_string &s) { charT *d = dat; dat = s.dat; s.dat = d; } - - basic_string& append (const basic_string& str, size_type pos = 0, - size_type n = npos) - { return replace (length (), 0, str, pos, n); } - basic_string& append (const charT* s, size_type n) - { return replace (length (), 0, s, n); } - basic_string& append (const charT* s) - { return append (s, traits::length (s)); } - basic_string& append (size_type n, charT c) - { return replace (length (), 0, n, c); } -#ifdef __STL_MEMBER_TEMPLATES - template - basic_string& append(InputIterator first, InputIterator last) -#else - basic_string& append(const_iterator first, const_iterator last) -#endif - { return replace (iend (), iend (), first, last); } - - void push_back(charT __c) - { append(1, __c); } - - basic_string& assign (const basic_string& str, size_type pos = 0, - size_type n = npos) - { return replace (0, npos, str, pos, n); } - basic_string& assign (const charT* s, size_type n) - { return replace (0, npos, s, n); } - basic_string& assign (const charT* s) - { return assign (s, traits::length (s)); } - basic_string& assign (size_type n, charT c) - { return replace (0, npos, n, c); } -#ifdef __STL_MEMBER_TEMPLATES - template - basic_string& assign(InputIterator first, InputIterator last) -#else - basic_string& assign(const_iterator first, const_iterator last) -#endif - { return replace (ibegin (), iend (), first, last); } - - basic_string& operator= (const charT* s) - { return assign (s); } - basic_string& operator= (charT c) - { return assign (1, c); } - - basic_string& operator+= (const basic_string& rhs) - { return append (rhs); } - basic_string& operator+= (const charT* s) - { return append (s); } - basic_string& operator+= (charT c) - { return append (1, c); } - - basic_string& insert (size_type pos1, const basic_string& str, - size_type pos2 = 0, size_type n = npos) - { return replace (pos1, 0, str, pos2, n); } - basic_string& insert (size_type pos, const charT* s, size_type n) - { return replace (pos, 0, s, n); } - basic_string& insert (size_type pos, const charT* s) - { return insert (pos, s, traits::length (s)); } - basic_string& insert (size_type pos, size_type n, charT c) - { return replace (pos, 0, n, c); } - iterator insert(iterator p, charT c) - { size_type __o = p - ibegin (); - insert (p - ibegin (), 1, c); selfish (); - return ibegin () + __o; } - iterator insert(iterator p, size_type n, charT c) - { size_type __o = p - ibegin (); - insert (p - ibegin (), n, c); selfish (); - return ibegin () + __o; } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(iterator p, InputIterator first, InputIterator last) -#else - void insert(iterator p, const_iterator first, const_iterator last) -#endif - { replace (p, p, first, last); } - - basic_string& erase (size_type pos = 0, size_type n = npos) - { return replace (pos, n, (size_type)0, (charT)0); } - iterator erase(iterator p) - { size_type __o = p - begin(); - replace (__o, 1, (size_type)0, (charT)0); selfish (); - return ibegin() + __o; } - iterator erase(iterator f, iterator l) - { size_type __o = f - ibegin(); - replace (__o, l-f, (size_type)0, (charT)0);selfish (); - return ibegin() + __o; } - - basic_string& replace (size_type pos1, size_type n1, const basic_string& str, - size_type pos2 = 0, size_type n2 = npos); - basic_string& replace (size_type pos, size_type n1, const charT* s, - size_type n2); - basic_string& replace (size_type pos, size_type n1, const charT* s) - { return replace (pos, n1, s, traits::length (s)); } - basic_string& replace (size_type pos, size_type n1, size_type n2, charT c); - basic_string& replace (size_type pos, size_type n, charT c) - { return replace (pos, n, 1, c); } - basic_string& replace (iterator i1, iterator i2, const basic_string& str) - { return replace (i1 - ibegin (), i2 - i1, str); } - basic_string& replace (iterator i1, iterator i2, const charT* s, size_type n) - { return replace (i1 - ibegin (), i2 - i1, s, n); } - basic_string& replace (iterator i1, iterator i2, const charT* s) - { return replace (i1 - ibegin (), i2 - i1, s); } - basic_string& replace (iterator i1, iterator i2, size_type n, charT c) - { return replace (i1 - ibegin (), i2 - i1, n, c); } -#ifdef __STL_MEMBER_TEMPLATES - template - basic_string& replace(iterator i1, iterator i2, - InputIterator j1, InputIterator j2); -#else - basic_string& replace(iterator i1, iterator i2, - const_iterator j1, const_iterator j2); -#endif - -private: - static charT eos () { return traits::eos (); } - void unique () { if (rep ()->ref > 1) alloc (length (), true); } - void selfish () { unique (); rep ()->selfish = true; } - -public: - charT operator[] (size_type pos) const - { - if (pos == length ()) - return eos (); - return data ()[pos]; - } - - reference operator[] (size_type pos) - { selfish (); return (*rep ())[pos]; } - - reference at (size_type pos) - { - OUTOFRANGE (pos >= length ()); - return (*this)[pos]; - } - const_reference at (size_type pos) const - { - OUTOFRANGE (pos >= length ()); - return data ()[pos]; - } - -private: - void terminate () const - { traits::assign ((*rep ())[length ()], eos ()); } - -public: - const charT* c_str () const - { if (length () == 0) return ""; terminate (); return data (); } - void resize (size_type n, charT c); - void resize (size_type n) - { resize (n, eos ()); } - void reserve (size_type) { } - - void clear() { erase(begin(), end()); } - - size_type copy (charT* s, size_type n, size_type pos = 0) const; - - size_type find (const basic_string& str, size_type pos = 0) const - { return find (str.data(), pos, str.length()); } - size_type find (const charT* s, size_type pos, size_type n) const; - size_type find (const charT* s, size_type pos = 0) const - { return find (s, pos, traits::length (s)); } - size_type find (charT c, size_type pos = 0) const; - - size_type rfind (const basic_string& str, size_type pos = npos) const - { return rfind (str.data(), pos, str.length()); } - size_type rfind (const charT* s, size_type pos, size_type n) const; - size_type rfind (const charT* s, size_type pos = npos) const - { return rfind (s, pos, traits::length (s)); } - size_type rfind (charT c, size_type pos = npos) const; - - size_type find_first_of (const basic_string& str, size_type pos = 0) const - { return find_first_of (str.data(), pos, str.length()); } - size_type find_first_of (const charT* s, size_type pos, size_type n) const; - size_type find_first_of (const charT* s, size_type pos = 0) const - { return find_first_of (s, pos, traits::length (s)); } - size_type find_first_of (charT c, size_type pos = 0) const - { return find (c, pos); } - - size_type find_last_of (const basic_string& str, size_type pos = npos) const - { return find_last_of (str.data(), pos, str.length()); } - size_type find_last_of (const charT* s, size_type pos, size_type n) const; - size_type find_last_of (const charT* s, size_type pos = npos) const - { return find_last_of (s, pos, traits::length (s)); } - size_type find_last_of (charT c, size_type pos = npos) const - { return rfind (c, pos); } - - size_type find_first_not_of (const basic_string& str, size_type pos = 0) const - { return find_first_not_of (str.data(), pos, str.length()); } - size_type find_first_not_of (const charT* s, size_type pos, size_type n) const; - size_type find_first_not_of (const charT* s, size_type pos = 0) const - { return find_first_not_of (s, pos, traits::length (s)); } - size_type find_first_not_of (charT c, size_type pos = 0) const; - - size_type find_last_not_of (const basic_string& str, size_type pos = npos) const - { return find_last_not_of (str.data(), pos, str.length()); } - size_type find_last_not_of (const charT* s, size_type pos, size_type n) const; - size_type find_last_not_of (const charT* s, size_type pos = npos) const - { return find_last_not_of (s, pos, traits::length (s)); } - size_type find_last_not_of (charT c, size_type pos = npos) const; - - basic_string substr (size_type pos = 0, size_type n = npos) const - { return basic_string (*this, pos, n); } - - int compare (const basic_string& str, size_type pos = 0, size_type n = npos) const; - // There is no 'strncmp' equivalent for charT pointers. - int compare (const charT* s, size_type pos, size_type n) const; - int compare (const charT* s, size_type pos = 0) const - { return compare (s, pos, traits::length (s)); } - - iterator begin () { selfish (); return &(*this)[0]; } - iterator end () { selfish (); return &(*this)[length ()]; } - -private: - iterator ibegin () const { return &(*rep ())[0]; } - iterator iend () const { return &(*rep ())[length ()]; } - -public: - const_iterator begin () const { return ibegin (); } - const_iterator end () const { return iend (); } - - 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 ()); } - -private: - void alloc (size_type size, bool save); - static size_type _find (const charT* ptr, charT c, size_type xpos, size_type len); - inline bool check_realloc (size_type s) const; - - static Rep nilRep; - charT *dat; -}; - -#ifdef __STL_MEMBER_TEMPLATES -template template -basic_string & basic_string :: -replace (iterator i1, iterator i2, InputIterator j1, InputIterator j2) -#else -template -basic_string & basic_string :: -replace (iterator i1, iterator i2, const_iterator j1, const_iterator j2) -#endif -{ - const size_type len = length (); - size_type pos = i1 - ibegin (); - size_type n1 = i2 - i1; - size_type n2 = j2 - j1; - - OUTOFRANGE (pos > len); - if (n1 > len - pos) - n1 = len - pos; - LENGTHERROR (len - n1 > max_size () - n2); - size_t newlen = len - n1 + n2; - - if (check_realloc (newlen)) - { - Rep *p = Rep::create (newlen); - p->copy (0, data (), pos); - p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); - for (; j1 != j2; ++j1, ++pos) - traits::assign ((*p)[pos], *j1); - repup (p); - } - else - { - rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); - for (; j1 != j2; ++j1, ++pos) - traits::assign ((*rep ())[pos], *j1); - } - rep ()->len = newlen; - - return *this; -} - -template -inline basic_string -operator+ (const basic_string & lhs, - const basic_string & rhs) -{ - basic_string str (lhs); - str.append (rhs); - return str; -} - -template -inline basic_string -operator+ (const charT* lhs, const basic_string & rhs) -{ - basic_string str (lhs); - str.append (rhs); - return str; -} - -template -inline basic_string -operator+ (charT lhs, const basic_string & rhs) -{ - basic_string str (1, lhs); - str.append (rhs); - return str; -} - -template -inline basic_string -operator+ (const basic_string & lhs, const charT* rhs) -{ - basic_string str (lhs); - str.append (rhs); - return str; -} - -template -inline basic_string -operator+ (const basic_string & lhs, charT rhs) -{ - basic_string str (lhs); - str.append (1, rhs); - return str; -} - -template -inline bool -operator== (const basic_string & lhs, - const basic_string & rhs) -{ - return (lhs.compare (rhs) == 0); -} - -template -inline bool -operator== (const charT* lhs, const basic_string & rhs) -{ - return (rhs.compare (lhs) == 0); -} - -template -inline bool -operator== (const basic_string & lhs, const charT* rhs) -{ - return (lhs.compare (rhs) == 0); -} - -template -inline bool -operator!= (const charT* lhs, const basic_string & rhs) -{ - return (rhs.compare (lhs) != 0); -} - -template -inline bool -operator!= (const basic_string & lhs, const charT* rhs) -{ - return (lhs.compare (rhs) != 0); -} - -template -inline bool -operator< (const basic_string & lhs, - const basic_string & rhs) -{ - return (lhs.compare (rhs) < 0); -} - -template -inline bool -operator< (const charT* lhs, const basic_string & rhs) -{ - return (rhs.compare (lhs) > 0); -} - -template -inline bool -operator< (const basic_string & lhs, const charT* rhs) -{ - return (lhs.compare (rhs) < 0); -} - -template -inline bool -operator> (const charT* lhs, const basic_string & rhs) -{ - return (rhs.compare (lhs) < 0); -} - -template -inline bool -operator> (const basic_string & lhs, const charT* rhs) -{ - return (lhs.compare (rhs) > 0); -} - -template -inline bool -operator<= (const charT* lhs, const basic_string & rhs) -{ - return (rhs.compare (lhs) >= 0); -} - -template -inline bool -operator<= (const basic_string & lhs, const charT* rhs) -{ - return (lhs.compare (rhs) <= 0); -} - -template -inline bool -operator>= (const charT* lhs, const basic_string & rhs) -{ - return (rhs.compare (lhs) <= 0); -} - -template -inline bool -operator>= (const basic_string & lhs, const charT* rhs) -{ - return (lhs.compare (rhs) >= 0); -} - -template -inline bool -operator!= (const basic_string & lhs, - const basic_string & rhs) -{ - return (lhs.compare (rhs) != 0); -} - -template -inline bool -operator> (const basic_string & lhs, - const basic_string & rhs) -{ - return (lhs.compare (rhs) > 0); -} - -template -inline bool -operator<= (const basic_string & lhs, - const basic_string & rhs) -{ - return (lhs.compare (rhs) <= 0); -} - -template -inline bool -operator>= (const basic_string & lhs, - const basic_string & rhs) -{ - return (lhs.compare (rhs) >= 0); -} - -class istream; class ostream; -template istream& -operator>> (istream&, basic_string &); -template ostream& -operator<< (ostream&, const basic_string &); -template istream& -getline (istream&, basic_string &, charT delim = '\n'); - -} // extern "C++" - -#include - -#endif diff --git a/libstdc++/std/complext.cc b/libstdc++/std/complext.cc deleted file mode 100644 index 60227f21329..00000000000 --- a/libstdc++/std/complext.cc +++ /dev/null @@ -1,273 +0,0 @@ -// Member templates for the -*- C++ -*- complex number classes. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification in the 27 May 1994 -// C++ working paper, ANSI document X3J16/94-0098. - -#include - -extern "C++" { -template complex -cos (const complex& x) -{ - return complex (cos (real (x)) * cosh (imag (x)), - - sin (real (x)) * sinh (imag (x))); -} - -template complex -cosh (const complex& x) -{ - return complex (cosh (real (x)) * cos (imag (x)), - sinh (real (x)) * sin (imag (x))); -} - -template complex -exp (const complex& x) -{ - return polar (FLOAT (exp (real (x))), imag (x)); -} - -template complex -log (const complex& x) -{ - return complex (log (abs (x)), arg (x)); -} - -template complex -pow (const complex& x, const complex& y) -{ - FLOAT logr = log (abs (x)); - FLOAT t = arg (x); - - return polar (FLOAT (exp (logr * real (y) - imag (y) * t)), - FLOAT (imag (y) * logr + real (y) * t)); -} - -template complex -pow (const complex& x, FLOAT y) -{ - return exp (FLOAT (y) * log (x)); -} - -template complex -pow (FLOAT x, const complex& y) -{ - return exp (y * FLOAT (log (x))); -} - -template complex -sin (const complex& x) -{ - return complex (sin (real (x)) * cosh (imag (x)), - cos (real (x)) * sinh (imag (x))); -} - -template complex -sinh (const complex& x) -{ - return complex (sinh (real (x)) * cos (imag (x)), - cosh (real (x)) * sin (imag (x))); -} - -#include - -template istream& -operator >> (istream& is, complex& x) -{ - FLOAT re, im = 0; - char ch = 0; - - if (is.ipfx0 ()) - { - if (is.peek () == '(') - is >> ch; - is >> re; - if (ch == '(') - { - is >> ch; - if (ch == ',') - is >> im >> ch; - } - } - is.isfx (); - - if (ch != 0 && ch != ')') - is.setstate (ios::failbit); - else if (is.good ()) - x = complex (re, im); - - return is; -} - -template ostream& -operator << (ostream& os, const complex& x) -{ - return os << '(' << real (x) << ',' << imag (x) << ')'; -} - -// The code below is adapted from f2c's libF77, and is subject to this -// copyright: - -/**************************************************************** -Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories and Bellcore. - -Permission to use, copy, modify, and distribute this software -and its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the names of AT&T Bell Laboratories or -Bellcore or any of their entities not be used in advertising or -publicity pertaining to distribution of the software without -specific, written prior permission. - -AT&T and Bellcore disclaim all warranties with regard to this -software, including all implied warranties of merchantability -and fitness. In no event shall AT&T or Bellcore be liable for -any special, indirect or consequential damages or any damages -whatsoever resulting from loss of use, data or profits, whether -in an action of contract, negligence or other tortious action, -arising out of or in connection with the use or performance of -this software. -****************************************************************/ - -template complex& -__doadv (complex* ths, const complex& y) -{ - FLOAT ar = abs (y.re); - FLOAT ai = abs (y.im); - FLOAT nr, ni; - FLOAT t, d; - if (ar <= ai) - { - t = y.re / y.im; - d = y.im * (1 + t*t); - nr = (ths->re * t + ths->im) / d; - ni = (ths->im * t - ths->re) / d; - } - else - { - t = y.im / y.re; - d = y.re * (1 + t*t); - nr = (ths->re + ths->im * t) / d; - ni = (ths->im - ths->re * t) / d; - } - ths->re = nr; - ths->im = ni; - return *ths; -} - -template complex -operator / (const complex& x, const complex& y) -{ - FLOAT ar = abs (real (y)); - FLOAT ai = abs (imag (y)); - FLOAT nr, ni; - FLOAT t, d; - if (ar <= ai) - { - t = real (y) / imag (y); - d = imag (y) * (1 + t*t); - nr = (real (x) * t + imag (x)) / d; - ni = (imag (x) * t - real (x)) / d; - } - else - { - t = imag (y) / real (y); - d = real (y) * (1 + t*t); - nr = (real (x) + imag (x) * t) / d; - ni = (imag (x) - real (x) * t) / d; - } - return complex (nr, ni); -} - -template complex -operator / (FLOAT x, const complex& y) -{ - FLOAT ar = abs (real (y)); - FLOAT ai = abs (imag (y)); - FLOAT nr, ni; - FLOAT t, d; - if (ar <= ai) - { - t = real (y) / imag (y); - d = imag (y) * (1 + t*t); - nr = x * t / d; - ni = -x / d; - } - else - { - t = imag (y) / real (y); - d = real (y) * (1 + t*t); - nr = x / d; - ni = -x * t / d; - } - return complex (nr, ni); -} - -template complex -pow (const complex& xin, int y) -{ - if (y == 0) - return complex (1.0); - complex r (1.0); - complex x (xin); - if (y < 0) - { - y = -y; - x = FLOAT(1)/x; - } - for (;;) - { - if (y & 1) - r *= x; - if (y >>= 1) - x *= x; - else - return r; - } -} - -template complex -sqrt (const complex& x) -{ - FLOAT r = abs (x); - FLOAT nr, ni; - if (r == 0.0) - nr = ni = r; - else if (real (x) > 0) - { - nr = sqrt (0.5 * (r + real (x))); - ni = imag (x) / nr / 2; - } - else - { - ni = sqrt (0.5 * (r - real (x))); - if (imag (x) < 0) - ni = - ni; - nr = imag (x) / ni / 2; - } - return complex (nr, ni); -} -} // extern "C++" diff --git a/libstdc++/std/complext.h b/libstdc++/std/complext.h deleted file mode 100644 index 6c55037bf94..00000000000 --- a/libstdc++/std/complext.h +++ /dev/null @@ -1,400 +0,0 @@ -// The template and inlines for the -*- C++ -*- complex number classes. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files compiled -// with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification in the 27 May 1994 -// C++ working paper, ANSI document X3J16/94-0098. - -#ifndef __COMPLEXT__ -#define __COMPLEXT__ - -#ifdef __GNUG__ -#pragma interface -#endif - -#include - -#if ! defined (__GNUG__) && ! defined (__attribute__) -#define __attribute__(foo) /* Ignore. */ -#endif - -class istream; -class ostream; - -extern "C++" { -template class complex; -template complex<_FLT>& - __doapl (complex<_FLT>* ths, const complex<_FLT>& r); -template complex<_FLT>& - __doami (complex<_FLT>* ths, const complex<_FLT>& r); -template complex<_FLT>& - __doaml (complex<_FLT>* ths, const complex<_FLT>& r); -template complex<_FLT>& - __doadv (complex<_FLT>* ths, const complex<_FLT>& r); - -template -class complex -{ -public: - complex (_FLT r = 0, _FLT i = 0): re (r), im (i) { } - complex& operator += (const complex&); - complex& operator -= (const complex&); - complex& operator *= (const complex&); - complex& operator /= (const complex&); - _FLT real () const { return re; } - _FLT imag () const { return im; } -private: - _FLT re, im; - - friend complex& __doapl<> (complex *, const complex&); - friend complex& __doami<> (complex *, const complex&); - friend complex& __doaml<> (complex *, const complex&); - friend complex& __doadv<> (complex *, const complex&); -}; - -// Declare specializations. -class complex; -class complex; -class complex; - -template -inline complex<_FLT>& -__doapl (complex<_FLT>* ths, const complex<_FLT>& r) -{ - ths->re += r.re; - ths->im += r.im; - return *ths; -} -template -inline complex<_FLT>& -complex<_FLT>::operator += (const complex<_FLT>& r) -{ - return __doapl (this, r); -} - -template -inline complex<_FLT>& -__doami (complex<_FLT>* ths, const complex<_FLT>& r) -{ - ths->re -= r.re; - ths->im -= r.im; - return *ths; -} -template -inline complex<_FLT>& -complex<_FLT>::operator -= (const complex<_FLT>& r) -{ - return __doami (this, r); -} - -template -inline complex<_FLT>& -__doaml (complex<_FLT>* ths, const complex<_FLT>& r) -{ - _FLT f = ths->re * r.re - ths->im * r.im; - ths->im = ths->re * r.im + ths->im * r.re; - ths->re = f; - return *ths; -} -template -inline complex<_FLT>& -complex<_FLT>::operator *= (const complex<_FLT>& r) -{ - return __doaml (this, r); -} - -template -inline complex<_FLT>& -complex<_FLT>::operator /= (const complex<_FLT>& r) -{ - return __doadv (this, r); -} - -template inline _FLT -imag (const complex<_FLT>& x) __attribute__ ((const)); - -template inline _FLT -imag (const complex<_FLT>& x) -{ - return x.imag (); -} - -template inline _FLT -real (const complex<_FLT>& x) __attribute__ ((const)); - -template inline _FLT -real (const complex<_FLT>& x) -{ - return x.real (); -} - -template inline complex<_FLT> -operator + (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline complex<_FLT> -operator + (const complex<_FLT>& x, const complex<_FLT>& y) -{ - return complex<_FLT> (real (x) + real (y), imag (x) + imag (y)); -} - -template inline complex<_FLT> -operator + (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); - -template inline complex<_FLT> -operator + (const complex<_FLT>& x, _FLT y) -{ - return complex<_FLT> (real (x) + y, imag (x)); -} - -template inline complex<_FLT> -operator + (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline complex<_FLT> -operator + (_FLT x, const complex<_FLT>& y) -{ - return complex<_FLT> (x + real (y), imag (y)); -} - -template inline complex<_FLT> -operator - (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline complex<_FLT> -operator - (const complex<_FLT>& x, const complex<_FLT>& y) -{ - return complex<_FLT> (real (x) - real (y), imag (x) - imag (y)); -} - -template inline complex<_FLT> -operator - (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); - -template inline complex<_FLT> -operator - (const complex<_FLT>& x, _FLT y) -{ - return complex<_FLT> (real (x) - y, imag (x)); -} - -template inline complex<_FLT> -operator - (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline complex<_FLT> -operator - (_FLT x, const complex<_FLT>& y) -{ - return complex<_FLT> (x - real (y), - imag (y)); -} - -template inline complex<_FLT> -operator * (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline complex<_FLT> -operator * (const complex<_FLT>& x, const complex<_FLT>& y) -{ - return complex<_FLT> (real (x) * real (y) - imag (x) * imag (y), - real (x) * imag (y) + imag (x) * real (y)); -} - -template inline complex<_FLT> -operator * (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); - -template inline complex<_FLT> -operator * (const complex<_FLT>& x, _FLT y) -{ - return complex<_FLT> (real (x) * y, imag (x) * y); -} - -template inline complex<_FLT> -operator * (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline complex<_FLT> -operator * (_FLT x, const complex<_FLT>& y) -{ - return complex<_FLT> (x * real (y), x * imag (y)); -} - -template complex<_FLT> -operator / (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); - -template complex<_FLT> -operator / (const complex<_FLT>& x, _FLT y) -{ - return complex<_FLT> (real (x) / y, imag (x) / y); -} - -template inline complex<_FLT> -operator + (const complex<_FLT>& x) __attribute__ ((const)); - -template inline complex<_FLT> -operator + (const complex<_FLT>& x) -{ - return x; -} - -template inline complex<_FLT> -operator - (const complex<_FLT>& x) __attribute__ ((const)); - -template inline complex<_FLT> -operator - (const complex<_FLT>& x) -{ - return complex<_FLT> (-real (x), -imag (x)); -} - -template inline bool -operator == (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline bool -operator == (const complex<_FLT>& x, const complex<_FLT>& y) -{ - return real (x) == real (y) && imag (x) == imag (y); -} - -template inline bool -operator == (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); - -template inline bool -operator == (const complex<_FLT>& x, _FLT y) -{ - return real (x) == y && imag (x) == 0; -} - -template inline bool -operator == (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline bool -operator == (_FLT x, const complex<_FLT>& y) -{ - return x == real (y) && imag (y) == 0; -} - -template inline bool -operator != (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline bool -operator != (const complex<_FLT>& x, const complex<_FLT>& y) -{ - return real (x) != real (y) || imag (x) != imag (y); -} - -template inline bool -operator != (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); - -template inline bool -operator != (const complex<_FLT>& x, _FLT y) -{ - return real (x) != y || imag (x) != 0; -} - -template inline bool -operator != (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); - -template inline bool -operator != (_FLT x, const complex<_FLT>& y) -{ - return x != real (y) || imag (y) != 0; -} - -// Some targets don't provide a prototype for hypot when -ansi. -extern "C" double hypot (double, double) __attribute__ ((const)); - -template inline _FLT -abs (const complex<_FLT>& x) __attribute__ ((const)); - -template inline _FLT -abs (const complex<_FLT>& x) -{ - return hypot (real (x), imag (x)); -} - -template inline _FLT -arg (const complex<_FLT>& x) __attribute__ ((const)); - -template inline _FLT -arg (const complex<_FLT>& x) -{ - return atan2 (imag (x), real (x)); -} - -template inline complex<_FLT> -polar (_FLT r, _FLT t) __attribute__ ((const)); - -template inline complex<_FLT> -polar (_FLT r, _FLT t) -{ - return complex<_FLT> (r * cos (t), r * sin (t)); -} - -template inline complex<_FLT> -conj (const complex<_FLT>& x) __attribute__ ((const)); - -template inline complex<_FLT> -conj (const complex<_FLT>& x) -{ - return complex<_FLT> (real (x), -imag (x)); -} - -template inline _FLT -norm (const complex<_FLT>& x) __attribute__ ((const)); - -template inline _FLT -norm (const complex<_FLT>& x) -{ - return real (x) * real (x) + imag (x) * imag (x); -} - -// Declarations of templates in complext.ccI - -template complex<_FLT> - operator / (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - operator / (_FLT, const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - cos (const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - cosh (const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - exp (const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - log (const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - pow (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - pow (const complex<_FLT>&, _FLT) __attribute__ ((const)); -template complex<_FLT> - pow (const complex<_FLT>&, int) __attribute__ ((const)); -template complex<_FLT> - pow (_FLT, const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - sin (const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - sinh (const complex<_FLT>&) __attribute__ ((const)); -template complex<_FLT> - sqrt (const complex<_FLT>&) __attribute__ ((const)); - -template istream& operator >> (istream&, complex<_FLT>&); -template ostream& operator << (ostream&, const complex<_FLT>&); -} // extern "C++" - -// Specializations and such - -#include -#include -#include - -#endif diff --git a/libstdc++/std/cpp_type_traits.h b/libstdc++/std/cpp_type_traits.h deleted file mode 100644 index 1a065b4efa8..00000000000 --- a/libstdc++/std/cpp_type_traits.h +++ /dev/null @@ -1,299 +0,0 @@ -// The -*- C++ -*- type traits classes for internal use in libstdc++ - -// Copyright (C) 2000 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. - -// Written by Gabriel Dos Reis - -#ifndef _CPP_BITS_CPP_TYPE_TRAITS_H -#define _CPP_BITS_CPP_TYPE_TRAITS_H 1 - -// -// This file provides some compile-time information about various types. -// These informations were designed, on purpose, to be constant-expressions -// and not types as found in . In particular, they -// can be used in control structures and the optimizer, hopefully, will do -// the obvious thing. -// -// Why integral expressions, and not functions nor types? -// Firstly, these compile-time information entities are used as -// template-arguments so function return values won't work. We -// need compile-time entities. We're left with types and iintegral constant -// expressions. -// Secondly, from the point of view of ease of use, type-based compile-time -// information is -not- *that* convenient. One has to write lots of -// overloaded functions and to hope that the compiler will select the right -// one. As a net effect, the overall structure isn't very clear at first -// glance. -// Thirdly, partial ordering and overload resolution (of template functions) -// is very costly in terms of compiler-resource. It is a Good Thing to -// keep these resource consumption as least as possible. Please, direct -// any comment to . -// -// -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06. -// - -extern "C++" { - template - struct __is_void - { - enum - { - _M_type = 0 - }; - }; - - template<> - struct __is_void - { - enum - { - _M_type = 1 - }; - }; - - // - // Integer types - // - template - struct __is_integer - { - enum - { - _M_type = 0 - }; - }; - - // Thirteen specializations (yes there are eleven standard integer - // types; 'long long' and 'unsigned long long' are supported as - // extensions) - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - -# if 0 - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; -# endif - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - -# if 0 - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_integer - { - enum - { - _M_type = 1 - }; - }; -# endif - - // - // Floating point types - // - template - struct __is_floating - { - enum - { - _M_type = 0 - }; - }; - - // three specializations (float, double and 'long double') - template<> - struct __is_floating - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_floating - { - enum - { - _M_type = 1 - }; - }; - - template<> - struct __is_floating - { - enum - { - _M_type = 1 - }; - }; - - // - // An arithmetic type is an integer type or a floating point type - // - template - struct __is_arithmetic - { - enum - { - _M_type = __is_integer<_Tp>::_M_type || __is_floating<_Tp>::_M_type - }; - }; - - // - // A fundamental type is `void' or and arithmetic type - // - template - struct __is_fundamental - { - enum - { - _M_type = __is_void<_Tp>::_M_type || __is_arithmetic<_Tp>::_M_type - }; - }; - - // - // For the immediate use, the following is a good approximation - // - template - struct __is_pod - { - enum - { - _M_type = __is_fundamental<_Tp>::_M_type - }; - }; -} // extern "C++" - -#endif //_CPP_BITS_CPP_TYPE_TRAITS_H - - - - - - - diff --git a/libstdc++/std/dcomplex.h b/libstdc++/std/dcomplex.h deleted file mode 100644 index 5812d9fa7df..00000000000 --- a/libstdc++/std/dcomplex.h +++ /dev/null @@ -1,91 +0,0 @@ -// The -*- C++ -*- double_complex class. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification in the 27 May 1994 -// C++ working paper, ANSI document X3J16/94-0098. - -#ifndef __DCOMPLEX__ -#define __DCOMPLEX__ - -#ifdef __GNUG__ -#pragma interface "dcomplex" -#endif - -extern "C++" { -class complex -{ -public: - complex (double r = 0, double i = 0): re (r), im (i) { } - complex (const complex& r): re (r.real ()), im (r.imag ()) { } - explicit complex (const complex& r); - - complex& operator+= (const complex& r) { return __doapl (this, r); } - complex& operator-= (const complex& r) { return __doami (this, r); } - complex& operator*= (const complex& r) { return __doaml (this, r); } - complex& operator/= (const complex& r) { return __doadv (this, r); } - - double real () const { return re; } - double imag () const { return im; } -private: - double re, im; - - friend complex& __doapl<> (complex *, const complex&); - friend complex& __doami<> (complex *, const complex&); - friend complex& __doaml<> (complex *, const complex&); - friend complex& __doadv<> (complex *, const complex&); - -#ifndef __STRICT_ANSI__ - friend inline complex operator + (const complex& x, double y) - { return operator+<> (x, y); } - friend inline complex operator + (double x, const complex& y) - { return operator+<> (x, y); } - friend inline complex operator - (const complex& x, double y) - { return operator-<> (x, y); } - friend inline complex operator - (double x, const complex& y) - { return operator-<> (x, y); } - friend inline complex operator * (const complex& x, double y) - { return operator*<> (x, y); } - friend inline complex operator * (double x, const complex& y) - { return operator*<> (x, y); } - friend inline complex operator / (const complex& x, double y) - { return operator/<> (x, y); } - friend inline complex operator / (double x, const complex& y) - { return operator/<> (x, y); } - friend inline bool operator == (const complex& x, double y) - { return operator==<> (x, y); } - friend inline bool operator == (double x, const complex& y) - { return operator==<> (x, y); } - friend inline bool operator != (const complex& x, double y) - { return operator!=<> (x, y); } - friend inline bool operator != (double x, const complex& y) - { return operator!=<> (x, y); } -#endif /* __STRICT_ANSI__ */ -}; - -inline complex::complex (const complex& r) -: re (r.real ()), im (r.imag ()) -{ } -} // extern "C++" - -#endif diff --git a/libstdc++/std/fcomplex.h b/libstdc++/std/fcomplex.h deleted file mode 100644 index cd9af1a2e0c..00000000000 --- a/libstdc++/std/fcomplex.h +++ /dev/null @@ -1,87 +0,0 @@ -// The -*- C++ -*- float_complex class. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification in the 27 May 1994 -// C++ working paper, ANSI document X3J16/94-0098. - -#ifndef __FCOMPLEX__ -#define __FCOMPLEX__ - -#ifdef __GNUG__ -#pragma interface "fcomplex" -#endif - -extern "C++" { -class complex -{ -public: - complex (float r = 0, float i = 0): re (r), im (i) { } - explicit complex (const complex& r); - explicit complex (const complex& r); - - complex& operator+= (const complex& r) { return __doapl (this, r); } - complex& operator-= (const complex& r) { return __doami (this, r); } - complex& operator*= (const complex& r) { return __doaml (this, r); } - complex& operator/= (const complex& r) { return __doadv (this, r); } - - float real () const { return re; } - float imag () const { return im; } -private: - float re, im; - - friend complex& __doapl<> (complex *, const complex&); - friend complex& __doami<> (complex *, const complex&); - friend complex& __doaml<> (complex *, const complex&); - friend complex& __doadv<> (complex *, const complex&); - -#ifndef __STRICT_ANSI__ - friend inline complex operator + (const complex& x, float y) - { return operator+<> (x, y); } - friend inline complex operator + (float x, const complex& y) - { return operator+<> (x, y); } - friend inline complex operator - (const complex& x, float y) - { return operator-<> (x, y); } - friend inline complex operator - (float x, const complex& y) - { return operator-<> (x, y); } - friend inline complex operator * (const complex& x, float y) - { return operator*<> (x, y); } - friend inline complex operator * (float x, const complex& y) - { return operator*<> (x, y); } - friend inline complex operator / (const complex& x, float y) - { return operator/<> (x, y); } - friend inline complex operator / (float x, const complex& y) - { return operator/<> (x, y); } - friend inline bool operator == (const complex& x, float y) - { return operator==<> (x, y); } - friend inline bool operator == (float x, const complex& y) - { return operator==<> (x, y); } - friend inline bool operator != (const complex& x, float y) - { return operator!=<> (x, y); } - friend inline bool operator != (float x, const complex& y) - { return operator!=<> (x, y); } -#endif /* __STRICT_ANSI__ */ -}; -} // extern "C++" - -#endif diff --git a/libstdc++/std/gslice.h b/libstdc++/std/gslice.h deleted file mode 100644 index 4f6e854a14c..00000000000 --- a/libstdc++/std/gslice.h +++ /dev/null @@ -1,111 +0,0 @@ -// The template and inlines for the -*- C++ -*- gslice class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __GSLICE__ -#define __GSLICE__ - -extern "C++" { - -struct _Indexer { - size_t _M_count; - size_t _M_start; - valarray _M_size; - valarray _M_stride; - valarray _M_index; - _Indexer(size_t, const valarray&, const valarray&); - void _M_increment_use() { ++_M_count; } - size_t _M_decrement_use() { return --_M_count; } -}; - - -class gslice -{ -public: - gslice (); - gslice (size_t, const valarray&, const valarray&); - gslice(const gslice&); - ~gslice(); - - gslice& operator= (const gslice&); - size_t start () const; - valarray size () const; - valarray stride () const; - -private: - _Indexer* _M_index; - - template friend class valarray; -}; - -inline size_t -gslice::start () const -{ return _M_index ? _M_index->_M_start : 0; } - -inline valarray -gslice::size () const -{ return _M_index ? _M_index->_M_size : valarray(); } - -inline valarray -gslice::stride () const -{ return _M_index ? _M_index->_M_stride : valarray(); } - -inline gslice::gslice () : _M_index(0) {} - -inline -gslice::gslice(size_t __o, const valarray& __l, - const valarray& __s) - : _M_index(new _Indexer(__o, __l, __s)) {} - -inline -gslice::gslice(const gslice& __g) : _M_index(__g._M_index) -{ if (_M_index) _M_index->_M_increment_use(); } - -inline -gslice::~gslice() -{ if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; } - -inline gslice& -gslice::operator= (const gslice& __g) -{ - if (__g._M_index) __g._M_index->_M_increment_use(); - if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; - _M_index = __g._M_index; - return *this; -} - - -} // extern "C++" - -#endif // __GSLICE__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/gslice_array.h b/libstdc++/std/gslice_array.h deleted file mode 100644 index 9ea61ffc03c..00000000000 --- a/libstdc++/std/gslice_array.h +++ /dev/null @@ -1,170 +0,0 @@ -// The template and inlines for the -*- C++ -*- gslice_array class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __GSLICE_ARRAY__ -#define __GSLICE_ARRAY__ - -extern "C++" { - -template 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 - void operator= (const _Expr<_Dom,_Tp>&) const; - template - void operator*= (const _Expr<_Dom,_Tp>&) const; - template - void operator/= (const _Expr<_Dom,_Tp>&) const; - template - void operator%= (const _Expr<_Dom,_Tp>&) const; - template - void operator+= (const _Expr<_Dom,_Tp>&) const; - template - void operator-= (const _Expr<_Dom,_Tp>&) const; - template - void operator^= (const _Expr<_Dom,_Tp>&) const; - template - void operator&= (const _Expr<_Dom,_Tp>&) const; - template - void operator|= (const _Expr<_Dom,_Tp>&) const; - template - void operator<<= (const _Expr<_Dom,_Tp>&) const; - template - void operator>>= (const _Expr<_Dom,_Tp>&) const; - -private: - _Array<_Tp> _M_array; - const valarray& _M_index; - - friend class valarray<_Tp>; - - gslice_array (_Array<_Tp>, const valarray&); - - // this constructor needs to be implemented. - gslice_array (const gslice_array&); - - // not implemented - gslice_array(); - gslice_array& operator= (const gslice_array&); -}; - -template -inline -gslice_array<_Tp>::gslice_array (_Array<_Tp> __a, - const valarray& __i) - : _M_array (__a), _M_index (__i) {} - - -template -inline -gslice_array<_Tp>::gslice_array (const gslice_array<_Tp>& __a) - : _M_array (__a._M_array), _M_index (__a._M_index) {} - - -template -inline void -gslice_array<_Tp>::operator= (const _Tp& __t) -{ - __valarray_fill (_M_array, _Array(_M_index), - _M_index.size(), __t); -} - -template -inline void -gslice_array<_Tp>::operator= (const valarray<_Tp>& __v) const -{ - __valarray_copy (_Array<_Tp> (__v), __v.size (), - _M_array, _Array(_M_index)); -} - -template -template -inline void -gslice_array<_Tp>::operator= (const _Expr& __e) const -{ - __valarray_copy (__e, _M_index.size(), _M_array, - _Array(_M_index)); -} - -#undef _DEFINE_VALARRAY_OPERATOR -#define _DEFINE_VALARRAY_OPERATOR(op, name) \ -template \ -inline void \ -gslice_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \ -{ \ - _Array_augmented_##name (_M_array, _Array(_M_index), \ - _Array<_Tp> (__v), __v.size ()); \ -} \ - \ -template template \ -inline void \ -gslice_array<_Tp>::operator op##= (const _Expr& __e) const \ -{ \ - _Array_augmented_##name (_M_array, _Array(_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) - -#undef _DEFINE_VALARRAY_OPERATOR - -} // extern "C++" - - -#endif // __GSLICE_ARRAY__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/indirect_array.h b/libstdc++/std/indirect_array.h deleted file mode 100644 index 7a1d3c2b0d1..00000000000 --- a/libstdc++/std/indirect_array.h +++ /dev/null @@ -1,157 +0,0 @@ -// The template and inlines for the -*- C++ -*- indirect_array class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __INDIRECT_ARRAY__ -#define __INDIRECT_ARRAY__ - -extern "C++" { - -template class indirect_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 - void operator= (const _Expr<_Dom, _Tp>&) const; - template - void operator*= (const _Expr<_Dom, _Tp>&) const; - template - void operator/= (const _Expr<_Dom, _Tp>&) const; - template - void operator%= (const _Expr<_Dom, _Tp>&) const; - template - void operator+= (const _Expr<_Dom, _Tp>&) const; - template - void operator-= (const _Expr<_Dom, _Tp>&) const; - template - void operator^= (const _Expr<_Dom, _Tp>&) const; - template - void operator&= (const _Expr<_Dom, _Tp>&) const; - template - void operator|= (const _Expr<_Dom, _Tp>&) const; - template - void operator<<= (const _Expr<_Dom, _Tp>&) const; - template - void operator>>= (const _Expr<_Dom, _Tp>&) const; - -private: - indirect_array (const indirect_array&); - indirect_array (_Array<_Tp>, size_t, _Array); - - friend class valarray<_Tp>; - friend class gslice_array<_Tp>; - - const size_t _M_sz; - const _Array _M_index; - const _Array<_Tp> _M_array; - - // not implemented - indirect_array (); - indirect_array& operator= (const indirect_array&); -}; - -template -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 -inline -indirect_array<_Tp>::indirect_array (_Array<_Tp> __a, size_t __s, - _Array __i) - : _M_sz (__s), _M_index (__i), _M_array (__a) {} - - -template -inline void -indirect_array<_Tp>::operator= (const _Tp& __t) -{ __valarray_fill(_M_array, _M_index, _M_sz, __t); } - -template -inline void -indirect_array<_Tp>::operator= (const valarray<_Tp>& __v) const -{ __valarray_copy (_Array<_Tp> (__v), _M_sz, _M_array, _M_index); } - -template -template -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 \ -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 template \ -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) - -#undef _DEFINE_VALARRAY_OPERATOR - -} // extern "C++" - -#endif // __INDIRECT_ARRAY__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/ldcomplex.h b/libstdc++/std/ldcomplex.h deleted file mode 100644 index bc91fa422bf..00000000000 --- a/libstdc++/std/ldcomplex.h +++ /dev/null @@ -1,95 +0,0 @@ -// The -*- C++ -*- long_double_complex class. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification in the 27 May 1994 -// C++ working paper, ANSI document X3J16/94-0098. - -#ifndef __LDCOMPLEX__ -#define __LDCOMPLEX__ - -#ifdef __GNUG__ -#pragma interface "ldcomplex" -#endif - -extern "C++" { -class complex -{ -public: - complex (long double r = 0, long double i = 0): re (r), im (i) { } - complex (const complex& r): re (r.real ()), im (r.imag ()) { } - complex (const complex& r): re (r.real ()), im (r.imag ()) { } - - complex& operator+= (const complex& r) { return __doapl (this, r); } - complex& operator-= (const complex& r) { return __doami (this, r); } - complex& operator*= (const complex& r) { return __doaml (this, r); } - complex& operator/= (const complex& r) { return __doadv (this, r); } - - long double real () const { return re; } - long double imag () const { return im; } -private: - long double re, im; - - friend complex& __doapl<> (complex *, const complex&); - friend complex& __doami<> (complex *, const complex&); - friend complex& __doaml<> (complex *, const complex&); - friend complex& __doadv<> (complex *, const complex&); - -#ifndef __STRICT_ANSI__ - friend inline complex operator + (const complex& x, long double y) - { return operator+<> (x, y); } - friend inline complex operator + (long double x, const complex& y) - { return operator+<> (x, y); } - friend inline complex operator - (const complex& x, long double y) - { return operator-<> (x, y); } - friend inline complex operator - (long double x, const complex& y) - { return operator-<> (x, y); } - friend inline complex operator * (const complex& x, long double y) - { return operator*<> (x, y); } - friend inline complex operator * (long double x, const complex& y) - { return operator*<> (x, y); } - friend inline complex operator / (const complex& x, long double y) - { return operator/<> (x, y); } - friend inline complex operator / (long double x, const complex& y) - { return operator/<> (x, y); } - friend inline bool operator == (const complex& x, long double y) - { return operator==<> (x, y); } - friend inline bool operator == (long double x, const complex& y) - { return operator==<> (x, y); } - friend inline bool operator != (const complex& x, long double y) - { return operator!=<> (x, y); } - friend inline bool operator != (long double x, const complex& y) - { return operator!=<> (x, y); } -#endif /* __STRICT_ANSI__ */ -}; - -inline complex::complex (const complex& r) -: re (r.real ()), im (r.imag ()) -{ } - -inline complex::complex (const complex& r) -: re (r.real ()), im (r.imag ()) -{ } -} // extern "C++" - -#endif diff --git a/libstdc++/std/mask_array.h b/libstdc++/std/mask_array.h deleted file mode 100644 index 033e6f218fa..00000000000 --- a/libstdc++/std/mask_array.h +++ /dev/null @@ -1,154 +0,0 @@ -// The template and inlines for the -*- C++ -*- mask_array class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __MASK_ARRAY__ -#define __MASK_ARRAY__ - -extern "C++" { - -template class mask_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 - void operator= (const _Expr<_Dom,_Tp>&) const; - template - void operator*= (const _Expr<_Dom,_Tp>&) const; - template - void operator/= (const _Expr<_Dom,_Tp>&) const; - template - void operator%= (const _Expr<_Dom,_Tp>&) const; - template - void operator+= (const _Expr<_Dom,_Tp>&) const; - template - void operator-= (const _Expr<_Dom,_Tp>&) const; - template - void operator^= (const _Expr<_Dom,_Tp>&) const; - template - void operator&= (const _Expr<_Dom,_Tp>&) const; - template - void operator|= (const _Expr<_Dom,_Tp>&) const; - template - void operator<<=(const _Expr<_Dom,_Tp>&) const; - template - void operator>>=(const _Expr<_Dom,_Tp>&) const; - -private: - mask_array (_Array<_Tp>, size_t, _Array); - friend class valarray<_Tp>; - - const size_t _M_sz; - const _Array _M_mask; - const _Array<_Tp> _M_array; - - mask_array (const mask_array&); - - // not implemented - mask_array (); - mask_array& operator= (const mask_array&); -}; - -template -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 -inline -mask_array<_Tp>::mask_array (_Array<_Tp> __a, size_t __s, _Array __m) - : _M_sz (__s), _M_mask (__m), _M_array (__a) {} - -template -inline void -mask_array<_Tp>::operator= (const _Tp& __t) -{ __valarray_fill (_M_array, _M_sz, _M_mask, __t); } - -template -inline void -mask_array<_Tp>::operator= (const valarray<_Tp>& __v) const -{ __valarray_copy (_Array<_Tp> (__v), __v.size (), _M_array, _M_mask); } - -template -template -inline void -mask_array<_Tp>::operator= (const _Expr& __e) const -{ __valarray_copy (__e, __e.size (), _M_array, _M_mask); } - -#undef _DEFINE_VALARRAY_OPERATOR -#define _DEFINE_VALARRAY_OPERATOR(op, name) \ -template \ -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 template \ -inline void \ -mask_array<_Tp>::operator op##= (const _Expr& __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) - -#undef _DEFINE_VALARRAY_OPERATOR - -} // extern "C++" - -#endif // __MASK_ARRAY__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/slice.h b/libstdc++/std/slice.h deleted file mode 100644 index cf2fb283de9..00000000000 --- a/libstdc++/std/slice.h +++ /dev/null @@ -1,76 +0,0 @@ -// The template and inlines for the -*- C++ -*- slice class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __SLICE__ -#define __SLICE__ - -extern "C++" { - -class slice -{ -public: - slice (); - slice (size_t, size_t, size_t); - - size_t start () const; - size_t size () const; - size_t stride () const; - -private: - size_t _M_off; // offset - size_t _M_sz; // size - size_t _M_st; // stride unit -}; - -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; } - -} // extern "C++" - -#endif // __SLICE__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/slice_array.h b/libstdc++/std/slice_array.h deleted file mode 100644 index 0d3ac794753..00000000000 --- a/libstdc++/std/slice_array.h +++ /dev/null @@ -1,156 +0,0 @@ -// The template and inlines for the -*- C++ -*- slice_array class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __SLICE_ARRAY__ -#define __SLICE_ARRAY__ - -extern "C++" { - -template -class slice_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 - void operator= (const _Expr<_Dom,_Tp>&) const; - template - void operator*= (const _Expr<_Dom,_Tp>&) const; - template - void operator/= (const _Expr<_Dom,_Tp>&) const; - template - void operator%= (const _Expr<_Dom,_Tp>&) const; - template - void operator+= (const _Expr<_Dom,_Tp>&) const; - template - void operator-= (const _Expr<_Dom,_Tp>&) const; - template - void operator^= (const _Expr<_Dom,_Tp>&) const; - template - void operator&= (const _Expr<_Dom,_Tp>&) const; - template - void operator|= (const _Expr<_Dom,_Tp>&) const; - template - void operator<<= (const _Expr<_Dom,_Tp>&) const; - template - 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; - - // this constructor is implemented since we need to return a value. - slice_array (const slice_array&); - - // not implemented - slice_array (); - slice_array& operator= (const slice_array&); -}; - -template -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 -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 -inline void -slice_array<_Tp>::operator= (const _Tp& __t) -{ __valarray_fill (_M_array, _M_sz, _M_stride, __t); } - -template -inline void -slice_array<_Tp>::operator= (const valarray<_Tp>& __v) const -{ __valarray_copy (_Array<_Tp> (__v), _M_array, _M_sz, _M_stride); } - -template -template -inline void -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 \ -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 template \ -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) - -#undef _DEFINE_VALARRAY_OPERATOR - -} // extern "C++" - -#endif // __SLICE_ARRAY__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/std_valarray.h b/libstdc++/std/std_valarray.h deleted file mode 100644 index 8d4c94aa045..00000000000 --- a/libstdc++/std/std_valarray.h +++ /dev/null @@ -1,737 +0,0 @@ -// The template and inlines for the -*- C++ -*- valarray class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __STD_VALARRAY__ -#define __STD_VALARRAY__ -#define _G_NO_VALARRAY_TEMPLATE_EXPORT 1 - -#include -#include -#include -#include -#include -#include - -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) -#include -#else /* not sparc */ -#if defined (MSDOS) && !defined (__TURBOC__) -#include -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include - #pragma alloca -#else /* not MSDOS, __TURBOC__, or _AIX */ -#ifdef __hpux -#endif /* __hpux */ -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc. */ -#endif /* not GNU C. */ -#endif /* alloca not defined. */ - -extern "C" { - void* alloca(size_t); -} - -extern "C++" { - -template class _Expr; - -template class _ValArray; - -template class _Oper, - template class _Meta, class _Dom> struct _UnClos; - -template class _Oper, - template class _Meta1, - template class _Meta2, - class _Dom1, class _Dom2> class _BinClos; - -template class _Meta, class _Dom> class _SClos; - -template class _Meta, class _Dom> class _GClos; - -template class _Meta, class _Dom> class _IClos; - -template class _Meta, class _Dom> class _ValFunClos; - -template class _Meta, class _Dom> class _RefFunClos; - -template struct _Unary_plus; -template struct _Bitwise_and; -template struct _Bitwise_or; -template struct _Bitwise_xor; -template struct _Bitwise_not; -template struct _Shift_left; -template struct _Shift_right; - -template class valarray; // An array of type _Tp -class slice; // BLAS-like slice out of an array -template class slice_array; -class gslice; // generalized slice out of an array -template class gslice_array; -template class mask_array; // masked array -template class indirect_array; // indirected array - -} // extern "C++" - -#include -#include - -extern "C++" { - -template class valarray -{ -public: - typedef _Tp value_type; - - // _lib.valarray.cons_ construct/destroy: - valarray(); - explicit valarray(size_t); - valarray(const _Tp&, size_t); - valarray(const _Tp* __restrict__, size_t); - valarray(const valarray&); - valarray(const slice_array<_Tp>&); - valarray(const gslice_array<_Tp>&); - valarray(const mask_array<_Tp>&); - valarray(const indirect_array<_Tp>&); - template - valarray(const _Expr<_Dom,_Tp>& __e); - ~valarray(); - - // _lib.valarray.assign_ assignment: - valarray<_Tp>& operator=(const valarray<_Tp>&); - valarray<_Tp>& operator=(const _Tp&); - valarray<_Tp>& operator=(const slice_array<_Tp>&); - valarray<_Tp>& operator=(const gslice_array<_Tp>&); - valarray<_Tp>& operator=(const mask_array<_Tp>&); - valarray<_Tp>& operator=(const indirect_array<_Tp>&); - - template valarray<_Tp>& - operator= (const _Expr<_Dom,_Tp>&); - - // _lib.valarray.access_ element access: - _Tp operator[](size_t) const; - _Tp& operator[](size_t); - // _lib.valarray.sub_ subset operations: - _Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const; - slice_array<_Tp> operator[](slice); - _Expr<_GClos<_ValArray,_Tp>, _Tp> operator[](const gslice&) const; - gslice_array<_Tp> operator[](const gslice&); - valarray<_Tp> operator[](const valarray&) const; - mask_array<_Tp> operator[](const valarray&); - _Expr<_IClos<_ValArray, _Tp>, _Tp> - operator[](const valarray&) const; - indirect_array<_Tp> operator[](const valarray&); - - // _lib.valarray.unary_ unary operators: - _Expr<_UnClos<_Unary_plus,_ValArray,_Tp>,_Tp> operator+ () const; - _Expr<_UnClos,_Tp> operator- () const; - _Expr<_UnClos<_Bitwise_not,_ValArray,_Tp>,_Tp> operator~ () const; - _Expr<_UnClos,bool> 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 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 - valarray<_Tp>& operator*= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator/= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator%= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator+= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator-= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator^= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator|= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator&= (const _Expr<_Dom,_Tp>&); - template - valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&); - template - 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; - - valarray<_Tp> shift (int) const; - valarray<_Tp> cshift(int) const; - _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(_Tp)) const; - _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const; - void resize(size_t __size, _Tp __c = _Tp()); - -private: - size_t _M_size; - _Tp* __restrict__ _M_data; - - friend class _Array<_Tp>; -}; - - -template struct _Unary_plus : unary_function<_Tp,_Tp> { - _Tp operator() (const _Tp& __t) const { return __t; } -}; - -template struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; } -}; - -template struct _Bitwise_or : binary_function<_Tp,_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x | __y; } -}; - -template struct _Bitwise_xor : binary_function<_Tp,_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x ^ __y; } -}; - -template struct _Bitwise_not : unary_function<_Tp,_Tp> { - _Tp operator() (_Tp __t) const { return ~__t; } -}; - -template struct _Shift_left : unary_function<_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x << __y; } -}; - -template struct _Shift_right : unary_function<_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x >> __y; } -}; - - -template -inline _Tp -valarray<_Tp>::operator[] (size_t __i) const -{ return _M_data[__i]; } - -template -inline _Tp& -valarray<_Tp>::operator[] (size_t __i) -{ return _M_data[__i]; } - -} // extern "C++" - -#include -#include -#include -#include -#include -#include - -extern "C++" { - -template -inline valarray<_Tp>::valarray () : _M_size (0), _M_data (0) {} - -template -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 -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 -inline valarray<_Tp>::valarray (const _Tp* __restrict__ __pT, size_t __n) - : _M_size (__n), _M_data(__valarray_get_storage<_Tp>(__n)) -{ __valarray_copy_construct(__pT, __pT + __n, _M_data); } - -template -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 -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 -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(__ga._M_index), - _Array<_Tp>(_M_data), _M_size); -} - -template -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 -inline valarray<_Tp>::valarray (const indirect_array<_Tp>& __ia) - : _M_size (__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_size)) -{ - __valarray_copy - (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); -} - -template template -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 -inline valarray<_Tp>::~valarray () -{ - __valarray_destroy_elements(_M_data, _M_data + _M_size); - __valarray_release_storage(_M_data); -} - -template -inline valarray<_Tp>& -valarray<_Tp>::operator= (const valarray<_Tp>& __v) -{ - __valarray_copy(__v._M_data, _M_size, _M_data); - return *this; -} - -template -inline valarray<_Tp>& -valarray<_Tp>::operator= (const _Tp& __t) -{ - __valarray_fill (_M_data, _M_size, __t); - return *this; -} - -template -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 -inline valarray<_Tp>& -valarray<_Tp>::operator= (const gslice_array<_Tp>& __ga) -{ - __valarray_copy (__ga._M_array, _Array(__ga._M_index), - _Array<_Tp>(_M_data), _M_size); - return *this; -} - -template -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 -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 template -inline valarray<_Tp>& -valarray<_Tp>::operator= (const _Expr<_Dom, _Tp>& __e) -{ - __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); - return *this; -} - -template -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)); -} - -template -inline slice_array<_Tp> -valarray<_Tp>::operator[] (slice __s) -{ - return slice_array<_Tp> (_Array<_Tp>(_M_data), __s); -} - -template -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)); -} - -template -inline gslice_array<_Tp> -valarray<_Tp>::operator[] (const gslice& __gs) -{ - return gslice_array<_Tp> - (_Array<_Tp>(_M_data), __gs._M_index->_M_index); -} - -template -inline valarray<_Tp> -valarray<_Tp>::operator[] (const valarray& __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 (__m))); -} - -template -inline mask_array<_Tp> -valarray<_Tp>::operator[] (const valarray& __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 (__m)); -} - -template -inline _Expr<_IClos<_ValArray,_Tp>, _Tp> -valarray<_Tp>::operator[] (const valarray& __i) const -{ - typedef _IClos<_ValArray,_Tp> _Closure; - return _Expr<_Closure, _Tp> (_Closure (*this, __i)); -} - -template -inline indirect_array<_Tp> -valarray<_Tp>::operator[] (const valarray& __i) -{ - return indirect_array<_Tp> (_Array<_Tp>(_M_data), __i.size(), - _Array (__i)); -} - -template -inline size_t valarray<_Tp>::size () const { return _M_size; } - -template -inline _Tp -valarray<_Tp>::sum () const -{ - return __valarray_sum(_M_data, _M_data + _M_size); -} - -template -inline valarray<_Tp> -valarray<_Tp>::shift (int __n) const -{ - _Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size)); - if (! __n) // __n == 0: no shift - __valarray_copy_construct (_M_data, _M_size, __a); - else if (__n > 0) { // __n > 0: shift left - if (__n > _M_size) - __valarray_default_construct(__a, __a + __n); - else { - __valarray_copy_construct (_M_data+__n, _M_size-__n, __a); - __valarray_default_construct (__a+_M_size-__n, __a + _M_size); - } - } - else { // __n < 0: shift right - __valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n); - __valarray_default_construct(__a, __a-__n); - } - return valarray<_Tp> (__a, _M_size); -} - -template -inline valarray<_Tp> -valarray<_Tp>::cshift (int __n) const -{ - _Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size)); - if (__n == 0) // __n == 0: no cshift - __valarray_copy_construct(_M_data, _M_data + _M_size, __a); - else if (__n > 0) { // __n > 0: cshift left - __valarray_copy_construct (_M_data, _M_data + __n, __a + _M_size-__n); - __valarray_copy_construct (_M_data + __n, _M_data + _M_size, __a); - } - else { // __n < 0: cshift right - __valarray_copy_construct - (_M_data + _M_size + __n, _M_data + _M_size, __a); - __valarray_copy_construct - (_M_data, _M_data + _M_size + __n, __a - __n); - } - return valarray<_Tp> (__a, _M_size); -} - -template -inline void -valarray<_Tp>::resize (size_t __n, _Tp __c) -{ - // this is so to make valarray > work - // even though it is not required by the standard. - __valarray_destroy_elements(_M_data, _M_data + _M_size); - if (_M_size != __n) { - __valarray_release_storage(_M_data); - _M_size = __n; - _M_data = __valarray_get_storage<_Tp>(__n); - } - __valarray_fill_construct (_M_data, _M_data + _M_size, __c); -} - -template -inline _Tp -valarray<_Tp>::min() const -{ - return *min_element (_M_data, _M_data+_M_size); -} - -template -inline _Tp -valarray<_Tp>::max() const -{ - return *max_element (_M_data, _M_data+_M_size); -} - -template -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)); -} - -template -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)); -} - -#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \ - template \ - inline _Expr<_UnClos<_Name,_ValArray,_Tp>, _Tp> \ - valarray<_Tp>::operator _Op() const \ - { \ - typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \ - return _Expr<_Closure, _Tp> (_Closure (*this)); \ - } - - _DEFINE_VALARRAY_UNARY_OPERATOR(+, _Unary_plus) - _DEFINE_VALARRAY_UNARY_OPERATOR(-, negate) - _DEFINE_VALARRAY_UNARY_OPERATOR(~, _Bitwise_not) - -#undef _DEFINE_VALARRAY_UNARY_OPERATOR - - template - inline _Expr<_UnClos, bool> - valarray<_Tp>::operator!() const - { - typedef _UnClos _Closure; - return _Expr<_Closure, bool> (_Closure (*this)); - } - -#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \ - template \ - inline valarray<_Tp> & \ - valarray<_Tp>::operator _Op##= (const _Tp &__t) \ - { \ - _Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, __t); \ - return *this; \ - } \ - \ - template \ - 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) - -#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT - - -#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \ - template template \ - 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) - -#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT - - -#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \ - template \ - inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \ - 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)); \ - } \ - \ - template \ - inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,_Tp> \ - operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \ - { \ - typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, _Tp> (_Closure (__v, __t)); \ - } \ - \ - template \ - 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 \ - 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 \ - inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,bool> \ - operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \ - { \ - typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, bool> (_Closure (__v, __t)); \ - } \ - \ - template \ - 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_VALARRAY_OPERATOR - -#undef _G_NO_VALARRAY_TEMPLATE_EXPORT - -} // extern "C++" - -#endif // __STD_VALARRAY__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/straits.h b/libstdc++/std/straits.h deleted file mode 100644 index eada4fc4d85..00000000000 --- a/libstdc++/std/straits.h +++ /dev/null @@ -1,161 +0,0 @@ -// Character traits template for the -*- C++ -*- string classes. -// Copyright (C) 1994, 2000 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Jason Merrill based upon the specification by Takanori Adachi -// in ANSI X3J16/94-0013R2. - -#ifndef __STRING_CHAR_TRAITS__ -#define __STRING_CHAR_TRAITS__ - -#ifdef __GNUG__ -// For string_char_traits -#pragma interface "std/straits.h" -#endif - -#include - -extern "C++" { -template -struct string_char_traits { - typedef charT char_type; // for users to acquire the basic character type - - // constraints - - static void assign (char_type& c1, const char_type& c2) - { c1 = c2; } - static bool eq (const char_type& c1, const char_type& c2) - { return (c1 == c2); } - static bool ne (const char_type& c1, const char_type& c2) - { return !(c1 == c2); } - static bool lt (const char_type& c1, const char_type& c2) - { return (c1 < c2); } - static char_type eos () { return char_type(); } // the null character - static bool is_del(char_type a) { return 0; } - // characteristic function for delimiters of charT - - // speed-up functions - - static int compare (const char_type* s1, const char_type* s2, size_t n) - { - size_t i; - for (i = 0; i < n; ++i) - if (ne (s1[i], s2[i])) - return lt (s1[i], s2[i]) ? -1 : 1; - - return 0; - } - - static size_t length (const char_type* s) - { - size_t l = 0; - while (ne (*s++, eos ())) - ++l; - return l; - } - - static char_type* copy (char_type* s1, const char_type* s2, size_t n) - { - for (; n--; ) - assign (s1[n], s2[n]); - return s1; - } - - static char_type* move (char_type* s1, const char_type* s2, size_t n) - { - char_type a[n]; - size_t i; - for (i = 0; i < n; ++i) - assign (a[i], s2[i]); - for (i = 0; i < n; ++i) - assign (s1[i], a[i]); - return s1; - } - - static char_type* set (char_type* s1, const char_type& c, size_t n) - { - for (; n--; ) - assign (s1[n], c); - return s1; - } -}; - -class istream; -class ostream; -#include -#include - -struct string_char_traits { - typedef char char_type; - - static void assign (char_type& c1, const char_type& c2) - { c1 = c2; } - static bool eq (const char_type & c1, const char_type& c2) - { return (c1 == c2); } - static bool ne (const char_type& c1, const char_type& c2) - { return (c1 != c2); } - static bool lt (const char_type& c1, const char_type& c2) - { return (c1 < c2); } - static char_type eos () { return 0; } - static bool is_del(char_type a) { return !!isspace(a); } - - static int compare (const char_type* s1, const char_type* s2, size_t n) - { return memcmp (s1, s2, n); } - static size_t length (const char_type* s) - { return strlen (s); } - static char_type* copy (char_type* s1, const char_type* s2, size_t n) - { return (char_type*) memcpy (s1, s2, n); } - static char_type* move (char_type* s1, const char_type* s2, size_t n) - { return (char_type*) memmove (s1, s2, n); } - static char_type* set (char_type* s1, const char_type& c, size_t n) - { return (char_type*) memset (s1, c, n); } -}; - -#if 0 -#include -struct string_char_traits { - typedef wchar_t char_type; - - static void assign (char_type& c1, const char_type& c2) - { c1 = c2; } - static bool eq (const char_type & c1, const char_type& c2) - { return (c1 == c2); } - static bool ne (const char_type& c1, const char_type& c2) - { return (c1 != c2); } - static bool lt (const char_type& c1, const char_type& c2) - { return (c1 < c2); } - static char_type eos () { return 0; } - static bool is_del(char_type a) { return !!iswspace(a); } - - static int compare (const char_type* s1, const char_type* s2, size_t n) - { return wmemcmp (s1, s2, n); } - static size_t length (const char_type* s) - { return wcslen (s); } - static char_type* copy (char_type* s1, const char_type* s2, size_t n) - { return wmemcpy (s1, s2, n); } - static char_type* set (char_type* s1, const char_type& c, size_t n) - { return wmemset (s1, c, n); } -}; -#endif -} // extern "C++" -#endif diff --git a/libstdc++/std/valarray_array.h b/libstdc++/std/valarray_array.h deleted file mode 100644 index bb429b0bc7e..00000000000 --- a/libstdc++/std/valarray_array.h +++ /dev/null @@ -1,538 +0,0 @@ -// The template and inlines for the -*- C++ -*- internal _Array helper class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __VALARRAY_ARRAY__ -#define __VALARRAY_ARRAY__ - -#include -#include -#include - -extern "C++" { - -// -// Helper functions on raw pointers -// - - inline void* - __valarray_get_memory(size_t __n) - { return operator new(__n); } - - template - inline _Tp*__restrict__ - __valarray_get_storage(size_t __n) - { - return static_cast<_Tp*__restrict__> - (__valarray_get_memory(__n * sizeof(_Tp))); - } - - // Return memory to the system - inline void - __valarray_release_storage(void* __p) - { operator delete(__p); } - - // Turn a raw-memory into an array of _Tp filled with _Tp() - // This is required in 'valarray v(n);' - template - struct _Array_default_ctor - { - // Please note that this isn't exception safe. But - // valarrays aren't required to be exception safe. - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { while (__b != __e) new(__b++) _Tp(); } - }; - - template - struct _Array_default_ctor<_Tp, true> - { - // For fundamental types, it suffices to say 'memset()' - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { memset(__b, 0, (__e - __b)*sizeof(_Tp)); } - }; - - template - inline void - __valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { - _Array_default_ctor<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__b, __e); - } - - // Turn a raw-memory into an array of _Tp filled with __t - // This is the required in valarray v(n, t). Also - // used in valarray<>::resize(). - template - struct _Array_init_ctor - { - // Please note that this isn't exception safe. But - // valarrays aren't required to be exception safe. - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) - { while (__b != __e) new(__b++) _Tp(__t); } - }; - - template - struct _Array_init_ctor<_Tp, true> - { - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) - { while (__b != __e) *__b++ = __t; } - }; - - template - inline void - __valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e, - const _Tp __t) - { - _Array_init_ctor<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__b, __e, __t); - } - - // - // copy-construct raw array [__o, *) from plain array [__b, __e) - // We can't just say 'memcpy()' - // - template - struct _Array_copy_ctor - { - // Please note that this isn't exception safe. But - // valarrays aren't required to be exception safe. - inline static void - _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, - _Tp* __restrict__ __o) - { while (__b != __e) new(__o++) _Tp(*__b++); } - }; - - template - struct _Array_copy_ctor<_Tp, true> - { - inline static void - _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, - _Tp* __restrict__ __o) - { memcpy(__o, __b, (__e - __b)*sizeof(_Tp)); } - }; - - template - inline void - __valarray_copy_construct(const _Tp* __restrict__ __b, - const _Tp* __restrict__ __e, - _Tp* __restrict__ __o) - { - _Array_copy_ctor<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__b, __e, __o); - } - - // copy-construct raw array [__o, *) from strided array __a[<__n : __s>] - template - inline void - __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n, - size_t __s, _Tp* __restrict__ __o) - { - if (__is_fundamental<_Tp>::_M_type) - while (__n--) { *__o++ = *__a; __a += __s; } - else - while (__n--) { new(__o++) _Tp(*__a); __a += __s; } - } - - // copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]] - template - inline void - __valarray_copy_construct (const _Tp* __restrict__ __a, - const size_t* __restrict__ __i, - _Tp* __restrict__ __o, size_t __n) - { - if (__is_fundamental<_Tp>::_M_type) - while (__n--) *__o++ = __a[*__i++]; - else - while (__n--) new (__o++) _Tp(__a[*__i++]); - } - - // Do the necessary cleanup when we're done with arrays. - template - inline void - __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { - if (!__is_fundamental<_Tp>::_M_type) - while (__b != __e) { __b->~_Tp(); ++__b; } - } - - - // fill plain array __a[<__n>] with __t - template - inline void - __valarray_fill (_Tp* __restrict__ __a, size_t __n, const _Tp& __t) - { while (__n--) *__a++ = __t; } - - // fill strided array __a[<__n-1 : __s>] with __t - template - inline void - __valarray_fill (_Tp* __restrict__ __a, size_t __n, - size_t __s, const _Tp& __t) - { for (size_t __i=0; __i<__n; ++__i, __a+=__s) *__a = __t; } - - // fill indirect array __a[__i[<__n>]] with __i - template - inline void - __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i, - size_t __n, const _Tp& __t) - { for (size_t __j=0; __j<__n; ++__j, ++__i) __a[*__i] = __t; } - - // copy plain array __a[<__n>] in __b[<__n>] - // For non-fundamental types, it is wrong to say 'memcpy()' - template - struct _Array_copier - { - inline static void - _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) - { while (__n--) *__b++ = *__a++; } - }; - - template - struct _Array_copier<_Tp, true> - { - inline static void - _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) - { memcpy (__b, __a, __n * sizeof (_Tp)); } - }; - - template - inline void - __valarray_copy (const _Tp* __restrict__ __a, size_t __n, - _Tp* __restrict__ __b) - { - _Array_copier<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__a, __n, __b); - } - -// copy strided array __a[<__n : __s>] in plain __b[<__n>] -template -inline void -__valarray_copy (const _Tp* __restrict__ __a, size_t __n, size_t __s, - _Tp* __restrict__ __b) -{ for (size_t __i=0; __i<__n; ++__i, ++__b, __a += __s) *__b = *__a; } - -// copy plain __a[<__n>] in strided __b[<__n : __s>] -template -inline void -__valarray_copy (const _Tp* __restrict__ __a, _Tp* __restrict__ __b, - size_t __n, size_t __s) -{ for (size_t __i=0; __i<__n; ++__i, ++__a, __b+=__s) *__b = *__a; } - -// copy indexed __a[__i[<__n>]] in plain __b[<__n>] -template -inline void -__valarray_copy (const _Tp* __restrict__ __a, - const size_t* __restrict__ __i, - _Tp* __restrict__ __b, size_t __n) -{ for (size_t __j=0; __j<__n; ++__j, ++__b, ++__i) *__b = __a[*__i]; } - -// copy plain __a[<__n>] in indexed __b[__i[<__n>]] -template -inline void -__valarray_copy (const _Tp* __restrict__ __a, size_t __n, - _Tp* __restrict__ __b, const size_t* __restrict__ __i) -{ for (size_t __j=0; __j<__n; ++__j, ++__a, ++__i) __b[*__i] = *__a; } - - // - // Compute the sum of elements in range [__f, __l) - // This is a naive algorithm. It suffers from cancelling. - // In the future try to specialize - // for _Tp = float, double, long double using a more accurate - // algorithm. - // - template - inline _Tp - __valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l) - { - _Tp __r = _Tp(); - while (__f != __l) __r = __r + *__f++; - return __r; - } - - // Compute the product of all elements in range [__f, __l) - template - inline _Tp - __valarray_product(const _Tp* __restrict__ __f, - const _Tp* __restrict__ __l) - { - _Tp __r = _Tp(1); - while (__f != __l) __r = __r * *__f++; - return __r; - } - - -// -// Helper class _Array, first layer of valarray abstraction. -// All operations on valarray should be forwarded to this class -// whenever possible. -- gdr -// - -template struct _Array { - - explicit _Array (size_t); - explicit _Array (_Tp* const __restrict__); - explicit _Array (const valarray<_Tp>&); - _Array (const _Tp* __restrict__, size_t); - - _Tp* begin () const; - - _Tp* const __restrict__ _M_data; -}; - -template -inline void -__valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t) -{ __valarray_fill (__a._M_data, __n, __t); } - -template -inline void -__valarray_fill (_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) -{ __valarray_fill (__a._M_data, __n, __s, __t); } - -template -inline void -__valarray_fill (_Array<_Tp> __a, _Array __i, - size_t __n, const _Tp& __t) -{ __valarray_fill (__a._M_data, __i._M_data, __n, __t); } - -template -inline void -__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) -{ __valarray_copy (__a._M_data, __n, __b._M_data); } - -template -inline void -__valarray_copy (_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b) -{ __valarray_copy(__a._M_data, __n, __s, __b._M_data); } - -template -inline void -__valarray_copy (_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s) -{ __valarray_copy (__a._M_data, __b._M_data, __n, __s); } - -template -inline void -__valarray_copy (_Array<_Tp> __a, _Array __i, - _Array<_Tp> __b, size_t __n) -{ __valarray_copy (__a._M_data, __i._M_data, __b._M_data, __n); } - -template -inline void -__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, - _Array __i) -{ __valarray_copy (__a._M_data, __n, __b._M_data, __i._M_data); } - -template -inline -_Array<_Tp>::_Array (size_t __n) - : _M_data (__valarray_get_storage<_Tp>(__n)) -{ __valarray_default_construct(_M_data, _M_data + __n); } - -template -inline -_Array<_Tp>::_Array (_Tp* const __restrict__ __p) : _M_data (__p) {} - -template -inline _Array<_Tp>::_Array (const valarray<_Tp>& __v) - : _M_data (__v._M_data) {} - -template -inline -_Array<_Tp>::_Array (const _Tp* __restrict__ __b, size_t __s) - : _M_data (__valarray_get_storage<_Tp>(__s )) -{ __valarray_copy_construct(__b, __s, _M_data); } - -template -inline _Tp* -_Array<_Tp>::begin () const -{ return _M_data; } - -#define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, const _Tp& __t) \ -{ \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p) \ - *__p _Op##= __t; \ -} \ - \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ -{ \ - _Tp* __p (__a._M_data); \ - for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__p, ++__q) \ - *__p _Op##= *__q; \ -} \ - \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, \ - const _Expr<_Dom,_Tp>& __e, size_t __n) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, ++__p) *__p _Op##= __e[__i]; \ -} \ - \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, size_t __s, \ - _Array<_Tp> __b) \ -{ \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__s*__n; __p+=__s, ++__q) \ - *__p _Op##= *__q; \ -} \ - \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array<_Tp> __b, \ - size_t __n, size_t __s) \ -{ \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, __q+=__s) \ - *__p _Op##= *__q; \ -} \ - \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __s, \ - const _Expr<_Dom,_Tp>& __e, size_t __n) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p _Op##= __e[__i]; \ -} \ - \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __i, \ - _Array<_Tp> __b, size_t __n) \ -{ \ - _Tp* __q (__b._M_data); \ - for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__q) \ - __a._M_data[*__j] _Op##= *__q; \ -} \ - \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ - _Array<_Tp> __b, _Array __i) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__p) \ - *__p _Op##= __b._M_data[*__j]; \ -} \ - \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __i, \ - const _Expr<_Dom, _Tp>& __e, size_t __n) \ -{ \ - size_t* __j (__i._M_data); \ - for (size_t __k=0; __k<__n; ++__k, ++__j) \ - __a._M_data[*__j] _Op##= __e[__k]; \ -} \ - \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __m, \ - _Array<_Tp> __b, size_t __n) \ -{ \ - bool* ok (__m._M_data); \ - _Tp* __p (__a._M_data); \ - for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++ok, ++__p) { \ - while (! *ok) { \ - ++ok; \ - ++__p; \ - } \ - *__p _Op##= *__q; \ - } \ -} \ - \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ - _Array<_Tp> __b, _Array __m) \ -{ \ - bool* ok (__m._M_data); \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++ok, ++__q) { \ - while (! *ok) { \ - ++ok; \ - ++__q; \ - } \ - *__p _Op##= *__q; \ - } \ -} \ - \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __m, \ - const _Expr<_Dom, _Tp>& __e, size_t __n) \ -{ \ - bool* ok(__m._M_data); \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, ++ok, ++__p) { \ - while (! *ok) { \ - ++ok; \ - ++__p; \ - } \ - *__p _Op##= __e[__i]; \ - } \ -} - -_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) - -#undef _DEFINE_ARRAY_FUNCTION - -} // extern "C++" - -#ifdef _G_NO_VALARRAY_TEMPLATE_EXPORT -# define export -# include -#endif - -#endif // __VALARRAY_ARRAY__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/valarray_array.tcc b/libstdc++/std/valarray_array.tcc deleted file mode 100644 index bd6692571fd..00000000000 --- a/libstdc++/std/valarray_array.tcc +++ /dev/null @@ -1,130 +0,0 @@ -// The template and inlines for the -*- C++ -*- internal _Array helper class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef __VALARRAY_ARRAY_TCC__ -#define __VALARRAY_ARRAY_TCC__ - -extern "C++" { - -export template -void -__valarray_fill (_Array<_Tp> __a, size_t __n, _Array __m, const _Tp& __t) -{ - _Tp* __p = __a._M_data; - bool* __ok (__m._M_data); - for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) { - while (! *__ok) { - ++__ok; - ++__p; - } - *__p = __t; - } -} - -export template -void -__valarray_copy (_Array<_Tp> __a, _Array __m, _Array<_Tp> __b, size_t __n) -{ - _Tp* __p (__a._M_data); - bool* __ok (__m._M_data); - for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++__ok, ++__p) { - while (! *__ok) { - ++__ok; - ++__p; - } - *__q = *__p; - } -} - -export template -void -__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, _Array __m) -{ - _Tp* __q (__b._M_data); - bool* __ok (__m._M_data); - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++__ok, ++__q) { - while (! *__ok) { - ++__ok; - ++__q; - } - *__q = *__p; - } -} - -export template -void -__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a) -{ - _Tp* __p (__a._M_data); - for (size_t __i=0; __i<__n; ++__i, ++__p) *__p = __e[__i]; -} - -export template -void -__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, - _Array<_Tp> __a, size_t __s) -{ - _Tp* __p (__a._M_data); - for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p = __e[__i]; -} - -export template -void -__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, - _Array<_Tp> __a, _Array __i) -{ - size_t* __j (__i._M_data); - for (size_t __k=0; __k<__n; ++__k, ++__j) __a._M_data[*__j] = __e[__k]; -} - -export template -void -__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, - _Array<_Tp> __a, _Array __m) -{ - bool* __ok (__m._M_data); - _Tp* __p (__a._M_data); - for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) { - while (! *__ok) { - ++__ok; - ++__p; - } - *__p = __e[__i]; - } -} - -} // extern "C++" - -#endif // __VALARRAY_ARRAY_TCC__ - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/std/valarray_meta.h b/libstdc++/std/valarray_meta.h deleted file mode 100644 index 9ad02658707..00000000000 --- a/libstdc++/std/valarray_meta.h +++ /dev/null @@ -1,1046 +0,0 @@ -// The template and inlines for the -*- C++ -*- internal _Meta class. - -// Copyright (C) 1997-1999 Cygnus Solutions -// -// 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. - -// Written by Gabriel Dos Reis - -#ifndef _CPP_VALARRAY_META_H -#define _CPP_VALARRAY_META_H 1 - -// -// 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 class _Constant; - -// -// Unary function application closure. -// -template 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); -}; - -template class _Meta, class _Dom> class _UnFunClos; - -template -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) {} -}; - -template -struct _UnFunClos<_ValArray,_Tp> : _UnFunBase > { - typedef _UnFunBase > _Base; - typedef typename _Base::value_type value_type; - - _UnFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp)) - : _Base (__v, __f) {} -}; - -// -// Binary function application closure. -// -template class _Meta1, - template class Meta2, - class _Dom1, class _Dom2> class _BinFunClos; - -template class _BinFunBase { -public: - typedef typename _Dom1::value_type value_type; - typedef value_type _Vt; - - _BinFunBase (const _Dom1& __e1, const _Dom2& __e2, - _Vt __f (_Vt, _Vt)) - : _M_expr1 (__e1), _M_expr2 (__e2), _M_func (__f) {} - - value_type operator[] (size_t __i) const - { return _M_func (_M_expr1[__i], _M_expr2[__i]); } - size_t size () const { return _M_expr1.size (); } - -private: - const _Dom1& _M_expr1; - const _Dom2& _M_expr2; - _Vt (*_M_func)(_Vt, _Vt); -}; - -template class _BinFunBase1 { -public: - typedef typename _Dom::value_type value_type ; - typedef value_type _Vt; - - _BinFunBase1 (const _Vt& __c, const _Dom& __e, _Vt __f(_Vt, _Vt)) - : _M_expr1 (__c), _M_expr2 (__e), _M_func (__f) {} - - value_type operator[] (size_t __i) const - { return _M_func (_M_expr1, _M_expr2[__i]); } - size_t size () const { return _M_expr2.size (); } - -private: - const _Vt& _M_expr1; - const _Dom& _M_expr2; - _Vt (*_M_func)(_Vt, _Vt); -}; - -template class _BinFunBase2 { -public: - typedef typename _Dom::value_type value_type; - typedef value_type _Vt; - - _BinFunBase2 (const _Dom& __e, const _Vt& __c, _Vt __f(_Vt, _Vt)) - : _M_expr1 (__e), _M_expr2 (__c), _M_func (__f) {} - - value_type operator[] (size_t __i) const - { return _M_func (_M_expr1[__i], _M_expr2); } - size_t size () const { return _M_expr1.size (); } - -private: - const _Dom& _M_expr1; - const _Vt& _M_expr2; - _Vt (*_M_func)(_Vt, _Vt); -}; - -template -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; - - _BinFunClos (const _Dom1& __e1, const _Dom2& __e2, - _Tp __f(_Tp, _Tp)) - : _Base (__e1, __e2, __f) {} -}; - -template -struct _BinFunClos<_ValArray,_ValArray,_Tp,_Tp> - : _BinFunBase, valarray<_Tp> > { - typedef _BinFunBase, valarray<_Tp> > _Base; - typedef _Tp value_type; - - _BinFunClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w, - _Tp __f(_Tp, _Tp)) - : _Base (__v, __w, __f) {} -}; - -template -struct _BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type> - : _BinFunBase<_Dom,valarray > { - typedef typename _Dom::value_type _Tp; - typedef _BinFunBase<_Dom,valarray<_Tp> > _Base; - typedef _Tp value_type; - - _BinFunClos (const _Dom& __e, const valarray<_Tp>& __v, - _Tp __f(_Tp, _Tp)) - : _Base (__e, __v, __f) {} -}; - -template -struct _BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom> - : _BinFunBase,_Dom> { - typedef typename _Dom::value_type _Tp; - typedef _BinFunBase<_Dom,valarray<_Tp> > _Base; - typedef _Tp value_type; - - _BinFunClos (const valarray<_Tp>& __v, const _Dom& __e, - _Tp __f(_Tp, _Tp)) - : _Base (__v, __e, __f) {} -}; - -template -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; - - _BinFunClos (const _Dom& __e, const _Tp& __t, _Tp __f (_Tp, _Tp)) - : _Base (__e, __t, __f) {} -}; - -template -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; - - _BinFunClos (const _Tp& __t, const _Dom& __e, _Tp __f (_Tp, _Tp)) - : _Base (__t, __e, __f) {} -}; - -template -struct _BinFunClos<_ValArray,_Constant,_Tp,_Tp> - : _BinFunBase2 > { - typedef _BinFunBase2 > _Base; - typedef _Tp value_type; - - _BinFunClos (const valarray<_Tp>& __v, const _Tp& __t, - _Tp __f(_Tp, _Tp)) - : _Base (__v, __t, __f) {} -}; - -template -struct _BinFunClos<_Constant,_ValArray,_Tp,_Tp> - : _BinFunBase1 > { - typedef _BinFunBase1 > _Base; - typedef _Tp value_type; - - _BinFunClos (const _Tp& __t, const valarray<_Tp>& __v, - _Tp __f (_Tp, _Tp)) - : _Base (__t, __v, __f) {} -}; - -// -// Apply function taking a value/const reference closure -// - -template class _FunBase { -public: - typedef typename _Dom::value_type value_type; - - _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]); } - size_t size() const { return _M_expr.size ();} - -private: - const _Dom& _M_expr; - value_type (*_M_func)(_Arg); -}; - -template -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) {} -}; - -template -struct _ValFunClos<_ValArray,_Tp> - : _FunBase, _Tp> { - typedef _FunBase, _Tp> _Base; - typedef _Tp value_type; - - _ValFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp)) - : _Base (__v, __f) {} -}; - -template -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) {} -}; - -template -struct _RefFunClos<_ValArray,_Tp> - : _FunBase, const _Tp&> { - typedef _FunBase, const _Tp&> _Base; - typedef _Tp value_type; - - _RefFunClos (const valarray<_Tp>& __v, _Tp __f(const _Tp&)) - : _Base (__v, __f) {} -}; - -// -// Unary expression closure. -// - -template class _Oper, typename _Arg> -class _UnBase { -public: - typedef _Oper _Op; - typedef typename _Op::result_type value_type; - - _UnBase (const _Arg& __e) : _M_expr(__e) {} - value_type operator[] (size_t) const; - size_t size () const { return _M_expr.size (); } - -private: - const _Arg& _M_expr; -}; - -template 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 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, 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. -// - -template class _Oper, typename _FirstArg, typename _SecondArg> -class _BinBase { -public: - typedef _Oper _Op; - typedef typename _Op::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 (); } - -private: - const _FirstArg& _M_expr1; - const _SecondArg& _M_expr2; -}; - -template 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 class _Oper, class _Clos> -class _BinBase2 { -public: - typedef typename _Clos::value_type _Vt; - typedef _Oper<_Vt> _Op; - typedef typename _Op::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 (); } - -private: - const _Clos& _M_expr1; - const _Vt& _M_expr2; -}; - -template 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); } - - -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; - - _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 (); } - -private: - const _Vt& _M_expr1; - const _Clos& _M_expr2; -}; - -template 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 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) {} -}; - -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; - - _BinClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w) - : _Base (__v, __w) {} -}; - -template class _Oper, class _Dom> -struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type> - : _BinBase<_Oper,_Dom,valarray > { - 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,_ValArray,_Expr,typename _Dom::value_type,_Dom> - : _BinBase<_Oper,valarray,_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 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) {} -}; - -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) {} -}; - -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) {} -}; - -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) {} -}; - - -// -// slice_array closure. -// -template class _SBase { -public: - typedef typename _Dom::value_type value_type; - - _SBase (const _Dom& __e, const slice& __s) - : _M_expr (__e), _M_slice (__s) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } - size_t size() const { return _M_slice.size (); } - -private: - const _Dom& _M_expr; - const slice& _M_slice; -}; - -template class _SBase<_Array<_Tp> > { -public: - typedef _Tp value_type; - - _SBase (_Array<_Tp> __a, const slice& __s) - : _M_array (__a._M_data+__s.start()), _M_size (__s.size()), - _M_stride (__s.stride()) {} - value_type operator[] (size_t __i) const - { return _M_array._M_data[__i * _M_stride]; } - size_t size() const { return _M_size; } - -private: - const _Array<_Tp> _M_array; - const size_t _M_size; - const size_t _M_stride; -}; - -template struct _SClos<_Expr,_Dom> : _SBase<_Dom> { - typedef _SBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {} -}; - -template -struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > { - typedef _SBase<_Array<_Tp> > _Base; - typedef _Tp value_type; - - _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {} -}; - -// -// gslice_array closure. -// -template class _GBase { -public: - typedef typename _Dom::value_type value_type; - - _GBase (const _Dom& __e, const valarray& __i) - : _M_expr (__e), _M_index(__i) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_index[__i]]; } - size_t size () const { return _M_index.size(); } - -private: - const _Dom& _M_expr; - const valarray& _M_index; -}; - -template class _GBase<_Array<_Tp> > { -public: - typedef _Tp value_type; - - _GBase (_Array<_Tp> __a, const valarray& __i) - : _M_array (__a), _M_index(__i) {} - value_type operator[] (size_t __i) const - { return _M_array._M_data[_M_index[__i]]; } - size_t size () const { return _M_index.size(); } - -private: - const _Array<_Tp> _M_array; - const valarray& _M_index; -}; - -template struct _GClos<_Expr,_Dom> : _GBase<_Dom> { - typedef _GBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _GClos (const _Dom& __e, const valarray& __i) - : _Base (__e, __i) {} -}; - -template -struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > { - typedef _GBase<_Array<_Tp> > _Base; - typedef typename _Base::value_type value_type; - - _GClos (_Array<_Tp> __a, const valarray& __i) - : _Base (__a, __i) {} -}; - -// -// indirect_array closure -// - -template class _IBase { -public: - typedef typename _Dom::value_type value_type; - - _IBase (const _Dom& __e, const valarray& __i) - : _M_expr (__e), _M_index (__i) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_index[__i]]; } - size_t size() const { return _M_index.size(); } - -private: - const _Dom& _M_expr; - const valarray& _M_index; -}; - -template struct _IClos<_Expr,_Dom> : _IBase<_Dom> { - typedef _IBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _IClos (const _Dom& __e, const valarray& __i) - : _Base (__e, __i) {} -}; - -template -struct _IClos<_ValArray,_Tp> : _IBase > { - typedef _IBase > _Base; - typedef _Tp value_type; - - _IClos (const valarray<_Tp>& __a, const valarray& __i) - : _Base (__a, __i) {} -}; - -// -// class _Expr -// -template class _Expr { -public: - typedef _Tp value_type; - - _Expr (const _Clos&); - - const _Clos& operator() () const; - - value_type operator[] (size_t) const; - valarray operator[] (slice) const; - valarray operator[] (const gslice&) const; - valarray operator[] (const valarray&) const; - valarray operator[] (const valarray&) const; - - _Expr<_UnClos<_Unary_plus,_Expr,_Clos>, value_type> - operator+ () const; - - _Expr<_UnClos, value_type> - operator- () const; - - _Expr<_UnClos<_Bitwise_not,_Expr,_Clos>, value_type> - operator~ () const; - - _Expr<_UnClos, bool> - operator! () const; - - size_t size () const; - value_type sum () const; - - valarray shift (int) const; - valarray cshift (int) const; -// _Meta<_ApplyFunctionWithValue<_Expr>, value_type> -// apply (value_type _M_func (value_type)) const; -// _Meta<_ApplyFunctionWithConstRef<_Expr>, value_type> -// apply (value_type _M_func (const value_type&)) const; - -private: - const _Clos _M_closure; -}; - -template -inline -_Expr<_Clos,_Tp>::_Expr (const _Clos& __c) : _M_closure(__c) {} - -template -inline const _Clos& -_Expr<_Clos,_Tp>::operator() () const -{ return _M_closure; } - -template -inline _Tp -_Expr<_Clos,_Tp>::operator[] (size_t __i) const -{ return _M_closure[__i]; } - -template -inline valarray<_Tp> -_Expr<_Clos,_Tp>::operator[] (slice __s) const -{ return _M_closure[__s]; } - -template -inline valarray<_Tp> -_Expr<_Clos,_Tp>::operator[] (const gslice& __gs) const -{ return _M_closure[__gs]; } - -template -inline valarray<_Tp> -_Expr<_Clos,_Tp>::operator[] (const valarray& __m) const -{ return _M_closure[__m]; } - -template -inline valarray<_Tp> -_Expr<_Clos,_Tp>::operator[] (const valarray& __i) const -{ return _M_closure[__i]; } - -template -inline size_t -_Expr<_Clos,_Tp>::size () const { return _M_closure.size (); } - -// XXX: replace this with a more robust summation algorithm. -template -inline _Tp -_Expr<_Clos,_Tp>::sum () const -{ - _Tp __s(_Tp()); - size_t __n (_M_closure.size ()); - for (size_t __i=0; __i<__n; ++__i) __s += _M_closure[__i]; - return __s; -} - -template -inline _Tp -min (const _Expr<_Dom,_Tp>& __e) -{ - size_t __s (__e.size ()); - _Tp __m (__e[0]); - for (size_t __i=1; __i<__s; ++__i) - if (__m > __e[__i]) __m = __e[__i]; - return __m; -} - -template -inline _Tp -max (const _Expr<_Dom,_Tp>& __e) -{ - size_t __s (__e.size()); - _Tp __m (__e[0]); - for (size_t __i=1; __i<__s; ++__i) - if (__m < __e[__i]) __m = __e[__i]; - return __m; -} - -template -inline _Expr<_UnClos, bool> -_Expr<_Dom,_Tp>::operator! () const -{ - typedef _UnClos _Closure; - return _Expr<_Closure,_Tp> (_Closure(this->_M_closure)); -} - -#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \ -template \ -inline _Expr<_UnClos<_Name,_Expr,_Dom>,_Tp> \ -_Expr<_Dom,_Tp>::operator _Op () const \ -{ \ - typedef _UnClos<_Name,_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) - -#undef _DEFINE_EXPR_UNARY_OPERATOR - - -#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \ -template \ -inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \ - typename _Name::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 _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \ - return _Expr<_Closure,_Value> (_Closure (__v (), __w ())); \ -} \ - \ -template \ -inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \ - typename _Name::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)); \ -} \ - \ -template \ -inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \ - typename _Name::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 ())); \ -} \ - \ -template \ -inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \ - typename _Name::result_type> \ -operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \ - const valarray& __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)); \ -} \ - \ -template \ -inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \ - typename _Name::result_type> \ -operator _Op (const valarray& __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 ())); \ -} - - _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) - -#undef _DEFINE_EXPR_BINARY_OPERATOR - -#define _DEFINE_EXPR_RELATIONAL_OPERATOR(_Op, _Name) \ -template \ -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 \ -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 \ -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 \ -inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \ - bool> \ -operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \ - const valarray& __v) \ -{ \ - typedef typename _Dom::value_type _Tp; \ - typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Tp> _Closure; \ - return _Expr<_Closure,bool> (_Closure (__e (), __v)); \ -} \ - \ -template \ -inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \ - bool> \ -operator _Op (const valarray& __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 \ -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 \ -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_EXPR_UNARY_FUNCTION(abs) - _DEFINE_EXPR_UNARY_FUNCTION(cos) - _DEFINE_EXPR_UNARY_FUNCTION(acos) - _DEFINE_EXPR_UNARY_FUNCTION(cosh) - _DEFINE_EXPR_UNARY_FUNCTION(sin) - _DEFINE_EXPR_UNARY_FUNCTION(asin) - _DEFINE_EXPR_UNARY_FUNCTION(sinh) - _DEFINE_EXPR_UNARY_FUNCTION(tan) - _DEFINE_EXPR_UNARY_FUNCTION(tanh) - _DEFINE_EXPR_UNARY_FUNCTION(atan) - _DEFINE_EXPR_UNARY_FUNCTION(exp) - _DEFINE_EXPR_UNARY_FUNCTION(log) - _DEFINE_EXPR_UNARY_FUNCTION(log10) - _DEFINE_EXPR_UNARY_FUNCTION(sqrt) - -#undef _DEFINE_EXPR_UNARY_FUNCTION - - -#define _DEFINE_EXPR_BINARY_FUNCTION(_Name) \ -template \ -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 \ -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& __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 \ -inline _Expr<_BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>, \ - typename _Dom::value_type> \ -_Name (const 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 \ -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 \ -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 \ -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 \ -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 \ -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_EXPR_BINARY_FUNCTION(atan2) -_DEFINE_EXPR_BINARY_FUNCTION(pow) - -#undef _DEFINE_EXPR_BINARY_FUNCTION - -#endif // _CPP_VALARRAY_META_H - -// Local Variables: -// mode:c++ -// End: diff --git a/libstdc++/stdexcept b/libstdc++/stdexcept deleted file mode 100644 index 69e9627d577..00000000000 --- a/libstdc++/stdexcept +++ /dev/null @@ -1,97 +0,0 @@ -// Methods for Exception Support for -*- C++ -*- -// Copyright (C) 1994, 1995, 1997 Free Software Foundation - -// This file is part of the GNU ANSI 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, if you link this library with files -// compiled with a GNU compiler to produce an executable, this does not 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. - -// Written by Mike Stump based upon the specification in the 20 September 1994 -// C++ working paper, ANSI document X3J16/94-0158. - -#ifndef __STDEXCEPT__ -#define __STDEXCEPT__ - -#ifdef __GNUG__ -#pragma interface "stdexcept" -#endif - -#include -#include - -extern "C++" { - -namespace std { - -class logic_error : public exception { - string _what; -public: - logic_error(const string& what_arg): _what (what_arg) { } - virtual const char* what () const { return _what.c_str (); } -}; - -class domain_error : public logic_error { -public: - domain_error (const string& what_arg): logic_error (what_arg) { } -}; - -class invalid_argument : public logic_error { -public: - invalid_argument (const string& what_arg): logic_error (what_arg) { } -}; - -class length_error : public logic_error { -public: - length_error (const string& what_arg): logic_error (what_arg) { } -}; - -class out_of_range : public logic_error { -public: - out_of_range (const string& what_arg): logic_error (what_arg) { } -}; - -class runtime_error : public exception { - string _what; -public: - runtime_error(const string& what_arg): _what (what_arg) { } - virtual const char* what () const { return _what.c_str (); } -protected: - runtime_error(): exception () { } -}; - -class range_error : public runtime_error { -public: - range_error (const string& what_arg): runtime_error (what_arg) { } -}; - -class overflow_error : public runtime_error { -public: - overflow_error (const string& what_arg): runtime_error (what_arg) { } -}; - -class underflow_error : public runtime_error { -public: - underflow_error (const string& what_arg): runtime_error (what_arg) { } -}; - -} // namespace std - -} // extern "C++" - -#endif diff --git a/libstdc++/stdexcepti.cc b/libstdc++/stdexcepti.cc deleted file mode 100644 index 9c02c71f497..00000000000 --- a/libstdc++/stdexcepti.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Implementation file for Exception Support for -*- C++ -*- -// This file is part of the GNU ANSI C++ Library. - -#ifdef __GNUG__ -#pragma implementation "stdexcept" -#endif - -#include - -// Entry points for string. - -void -__out_of_range (const char *s) -{ - throw std::out_of_range (s); -} - -void __length_error (const char *s) -{ - throw std::length_error (s); -} diff --git a/libstdc++/stl.h b/libstdc++/stl.h deleted file mode 100644 index 4b270742c9c..00000000000 --- a/libstdc++/stl.h +++ /dev/null @@ -1,15 +0,0 @@ -// -*- C++ -*- compatibility header. -// This file is part of the GNU ANSI C++ Library. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/libstdc++/stl/ChangeLog b/libstdc++/stl/ChangeLog deleted file mode 100644 index 8c1f2e31d03..00000000000 --- a/libstdc++/stl/ChangeLog +++ /dev/null @@ -1,387 +0,0 @@ -2000-11-08 Jan van Male - Gerald Pfeifer - - * README: Fix typo. Remove incorrect reference to Cygnus. - -2000-08-22 Geoff Berry - - * bitset (bitset::_M_is_any): Don't use __BITSET_WORDS macro - on _Nw since _Nw is already the number of words in the bitset. - -2000-07-10 Martin v. Löwis (loewis@informatik.hu-berlin.de) - - * stl_function.h (bind1st, bind2nd): Rename __opr to __oper, - as __opr is used internally by egcs. - * stl_numeric.h (__power, power): Likewise. - -2000-07-10 Alexandre Oliva - - * stl_algo.h (transform): Rename __opr to __oper, as __opr is used - internally by egcs. - Reported by Harri Porten - -2000-01-19 Gabriel Dos Reis - - * stl_iterator.h: Make it possible to use standard class - `iterator'. - -1999-12-14 Mumit Khan - - * stl_config.h (__MINGW32__): Define __STL_WIN32THREADS for thread - safe runtime. - -1999-11-10 Benjamin Kosnik - Matthias Klose - - * stl_rope.h: Fix initialization order. - * stl_deque.h: Use static_casts(signed_type). - -1999-11-06 Martin v. Löwis - - * bitset (class bitset): Declare reference as our friend. - * bitset: Include limits.h. - -1999-08-08 Alexandre Oliva - - * pthread_alloc: Solaris' ctype.h defines _U to 01; use _Up as - template parameter instead. - -1999-06-18 Martin von Löwis - - * stl_queue.h: Rename _M_c to c, and _M_comp to comp. - -1999-05-17 Mark Kettenis - - * stl_config.h: Only define __STL_PTHREADS with GLIBC >= 2 for - Linux. - -Mon May 17 03:33:47 1999 Mumit Khan - - * stl_config.h (__CYGWIN__): Cygwin newlib RTL lacks drand48. - -1999-05-07 Ulrich Drepper - - * stl_alloc.h: Make it possible to compile with __USE_MALLOC. - -Tue Apr 13 00:32:57 1999 Mumit Khan - - * stl_config.h (__MINGW32__): Mingw32 RTL lacks drand48. - -Sun Apr 11 23:48:30 1999 Jeffrey A Law (law@cygnus.com) - - * bitset: Re-install Alexandre's lost patch from 1998-11-27. - -1999-01-20 Ulrich Drepper - - * stl_construct.h (__destroy_aux): Use != instead of < for - ForwardIterator comparison. - Patch by jmaurer@menuett.rhein-main.de (Jens Maurer). - -1999-01-20 Mark Mitchell - - * stl_config.h (__STL_USE_NAMESPACES): Define. - -1998-11-27 Alexandre Oliva - - * bitset: Explicitly convert basic_string<...>::npos to size_t in - default argument to constructor, to avoid parse error at `>'. - (__STL_EXPLICIT_FUNCTION_TMPL_ARGS): Replace #if with #ifdef. - -1998-11-01 Mark Mitchell - - * stl_alloc.h (default_alloc_template::_S_free_list): Don't - qualify _NFREELISTS. - -1998-10-11 Mark Mitchell - - * stl_config.h (__SGI_STL_USE_AUTO_PTR_CONVERSIONS): Define. - * memory (auto_ptr::operator auto_ptr_ref<_Tp1>): Fix typo. - (auto_ptr::operator auto_ptr<_Tp1>): Add missing - semicolon. - -1998-09-03 Jason Merrill - - * stl_config.h: Define __STL_HAS_WCHAR_T, - __STL_MEMBER_TEMPLATE_CLASSES, __STL_HAS_NAMESPACES, - __STL_NO_NAMESPACES and __STL_LONG_LONG. - -1998-09-02 Jason Merrill - - * algorithm alloc.h defalloc.h hash_map.h hash_set.h iterator - memory pthread_alloc pthread_alloc.h rope ropeimpl.h stl_algo.h - stl_algobase.h stl_alloc.h stl_bvector.h stl_config.h - stl_construct.h stl_deque.h stl_function.h stl_hash_fun.h - stl_hash_map.h stl_hash_set.h stl_hashtable.h stl_heap.h - stl_iterator.h stl_list.h stl_map.h stl_multimap.h stl_multiset.h - stl_numeric.h stl_pair.h stl_queue.h stl_raw_storage_iter.h - stl_relops.h stl_rope.h stl_set.h stl_slist.h stl_stack.h - stl_tempbuf.h stl_tree.h stl_uninitialized.h stl_vector.h - tempbuf.h type_traits.h: Update to SGI STL 3.11. - -Fri Jul 10 15:20:09 1998 Klaus-Georg Adams - - * stl_tempbuf.h (temporary_buffer): Add missing typename. - * type_traits.h: update comments. - -Sun Jun 28 00:49:42 1998 Jeffrey A Law (law@cygnus.com) - - * stl_config.h (__STL_PTHREADS): Don't define for glibc 2 if - _G_USING_THUNKS is not defined. - -1998-04-07 18:32 Ulrich Drepper - - * stl_hashtable.h (__stl_prime_list): Mark last two numbers as - unsigned long since they are otherwise too large for long int on - 32bit machines. - -Fri Feb 20 16:15:05 1998 H.J. Lu (hjl@gnu.org) - Jason Merrill - - * ropeimpl.h: Check __STL_PTHREADS instead of _PTHREADS. - * stl_alloc.h: Ditto. - * stl_config.h: Ditto. - * stl_rope.h: Ditto. - - * stl_config.h: include <_G_config.h> if __GNUG__ is defined. - (__STL_PTHREADS): Defined if _PTHREADS is defined or - __GLIBC__ >= 2. - -Tue Jan 27 12:01:25 1998 Jason Merrill - - * stl_algo.h (__lg): Fix for n == 0. - -Sat Nov 8 00:45:17 1997 Jason Merrill - - * stl_hash_set.h (swap): Fix typo. - -Fri Nov 7 10:27:40 1997 Jason Merrill - - * stl_hashtable.h: Fix typo. - -Thu Nov 6 11:19:09 1997 Jason Merrill - - * stl_algo.h, stl_algobase.h, stl_bvector.h, - stl_deque.h: Update to October 28 SGI release. - -Sun Nov 2 12:14:56 1997 Jason Merrill - - * algo.h, algobase.h, alloc.h, bvector.h, defalloc.h, deque.h, - function.h, hash_map.h, hash_set.h, hashtable.h, heap.h, iterator.h, - list.h, map.h, multimap.h, multiset.h, pair.h, pthread_alloc.h, - rope.h, ropeimpl.h, set.h, slist.h, stack.h, stl_config.h, tempbuf.h, - tree.h, type_traits.h, vector.h: Update to October 27 SGI snapshot. - * algorithm, deque, functional, hash_map, hash_set, iterator, list, - map, memory, numeric, pthread_alloc, queue, rope, set, slist, stack, - stl_algo.h, stl_algobase.h, stl_alloc.h, stl_bvector.h, - stl_construct.h, stl_deque.h, stl_function.h, stl_hash_fun.h, - stl_hash_map.h, stl_hash_set.h, stl_hashtable.h, stl_heap.h, - stl_iterator.h, stl_list.h, stl_map.h, stl_multimap.h, stl_multiset.h, - stl_numeric.h, stl_pair.h, stl_queue.h, stl_raw_storage_iter.h, - stl_relops.h, stl_rope.h, stl_set.h, stl_slist.h, stl_stack.h, - stl_tempbuf.h, stl_tree.h, stl_uninitialized.h, stl_vector.h, - utility, vector: New files in October 27 SGI snapshot. - -Fri Oct 17 19:07:42 1997 Jason Merrill - - * tree.h, vector.h: Fix accidental divergence from SGI release. - -Tue Sep 9 19:47:28 1997 Jason Merrill - - * algo.h, algobase.h, alloc.h, bvector.h, deque.h, hashtable.h, - iterator.h, list.h, rope.h, ropeimpl.h, slist.h, stl_config.h, - tree.h, vector.h: Update To September 8 SGI release. - -Tue Sep 9 17:38:47 1997 Mark Mitchell - - * stl_config.h (__STL_MEMBER_TEMPLATES): Enable. - -Tue Aug 5 17:06:01 1997 Jason Merrill - - * deque.h, function.h, hashtable.h, list.h, rope.h, ropeimpl.h, - tree.h: Update to July 31 SGI release. - -Fri Jul 18 10:06:56 1997 Jason Merrill - - * algo.h, defalloc.h, hashtable.h, rope.h, ropeimpl.h, slist.h: - Update to June 30 SGI release. - -Fri Jul 04 02:17:15 1997 Ulrich Drepper - - * tree.h (rb_tree): Reverse order of member initializations - to prevent warnings. - -Sun Jun 15 18:17:21 1997 Jason Merrill - - * *.h: Update to 6/13 SGI release. - -Fri May 23 10:56:18 1997 Jason Merrill - - * stl_config.h: Add support for exceptions with g++. - - * *.h: Update to 5/8 SGI release. - -Thu Apr 24 19:00:23 1997 Jason Merrill - - * *.h: Update to 3/24 SGI release. - -Wed Feb 19 18:19:18 1997 Jason Merrill - - * *.h: Update to 2/18 SGI release. - - * bool.h: Lose. - -Mon Feb 10 16:33:23 1997 Jason Merrill - - * alloc.h: Don't define __USE_MALLOC for g++. - * bool.h: Lose g++ case. - - * *.h: Update to 2/4 SGI release. - -Mon Jan 13 14:39:16 1997 Jason Merrill - - * *.h: Update to 1/8 SGI release. - -Mon Sep 30 17:56:43 1996 Jason Merrill - - * alloc.h (__unlock): Never use __lock_release. - -Fri Sep 27 19:03:06 1996 Jason Merrill - - * alloc.h (__default_alloc_template): lock is a friend. - -Thu Sep 19 20:10:37 1996 Jason Merrill - - Propagate these changes to new STL code: - * tree.h: Rearrange member initializers in rb_tree constructors. - * vector.h (insert): Cast iterator difference to size_type to - avoid warning. - - * *.h: Update to SGI snapshot (fixed). - * *.c, Makefile.in, configure.in: Removed. - -Sat Sep 14 09:43:06 1996 Jason Merrill - - * deque.h, list.h, tree.h: Remove kludge obsoleted by new - overloading code. - -Sat Aug 10 14:59:50 1996 Jason Merrill - - * tempbuf.cc (__stl_temp_buffer): Align like a pointer. - -Wed Jun 26 13:00:44 1996 Jason Merrill - - * iterator.h: Add default template parameters. - -Wed Apr 24 10:45:22 1996 Doug Evans - - * Makefile.in (tempbuf.o,random.o): Add rules for SunOS VPATH. - -Fri Apr 5 17:52:31 1996 Per Bothner - - * configure.in (EXTRA_MOSTLYCLEAN): New, to remove stl.list. - -Fri Mar 22 14:58:30 1996 Jason Merrill - - Propagate these changes to new STL code: - * tree.h: Rearrange member initializers in rb_tree constructors. - * vector.h (insert): Cast iterator difference to size_type to - avoid warning. - -Sun Mar 10 07:49:03 1996 Jason Merrill - - * deque.h (distance_type): Add overload for g++. - From Joe Buck. - -Thu Feb 22 14:07:12 1996 Jason Merrill - - * bool.h: Revert. - * algo.h bvector.h deque.h function.h iterator.h list.h - pair.h stack.h tree.h vector.h: Wrap #include with - #ifndef __GNUG__. - * defalloc.h list.h deque.h tree.h: Use __GNUG__ to control - workarounds. - -Wed Feb 21 17:13:02 1996 Jason Merrill - - * bool.h (TRUE, FALSE): Define for people expecting the bool.h - from libg++. Is this a good idea? - -Tue Feb 20 18:40:02 1996 Jason Merrill - - * algo.h bool.h bvector.h defalloc.h deque.h function.h heap.h - iterator.h list.h map.h pair.h random.cc stack.h tree.c tree.h - vector.h: Revert to HP release with workarounds for missing - overloading functionality. - * Makefile.in (STL_OBJECTS): Remove tree.o. - -Thu Nov 9 17:05:23 1995 Jason Merrill - - * algo.h algobase.h bvector.h defalloc.h deque.h function.h heap.h - iterator.h list.h map.h multimap.h multiset.h pair.h projectn.h - set.h stack.h tempbuf.h tree.h vector.h: Wrap #include - with #ifndef __GNUG__. - -Thu Nov 2 17:05:44 1995 Jason Merrill - - * deque.h (deque::insert): Fix merge typo. - * vector.h (value_type): Lose. - -Thu Nov 2 14:33:47 1995 Per Bothner - - * algo.h, algobase.h, deque.h, function.h, list.h, pair.h, random.cc: - Merge in Oct 31 1995 release from HP. - -Fri Aug 11 17:11:12 1995 Per Bothner - - * list.h: Avoid duplicate construction and destruction of list_nodes. - Patch from Klamer Schutte . - -Fri Aug 11 16:45:18 1995 Per Bothner - - * algo.h, algobase.h, deque.h: Merged in Jul 12 1995 release from HP. - -Mon Jun 5 18:38:56 1995 Jason Merrill - - * Makefile.in (stl.list): Depend on stamp-picdir. - -Wed May 17 02:30:47 1995 Jason Merrill - - * tree.h: Rearrange member initializers in rb_tree constructors. - - * Update to HP's February 7, 1995 release. - -Fri May 5 10:45:31 1995 Mike Stump - - * random.cc (seed): Move `for' decl out of `for' statement. - -Wed Apr 26 13:09:16 1995 Jason Merrill - - * configure.in (XCXXINCLUDES): Rename. - -Wed Mar 29 19:24:56 1995 Jason Merrill - - * tree.h (insert): Return a value. - - * vector.h (insert): Cast iterator difference to size_type to - avoid warning. - -Sun Feb 12 09:12:17 1995 Mike Stump - - * tree.h (rb_tree::max_size): Add definition when using GNU - workaround. - -Thu Jan 12 01:37:42 1995 deanm@medulla.LABS.TEK.COM (Dean Messing) - - * configure.in (LIBDIR): Set to yes. - -Fri Dec 30 18:26:20 1994 Mike Stump - - * iterator.h: Add default template parameters where possible. - -Fri Dec 30 16:29:39 1994 Mike Stump - - * algo.h: Change rand to __rand to fix make check on linux systems. - -Tue Nov 29 15:30:30 1994 Per Bothner - - * Initial check-in, based on HP's October 21, 1994. diff --git a/libstdc++/stl/README b/libstdc++/stl/README deleted file mode 100644 index 6cf254f36e4..00000000000 --- a/libstdc++/stl/README +++ /dev/null @@ -1,13 +0,0 @@ -This directory contains an SGI release of the C++ Standard Template -Library, slightly modified to work with g++. - -Note that this is based on a pre-Draft Standard for C++. -Things are likely to change. For example, the header file names -are very likely to change. The Allocator interface will change. Etc, etc. -WE MAKE NO COMMITMENT (yet) TO SUPPORT BACKWARD COMPATIBILITY FOR STL. - -For examples of things that should work, look in the ../tests directory. - -DOCUMENTATION: -See http://www.sgi.com/Technology/STL/ or http://www.dinkumware.com/ -on the World-Wide Web. diff --git a/libstdc++/stl/algo.h b/libstdc++/stl/algo.h deleted file mode 100644 index 1707868c7c4..00000000000 --- a/libstdc++/stl/algo.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_ALGO_H -#define __SGI_STL_ALGO_H - -#include -#include -#include -#include - -#ifdef __STL_USE_NAMESPACES - -// Names from -using __STD::for_each; -using __STD::find; -using __STD::find_if; -using __STD::adjacent_find; -using __STD::count; -using __STD::count_if; -using __STD::search; -using __STD::search_n; -using __STD::swap_ranges; -using __STD::transform; -using __STD::replace; -using __STD::replace_if; -using __STD::replace_copy; -using __STD::replace_copy_if; -using __STD::generate; -using __STD::generate_n; -using __STD::remove; -using __STD::remove_if; -using __STD::remove_copy; -using __STD::remove_copy_if; -using __STD::unique; -using __STD::unique_copy; -using __STD::reverse; -using __STD::reverse_copy; -using __STD::rotate; -using __STD::rotate_copy; -using __STD::random_shuffle; -using __STD::random_sample; -using __STD::random_sample_n; -using __STD::partition; -using __STD::stable_partition; -using __STD::sort; -using __STD::stable_sort; -using __STD::partial_sort; -using __STD::partial_sort_copy; -using __STD::nth_element; -using __STD::lower_bound; -using __STD::upper_bound; -using __STD::equal_range; -using __STD::binary_search; -using __STD::merge; -using __STD::inplace_merge; -using __STD::includes; -using __STD::set_union; -using __STD::set_intersection; -using __STD::set_difference; -using __STD::set_symmetric_difference; -using __STD::min_element; -using __STD::max_element; -using __STD::next_permutation; -using __STD::prev_permutation; -using __STD::find_first_of; -using __STD::find_end; -using __STD::is_sorted; -using __STD::is_heap; - -// Names from stl_heap.h -using __STD::push_heap; -using __STD::pop_heap; -using __STD::make_heap; -using __STD::sort_heap; - -// Names from -using __STD::accumulate; -using __STD::inner_product; -using __STD::partial_sum; -using __STD::adjacent_difference; -using __STD::power; -using __STD::iota; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_ALGO_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/algobase.h b/libstdc++/stl/algobase.h deleted file mode 100644 index f35e7af4a97..00000000000 --- a/libstdc++/stl/algobase.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_ALGOBASE_H -#define __SGI_STL_ALGOBASE_H - -#ifndef __SGI_STL_PAIR_H -#include -#endif -#ifndef __SGI_STL_ITERATOR_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_ALGOBASE_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H -#include -#endif - -#ifdef __STL_USE_NAMESPACES - -// Names from stl_algobase.h -using __STD::iter_swap; -using __STD::swap; -using __STD::min; -using __STD::max; -using __STD::copy; -using __STD::copy_backward; -using __STD::copy_n; -using __STD::fill; -using __STD::fill_n; -using __STD::mismatch; -using __STD::equal; -using __STD::lexicographical_compare; -using __STD::lexicographical_compare_3way; - -// Names from stl_uninitialized.h -using __STD::uninitialized_copy; -using __STD::uninitialized_copy_n; -using __STD::uninitialized_fill; -using __STD::uninitialized_fill_n; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_ALGOBASE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/algorithm b/libstdc++/stl/algorithm deleted file mode 100644 index 1ba584f06d4..00000000000 --- a/libstdc++/stl/algorithm +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_ALGORITHM -#define __SGI_STL_ALGORITHM - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_ALGORITHM */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/alloc.h b/libstdc++/stl/alloc.h deleted file mode 100644 index f99a862316e..00000000000 --- a/libstdc++/stl/alloc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -#ifndef __SGI_STL_ALLOC_H -#define __SGI_STL_ALLOC_H - -#ifndef __STL_CONFIG_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_ALLOC_H -#include -#endif - -#ifdef __STL_USE_NAMESPACES - -using __STD::__malloc_alloc_template; -using __STD::malloc_alloc; -using __STD::simple_alloc; -using __STD::debug_alloc; -using __STD::__default_alloc_template; -using __STD::alloc; -using __STD::single_client_alloc; -#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG -using __STD::__malloc_alloc_oom_handler; -#endif /* __STL_STATIC_TEMPLATE_MEMBER_BUG */ -#ifdef __STL_USE_STD_ALLOCATORS -using __STD::allocator; -#endif /* __STL_USE_STD_ALLOCATORS */ - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_ALLOC_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/bitset b/libstdc++/stl/bitset deleted file mode 100644 index 3b702ab1f4c..00000000000 --- a/libstdc++/stl/bitset +++ /dev/null @@ -1,1066 +0,0 @@ -/* - * Copyright (c) 1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_BITSET -#define __SGI_STL_BITSET - -// This implementation of bitset<> has a second template parameter, -// _WordT, which defaults to unsigned long. *YOU SHOULD NOT USE -// THIS FEATURE*. It is experimental, and it may be removed in -// future releases. - -// A bitset of size N, using words of type _WordT, will have -// N % (sizeof(_WordT) * CHAR_BIT) unused bits. (They are the high- -// order bits in the highest word.) It is a class invariant -// of class bitset<> that those unused bits are always zero. - -// Most of the actual code isn't contained in bitset<> itself, but in the -// base class _Base_bitset. The base class works with whole words, not with -// individual bits. This allows us to specialize _Base_bitset for the -// important special case where the bitset is only a single word. - -// The C++ standard does not define the precise semantics of operator[]. -// In this implementation the const version of operator[] is equivalent -// to test(), except that it does no range checking. The non-const version -// returns a reference to a bit, again without doing any range checking. - - -#include // for size_t -#include // for CHAR_BIT -#include -#include // for invalid_argument, out_of_range, overflow_error -#include // for istream, ostream - -#define __BITS_PER_WORDT(__wt) (CHAR_BIT*sizeof(__wt)) -#define __BITSET_WORDS(__n,__wt) \ - ((__n) < 1 ? 1 : ((__n) + __BITS_PER_WORDT(__wt) - 1)/__BITS_PER_WORDT(__wt)) - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1209 -#endif - -// structure to aid in counting bits -template -struct _Bit_count { - static unsigned char _S_bit_count[256]; -}; - -// Mapping from 8 bit unsigned integers to the index of the first one -// bit: -template -struct _First_one { - static unsigned char _S_first_one[256]; -}; - -// -// Base class: general case. -// - -template -struct _Base_bitset { - _WordT _M_w[_Nw]; // 0 is the least significant word. - - _Base_bitset( void ) { _M_do_reset(); } - - _Base_bitset(unsigned long __val); - - static size_t _S_whichword( size_t __pos ) { - return __pos / __BITS_PER_WORDT(_WordT); - } - static size_t _S_whichbyte( size_t __pos ) { - return (__pos % __BITS_PER_WORDT(_WordT)) / CHAR_BIT; - } - static size_t _S_whichbit( size_t __pos ) { - return __pos % __BITS_PER_WORDT(_WordT); - } - static _WordT _S_maskbit( size_t __pos ) { - return (static_cast<_WordT>(1)) << _S_whichbit(__pos); - } - - _WordT& _M_getword(size_t __pos) { return _M_w[_S_whichword(__pos)]; } - _WordT _M_getword(size_t __pos) const { return _M_w[_S_whichword(__pos)]; } - - _WordT& _M_hiword() { return _M_w[_Nw - 1]; } - _WordT _M_hiword() const { return _M_w[_Nw - 1]; } - - void _M_do_and(const _Base_bitset<_Nw,_WordT>& __x) { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] &= __x._M_w[__i]; - } - } - - void _M_do_or(const _Base_bitset<_Nw,_WordT>& __x) { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] |= __x._M_w[__i]; - } - } - - void _M_do_xor(const _Base_bitset<_Nw,_WordT>& __x) { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] ^= __x._M_w[__i]; - } - } - - void _M_do_left_shift(size_t __shift); - - void _M_do_right_shift(size_t __shift); - - void _M_do_flip() { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] = ~_M_w[__i]; - } - } - - void _M_do_set() { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] = ~static_cast<_WordT>(0); - } - } - - void _M_do_reset() { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] = 0; - } - } - - bool _M_is_equal(const _Base_bitset<_Nw,_WordT>& __x) const { - for (size_t __i = 0; __i < _Nw; ++__i) { - if (_M_w[__i] != __x._M_w[__i]) - return false; - } - return true; - } - - bool _M_is_any() const { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - if ( _M_w[__i] != static_cast<_WordT>(0) ) - return true; - } - return false; - } - - size_t _M_do_count() const { - size_t __result = 0; - const unsigned char* __byte_ptr = (const unsigned char*)_M_w; - const unsigned char* __end_ptr = (const unsigned char*)(_M_w+_Nw); - - while ( __byte_ptr < __end_ptr ) { - __result += _Bit_count::_S_bit_count[*__byte_ptr]; - __byte_ptr++; - } - return __result; - } - - unsigned long _M_do_to_ulong() const; - - // find first "on" bit - size_t _M_do_find_first(size_t __not_found) const; - - // find the next "on" bit that follows "prev" - size_t _M_do_find_next(size_t __prev, size_t __not_found) const; -}; - -// -// Definitions of non-inline functions from _Base_bitset. -// - -template -_Base_bitset<_Nw, _WordT>::_Base_bitset(unsigned long __val) -{ - _M_do_reset(); - const size_t __n = min(sizeof(unsigned long)*CHAR_BIT, - __BITS_PER_WORDT(_WordT)*_Nw); - for(size_t __i = 0; __i < __n; ++__i, __val >>= 1) - if ( __val & 0x1 ) - _M_getword(__i) |= _S_maskbit(__i); -} - -template -void _Base_bitset<_Nw, _WordT>::_M_do_left_shift(size_t __shift) -{ - if (__shift != 0) { - const size_t __wshift = __shift / __BITS_PER_WORDT(_WordT); - const size_t __offset = __shift % __BITS_PER_WORDT(_WordT); - const size_t __sub_offset = __BITS_PER_WORDT(_WordT) - __offset; - size_t __n = _Nw - 1; - for ( ; __n > __wshift; --__n) - _M_w[__n] = (_M_w[__n - __wshift] << __offset) | - (_M_w[__n - __wshift - 1] >> __sub_offset); - if (__n == __wshift) - _M_w[__n] = _M_w[0] << __offset; - for (size_t __n1 = 0; __n1 < __n; ++__n1) - _M_w[__n1] = static_cast<_WordT>(0); - } -} - -template -void _Base_bitset<_Nw, _WordT>::_M_do_right_shift(size_t __shift) -{ - if (__shift != 0) { - const size_t __wshift = __shift / __BITS_PER_WORDT(_WordT); - const size_t __offset = __shift % __BITS_PER_WORDT(_WordT); - const size_t __sub_offset = __BITS_PER_WORDT(_WordT) - __offset; - const size_t __limit = _Nw - __wshift - 1; - size_t __n = 0; - for ( ; __n < __limit; ++__n) - _M_w[__n] = (_M_w[__n + __wshift] >> __offset) | - (_M_w[__n + __wshift + 1] << __sub_offset); - _M_w[__limit] = _M_w[_Nw-1] >> __offset; - for (size_t __n1 = __limit + 1; __n1 < _Nw; ++__n1) - _M_w[__n1] = static_cast<_WordT>(0); - } -} - -template -unsigned long _Base_bitset<_Nw, _WordT>::_M_do_to_ulong() const -{ - const overflow_error __overflow("bitset"); - - if (sizeof(_WordT) >= sizeof(unsigned long)) { - for (size_t __i = 1; __i < _Nw; ++__i) - if (_M_w[__i]) - __STL_THROW(__overflow); - - const _WordT __mask = static_cast<_WordT>(static_cast(-1)); - if (_M_w[0] & ~__mask) - __STL_THROW(__overflow); - - return static_cast(_M_w[0] & __mask); - } - else { // sizeof(_WordT) < sizeof(unsigned long). - const size_t __nwords = - (sizeof(unsigned long) + sizeof(_WordT) - 1) / sizeof(_WordT); - - size_t __min_nwords = __nwords; - if (_Nw > __nwords) { - for (size_t __i = __nwords; __i < _Nw; ++__i) - if (_M_w[__i]) - __STL_THROW(__overflow); - } - else - __min_nwords = _Nw; - - // If unsigned long is 8 bytes and _WordT is 6 bytes, then an unsigned - // long consists of all of one word plus 2 bytes from another word. - const size_t __part = sizeof(unsigned long) % sizeof(_WordT); - - if (__part != 0 && __nwords <= _Nw && - (_M_w[__min_nwords - 1] >> ((sizeof(_WordT) - __part) * CHAR_BIT)) != 0) - __STL_THROW(__overflow); - - unsigned long __result = 0; - for (size_t __i = 0; __i < __min_nwords; ++__i) { - __result |= static_cast( - _M_w[__i]) << (__i * sizeof(_WordT) * CHAR_BIT); - } - return __result; - } -} // End _M_do_to_ulong - -template -size_t _Base_bitset<_Nw, _WordT>::_M_do_find_first(size_t __not_found) const -{ - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _WordT __thisword = _M_w[__i]; - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*__BITS_PER_WORDT(_WordT) + __j*CHAR_BIT + - _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - } - // not found, so return an indication of failure. - return __not_found; -} - -template -size_t -_Base_bitset<_Nw, _WordT>::_M_do_find_next(size_t __prev, - size_t __not_found) const -{ - // make bound inclusive - ++__prev; - - // check out of bounds - if ( __prev >= _Nw * __BITS_PER_WORDT(_WordT) ) - return __not_found; - - // search first word - size_t __i = _S_whichword(__prev); - _WordT __thisword = _M_w[__i]; - - // mask off bits below bound - __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); - - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - // get first byte into place - __thisword >>= _S_whichbyte(__prev) * CHAR_BIT; - for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*__BITS_PER_WORDT(_WordT) + __j*CHAR_BIT + - _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - - // check subsequent words - __i++; - for ( ; __i < _Nw; __i++ ) { - _WordT __thisword = _M_w[__i]; - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*__BITS_PER_WORDT(_WordT) + __j*CHAR_BIT + - _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - } - - // not found, so return an indication of failure. - return __not_found; -} // end _M_do_find_next - - -// ------------------------------------------------------------ - -// -// Base class: specialization for a single word. -// - -template -struct _Base_bitset<1, _WordT> { - _WordT _M_w; - - _Base_bitset( void ) { _M_do_reset(); } - - _Base_bitset(unsigned long __val); - - static size_t _S_whichword( size_t __pos ) { - return __pos / __BITS_PER_WORDT(_WordT); - } - static size_t _S_whichbyte( size_t __pos ) { - return (__pos % __BITS_PER_WORDT(_WordT)) / CHAR_BIT; - } - static size_t _S_whichbit( size_t __pos ) { - return __pos % __BITS_PER_WORDT(_WordT); - } - static _WordT _S_maskbit( size_t __pos ) { - return (static_cast<_WordT>(1)) << _S_whichbit(__pos); - } - - _WordT& _M_getword(size_t) { return _M_w; } - _WordT _M_getword(size_t) const { return _M_w; } - - _WordT& _M_hiword() { return _M_w; } - _WordT _M_hiword() const { return _M_w; } - - void _M_do_and(const _Base_bitset<1,_WordT>& __x) { _M_w &= __x._M_w; } - void _M_do_or(const _Base_bitset<1,_WordT>& __x) { _M_w |= __x._M_w; } - void _M_do_xor(const _Base_bitset<1,_WordT>& __x) { _M_w ^= __x._M_w; } - void _M_do_left_shift(size_t __shift) { _M_w <<= __shift; } - void _M_do_right_shift(size_t __shift) { _M_w >>= __shift; } - void _M_do_flip() { _M_w = ~_M_w; } - void _M_do_set() { _M_w = ~static_cast<_WordT>(0); } - void _M_do_reset() { _M_w = 0; } - - bool _M_is_equal(const _Base_bitset<1,_WordT>& __x) const { - return _M_w == __x._M_w; - } - bool _M_is_any() const { - return _M_w != 0; - } - - size_t _M_do_count() const { - size_t __result = 0; - const unsigned char* __byte_ptr = (const unsigned char*)&_M_w; - const unsigned char* __end_ptr = ((const unsigned char*)&_M_w)+sizeof(_M_w); - while ( __byte_ptr < __end_ptr ) { - __result += _Bit_count::_S_bit_count[*__byte_ptr]; - __byte_ptr++; - } - return __result; - } - - unsigned long _M_do_to_ulong() const { - if (sizeof(_WordT) <= sizeof(unsigned long)) - return static_cast(_M_w); - else { - const _WordT __mask = static_cast<_WordT>(static_cast(-1)); - if (_M_w & ~__mask) - __STL_THROW(overflow_error("bitset")); - return static_cast(_M_w); - } - } - - size_t _M_do_find_first(size_t __not_found) const; - - // find the next "on" bit that follows "prev" - size_t _M_do_find_next(size_t __prev, size_t __not_found) const; - -}; - -// -// Definitions of non-inline functions from the single-word version of -// _Base_bitset. -// - -template -_Base_bitset<1, _WordT>::_Base_bitset(unsigned long __val) -{ - _M_do_reset(); - const size_t __n = min(sizeof(unsigned long)*CHAR_BIT, - __BITS_PER_WORDT(_WordT)*_Nw); - for(size_t __i = 0; __i < __n; ++__i, __val >>= 1) - if ( __val & 0x1 ) - _M_w |= _S_maskbit(__i); -} - -template -size_t _Base_bitset<1, _WordT>::_M_do_find_first(size_t __not_found) const -{ - _WordT __thisword = _M_w; - - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __j*CHAR_BIT + _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - // not found, so return a value that indicates failure. - return __not_found; -} - -template -size_t -_Base_bitset<1, _WordT>::_M_do_find_next(size_t __prev, - size_t __not_found ) const -{ - // make bound inclusive - ++__prev; - - // check out of bounds - if ( __prev >= __BITS_PER_WORDT(_WordT) ) - return __not_found; - - // search first (and only) word - _WordT __thisword = _M_w; - - // mask off bits below bound - __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); - - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - // get first byte into place - __thisword >>= _S_whichbyte(__prev) * CHAR_BIT; - for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __j*CHAR_BIT + _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - - // not found, so return a value that indicates failure. - return __not_found; -} // end _M_do_find_next - -// -// One last specialization: _M_do_to_ulong() and the constructor from -// unsigned long are very simple if the bitset consists of a single -// word of type unsigned long. -// - -template<> -inline unsigned long -_Base_bitset<1, unsigned long>::_M_do_to_ulong() const { return _M_w; } - -template<> -inline _Base_bitset<1, unsigned long>::_Base_bitset(unsigned long __val) { - _M_w = __val; -} - - -// ------------------------------------------------------------ -// Helper class to zero out the unused high-order bits in the highest word. - -template struct _Sanitize { - static void _M_do_sanitize(_WordT& __val) - { __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); } -}; - -template struct _Sanitize<_WordT, 0> { - static void _M_do_sanitize(_WordT) {} -}; - -// ------------------------------------------------------------ -// Class bitset. -// _Nb may be any nonzero number of type size_t. -// Type _WordT may be any unsigned integral type. - -template -class bitset : private _Base_bitset<__BITSET_WORDS(_Nb,_WordT), _WordT> -{ -private: - typedef _Base_bitset<__BITSET_WORDS(_Nb,_WordT), _WordT> _Base; - - // Import base's protected interface. Necessary because of new template - // name resolution rules. - using _Base::_S_whichword; - using _Base::_S_whichbyte; - using _Base::_S_whichbit; - using _Base::_S_maskbit; - using _Base::_M_getword; - using _Base::_M_hiword; - using _Base::_M_do_and; - using _Base::_M_do_or; - using _Base::_M_do_xor; - using _Base::_M_do_left_shift; - using _Base::_M_do_right_shift; - using _Base::_M_do_flip; - using _Base::_M_do_set; - using _Base::_M_do_reset; - using _Base::_M_is_equal; - using _Base::_M_is_any; - using _Base::_M_do_count; - using _Base::_M_do_to_ulong; - using _Base::_M_do_find_first; - using _Base::_M_do_find_next; - -private: - void _M_do_sanitize() { - _Sanitize<_WordT,_Nb%__BITS_PER_WORDT(_WordT) > - ::_M_do_sanitize(_M_hiword()); - } - -public: - - // bit reference: - class reference; - friend class reference; - class reference { - friend class bitset; - - _WordT *_M_wp; - size_t _M_bpos; - - // left undefined - reference(); - - reference( bitset& __b, size_t __pos ) { - _M_wp = &__b._M_getword(__pos); - _M_bpos = _S_whichbit(__pos); - } - - public: - ~reference() {} - - // for b[i] = __x; - reference& operator=(bool __x) { - if ( __x ) - *_M_wp |= _S_maskbit(_M_bpos); - else - *_M_wp &= ~_S_maskbit(_M_bpos); - - return *this; - } - - // for b[i] = b[__j]; - reference& operator=(const reference& __j) { - if ( (*(__j._M_wp) & _S_maskbit(__j._M_bpos)) ) - *_M_wp |= _S_maskbit(_M_bpos); - else - *_M_wp &= ~_S_maskbit(_M_bpos); - - return *this; - } - - // flips the bit - bool operator~() const { return (*(_M_wp) & _S_maskbit(_M_bpos)) == 0; } - - // for __x = b[i]; - operator bool() const { return (*(_M_wp) & _S_maskbit(_M_bpos)) != 0; } - - // for b[i].flip(); - reference& flip() { - *_M_wp ^= _S_maskbit(_M_bpos); - return *this; - } - }; - - // 23.3.5.1 constructors: - bitset() {} - bitset(unsigned long __val) : - _Base_bitset<__BITSET_WORDS(_Nb,_WordT), _WordT>(__val) {} - - template - explicit bitset(const basic_string<_CharT,_Traits,_Alloc>& __s, - size_t __pos = 0, - size_t __n = size_t(basic_string<_CharT,_Traits,_Alloc>::npos)) - : _Base() - { - if (__pos > __s.size()) - __STL_THROW(out_of_range("bitset")); - _M_copy_from_string(__s, __pos, __n); - } - - // 23.3.5.2 bitset operations: - bitset<_Nb,_WordT>& operator&=(const bitset<_Nb,_WordT>& __rhs) { - _M_do_and(__rhs); - return *this; - } - - bitset<_Nb,_WordT>& operator|=(const bitset<_Nb,_WordT>& __rhs) { - _M_do_or(__rhs); - return *this; - } - - bitset<_Nb,_WordT>& operator^=(const bitset<_Nb,_WordT>& __rhs) { - _M_do_xor(__rhs); - return *this; - } - - bitset<_Nb,_WordT>& operator<<=(size_t __pos) { - _M_do_left_shift(__pos); - _M_do_sanitize(); - return *this; - } - - bitset<_Nb,_WordT>& operator>>=(size_t __pos) { - _M_do_right_shift(__pos); - _M_do_sanitize(); - return *this; - } - - // - // Extension: - // Versions of single-bit set, reset, flip, test with no range checking. - // - - bitset<_Nb,_WordT>& _Unchecked_set(size_t __pos) { - _M_getword(__pos) |= _S_maskbit(__pos); - return *this; - } - - bitset<_Nb,_WordT>& _Unchecked_set(size_t __pos, int __val) { - if (__val) - _M_getword(__pos) |= _S_maskbit(__pos); - else - _M_getword(__pos) &= ~_S_maskbit(__pos); - - return *this; - } - - bitset<_Nb,_WordT>& _Unchecked_reset(size_t __pos) { - _M_getword(__pos) &= ~_S_maskbit(__pos); - return *this; - } - - bitset<_Nb,_WordT>& _Unchecked_flip(size_t __pos) { - _M_getword(__pos) ^= _S_maskbit(__pos); - return *this; - } - - bool _Unchecked_test(size_t __pos) const { - return (_M_getword(__pos) & _S_maskbit(__pos)) != static_cast<_WordT>(0); - } - - // Set, reset, and flip. - - bitset<_Nb,_WordT>& set() { - _M_do_set(); - _M_do_sanitize(); - return *this; - } - - bitset<_Nb,_WordT>& set(size_t __pos) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_set(__pos); - } - - bitset<_Nb,_WordT>& set(size_t __pos, int __val) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_set(__pos, __val); - } - - bitset<_Nb,_WordT>& reset() { - _M_do_reset(); - return *this; - } - - bitset<_Nb,_WordT>& reset(size_t __pos) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_reset(__pos); - } - - bitset<_Nb,_WordT>& flip() { - _M_do_flip(); - _M_do_sanitize(); - return *this; - } - - bitset<_Nb,_WordT>& flip(size_t __pos) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_flip(__pos); - } - - bitset<_Nb,_WordT> operator~() const { - return bitset<_Nb,_WordT>(*this).flip(); - } - - // element access: - //for b[i]; - reference operator[](size_t __pos) { return reference(*this,__pos); } - bool operator[](size_t __pos) const { return _Unchecked_test(__pos); } - - unsigned long to_ulong() const { return _M_do_to_ulong(); } - -#ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS - template - basic_string<_CharT, _Traits, _Alloc> to_string() const { - basic_string<_CharT, _Traits, _Alloc> __result; - _M_copy_to_string(__result); - return __result; - } -#endif /* __STL_EXPLICIT_FUNCTION_TMPL_ARGS */ - - // Helper functions for string operations. - template - void _M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s, - size_t, - size_t); - - // Helper functions for string operations. - template - void _M_copy_to_string(basic_string<_CharT,_Traits,_Alloc>&) const; - - size_t count() const { return _M_do_count(); } - - size_t size() const { return _Nb; } - - bool operator==(const bitset<_Nb,_WordT>& __rhs) const { - return _M_is_equal(__rhs); - } - bool operator!=(const bitset<_Nb,_WordT>& __rhs) const { - return !_M_is_equal(__rhs); - } - - bool test(size_t __pos) const { - if (__pos > _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_test(__pos); - } - - bool any() const { return _M_is_any(); } - bool none() const { return !_M_is_any(); } - - bitset<_Nb,_WordT> operator<<(size_t __pos) const - { return bitset<_Nb,_WordT>(*this) <<= __pos; } - bitset<_Nb,_WordT> operator>>(size_t __pos) const - { return bitset<_Nb,_WordT>(*this) >>= __pos; } - - // - // EXTENSIONS: bit-find operations. These operations are - // experimental, and are subject to change or removal in future - // versions. - // - - // find the index of the first "on" bit - size_t _Find_first() const - { return _M_do_find_first(_Nb); } - - // find the index of the next "on" bit after prev - size_t _Find_next( size_t __prev ) const - { return _M_do_find_next(__prev, _Nb); } - -}; - -// -// Definitions of non-inline member functions. -// - -template -template -void bitset<_Nb, _WordT> - ::_M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s, - size_t __pos, - size_t __n) -{ - reset(); - const size_t __nbits = min(_Nb, min(__n, __s.size() - __pos)); - for (size_t __i = 0; __i < __nbits; ++__i) { - switch(__s[__pos + __nbits - __i - 1]) { - case '0': - break; - case '1': - set(__i); - break; - default: - __STL_THROW(invalid_argument("bitset")); - } - } -} - -template -template -void bitset<_Nb, _WordT> - ::_M_copy_to_string(basic_string<_CharT, _Traits, _Alloc>& __s) const -{ - __s.assign(_Nb, '0'); - - for (size_t __i = 0; __i < _Nb; ++__i) - if (_Unchecked_test(__i)) - __s[_Nb - 1 - __i] = '1'; -} - -// ------------------------------------------------------------ - -// -// 23.3.5.3 bitset operations: -// - -template -inline bitset<_Nb,_WordT> operator&(const bitset<_Nb,_WordT>& __x, - const bitset<_Nb,_WordT>& __y) { - bitset<_Nb,_WordT> __result(__x); - __result &= __y; - return __result; -} - - -template -inline bitset<_Nb,_WordT> operator|(const bitset<_Nb,_WordT>& __x, - const bitset<_Nb,_WordT>& __y) { - bitset<_Nb,_WordT> __result(__x); - __result |= __y; - return __result; -} - -template -inline bitset<_Nb,_WordT> operator^(const bitset<_Nb,_WordT>& __x, - const bitset<_Nb,_WordT>& __y) { - bitset<_Nb,_WordT> __result(__x); - __result ^= __y; - return __result; -} - -// NOTE: these must be rewritten once we have templatized iostreams. - -template -istream& -operator>>(istream& __is, bitset<_Nb,_WordT>& __x) { - string __tmp; - __tmp.reserve(_Nb); - - // In new templatized iostreams, use istream::sentry - if (__is.flags() & ios::skipws) { - char __c; - do - __is.get(__c); - while (__is && isspace(__c)); - if (__is) - __is.putback(__c); - } - - for (size_t __i = 0; __i < _Nb; ++__i) { - char __c; - __is.get(__c); - - if (!__is) - break; - else if (__c != '0' && __c != '1') { - __is.putback(__c); - break; - } - else - __tmp.push_back(__c); - } - - if (__tmp.empty()) - __is.clear(__is.rdstate() | ios::failbit); - else - __x._M_copy_from_string(__tmp, static_cast(0), _Nb); - - return __is; -} - -template -ostream& operator<<(ostream& __os, const bitset<_Nb,_WordT>& __x) { - string __tmp; - __x._M_copy_to_string(__tmp); - return __os << __tmp; -} - -// ------------------------------------------------------------ -// Lookup tables for find and count operations. - -template -unsigned char _Bit_count<__dummy>::_S_bit_count[] = { - 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */ - 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */ - 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */ - 4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */ - 2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */ - 3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */ - 4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */ - 3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */ - 2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */ - 4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */ - 3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */ - 5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */ - 4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */ - 2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */ - 3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */ - 4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */ - 2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */ - 4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */ - 4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */ - 6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */ - 3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */ - 4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */ - 5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */ - 5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */ - 4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */ - 6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */ - 2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */ - 4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */ - 3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */ - 3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */ - 4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */ - 5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */ - 2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */ - 4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */ - 4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */ - 6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */ - 4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */ - 5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */ - 6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */ - 4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */ - 3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */ - 5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */ - 4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */ - 6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */ - 5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */ - 4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */ - 5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */ - 6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */ - 4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */ - 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */ - 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */ - 8 /* 255 */ -}; // end _Bit_count - -template -unsigned char _First_one<__dummy>::_S_first_one[] = { - 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */ - 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */ - 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */ - 0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */ - 2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */ - 0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */ - 1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */ - 0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */ - 3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */ - 0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */ - 1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */ - 0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */ - 2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */ - 0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */ - 1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */ - 0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */ - 4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */ - 0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */ - 1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */ - 0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */ - 2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */ - 0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */ - 1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */ - 0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */ - 3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */ - 0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */ - 1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */ - 0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */ - 2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */ - 0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */ - 1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */ - 0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */ - 5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */ - 0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */ - 1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */ - 0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */ - 2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */ - 0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */ - 1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */ - 0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */ - 3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */ - 0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */ - 1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */ - 0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */ - 2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */ - 0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */ - 1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */ - 0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */ - 4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */ - 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */ - 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */ - 0, /* 255 */ -}; // end _First_one - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1209 -#endif - -__STL_END_NAMESPACE - - -#undef __BITS_PER_WORDT -#undef __BITSET_WORDS - -#endif /* __SGI_STL_BITSET */ - - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/bvector.h b/libstdc++/stl/bvector.h deleted file mode 100644 index 03a3fb1c7f2..00000000000 --- a/libstdc++/stl/bvector.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_BVECTOR_H -#define __SGI_STL_BVECTOR_H - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION -#include -#else -#include -#include -#endif - -#include - -#ifdef __STL_USE_NAMESPACES - -using __STD::bit_vector; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_BVECTOR_H */ - -// Local Variables: -// mode:C++ -// End: - - diff --git a/libstdc++/stl/defalloc.h b/libstdc++/stl/defalloc.h deleted file mode 100644 index 0bfcc2c20a5..00000000000 --- a/libstdc++/stl/defalloc.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * 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. - * - */ - -// Inclusion of this file is DEPRECATED. This is the original HP -// default allocator. It is provided only for backward compatibility. -// This file WILL BE REMOVED in a future release. -// -// DO NOT USE THIS FILE unless you have an old container implementation -// that requires an allocator with the HP-style interface. -// -// Standard-conforming allocators have a very different interface. The -// standard default allocator is declared in the header . - -#ifndef DEFALLOC_H -#define DEFALLOC_H - -#include -#include -#include -#include -#include -#include - - -template -inline T* allocate(ptrdiff_t size, T*) { - set_new_handler(0); - T* tmp = (T*)(::operator new((size_t)(size * sizeof(T)))); - if (tmp == 0) { - cerr << "out of memory" << endl; - exit(1); - } - return tmp; -} - - -template -inline void deallocate(T* buffer) { - ::operator delete(buffer); -} - -template -class allocator { -public: - typedef T value_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - pointer allocate(size_type n) { - return ::allocate((difference_type)n, (pointer)0); - } - void deallocate(pointer p) { ::deallocate(p); } - pointer address(reference x) { return (pointer)&x; } - const_pointer const_address(const_reference x) { - return (const_pointer)&x; - } - size_type init_page_size() { - return max(size_type(1), size_type(4096/sizeof(T))); - } - size_type max_size() const { - return max(size_type(1), size_type(UINT_MAX/sizeof(T))); - } -}; - -class allocator { -public: - typedef void* pointer; -}; - - - -#endif diff --git a/libstdc++/stl/deque b/libstdc++/stl/deque deleted file mode 100644 index 61654acad5b..00000000000 --- a/libstdc++/stl/deque +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_DEQUE -#define __SGI_STL_DEQUE - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_DEQUE */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/deque.h b/libstdc++/stl/deque.h deleted file mode 100644 index ede38b1ceba..00000000000 --- a/libstdc++/stl/deque.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_DEQUE_H -#define __SGI_STL_DEQUE_H - -#include -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::deque; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_DEQUE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/function.h b/libstdc++/stl/function.h deleted file mode 100644 index 6474dd99fa2..00000000000 --- a/libstdc++/stl/function.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_FUNCTION_H -#define __SGI_STL_FUNCTION_H - -#ifndef __STL_CONFIG_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_RELOPS -#include -#endif -#include -#ifndef __SGI_STL_INTERNAL_FUNCTION_H -#include -#endif - -#ifdef __STL_USE_NAMESPACE_FOR_RELOPS - -// Names from stl_relops.h -using __STD_RELOPS::operator!=; -using __STD_RELOPS::operator>; -using __STD_RELOPS::operator<=; -using __STD_RELOPS::operator>=; - -#endif /* __STL_USE_NAMESPACE_FOR_RELOPS */ - -#ifdef __STL_USE_NAMESPACES - -// Names from stl_function.h -using __STD::unary_function; -using __STD::binary_function; -using __STD::plus; -using __STD::minus; -using __STD::multiplies; -using __STD::divides; -using __STD::identity_element; -using __STD::modulus; -using __STD::negate; -using __STD::equal_to; -using __STD::not_equal_to; -using __STD::greater; -using __STD::less; -using __STD::greater_equal; -using __STD::less_equal; -using __STD::logical_and; -using __STD::logical_or; -using __STD::logical_not; -using __STD::unary_negate; -using __STD::binary_negate; -using __STD::not1; -using __STD::not2; -using __STD::binder1st; -using __STD::binder2nd; -using __STD::bind1st; -using __STD::bind2nd; -using __STD::unary_compose; -using __STD::binary_compose; -using __STD::compose1; -using __STD::compose2; -using __STD::pointer_to_unary_function; -using __STD::pointer_to_binary_function; -using __STD::ptr_fun; -using __STD::identity; -using __STD::select1st; -using __STD::select2nd; -using __STD::project1st; -using __STD::project2nd; -using __STD::constant_void_fun; -using __STD::constant_unary_fun; -using __STD::constant_binary_fun; -using __STD::constant0; -using __STD::constant1; -using __STD::constant2; -using __STD::subtractive_rng; -using __STD::mem_fun_t; -using __STD::const_mem_fun_t; -using __STD::mem_fun_ref_t; -using __STD::const_mem_fun_ref_t; -using __STD::mem_fun1_t; -using __STD::const_mem_fun1_t; -using __STD::mem_fun1_ref_t; -using __STD::const_mem_fun1_ref_t; -using __STD::mem_fun; -using __STD::mem_fun_ref; -using __STD::mem_fun1; -using __STD::mem_fun1_ref; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_FUNCTION_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/functional b/libstdc++/stl/functional deleted file mode 100644 index d046dbb036d..00000000000 --- a/libstdc++/stl/functional +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - * - */ - -#ifndef __SGI_STL_FUNCTIONAL -#define __SGI_STL_FUNCTIONAL - -#include -#include -#include - -#endif /* __SGI_STL_FUNCTIONAL */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/hash_map b/libstdc++/stl/hash_map deleted file mode 100644 index f7421e026fa..00000000000 --- a/libstdc++/stl/hash_map +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -#ifndef __SGI_STL_HASH_MAP -#define __SGI_STL_HASH_MAP - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#include -#endif - -#include - -#endif /* __SGI_STL_HASH_MAP */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/hash_map.h b/libstdc++/stl/hash_map.h deleted file mode 100644 index f3471627044..00000000000 --- a/libstdc++/stl/hash_map.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -#ifndef __SGI_STL_HASH_MAP_H -#define __SGI_STL_HASH_MAP_H - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#include -#endif - -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::hash; -using __STD::hashtable; -using __STD::hash_map; -using __STD::hash_multimap; -#endif /* __STL_USE_NAMESPACES */ - - -#endif /* __SGI_STL_HASH_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/hash_set b/libstdc++/stl/hash_set deleted file mode 100644 index 2244f47cfa0..00000000000 --- a/libstdc++/stl/hash_set +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -#ifndef __SGI_STL_HASH_SET -#define __SGI_STL_HASH_SET - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#include -#endif - -#include - -#endif /* __SGI_STL_HASH_SET */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/hash_set.h b/libstdc++/stl/hash_set.h deleted file mode 100644 index d3e93c0c26b..00000000000 --- a/libstdc++/stl/hash_set.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -#ifndef __SGI_STL_HASH_SET_H -#define __SGI_STL_HASH_SET_H - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#include -#endif - -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::hash; -using __STD::hashtable; -using __STD::hash_set; -using __STD::hash_multiset; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_HASH_SET_H */ diff --git a/libstdc++/stl/hashtable.h b/libstdc++/stl/hashtable.h deleted file mode 100644 index 15dbfc91644..00000000000 --- a/libstdc++/stl/hashtable.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_HASHTABLE_H -#define __SGI_STL_HASHTABLE_H - -#include -#include -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::hash; -using __STD::hashtable; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_HASHTABLE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/heap.h b/libstdc++/stl/heap.h deleted file mode 100644 index 2ec93c07b76..00000000000 --- a/libstdc++/stl/heap.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_HEAP_H -#define __SGI_STL_HEAP_H - -#include -#include - -#ifdef __STL_USE_NAMESPACES - -using __STD::push_heap; -using __STD::pop_heap; -using __STD::make_heap; -using __STD::sort_heap; - -#endif /* __STL_USE_NAMESPACES */ - - -#endif /* __SGI_STL_HEAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/iterator b/libstdc++/stl/iterator deleted file mode 100644 index 4ddd208f275..00000000000 --- a/libstdc++/stl/iterator +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_ITERATOR -#define __SGI_STL_ITERATOR - -#include -#include -#include /* XXX should use */ -#if 0 /* XXX define a flag for this */ -#include -#else -#include -#endif -#include - -#endif /* __SGI_STL_ITERATOR */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/iterator.h b/libstdc++/stl/iterator.h deleted file mode 100644 index f8a02377422..00000000000 --- a/libstdc++/stl/iterator.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_ITERATOR_H -#define __SGI_STL_ITERATOR_H - -#ifndef __SGI_STL_FUNCTION_H -#include -#endif -#include -#include -#ifndef __SGI_STL_INTERNAL_ITERATOR_H -#include -#endif -#ifndef __TYPE_TRAITS_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H -#include -#endif - -#ifdef __STL_USE_NAMESPACES - -// Names from stl_iterator.h - -using __STD::input_iterator_tag; -using __STD::output_iterator_tag; -using __STD::forward_iterator_tag; -using __STD::bidirectional_iterator_tag; -using __STD::random_access_iterator_tag; - -#if 0 -using __STD::iterator; -#endif -using __STD::input_iterator; -using __STD::output_iterator; -using __STD::forward_iterator; -using __STD::bidirectional_iterator; -using __STD::random_access_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION -using __STD::iterator_traits; -#endif - -using __STD::iterator_category; -using __STD::distance_type; -using __STD::value_type; - -using __STD::distance; -using __STD::advance; - -using __STD::insert_iterator; -using __STD::front_insert_iterator; -using __STD::back_insert_iterator; -using __STD::inserter; -using __STD::front_inserter; -using __STD::back_inserter; - -using __STD::reverse_iterator; -using __STD::reverse_bidirectional_iterator; - -using __STD::istream_iterator; -using __STD::ostream_iterator; - -// Names from stl_construct.h -using __STD::construct; -using __STD::destroy; - -// Names from stl_raw_storage_iter.h -using __STD::raw_storage_iterator; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_ITERATOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/list b/libstdc++/stl/list deleted file mode 100644 index 5294f39fea6..00000000000 --- a/libstdc++/stl/list +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_LIST -#define __SGI_STL_LIST - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_LIST */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/list.h b/libstdc++/stl/list.h deleted file mode 100644 index 4e6ee0b4113..00000000000 --- a/libstdc++/stl/list.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_LIST_H -#define __SGI_STL_LIST_H - -#include -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::list; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_LIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/map b/libstdc++/stl/map deleted file mode 100644 index 4cfb7652c54..00000000000 --- a/libstdc++/stl/map +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_MAP -#define __SGI_STL_MAP - -#ifndef __SGI_STL_INTERNAL_TREE_H -#include -#endif -#include -#include - -#endif /* __SGI_STL_MAP */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/map.h b/libstdc++/stl/map.h deleted file mode 100644 index a89bd31e81c..00000000000 --- a/libstdc++/stl/map.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_MAP_H -#define __SGI_STL_MAP_H - -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::map; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/memory b/libstdc++/stl/memory deleted file mode 100644 index 64338dd313a..00000000000 --- a/libstdc++/stl/memory +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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. - * - */ - -#ifndef __SGI_STL_MEMORY -#define __SGI_STL_MEMORY - -#include -#include -#include -#include -#include -#include - - -#if defined(__STL_MEMBER_TEMPLATES) - -__STL_BEGIN_NAMESPACE - -template class auto_ptr { -private: - _Tp* _M_ptr; - -public: - typedef _Tp element_type; - explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {} - auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {} - template auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW - : _M_ptr(__a.release()) {} - auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW { - if (&__a != this) { - delete _M_ptr; - _M_ptr = __a.release(); - } - return *this; - } - template - auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW { - if (__a.get() != this->get()) { - delete _M_ptr; - _M_ptr = __a.release(); - } - return *this; - } - ~auto_ptr() __STL_NOTHROW { delete _M_ptr; } - - _Tp& operator*() const __STL_NOTHROW { - return *_M_ptr; - } - _Tp* operator->() const __STL_NOTHROW { - return _M_ptr; - } - _Tp* get() const __STL_NOTHROW { - return _M_ptr; - } - _Tp* release() __STL_NOTHROW { - _Tp* __tmp = _M_ptr; - _M_ptr = 0; - return __tmp; - } - void reset(_Tp* __p = 0) __STL_NOTHROW { - delete _M_ptr; - _M_ptr = __p; - } - - // According to the C++ standard, these conversions are required. Most - // present-day compilers, however, do not enforce that requirement---and, - // in fact, most present-day compilers do not support the language - // features that these conversions rely on. - -#ifdef __SGI_STL_USE_AUTO_PTR_CONVERSIONS - -private: - template struct auto_ptr_ref { - _Tp1* _M_ptr; - auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {} - }; - -public: - auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW - : _M_ptr(__ref._M_ptr) {} - template operator auto_ptr_ref<_Tp1>() __STL_NOTHROW - { return auto_ptr_ref<_Tp>(this->release()); } - template operator auto_ptr<_Tp1>() __STL_NOTHROW - { return auto_ptr<_Tp1>(this->release()); } - -#endif /* __SGI_STL_USE_AUTO_PTR_CONVERSIONS */ -}; - -__STL_END_NAMESPACE -#endif /* member templates */ - -#endif /* __SGI_STL_MEMORY */ - - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/multimap.h b/libstdc++/stl/multimap.h deleted file mode 100644 index 1a8ec4af4f9..00000000000 --- a/libstdc++/stl/multimap.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_MULTIMAP_H -#define __SGI_STL_MULTIMAP_H - -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::multimap; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_MULTIMAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/multiset.h b/libstdc++/stl/multiset.h deleted file mode 100644 index 3024fd74c03..00000000000 --- a/libstdc++/stl/multiset.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_MULTISET_H -#define __SGI_STL_MULTISET_H - -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::multiset; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_MULTISET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/numeric b/libstdc++/stl/numeric deleted file mode 100644 index 7f048e11b56..00000000000 --- a/libstdc++/stl/numeric +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_NUMERIC -#define __SGI_STL_NUMERIC - -#include -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_NUMERIC */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/pair.h b/libstdc++/stl/pair.h deleted file mode 100644 index 00f5caddb61..00000000000 --- a/libstdc++/stl/pair.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_PAIR_H -#define __SGI_STL_PAIR_H - -#ifndef __STL_CONFIG_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_RELOPS -#include -#endif -#ifndef __SGI_STL_INTERNAL_PAIR_H -#include -#endif - -#ifdef __STL_USE_NAMESPACES - -using __STD::pair; -using __STD::make_pair; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_PAIR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/pthread_alloc b/libstdc++/stl/pthread_alloc deleted file mode 100644 index 1852908095b..00000000000 --- a/libstdc++/stl/pthread_alloc +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_PTHREAD_ALLOC -#define __SGI_STL_PTHREAD_ALLOC - -// Pthread-specific node allocator. -// This is similar to the default allocator, except that free-list -// information is kept separately for each thread, avoiding locking. -// This should be reasonably fast even in the presence of threads. -// The down side is that storage may not be well-utilized. -// It is not an error to allocate memory in thread A and deallocate -// it in thread B. But this effectively transfers ownership of the memory, -// so that it can only be reallocated by thread B. Thus this can effectively -// result in a storage leak if it's done on a regular basis. -// It can also result in frequent sharing of -// cache lines among processors, with potentially serious performance -// consequences. - -#include -#include -#ifndef __RESTRICT -# define __RESTRICT -#endif - -__STL_BEGIN_NAMESPACE - -#define __STL_DATA_ALIGNMENT 8 - -union _Pthread_alloc_obj { - union _Pthread_alloc_obj * __free_list_link; - char __client_data[__STL_DATA_ALIGNMENT]; /* The client sees this. */ -}; - -// Pthread allocators don't appear to the client to have meaningful -// instances. We do in fact need to associate some state with each -// thread. That state is represented by -// _Pthread_alloc_per_thread_state<_Max_size>. - -template -struct _Pthread_alloc_per_thread_state { - typedef _Pthread_alloc_obj __obj; - enum { _S_NFREELISTS = _Max_size/__STL_DATA_ALIGNMENT }; - _Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS]; - _Pthread_alloc_per_thread_state<_Max_size> * __next; - // Free list link for list of available per thread structures. - // When one of these becomes available for reuse due to thread - // termination, any objects in its free list remain associated - // with it. The whole structure may then be used by a newly - // created thread. - _Pthread_alloc_per_thread_state() : __next(0) - { - memset((void *)__free_list, 0, _S_NFREELISTS * sizeof(__obj *)); - } - // Returns an object of size __n, and possibly adds to size n free list. - void *_M_refill(size_t __n); -}; - -// Pthread-specific allocator. -// The argument specifies the largest object size allocated from per-thread -// free lists. Larger objects are allocated using malloc_alloc. -// Max_size must be a power of 2. -template -class _Pthread_alloc_template { - -public: // but only for internal use: - - typedef _Pthread_alloc_obj __obj; - - // Allocates a chunk for nobjs of size "size". nobjs may be reduced - // if it is inconvenient to allocate the requested number. - static char *_S_chunk_alloc(size_t __size, int &__nobjs); - - enum {_S_ALIGN = __STL_DATA_ALIGNMENT}; - - static size_t _S_round_up(size_t __bytes) { - return (((__bytes) + _S_ALIGN-1) & ~(_S_ALIGN - 1)); - } - static size_t _S_freelist_index(size_t __bytes) { - return (((__bytes) + _S_ALIGN-1)/_S_ALIGN - 1); - } - -private: - // Chunk allocation state. And other shared state. - // Protected by _S_chunk_allocator_lock. - static pthread_mutex_t _S_chunk_allocator_lock; - static char *_S_start_free; - static char *_S_end_free; - static size_t _S_heap_size; - static _Pthread_alloc_per_thread_state<_Max_size>* _S_free_per_thread_states; - static pthread_key_t _S_key; - static bool _S_key_initialized; - // Pthread key under which per thread state is stored. - // Allocator instances that are currently unclaimed by any thread. - static void _S_destructor(void *instance); - // Function to be called on thread exit to reclaim per thread - // state. - static _Pthread_alloc_per_thread_state<_Max_size> *_S_new_per_thread_state(); - // Return a recycled or new per thread state. - static _Pthread_alloc_per_thread_state<_Max_size> *_S_get_per_thread_state(); - // ensure that the current thread has an associated - // per thread state. - friend class _M_lock; - class _M_lock { - public: - _M_lock () { pthread_mutex_lock(&_S_chunk_allocator_lock); } - ~_M_lock () { pthread_mutex_unlock(&_S_chunk_allocator_lock); } - }; - -public: - - /* n must be > 0 */ - static void * allocate(size_t __n) - { - __obj * volatile * __my_free_list; - __obj * __RESTRICT __result; - _Pthread_alloc_per_thread_state<_Max_size>* __a; - - if (__n > _Max_size) { - return(malloc_alloc::allocate(__n)); - } - if (!_S_key_initialized || - !(__a = (_Pthread_alloc_per_thread_state<_Max_size>*) - pthread_getspecific(_S_key))) { - __a = _S_get_per_thread_state(); - } - __my_free_list = __a -> __free_list + _S_freelist_index(__n); - __result = *__my_free_list; - if (__result == 0) { - void *__r = __a -> _M_refill(_S_round_up(__n)); - return __r; - } - *__my_free_list = __result -> __free_list_link; - return (__result); - }; - - /* p may not be 0 */ - static void deallocate(void *__p, size_t __n) - { - __obj *__q = (__obj *)__p; - __obj * volatile * __my_free_list; - _Pthread_alloc_per_thread_state<_Max_size>* __a; - - if (__n > _Max_size) { - malloc_alloc::deallocate(__p, __n); - return; - } - if (!_S_key_initialized || - !(__a = (_Pthread_alloc_per_thread_state<_Max_size> *) - pthread_getspecific(_S_key))) { - __a = _S_get_per_thread_state(); - } - __my_free_list = __a->__free_list + _S_freelist_index(__n); - __q -> __free_list_link = *__my_free_list; - *__my_free_list = __q; - } - - static void * reallocate(void *__p, size_t __old_sz, size_t __new_sz); - -} ; - -typedef _Pthread_alloc_template<> pthread_alloc; - - -template -void _Pthread_alloc_template<_Max_size>::_S_destructor(void * __instance) -{ - _M_lock __lock_instance; // Need to acquire lock here. - _Pthread_alloc_per_thread_state<_Max_size>* __s = - (_Pthread_alloc_per_thread_state<_Max_size> *)__instance; - __s -> __next = _S_free_per_thread_states; - _S_free_per_thread_states = __s; -} - -template -_Pthread_alloc_per_thread_state<_Max_size> * -_Pthread_alloc_template<_Max_size>::_S_new_per_thread_state() -{ - /* lock already held here. */ - if (0 != _S_free_per_thread_states) { - _Pthread_alloc_per_thread_state<_Max_size> *__result = - _S_free_per_thread_states; - _S_free_per_thread_states = _S_free_per_thread_states -> __next; - return __result; - } else { - return new _Pthread_alloc_per_thread_state<_Max_size>; - } -} - -template -_Pthread_alloc_per_thread_state<_Max_size> * -_Pthread_alloc_template<_Max_size>::_S_get_per_thread_state() -{ - /*REFERENCED*/ - _M_lock __lock_instance; // Need to acquire lock here. - _Pthread_alloc_per_thread_state<_Max_size> * __result; - if (!_S_key_initialized) { - if (pthread_key_create(&_S_key, _S_destructor)) { - abort(); // failed - } - _S_key_initialized = true; - } - __result = _S_new_per_thread_state(); - if (pthread_setspecific(_S_key, __result)) abort(); - return __result; -} - -/* We allocate memory in large chunks in order to avoid fragmenting */ -/* the malloc heap too much. */ -/* We assume that size is properly aligned. */ -template -char *_Pthread_alloc_template<_Max_size> -::_S_chunk_alloc(size_t __size, int &__nobjs) -{ - { - char * __result; - size_t __total_bytes; - size_t __bytes_left; - /*REFERENCED*/ - _M_lock __lock_instance; // Acquire lock for this routine - - __total_bytes = __size * __nobjs; - __bytes_left = _S_end_free - _S_start_free; - if (__bytes_left >= __total_bytes) { - __result = _S_start_free; - _S_start_free += __total_bytes; - return(__result); - } else if (__bytes_left >= __size) { - __nobjs = __bytes_left/__size; - __total_bytes = __size * __nobjs; - __result = _S_start_free; - _S_start_free += __total_bytes; - return(__result); - } else { - size_t __bytes_to_get = - 2 * __total_bytes + _S_round_up(_S_heap_size >> 4); - // Try to make use of the left-over piece. - if (__bytes_left > 0) { - _Pthread_alloc_per_thread_state<_Max_size>* __a = - (_Pthread_alloc_per_thread_state<_Max_size>*) - pthread_getspecific(_S_key); - __obj * volatile * __my_free_list = - __a->__free_list + _S_freelist_index(__bytes_left); - - ((__obj *)_S_start_free) -> __free_list_link = *__my_free_list; - *__my_free_list = (__obj *)_S_start_free; - } -# ifdef _SGI_SOURCE - // Try to get memory that's aligned on something like a - // cache line boundary, so as to avoid parceling out - // parts of the same line to different threads and thus - // possibly different processors. - { - const int __cache_line_size = 128; // probable upper bound - __bytes_to_get &= ~(__cache_line_size-1); - _S_start_free = (char *)memalign(__cache_line_size, __bytes_to_get); - if (0 == _S_start_free) { - _S_start_free = (char *)malloc_alloc::allocate(__bytes_to_get); - } - } -# else /* !SGI_SOURCE */ - _S_start_free = (char *)malloc_alloc::allocate(__bytes_to_get); -# endif - _S_heap_size += __bytes_to_get; - _S_end_free = _S_start_free + __bytes_to_get; - } - } - // lock is released here - return(_S_chunk_alloc(__size, __nobjs)); -} - - -/* Returns an object of size n, and optionally adds to size n free list.*/ -/* We assume that n is properly aligned. */ -/* We hold the allocation lock. */ -template -void *_Pthread_alloc_per_thread_state<_Max_size> -::_M_refill(size_t __n) -{ - int __nobjs = 128; - char * __chunk = - _Pthread_alloc_template<_Max_size>::_S_chunk_alloc(__n, __nobjs); - __obj * volatile * __my_free_list; - __obj * __result; - __obj * __current_obj, * __next_obj; - int __i; - - if (1 == __nobjs) { - return(__chunk); - } - __my_free_list = __free_list - + _Pthread_alloc_template<_Max_size>::_S_freelist_index(__n); - - /* Build free list in chunk */ - __result = (__obj *)__chunk; - *__my_free_list = __next_obj = (__obj *)(__chunk + __n); - for (__i = 1; ; __i++) { - __current_obj = __next_obj; - __next_obj = (__obj *)((char *)__next_obj + __n); - if (__nobjs - 1 == __i) { - __current_obj -> __free_list_link = 0; - break; - } else { - __current_obj -> __free_list_link = __next_obj; - } - } - return(__result); -} - -template -void *_Pthread_alloc_template<_Max_size> -::reallocate(void *__p, size_t __old_sz, size_t __new_sz) -{ - void * __result; - size_t __copy_sz; - - if (__old_sz > _Max_size - && __new_sz > _Max_size) { - return(realloc(__p, __new_sz)); - } - if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p); - __result = allocate(__new_sz); - __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz; - memcpy(__result, __p, __copy_sz); - deallocate(__p, __old_sz); - return(__result); -} - -template -_Pthread_alloc_per_thread_state<_Max_size> * -_Pthread_alloc_template<_Max_size>::_S_free_per_thread_states = 0; - -template -pthread_key_t _Pthread_alloc_template<_Max_size>::_S_key; - -template -bool _Pthread_alloc_template<_Max_size>::_S_key_initialized = false; - -template -pthread_mutex_t _Pthread_alloc_template<_Max_size>::_S_chunk_allocator_lock -= PTHREAD_MUTEX_INITIALIZER; - -template -char *_Pthread_alloc_template<_Max_size> -::_S_start_free = 0; - -template -char *_Pthread_alloc_template<_Max_size> -::_S_end_free = 0; - -template -size_t _Pthread_alloc_template<_Max_size> -::_S_heap_size = 0; - -#ifdef __STL_USE_STD_ALLOCATORS - -template -class pthread_allocator { - typedef pthread_alloc _S_Alloc; // The underlying allocator. -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef const _Tp* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; - typedef _Tp value_type; - - template struct rebind { - typedef pthread_allocator<_Up> other; - }; - - pthread_allocator() __STL_NOTHROW {} - pthread_allocator(const pthread_allocator& a) __STL_NOTHROW {} - template pthread_allocator(const pthread_allocator<_Up>&) - __STL_NOTHROW {} - ~pthread_allocator() __STL_NOTHROW {} - - pointer address(reference __x) const { return &__x; } - const_pointer address(const_reference __x) const { return &__x; } - - // __n is permitted to be 0. The C++ standard says nothing about what - // the return value is when __n == 0. - _Tp* allocate(size_type __n, const void* = 0) { - return __n != 0 ? static_cast<_Tp*>(_S_Alloc::allocate(__n * sizeof(_Tp))) - : 0; - } - - // p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type __n) - { _S_Alloc::deallocate(__p, __n * sizeof(_Tp)); } - - size_type max_size() const __STL_NOTHROW - { return size_t(-1) / sizeof(_Tp); } - - void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); } - void destroy(pointer _p) { _p->~_Tp(); } -}; - -template<> -class pthread_allocator { -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; - typedef const void* const_pointer; - typedef void value_type; - - template struct rebind { - typedef pthread_allocator<_Up> other; - }; -}; - -template -inline bool operator==(const _Pthread_alloc_template<_Max_size>&, - const _Pthread_alloc_template<_Max_size>&) -{ - return true; -} - -template -inline bool operator==(const pthread_allocator<_T1>&, - const pthread_allocator<_T2>& a2) -{ - return true; -} - -template -inline bool operator!=(const pthread_allocator<_T1>&, - const pthread_allocator<_T2>&) -{ - return false; -} - -template -struct _Alloc_traits<_Tp, _Pthread_alloc_template<_Max_size> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, _Pthread_alloc_template<_Max_size> > _Alloc_type; - typedef __allocator<_Tp, _Pthread_alloc_template<_Max_size> > - allocator_type; -}; - -template -struct _Alloc_traits<_Tp, __allocator<_Up, _Pthread_alloc_template<_Max> > > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, _Pthread_alloc_template<_Max> > _Alloc_type; - typedef __allocator<_Tp, _Pthread_alloc_template<_Max> > allocator_type; -}; - -template -struct _Alloc_traits<_Tp, pthread_allocator<_Up> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, _Pthread_alloc_template<> > _Alloc_type; - typedef pthread_allocator<_Tp> allocator_type; -}; - - -#endif /* __STL_USE_STD_ALLOCATORS */ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_PTHREAD_ALLOC */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/pthread_alloc.h b/libstdc++/stl/pthread_alloc.h deleted file mode 100644 index 774ef04edc8..00000000000 --- a/libstdc++/stl/pthread_alloc.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -#ifndef __SGI_STL_PTHREAD_ALLOC_H -#define __SGI_STL_PTHREAD_ALLOC_H - -#include - -#ifdef __STL_USE_NAMESPACES - -using __STD::_Pthread_alloc_template; -using __STD::pthread_alloc; - -#endif /* __STL_USE_NAMESPACES */ - - -#endif /* __SGI_STL_PTHREAD_ALLOC_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/queue b/libstdc++/stl/queue deleted file mode 100644 index f9417fb1fbb..00000000000 --- a/libstdc++/stl/queue +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_QUEUE -#define __SGI_STL_QUEUE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_QUEUE */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/rope b/libstdc++/stl/rope deleted file mode 100644 index f861500000b..00000000000 --- a/libstdc++/stl/rope +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ - -#ifndef __SGI_STL_ROPE -#define __SGI_STL_ROPE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_ROPE */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/rope.h b/libstdc++/stl/rope.h deleted file mode 100644 index d767fa32e7a..00000000000 --- a/libstdc++/stl/rope.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - */ - -#ifndef __SGI_STL_ROPE_H -#define __SGI_STL_ROPE_H - -#include -#include - -#ifdef __STL_USE_NAMESPACES - -using __STD::char_producer; -using __STD::sequence_buffer; -using __STD::rope; -using __STD::crope; -using __STD::wrope; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_ROPE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/ropeimpl.h b/libstdc++/stl/ropeimpl.h deleted file mode 100644 index 18bb2c9ec9d..00000000000 --- a/libstdc++/stl/ropeimpl.h +++ /dev/null @@ -1,1550 +0,0 @@ -/* - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -# include /* XXX should use */ -# include /* XXX should use */ - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#endif - -// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf -// if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct. -// Results in a valid buf_ptr if the iterator can be legitimately -// dereferenced. -template -void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf( - _Rope_iterator_base<_CharT,_Alloc>& __x) -{ - const _RopeRep* __leaf = __x._M_path_end[__x._M_leaf_index]; - size_t __leaf_pos = __x._M_leaf_pos; - size_t __pos = __x._M_current_pos; - - switch(__leaf->_M_tag) { - case _RopeRep::_S_leaf: - __x._M_buf_start = - ((_Rope_RopeLeaf<_CharT,_Alloc>*)__leaf)->_M_data; - __x._M_buf_ptr = __x._M_buf_start + (__pos - __leaf_pos); - __x._M_buf_end = __x._M_buf_start + __leaf->_M_size; - break; - case _RopeRep::_S_function: - case _RopeRep::_S_substringfn: - { - size_t __len = _S_iterator_buf_len; - size_t __buf_start_pos = __leaf_pos; - size_t __leaf_end = __leaf_pos + __leaf->_M_size; - char_producer<_CharT>* __fn = - ((_Rope_RopeFunction<_CharT,_Alloc>*)__leaf)->_M_fn; - - if (__buf_start_pos + __len <= __pos) { - __buf_start_pos = __pos - __len/4; - if (__buf_start_pos + __len > __leaf_end) { - __buf_start_pos = __leaf_end - __len; - } - } - if (__buf_start_pos + __len > __leaf_end) { - __len = __leaf_end - __buf_start_pos; - } - (*__fn)(__buf_start_pos - __leaf_pos, __len, __x._M_tmp_buf); - __x._M_buf_ptr = __x._M_tmp_buf + (__pos - __buf_start_pos); - __x._M_buf_start = __x._M_tmp_buf; - __x._M_buf_end = __x._M_tmp_buf + __len; - } - break; - default: - __stl_assert(0); - } -} - -// Set path and buffer inside a rope iterator. We assume that -// pos and root are already set. -template -void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache -(_Rope_iterator_base<_CharT,_Alloc>& __x) -{ - const _RopeRep* __path[_RopeRep::_S_max_rope_depth+1]; - const _RopeRep* __curr_rope; - int __curr_depth = -1; /* index into path */ - size_t __curr_start_pos = 0; - size_t __pos = __x._M_current_pos; - unsigned char __dirns = 0; // Bit vector marking right turns in the path - - __stl_assert(__pos <= __x._M_root->_M_size); - if (__pos >= __x._M_root->_M_size) { - __x._M_buf_ptr = 0; - return; - } - __curr_rope = __x._M_root; - if (0 != __curr_rope->_M_c_string) { - /* Treat the root as a leaf. */ - __x._M_buf_start = __curr_rope->_M_c_string; - __x._M_buf_end = __curr_rope->_M_c_string + __curr_rope->_M_size; - __x._M_buf_ptr = __curr_rope->_M_c_string + __pos; - __x._M_path_end[0] = __curr_rope; - __x._M_leaf_index = 0; - __x._M_leaf_pos = 0; - return; - } - for(;;) { - ++__curr_depth; - __stl_assert(__curr_depth <= _RopeRep::_S_max_rope_depth); - __path[__curr_depth] = __curr_rope; - switch(__curr_rope->_M_tag) { - case _RopeRep::_S_leaf: - case _RopeRep::_S_function: - case _RopeRep::_S_substringfn: - __x._M_leaf_pos = __curr_start_pos; - goto done; - case _RopeRep::_S_concat: - { - _Rope_RopeConcatenation<_CharT,_Alloc>* __c = - (_Rope_RopeConcatenation<_CharT,_Alloc>*)__curr_rope; - _RopeRep* __left = __c->_M_left; - size_t __left_len = __left->_M_size; - - __dirns <<= 1; - if (__pos >= __curr_start_pos + __left_len) { - __dirns |= 1; - __curr_rope = __c->_M_right; - __curr_start_pos += __left_len; - } else { - __curr_rope = __left; - } - } - break; - } - } - done: - // Copy last section of path into _M_path_end. - { - int __i = -1; - int __j = __curr_depth + 1 - _S_path_cache_len; - - if (__j < 0) __j = 0; - while (__j <= __curr_depth) { - __x._M_path_end[++__i] = __path[__j++]; - } - __x._M_leaf_index = __i; - } - __x._M_path_directions = __dirns; - _S_setbuf(__x); -} - -// Specialized version of the above. Assumes that -// the path cache is valid for the previous position. -template -void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr -(_Rope_iterator_base<_CharT,_Alloc>& __x) -{ - int __current_index = __x._M_leaf_index; - const _RopeRep* __current_node = __x._M_path_end[__current_index]; - size_t __len = __current_node->_M_size; - size_t __node_start_pos = __x._M_leaf_pos; - unsigned char __dirns = __x._M_path_directions; - _Rope_RopeConcatenation<_CharT,_Alloc>* __c; - - __stl_assert(__x._M_current_pos <= __x._M_root->_M_size); - if (__x._M_current_pos - __node_start_pos < __len) { - /* More stuff in this leaf, we just didn't cache it. */ - _S_setbuf(__x); - return; - } - __stl_assert(__node_start_pos + __len == __x._M_current_pos); - // node_start_pos is starting position of last_node. - while (--__current_index >= 0) { - if (!(__dirns & 1) /* Path turned left */) - break; - __current_node = __x._M_path_end[__current_index]; - __c = (_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node; - // Otherwise we were in the right child. Thus we should pop - // the concatenation node. - __node_start_pos -= __c->_M_left->_M_size; - __dirns >>= 1; - } - if (__current_index < 0) { - // We underflowed the cache. Punt. - _S_setcache(__x); - return; - } - __current_node = __x._M_path_end[__current_index]; - __c = (_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node; - // current_node is a concatenation node. We are positioned on the first - // character in its right child. - // node_start_pos is starting position of current_node. - __node_start_pos += __c->_M_left->_M_size; - __current_node = __c->_M_right; - __x._M_path_end[++__current_index] = __current_node; - __dirns |= 1; - while (_RopeRep::_S_concat == __current_node->_M_tag) { - ++__current_index; - if (_S_path_cache_len == __current_index) { - int __i; - for (__i = 0; __i < _S_path_cache_len-1; __i++) { - __x._M_path_end[__i] = __x._M_path_end[__i+1]; - } - --__current_index; - } - __current_node = - ((_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node)->_M_left; - __x._M_path_end[__current_index] = __current_node; - __dirns <<= 1; - // node_start_pos is unchanged. - } - __x._M_leaf_index = __current_index; - __x._M_leaf_pos = __node_start_pos; - __x._M_path_directions = __dirns; - _S_setbuf(__x); -} - -template -void _Rope_iterator_base<_CharT,_Alloc>::_M_incr(size_t __n) { - _M_current_pos += __n; - if (0 != _M_buf_ptr) { - size_t __chars_left = _M_buf_end - _M_buf_ptr; - if (__chars_left > __n) { - _M_buf_ptr += __n; - } else if (__chars_left == __n) { - _M_buf_ptr += __n; - _S_setcache_for_incr(*this); - } else { - _M_buf_ptr = 0; - } - } -} - -template -void _Rope_iterator_base<_CharT,_Alloc>::_M_decr(size_t __n) { - if (0 != _M_buf_ptr) { - size_t __chars_left = _M_buf_ptr - _M_buf_start; - if (__chars_left >= __n) { - _M_buf_ptr -= __n; - } else { - _M_buf_ptr = 0; - } - } - _M_current_pos -= __n; -} - -template -void _Rope_iterator<_CharT,_Alloc>::_M_check() { - if (_M_root_rope->_M_tree_ptr != _M_root) { - // _Rope was modified. Get things fixed up. - _RopeRep::_S_unref(_M_root); - _M_root = _M_root_rope->_M_tree_ptr; - _RopeRep::_S_ref(_M_root); - _M_buf_ptr = 0; - } -} - -template -inline -_Rope_const_iterator<_CharT, _Alloc>::_Rope_const_iterator( - const _Rope_iterator<_CharT,_Alloc>& __x) -: _Rope_iterator_base<_CharT,_Alloc>(__x) -{ } - -template -inline _Rope_iterator<_CharT,_Alloc>::_Rope_iterator( - rope<_CharT,_Alloc>& __r, size_t __pos) -: _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos), - _M_root_rope(&__r) -{ - _RopeRep::_S_ref(_M_root); -} - -template -inline size_t -rope<_CharT,_Alloc>::_S_char_ptr_len(const _CharT* __s) -{ - const _CharT* __p = __s; - - while (!_S_is0(*__p)) { ++__p; } - return (__p - __s); -} - - -#ifndef __GC - -template -inline void _Rope_RopeRep<_CharT,_Alloc>::_M_free_c_string() -{ - _CharT* __cstr = _M_c_string; - if (0 != __cstr) { - size_t __size = _M_size + 1; - destroy(__cstr, __cstr + __size); - _Data_deallocate(__cstr, __size); - } -} - - -template -#ifdef __STL_USE_STD_ALLOCATORS - inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string(_CharT* __s, - size_t __n, - allocator_type __a) -#else - inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string(_CharT* __s, - size_t __n) -#endif -{ - if (!_S_is_basic_char_type((_CharT*)0)) { - destroy(__s, __s + __n); - } -// This has to be a static member, so this gets a bit messy -# ifdef __STL_USE_STD_ALLOCATORS - __a.deallocate( - __s, _Rope_RopeLeaf<_CharT,_Alloc>::_S_rounded_up_size(__n)); -# else - _Data_deallocate( - __s, _Rope_RopeLeaf<_CharT,_Alloc>::_S_rounded_up_size(__n)); -# endif -} - - -// There are several reasons for not doing this with virtual destructors -// and a class specific delete operator: -// - A class specific delete operator can't easily get access to -// allocator instances if we need them. -// - Any virtual function would need a 4 or byte vtable pointer; -// this only requires a one byte tag per object. -template -void _Rope_RopeRep<_CharT,_Alloc>::_M_free_tree() -{ - switch(_M_tag) { - case _S_leaf: - { - _Rope_RopeLeaf<_CharT,_Alloc>* __l - = (_Rope_RopeLeaf<_CharT,_Alloc>*)this; - __l->_Rope_RopeLeaf<_CharT,_Alloc>::~_Rope_RopeLeaf(); - _L_deallocate(__l, 1); - break; - } - case _S_concat: - { - _Rope_RopeConcatenation<_CharT,_Alloc>* __c - = (_Rope_RopeConcatenation<_CharT,_Alloc>*)this; - __c->_Rope_RopeConcatenation<_CharT,_Alloc>:: - ~_Rope_RopeConcatenation(); - _C_deallocate(__c, 1); - break; - } - case _S_function: - { - _Rope_RopeFunction<_CharT,_Alloc>* __f - = (_Rope_RopeFunction<_CharT,_Alloc>*)this; - __f->_Rope_RopeFunction<_CharT,_Alloc>::~_Rope_RopeFunction(); - _F_deallocate(__f, 1); - break; - } - case _S_substringfn: - { - _Rope_RopeSubstring<_CharT,_Alloc>* __ss = - (_Rope_RopeSubstring<_CharT,_Alloc>*)this; - __ss->_Rope_RopeSubstring<_CharT,_Alloc>:: - ~_Rope_RopeSubstring(); - _S_deallocate(__ss, 1); - break; - } - } -} -#else - -template -#ifdef __STL_USE_STD_ALLOCATORS - inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string - (const _CharT*, size_t, allocator_type) -#else - inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string - (const _CharT*, size_t) -#endif -{} - -#endif - - -// Concatenate a C string onto a leaf rope by copying the rope data. -// Used for short ropes. -template -rope<_CharT,_Alloc>::_RopeLeaf* -rope<_CharT,_Alloc>::_S_leaf_concat_char_iter - (_RopeLeaf* __r, const _CharT* __iter, size_t __len) -{ - size_t __old_len = __r->_M_size; - _CharT* __new_data = (_CharT*) - _Data_allocate(_S_rounded_up_size(__old_len + __len)); - _RopeLeaf* __result; - - uninitialized_copy_n(__r->_M_data, __old_len, __new_data); - uninitialized_copy_n(__iter, __len, __new_data + __old_len); - _S_cond_store_eos(__new_data[__old_len + __len]); - __STL_TRY { - __result = _S_new_RopeLeaf(__new_data, __old_len + __len, - __r->get_allocator()); - } - __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len, - __r->get_allocator())); - return __result; -} - -#ifndef __GC -// As above, but it's OK to clobber original if refcount is 1 -template -rope<_CharT,_Alloc>::_RopeLeaf* -rope<_CharT,_Alloc>::_S_destr_leaf_concat_char_iter - (_RopeLeaf* __r, const _CharT* __iter, size_t __len) -{ - __stl_assert(__r->_M_refcount >= 1); - if (__r->_M_refcount > 1) - return _S_leaf_concat_char_iter(__r, __iter, __len); - size_t __old_len = __r->_M_size; - if (_S_allocated_capacity(__old_len) >= __old_len + __len) { - // The space has been partially initialized for the standard - // character types. But that doesn't matter for those types. - uninitialized_copy_n(__iter, __len, __r->_M_data + __old_len); - if (_S_is_basic_char_type((_CharT*)0)) { - _S_cond_store_eos(__r->_M_data[__old_len + __len]); - __stl_assert(__r->_M_c_string == __r->_M_data); - } else if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string) { - __r->_M_free_c_string(); - __r->_M_c_string = 0; - } - __r->_M_size = __old_len + __len; - __stl_assert(__r->_M_refcount == 1); - __r->_M_refcount = 2; - return __r; - } else { - _RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len); - __stl_assert(__result->_M_refcount == 1); - return __result; - } -} -#endif - -// Assumes left and right are not 0. -// Does not increment (nor decrement on exception) child reference counts. -// Result has ref count 1. -template -rope<_CharT,_Alloc>::_RopeRep* -rope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right) -{ - _RopeConcatenation* __result = - _S_new_RopeConcatenation(__left, __right, __left->get_allocator()); - size_t __depth = __result->_M_depth; - -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(__left->get_allocator() == __right->get_allocator()); -# endif - if (__depth > 20 && (__result->_M_size < 1000 || - __depth > _RopeRep::_S_max_rope_depth)) { - _RopeRep* __balanced; - - __STL_TRY { - __balanced = _S_balance(__result); -# ifndef __GC - if (__result != __balanced) { - __stl_assert(1 == __result->_M_refcount - && 1 == __balanced->_M_refcount); - } -# endif - __result->_M_unref_nonnil(); - } - __STL_UNWIND((_C_deallocate(__result,1))); - // In case of exception, we need to deallocate - // otherwise dangling result node. But caller - // still owns its children. Thus unref is - // inappropriate. - return __balanced; - } else { - return __result; - } -} - -template -rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter - (_RopeRep* __r, const _CharT*__s, size_t __slen) -{ - _RopeRep* __result; - if (0 == __slen) { - _S_ref(__r); - return __r; - } - if (0 == __r) - return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, - __r->get_allocator()); - if (_RopeRep::_S_leaf == __r->_M_tag && - __r->_M_size + __slen <= _S_copy_max) { - __result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen); -# ifndef __GC - __stl_assert(1 == __result->_M_refcount); -# endif - return __result; - } - if (_RopeRep::_S_concat == __r->_M_tag - && _RopeRep::_S_leaf == ((_RopeConcatenation*)__r)->_M_right->_M_tag) { - _RopeLeaf* __right = - (_RopeLeaf* )(((_RopeConcatenation* )__r)->_M_right); - if (__right->_M_size + __slen <= _S_copy_max) { - _RopeRep* __left = ((_RopeConcatenation*)__r)->_M_left; - _RopeRep* __nright = - _S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen); - __left->_M_ref_nonnil(); - __STL_TRY { - __result = _S_tree_concat(__left, __nright); - } - __STL_UNWIND(_S_unref(__left); _S_unref(__nright)); -# ifndef __GC - __stl_assert(1 == __result->_M_refcount); -# endif - return __result; - } - } - _RopeRep* __nright = - __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator()); - __STL_TRY { - __r->_M_ref_nonnil(); - __result = _S_tree_concat(__r, __nright); - } - __STL_UNWIND(_S_unref(__r); _S_unref(__nright)); -# ifndef __GC - __stl_assert(1 == __result->_M_refcount); -# endif - return __result; -} - -#ifndef __GC -template -rope<_CharT,_Alloc>::_RopeRep* -rope<_CharT,_Alloc>::_S_destr_concat_char_iter( - _RopeRep* __r, const _CharT* __s, size_t __slen) -{ - _RopeRep* __result; - if (0 == __r) - return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, - __r->get_allocator()); - size_t __count = __r->_M_refcount; - size_t __orig_size = __r->_M_size; - __stl_assert(__count >= 1); - if (__count > 1) return _S_concat_char_iter(__r, __s, __slen); - if (0 == __slen) { - __r->_M_refcount = 2; // One more than before - return __r; - } - if (__orig_size + __slen <= _S_copy_max && - _RopeRep::_S_leaf == __r->_M_tag) { - __result = _S_destr_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen); - return __result; - } - if (_RopeRep::_S_concat == __r->_M_tag) { - _RopeLeaf* __right = (_RopeLeaf*)(((_RopeConcatenation*)__r)->_M_right); - if (_RopeRep::_S_leaf == __right->_M_tag - && __right->_M_size + __slen <= _S_copy_max) { - _RopeRep* __new_right = - _S_destr_leaf_concat_char_iter(__right, __s, __slen); - if (__right == __new_right) { - __stl_assert(__new_right->_M_refcount == 2); - __new_right->_M_refcount = 1; - } else { - __stl_assert(__new_right->_M_refcount >= 1); - __right->_M_unref_nonnil(); - } - __stl_assert(__r->_M_refcount == 1); - __r->_M_refcount = 2; // One more than before. - ((_RopeConcatenation*)__r)->_M_right = __new_right; - __r->_M_size = __orig_size + __slen; - if (0 != __r->_M_c_string) { - __r->_M_free_c_string(); - __r->_M_c_string = 0; - } - return __r; - } - } - _RopeRep* __right = - __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator()); - __r->_M_ref_nonnil(); - __STL_TRY { - __result = _S_tree_concat(__r, __right); - } - __STL_UNWIND(_S_unref(__r); _S_unref(__right)) - __stl_assert(1 == __result->_M_refcount); - return __result; -} -#endif /* !__GC */ - -template -rope<_CharT,_Alloc>::_RopeRep* -rope<_CharT,_Alloc>::_S_concat(_RopeRep* __left, _RopeRep* __right) -{ - if (0 == __left) { - _S_ref(__right); - return __right; - } - if (0 == __right) { - __left->_M_ref_nonnil(); - return __left; - } - if (_RopeRep::_S_leaf == __right->_M_tag) { - if (_RopeRep::_S_leaf == __left->_M_tag) { - if (__right->_M_size + __left->_M_size <= _S_copy_max) { - return _S_leaf_concat_char_iter((_RopeLeaf*)__left, - ((_RopeLeaf*)__right)->_M_data, - __right->_M_size); - } - } else if (_RopeRep::_S_concat == __left->_M_tag - && _RopeRep::_S_leaf == - ((_RopeConcatenation*)__left)->_M_right->_M_tag) { - _RopeLeaf* __leftright = - (_RopeLeaf*)(((_RopeConcatenation*)__left)->_M_right); - if (__leftright->_M_size + __right->_M_size <= _S_copy_max) { - _RopeRep* __leftleft = ((_RopeConcatenation*)__left)->_M_left; - _RopeRep* __rest = _S_leaf_concat_char_iter(__leftright, - ((_RopeLeaf*)__right)->_M_data, - __right->_M_size); - __leftleft->_M_ref_nonnil(); - __STL_TRY { - return(_S_tree_concat(__leftleft, __rest)); - } - __STL_UNWIND(_S_unref(__leftleft); _S_unref(__rest)) - } - } - } - __left->_M_ref_nonnil(); - __right->_M_ref_nonnil(); - __STL_TRY { - return(_S_tree_concat(__left, __right)); - } - __STL_UNWIND(_S_unref(__left); _S_unref(__right)); -} - -template -rope<_CharT,_Alloc>::_RopeRep* -rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, - size_t __start, size_t __endp1) -{ - if (0 == __base) return 0; - size_t __len = __base->_M_size; - size_t __adj_endp1; - const size_t __lazy_threshold = 128; - - if (__endp1 >= __len) { - if (0 == __start) { - __base->_M_ref_nonnil(); - return __base; - } else { - __adj_endp1 = __len; - } - } else { - __adj_endp1 = __endp1; - } - switch(__base->_M_tag) { - case _RopeRep::_S_concat: - { - _RopeConcatenation* __c = (_RopeConcatenation*)__base; - _RopeRep* __left = __c->_M_left; - _RopeRep* __right = __c->_M_right; - size_t __left_len = __left->_M_size; - _RopeRep* __result; - - if (__adj_endp1 <= __left_len) { - return _S_substring(__left, __start, __endp1); - } else if (__start >= __left_len) { - return _S_substring(__right, __start - __left_len, - __adj_endp1 - __left_len); - } - _Self_destruct_ptr __left_result( - _S_substring(__left, __start, __left_len)); - _Self_destruct_ptr __right_result( - _S_substring(__right, 0, __endp1 - __left_len)); - __result = _S_concat(__left_result, __right_result); -# ifndef __GC - __stl_assert(1 == __result->_M_refcount); -# endif - return __result; - } - case _RopeRep::_S_leaf: - { - _RopeLeaf* __l = (_RopeLeaf*)__base; - _RopeLeaf* __result; - size_t __result_len; - if (__start >= __adj_endp1) return 0; - __result_len = __adj_endp1 - __start; - if (__result_len > __lazy_threshold) goto lazy; -# ifdef __GC - const _CharT* __section = __l->_M_data + __start; - __result = _S_new_RopeLeaf(__section, __result_len, - __base->get_allocator()); - __result->_M_c_string = 0; // Not eos terminated. -# else - // We should sometimes create substring node instead. - __result = __STL_ROPE_FROM_UNOWNED_CHAR_PTR( - __l->_M_data + __start, __result_len, - __base->get_allocator()); -# endif - return __result; - } - case _RopeRep::_S_substringfn: - // Avoid introducing multiple layers of substring nodes. - { - _RopeSubstring* __old = (_RopeSubstring*)__base; - size_t __result_len; - if (__start >= __adj_endp1) return 0; - __result_len = __adj_endp1 - __start; - if (__result_len > __lazy_threshold) { - _RopeSubstring* __result = - _S_new_RopeSubstring(__old->_M_base, - __start + __old->_M_start, - __adj_endp1 - __start, - __base->get_allocator()); - return __result; - - } // *** else fall through: *** - } - case _RopeRep::_S_function: - { - _RopeFunction* __f = (_RopeFunction*)__base; - _CharT* __section; - size_t __result_len; - if (__start >= __adj_endp1) return 0; - __result_len = __adj_endp1 - __start; - - if (__result_len > __lazy_threshold) goto lazy; - __section = (_CharT*) - _Data_allocate(_S_rounded_up_size(__result_len)); - __STL_TRY { - (*(__f->_M_fn))(__start, __result_len, __section); - } - __STL_UNWIND(_RopeRep::__STL_FREE_STRING( - __section, __result_len, __base->get_allocator())); - _S_cond_store_eos(__section[__result_len]); - return _S_new_RopeLeaf(__section, __result_len, - __base->get_allocator()); - } - } - /*NOTREACHED*/ - __stl_assert(false); - lazy: - { - // Create substring node. - return _S_new_RopeSubstring(__base, __start, __adj_endp1 - __start, - __base->get_allocator()); - } -} - -template -class _Rope_flatten_char_consumer : public _Rope_char_consumer<_CharT> { - private: - _CharT* _M_buf_ptr; - public: - // _CharT* _M_buffer; // XXX not used - - _Rope_flatten_char_consumer(_CharT* __buffer) { - _M_buf_ptr = __buffer; - }; - ~_Rope_flatten_char_consumer() {} - bool operator() (const _CharT* __leaf, size_t __n) { - uninitialized_copy_n(__leaf, __n, _M_buf_ptr); - _M_buf_ptr += __n; - return true; - } -}; - -template -class _Rope_find_char_char_consumer : public _Rope_char_consumer<_CharT> { - private: - _CharT _M_pattern; - public: - size_t _M_count; // Number of nonmatching characters - _Rope_find_char_char_consumer(_CharT __p) - : _M_pattern(__p), _M_count(0) {} - ~_Rope_find_char_char_consumer() {} - bool operator() (const _CharT* __leaf, size_t __n) { - size_t __i; - for (__i = 0; __i < __n; __i++) { - if (__leaf[__i] == _M_pattern) { - _M_count += __i; return false; - } - } - _M_count += __n; return true; - } -}; - -template -class _Rope_insert_char_consumer : public _Rope_char_consumer<_CharT> { - private: - typedef ostream _Insert_ostream; - _Insert_ostream& _M_o; - public: - // _CharT* buffer; // XXX not used - _Rope_insert_char_consumer(_Insert_ostream& __writer) - : _M_o(__writer) {}; - ~_Rope_insert_char_consumer() { }; - // Caller is presumed to own the ostream - bool operator() (const _CharT* __leaf, size_t __n); - // Returns true to continue traversal. -}; - -template -bool _Rope_insert_char_consumer<_CharT>::operator() - (const _CharT* __leaf, size_t __n) -{ - size_t __i; - // We assume that formatting is set up correctly for each element. - for (__i = 0; __i < __n; __i++) _M_o << __leaf[__i]; - return true; -} - -inline bool _Rope_insert_char_consumer::operator() - (const char* __leaf, size_t __n) -{ - size_t __i; - for (__i = 0; __i < __n; __i++) _M_o.put(__leaf[__i]); - return true; -} - -#if 0 -// I couldn't get this to work work with the VC++ version of basic_ostream. -// It also doesn't really do the right thing unless o is a wide stream. -// Given that wchar_t is often 4 bytes, its not clear to me how useful -// this stuff is anyway. -inline bool _Rope_insert_char_consumer::operator() - (const wchar_t* __leaf, size_t __n) -{ - size_t __i; - for (__i = 0; __i < __n; __i++) _M_o.put(__leaf[__i]); - return true; -} -#endif /* !_MSC_VER && !BORLAND */ - -template -bool rope<_CharT, _Alloc>::_S_apply_to_pieces( - _Rope_char_consumer<_CharT>& __c, - const _RopeRep* __r, - size_t __begin, size_t __end) -{ - if (0 == __r) return true; - switch(__r->_M_tag) { - case _RopeRep::_S_concat: - { - _RopeConcatenation* __conc = (_RopeConcatenation*)__r; - _RopeRep* __left = __conc->_M_left; - size_t __left_len = __left->_M_size; - if (__begin < __left_len) { - size_t __left_end = min(__left_len, __end); - if (!_S_apply_to_pieces(__c, __left, __begin, __left_end)) - return false; - } - if (__end > __left_len) { - _RopeRep* __right = __conc->_M_right; - size_t __right_start = max(__left_len, __begin); - if (!_S_apply_to_pieces(__c, __right, - __right_start - __left_len, - __end - __left_len)) { - return false; - } - } - } - return true; - case _RopeRep::_S_leaf: - { - _RopeLeaf* __l = (_RopeLeaf*)__r; - return __c(__l->_M_data + __begin, __end - __begin); - } - case _RopeRep::_S_function: - case _RopeRep::_S_substringfn: - { - _RopeFunction* __f = (_RopeFunction*)__r; - size_t __len = __end - __begin; - bool __result; - _CharT* __buffer = - (_CharT*)alloc::allocate(__len * sizeof(_CharT)); - __STL_TRY { - (*(__f->_M_fn))(__begin, __end, __buffer); - __result = __c(__buffer, __len); - alloc::deallocate(__buffer, __len * sizeof(_CharT)); - } - __STL_UNWIND((alloc::deallocate(__buffer, - __len * sizeof(_CharT)))) - return __result; - } - default: - __stl_assert(false); - /*NOTREACHED*/ - return false; - } -} - -inline void _Rope_fill(ostream& __o, size_t __n) -{ - char __f = __o.fill(); - size_t __i; - - for (__i = 0; __i < __n; __i++) __o.put(__f); -} - - -template inline bool _Rope_is_simple(_CharT*) { return false; } -inline bool _Rope_is_simple(char*) { return true; } -inline bool _Rope_is_simple(wchar_t*) { return true; } - - -template -ostream& operator<< (ostream& __o, const rope<_CharT, _Alloc>& __r) -{ - size_t __w = __o.width(); - bool __left = bool(__o.flags() & ios::left); - size_t __pad_len; - size_t __rope_len = __r.size(); - _Rope_insert_char_consumer<_CharT> __c(__o); - bool __is_simple = _Rope_is_simple((_CharT*)0); - - if (__rope_len < __w) { - __pad_len = __w - __rope_len; - } else { - __pad_len = 0; - } - if (!__is_simple) __o.width(__w/__rope_len); - __STL_TRY { - if (__is_simple && !__left && __pad_len > 0) { - _Rope_fill(__o, __pad_len); - } - __r.apply_to_pieces(0, __r.size(), __c); - if (__is_simple && __left && __pad_len > 0) { - _Rope_fill(__o, __pad_len); - } - if (!__is_simple) - __o.width(__w); - } - __STL_UNWIND(if (!__is_simple) __o.width(__w)) - return __o; -} - -template -_CharT* -rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, - size_t __start, size_t __len, - _CharT* __buffer) -{ - _Rope_flatten_char_consumer<_CharT> __c(__buffer); - _S_apply_to_pieces(__c, __r, __start, __start + __len); - return(__buffer + __len); -} - -template -size_t -rope<_CharT,_Alloc>::find(_CharT __pattern, size_t __start) const -{ - _Rope_find_char_char_consumer<_CharT> __c(__pattern); - _S_apply_to_pieces(__c, _M_tree_ptr, __start, size()); - size_type __result_pos = __start + __c._M_count; -# ifndef __STL_OLD_ROPE_SEMANTICS - if (__result_pos == size()) __result_pos = npos; -# endif - return __result_pos; -} - -template -_CharT* -rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer) -{ - if (0 == __r) return __buffer; - switch(__r->_M_tag) { - case _RopeRep::_S_concat: - { - _RopeConcatenation* __c = (_RopeConcatenation*)__r; - _RopeRep* __left = __c->_M_left; - _RopeRep* __right = __c->_M_right; - _CharT* __rest = _S_flatten(__left, __buffer); - return _S_flatten(__right, __rest); - } - case _RopeRep::_S_leaf: - { - _RopeLeaf* __l = (_RopeLeaf*)__r; - return copy_n(__l->_M_data, __l->_M_size, __buffer).second; - } - case _RopeRep::_S_function: - case _RopeRep::_S_substringfn: - // We dont yet do anything with substring nodes. - // This needs to be fixed before ropefiles will work well. - { - _RopeFunction* __f = (_RopeFunction*)__r; - (*(__f->_M_fn))(0, __f->_M_size, __buffer); - return __buffer + __f->_M_size; - } - default: - __stl_assert(false); - /*NOTREACHED*/ - return 0; - } -} - - -// This needs work for _CharT != char -template -void -rope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent) -{ - for (int __i = 0; __i < __indent; __i++) putchar(' '); - if (0 == __r) { - printf("NULL\n"); return; - } - if (_RopeRep::_S_concat == __r->_M_tag) { - _RopeConcatenation* __c = (_RopeConcatenation*)__r; - _RopeRep* __left = __c->_M_left; - _RopeRep* __right = __c->_M_right; - -# ifdef __GC - printf("Concatenation %p (depth = %d, len = %ld, %s balanced)\n", - __r, __r->_M_depth, __r->_M_size, __r->_M_is_balanced? "" : "not"); -# else - printf("Concatenation %p (rc = %ld, depth = %d, " - "len = %ld, %s balanced)\n", - __r, __r->_M_refcount, __r->_M_depth, __r->_M_size, - __r->_M_is_balanced? "" : "not"); -# endif - _S_dump(__left, __indent + 2); - _S_dump(__right, __indent + 2); - return; - } else { - char* __kind; - - switch (__r->_M_tag) { - case _RopeRep::_S_leaf: - __kind = "Leaf"; - break; - case _RopeRep::_S_function: - __kind = "Function"; - break; - case _RopeRep::_S_substringfn: - __kind = "Function representing substring"; - break; - default: - __kind = "(corrupted kind field!)"; - } -# ifdef __GC - printf("%s %p (depth = %d, len = %ld) ", - __kind, __r, __r->_M_depth, __r->_M_size); -# else - printf("%s %p (rc = %ld, depth = %d, len = %ld) ", - __kind, __r, __r->_M_refcount, __r->_M_depth, __r->_M_size); -# endif - if (_S_is_one_byte_char_type((_CharT*)0)) { - const int __max_len = 40; - _Self_destruct_ptr __prefix(_S_substring(__r, 0, __max_len)); - _CharT __buffer[__max_len + 1]; - bool __too_big = __r->_M_size > __prefix->_M_size; - - _S_flatten(__prefix, __buffer); - __buffer[__prefix->_M_size] = _S_eos((_CharT*)0); - printf("%s%s\n", - (char*)__buffer, __too_big? "...\n" : "\n"); - } else { - printf("\n"); - } - } -} - -template -const unsigned long -rope<_CharT,_Alloc>::_S_min_len[ - _Rope_RopeRep<_CharT,_Alloc>::_S_max_rope_depth + 1] = { -/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21, -/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377, -/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181, -/* 18 */6765, /* 19 */10946, /* 20 */17711, /* 21 */28657, /* 22 */46368, -/* 23 */75025, /* 24 */121393, /* 25 */196418, /* 26 */317811, -/* 27 */514229, /* 28 */832040, /* 29 */1346269, /* 30 */2178309, -/* 31 */3524578, /* 32 */5702887, /* 33 */9227465, /* 34 */14930352, -/* 35 */24157817, /* 36 */39088169, /* 37 */63245986, /* 38 */102334155, -/* 39 */165580141, /* 40 */267914296, /* 41 */433494437, -/* 42 */701408733, /* 43 */1134903170, /* 44 */1836311903, -/* 45 */2971215073u }; -// These are Fibonacci numbers < 2**32. - -template -rope<_CharT,_Alloc>::_RopeRep* -rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r) -{ - _RopeRep* __forest[_RopeRep::_S_max_rope_depth + 1]; - _RopeRep* __result = 0; - int __i; - // Invariant: - // The concatenation of forest in descending order is equal to __r. - // __forest[__i]._M_size >= _S_min_len[__i] - // __forest[__i]._M_depth = __i - // References from forest are included in refcount. - - for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) - __forest[__i] = 0; - __STL_TRY { - _S_add_to_forest(__r, __forest); - for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) - if (0 != __forest[__i]) { -# ifndef __GC - _Self_destruct_ptr __old(__result); -# endif - __result = _S_concat(__forest[__i], __result); - __forest[__i]->_M_unref_nonnil(); -# if !defined(__GC) && defined(__STL_USE_EXCEPTIONS) - __forest[__i] = 0; -# endif - } - } - __STL_UNWIND(for(__i = 0; __i <= _RopeRep::_S_max_rope_depth; __i++) - _S_unref(__forest[__i])) - if (__result->_M_depth > _RopeRep::_S_max_rope_depth) abort(); - return(__result); -} - - -template -void -rope<_CharT,_Alloc>::_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest) -{ - if (__r->_M_is_balanced) { - _S_add_leaf_to_forest(__r, __forest); - return; - } - __stl_assert(__r->_M_tag == _RopeRep::_S_concat); - { - _RopeConcatenation* __c = (_RopeConcatenation*)__r; - - _S_add_to_forest(__c->_M_left, __forest); - _S_add_to_forest(__c->_M_right, __forest); - } -} - - -template -void -rope<_CharT,_Alloc>::_S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest) -{ - _RopeRep* __insertee; // included in refcount - _RopeRep* __too_tiny = 0; // included in refcount - int __i; // forest[0..__i-1] is empty - size_t __s = __r->_M_size; - - for (__i = 0; __s >= _S_min_len[__i+1]/* not this bucket */; ++__i) { - if (0 != __forest[__i]) { -# ifndef __GC - _Self_destruct_ptr __old(__too_tiny); -# endif - __too_tiny = _S_concat_and_set_balanced(__forest[__i], __too_tiny); - __forest[__i]->_M_unref_nonnil(); - __forest[__i] = 0; - } - } - { -# ifndef __GC - _Self_destruct_ptr __old(__too_tiny); -# endif - __insertee = _S_concat_and_set_balanced(__too_tiny, __r); - } - // Too_tiny dead, and no longer included in refcount. - // Insertee is live and included. - __stl_assert(_S_is_almost_balanced(__insertee)); - __stl_assert(__insertee->_M_depth <= __r->_M_depth + 1); - for (;; ++__i) { - if (0 != __forest[__i]) { -# ifndef __GC - _Self_destruct_ptr __old(__insertee); -# endif - __insertee = _S_concat_and_set_balanced(__forest[__i], __insertee); - __forest[__i]->_M_unref_nonnil(); - __forest[__i] = 0; - __stl_assert(_S_is_almost_balanced(__insertee)); - } - __stl_assert(_S_min_len[__i] <= __insertee->_M_size); - __stl_assert(__forest[__i] == 0); - if (__i == _RopeRep::_S_max_rope_depth || - __insertee->_M_size < _S_min_len[__i+1]) { - __forest[__i] = __insertee; - // refcount is OK since __insertee is now dead. - return; - } - } -} - -template -_CharT -rope<_CharT,_Alloc>::_S_fetch(_RopeRep* __r, size_type __i) -{ - __GC_CONST _CharT* __cstr = __r->_M_c_string; - - __stl_assert(__i < __r->_M_size); - if (0 != __cstr) return __cstr[__i]; - for(;;) { - switch(__r->_M_tag) { - case _RopeRep::_S_concat: - { - _RopeConcatenation* __c = (_RopeConcatenation*)__r; - _RopeRep* __left = __c->_M_left; - size_t __left_len = __left->_M_size; - - if (__i >= __left_len) { - __i -= __left_len; - __r = __c->_M_right; - } else { - __r = __left; - } - } - break; - case _RopeRep::_S_leaf: - { - _RopeLeaf* __l = (_RopeLeaf*)__r; - return __l->_M_data[__i]; - } - case _RopeRep::_S_function: - case _RopeRep::_S_substringfn: - { - _RopeFunction* __f = (_RopeFunction*)__r; - _CharT __result; - - (*(__f->_M_fn))(__i, 1, &__result); - return __result; - } - } - } -} - -# ifndef __GC -// Return a uniquely referenced character slot for the given -// position, or 0 if that's not possible. -template -_CharT* -rope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i) -{ - _RopeRep* __clrstack[_RopeRep::_S_max_rope_depth]; - size_t __csptr = 0; - - for(;;) { - if (__r->_M_refcount > 1) return 0; - switch(__r->_M_tag) { - case _RopeRep::_S_concat: - { - _RopeConcatenation* __c = (_RopeConcatenation*)__r; - _RopeRep* __left = __c->_M_left; - size_t __left_len = __left->_M_size; - - if (__c->_M_c_string != 0) __clrstack[__csptr++] = __c; - if (__i >= __left_len) { - __i -= __left_len; - __r = __c->_M_right; - } else { - __r = __left; - } - } - break; - case _RopeRep::_S_leaf: - { - _RopeLeaf* __l = (_RopeLeaf*)__r; - if (__l->_M_c_string != __l->_M_data && __l->_M_c_string != 0) - __clrstack[__csptr++] = __l; - while (__csptr > 0) { - -- __csptr; - _RopeRep* __d = __clrstack[__csptr]; - __d->_M_free_c_string(); - __d->_M_c_string = 0; - } - return __l->_M_data + __i; - } - case _RopeRep::_S_function: - case _RopeRep::_S_substringfn: - return 0; - } - } -} -# endif /* __GC */ - -// The following could be implemented trivially using -// lexicographical_compare_3way. -// We do a little more work to avoid dealing with rope iterators for -// flat strings. -template -int -rope<_CharT,_Alloc>::_S_compare (const _RopeRep* __left, - const _RopeRep* __right) -{ - size_t __left_len; - size_t __right_len; - - if (0 == __right) return 0 != __left; - if (0 == __left) return -1; - __left_len = __left->_M_size; - __right_len = __right->_M_size; - if (_RopeRep::_S_leaf == __left->_M_tag) { - _RopeLeaf* __l = (_RopeLeaf*) __left; - if (_RopeRep::_S_leaf == __right->_M_tag) { - _RopeLeaf* __r = (_RopeLeaf*) __right; - return lexicographical_compare_3way( - __l->_M_data, __l->_M_data + __left_len, - __r->_M_data, __r->_M_data + __right_len); - } else { - const_iterator __rstart(__right, 0); - const_iterator __rend(__right, __right_len); - return lexicographical_compare_3way( - __l->_M_data, __l->_M_data + __left_len, - __rstart, __rend); - } - } else { - const_iterator __lstart(__left, 0); - const_iterator __lend(__left, __left_len); - if (_RopeRep::_S_leaf == __right->_M_tag) { - _RopeLeaf* __r = (_RopeLeaf*) __right; - return lexicographical_compare_3way( - __lstart, __lend, - __r->_M_data, __r->_M_data + __right_len); - } else { - const_iterator __rstart(__right, 0); - const_iterator __rend(__right, __right_len); - return lexicographical_compare_3way( - __lstart, __lend, - __rstart, __rend); - } - } -} - -// Assignment to reference proxies. -template -_Rope_char_ref_proxy<_CharT, _Alloc>& -_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c) { - _RopeRep* __old = _M_root->_M_tree_ptr; -# ifndef __GC - // First check for the case in which everything is uniquely - // referenced. In that case we can do this destructively. - _CharT* __ptr = _My_rope::_S_fetch_ptr(__old, _M_pos); - if (0 != __ptr) { - *__ptr = __c; - return *this; - } -# endif - _Self_destruct_ptr __left( - _My_rope::_S_substring(__old, 0, _M_pos)); - _Self_destruct_ptr __right( - _My_rope::_S_substring(__old, _M_pos+1, __old->_M_size)); - _Self_destruct_ptr __result_left( - _My_rope::_S_destr_concat_char_iter(__left, &__c, 1)); - -# ifndef __GC - __stl_assert(__left == __result_left || 1 == __result_left->_M_refcount); -# endif - _RopeRep* __result = - _My_rope::_S_concat(__result_left, __right); -# ifndef __GC - __stl_assert(1 <= __result->_M_refcount); - _RopeRep::_S_unref(__old); -# endif - _M_root->_M_tree_ptr = __result; - return *this; -} - -template -inline _Rope_char_ref_proxy<_CharT, _Alloc>::operator _CharT () const -{ - if (_M_current_valid) { - return _M_current; - } else { - return _My_rope::_S_fetch(_M_root->_M_tree_ptr, _M_pos); - } -} -template -_Rope_char_ptr_proxy<_CharT, _Alloc> -_Rope_char_ref_proxy<_CharT, _Alloc>::operator& () const { - return _Rope_char_ptr_proxy<_CharT, _Alloc>(*this); -} - -template -rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c, - const allocator_type& __a) -: _Base(__a) -{ - rope<_CharT,_Alloc> __result; - const size_t __exponentiate_threshold = 32; - size_t __exponent; - size_t __rest; - _CharT* __rest_buffer; - _RopeRep* __remainder; - rope<_CharT,_Alloc> __remainder_rope; - - if (0 == __n) - return; - - __exponent = __n / __exponentiate_threshold; - __rest = __n % __exponentiate_threshold; - if (0 == __rest) { - __remainder = 0; - } else { - __rest_buffer = _Data_allocate(_S_rounded_up_size(__rest)); - uninitialized_fill_n(__rest_buffer, __rest, __c); - _S_cond_store_eos(__rest_buffer[__rest]); - __STL_TRY { - __remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a); - } - __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a)) - } - __remainder_rope._M_tree_ptr = __remainder; - if (__exponent != 0) { - _CharT* __base_buffer = - _Data_allocate(_S_rounded_up_size(__exponentiate_threshold)); - _RopeLeaf* __base_leaf; - rope __base_rope; - uninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c); - _S_cond_store_eos(__base_buffer[__exponentiate_threshold]); - __STL_TRY { - __base_leaf = _S_new_RopeLeaf(__base_buffer, - __exponentiate_threshold, __a); - } - __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__base_buffer, - __exponentiate_threshold, __a)) - __base_rope._M_tree_ptr = __base_leaf; - if (1 == __exponent) { - __result = __base_rope; -# ifndef __GC - __stl_assert(2 == __result._M_tree_ptr->_M_refcount); - // One each for base_rope and __result -# endif - } else { - // XXX what is power()? - __result = power(__base_rope, __exponent, _Concat_fn()); - } - if (0 != __remainder) { - __result += __remainder_rope; - } - } else { - __result = __remainder_rope; - } - _M_tree_ptr = __result._M_tree_ptr; - _M_tree_ptr->_M_ref_nonnil(); -} - -template - _CharT rope<_CharT,_Alloc>::_S_empty_c_str[1]; - -# ifdef __STL_PTHREADS - template - pthread_mutex_t - rope<_CharT,_Alloc>::_S_swap_lock = PTHREAD_MUTEX_INITIALIZER; -# endif - -template -const _CharT* rope<_CharT,_Alloc>::c_str() const { - if (0 == _M_tree_ptr) { - _S_empty_c_str[0] = _S_eos((_CharT*)0); // Possibly redundant, - // but probably fast. - return _S_empty_c_str; - } - __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string; - if (0 != __old_c_string) return(__old_c_string); - size_t __s = size(); - _CharT* __result = _Data_allocate(__s + 1); - _S_flatten(_M_tree_ptr, __result); - __result[__s] = _S_eos((_CharT*)0); -# ifdef __GC - _M_tree_ptr->_M_c_string = __result; -# else - if ((__old_c_string = - _S_atomic_swap(&(_M_tree_ptr->_M_c_string), __result)) != 0) { - // It must have been added in the interim. Hence it had to have been - // separately allocated. Deallocate the old copy, since we just - // replaced it. - destroy(__old_c_string, __old_c_string + __s + 1); - _Data_deallocate(__old_c_string, __s + 1); - } -# endif - return(__result); -} - -template -const _CharT* rope<_CharT,_Alloc>::replace_with_c_str() { - if (0 == _M_tree_ptr) { - _S_empty_c_str[0] = _S_eos((_CharT*)0); - return _S_empty_c_str; - } - __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string; - if (_RopeRep::_S_leaf == _M_tree_ptr->_M_tag && 0 != __old_c_string) { - return(__old_c_string); - } - size_t __s = size(); - _CharT* __result = _Data_allocate(_S_rounded_up_size(__s)); - _S_flatten(_M_tree_ptr, __result); - __result[__s] = _S_eos((_CharT*)0); - _M_tree_ptr->_M_unref_nonnil(); - _M_tree_ptr = _S_new_RopeLeaf(__result, __s, get_allocator()); - return(__result); -} - -// Algorithm specializations. More should be added. - -#ifndef _MSC_VER -// I couldn't get this to work with VC++ -template -void -_Rope_rotate(_Rope_iterator<_CharT,_Alloc> __first, - _Rope_iterator<_CharT,_Alloc> __middle, - _Rope_iterator<_CharT,_Alloc> __last) -{ - __stl_assert(__first.container() == __middle.container() - && __middle.container() == __last.container()); - rope<_CharT,_Alloc>& __r(__first.container()); - rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index()); - rope<_CharT,_Alloc> __suffix = - __r.substr(__last.index(), __r.size() - __last.index()); - rope<_CharT,_Alloc> __part1 = - __r.substr(__middle.index(), __last.index() - __middle.index()); - rope<_CharT,_Alloc> __part2 = - __r.substr(__first.index(), __middle.index() - __first.index()); - __r = __prefix; - __r += __part1; - __r += __part2; - __r += __suffix; -} - -#if !defined(__GNUC__) -// Appears to confuse g++ -inline void rotate(_Rope_iterator __first, - _Rope_iterator __middle, - _Rope_iterator __last) { - _Rope_rotate(__first, __middle, __last); -} -#endif - -# if 0 -// Probably not useful for several reasons: -// - for SGIs 7.1 compiler and probably some others, -// this forces lots of rope instantiations, creating a -// code bloat and compile time problem. (Fixed in 7.2.) -// - wchar_t is 4 bytes wide on most UNIX platforms, making it unattractive -// for unicode strings. Unsigned short may be a better character -// type. -inline void rotate( - _Rope_iterator __first, - _Rope_iterator __middle, - _Rope_iterator __last) { - _Rope_rotate(__first, __middle, __last); -} -# endif -#endif /* _MSC_VER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#endif - -__STL_END_NAMESPACE - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/set b/libstdc++/stl/set deleted file mode 100644 index c836c4596d2..00000000000 --- a/libstdc++/stl/set +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_SET -#define __SGI_STL_SET - -#ifndef __SGI_STL_INTERNAL_TREE_H -#include -#endif -#include -#include - -#endif /* __SGI_STL_SET */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/set.h b/libstdc++/stl/set.h deleted file mode 100644 index 9004d2e0477..00000000000 --- a/libstdc++/stl/set.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_SET_H -#define __SGI_STL_SET_H - -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::set; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_SET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/slist b/libstdc++/stl/slist deleted file mode 100644 index c3ec74204c5..00000000000 --- a/libstdc++/stl/slist +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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. - * - */ - -#ifndef __SGI_STL_SLIST -#define __SGI_STL_SLIST - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_SLIST */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/slist.h b/libstdc++/stl/slist.h deleted file mode 100644 index d2377b0cf5a..00000000000 --- a/libstdc++/stl/slist.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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. - * - */ - -#ifndef __SGI_STL_SLIST_H -#define __SGI_STL_SLIST_H - -#include -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::slist; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_SLIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stack b/libstdc++/stl/stack deleted file mode 100644 index 36461d95b8c..00000000000 --- a/libstdc++/stl/stack +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_STACK -#define __SGI_STL_STACK - -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_STACK */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stack.h b/libstdc++/stl/stack.h deleted file mode 100644 index 89beca82f12..00000000000 --- a/libstdc++/stl/stack.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_STACK_H -#define __SGI_STL_STACK_H - -#include -#include -#include -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::stack; -using __STD::queue; -using __STD::priority_queue; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_STACK_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_algo.h b/libstdc++/stl/stl_algo.h deleted file mode 100644 index e9beaee15f1..00000000000 --- a/libstdc++/stl/stl_algo.h +++ /dev/null @@ -1,2894 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ALGO_H -#define __SGI_STL_INTERNAL_ALGO_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1209 -#endif - -// __median (an extension, not present in the C++ standard). - -template -inline const _Tp& __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) { - if (__a < __b) - if (__b < __c) - return __b; - else if (__a < __c) - return __c; - else - return __a; - else if (__a < __c) - return __a; - else if (__b < __c) - return __c; - else - return __b; -} - -template -inline const _Tp& -__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) { - if (__comp(__a, __b)) - if (__comp(__b, __c)) - return __b; - else if (__comp(__a, __c)) - return __c; - else - return __a; - else if (__comp(__a, __c)) - return __a; - else if (__comp(__b, __c)) - return __c; - else - return __b; -} - -// for_each. Apply a function to every element of a range. -template -_Function for_each(_InputIter __first, _InputIter __last, _Function __f) { - for ( ; __first != __last; ++__first) - __f(*__first); - return __f; -} - -// find and find_if. - -template -inline _InputIter find(_InputIter __first, _InputIter __last, - const _Tp& __val, - input_iterator_tag) -{ - while (__first != __last && *__first != __val) - ++__first; - return __first; -} - -template -inline _InputIter find_if(_InputIter __first, _InputIter __last, - _Predicate __pred, - input_iterator_tag) -{ - while (__first != __last && !__pred(*__first)) - ++__first; - return __first; -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -_RandomAccessIter find(_RandomAccessIter __first, _RandomAccessIter __last, - const _Tp& __val, - random_access_iterator_tag) -{ - typename iterator_traits<_RandomAccessIter>::difference_type __trip_count - = (__last - __first) >> 2; - - for ( ; __trip_count > 0 ; --__trip_count) { - if (*__first == __val) return __first; - ++__first; - - if (*__first == __val) return __first; - ++__first; - - if (*__first == __val) return __first; - ++__first; - - if (*__first == __val) return __first; - ++__first; - } - - switch(__last - __first) { - case 3: - if (*__first == __val) return __first; - ++__first; - case 2: - if (*__first == __val) return __first; - ++__first; - case 1: - if (*__first == __val) return __first; - ++__first; - case 0: - default: - return __last; - } -} - -template -_RandomAccessIter find_if(_RandomAccessIter __first, _RandomAccessIter __last, - _Predicate __pred, - random_access_iterator_tag) -{ - typename iterator_traits<_RandomAccessIter>::difference_type __trip_count - = (__last - __first) >> 2; - - for ( ; __trip_count > 0 ; --__trip_count) { - if (__pred(*__first)) return __first; - ++__first; - - if (__pred(*__first)) return __first; - ++__first; - - if (__pred(*__first)) return __first; - ++__first; - - if (__pred(*__first)) return __first; - ++__first; - } - - switch(__last - __first) { - case 3: - if (__pred(*__first)) return __first; - ++__first; - case 2: - if (__pred(*__first)) return __first; - ++__first; - case 1: - if (__pred(*__first)) return __first; - ++__first; - case 0: - default: - return __last; - } -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline _InputIter find(_InputIter __first, _InputIter __last, - const _Tp& __val) -{ - return find(__first, __last, __val, __ITERATOR_CATEGORY(__first)); -} - -template -inline _InputIter find_if(_InputIter __first, _InputIter __last, - _Predicate __pred) { - return find_if(__first, __last, __pred, __ITERATOR_CATEGORY(__first)); -} - -// adjacent_find. - -template -_ForwardIter adjacent_find(_ForwardIter __first, _ForwardIter __last) { - if (__first == __last) - return __last; - _ForwardIter __next = __first; - while(++__next != __last) { - if (*__first == *__next) - return __first; - __first = __next; - } - return __last; -} - -template -_ForwardIter adjacent_find(_ForwardIter __first, _ForwardIter __last, - _BinaryPredicate __binary_pred) { - if (__first == __last) - return __last; - _ForwardIter __next = __first; - while(++__next != __last) { - if (__binary_pred(*__first, *__next)) - return __first; - __first = __next; - } - return __last; -} - -// count and count_if. There are two version of each, one whose return type -// type is void and one (present only if we have partial specialization) -// whose return type is iterator_traits<_InputIter>::difference_type. The -// C++ standard only has the latter version, but the former, which was present -// in the HP STL, is retained for backward compatibility. - -template -void count(_InputIter __first, _InputIter __last, const _Tp& __value, - _Size& __n) { - for ( ; __first != __last; ++__first) - if (*__first == __value) - ++__n; -} - -template -void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, - _Size& __n) { - for ( ; __first != __last; ++__first) - if (__pred(*__first)) - ++__n; -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -typename iterator_traits<_InputIter>::difference_type -count(_InputIter __first, _InputIter __last, const _Tp& __value) { - typename iterator_traits<_InputIter>::difference_type __n = 0; - for ( ; __first != __last; ++__first) - if (*__first == __value) - ++__n; - return __n; -} - -template -typename iterator_traits<_InputIter>::difference_type -count_if(_InputIter __first, _InputIter __last, _Predicate __pred) { - typename iterator_traits<_InputIter>::difference_type __n = 0; - for ( ; __first != __last; ++__first) - if (__pred(*__first)) - ++__n; - return __n; -} - - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// search. - -template -_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2) -{ - // Test for empty ranges - if (__first1 == __last1 || __first2 == __last2) - return __first1; - - // Test for a pattern of length 1. - _ForwardIter2 __tmp(__first2); - ++__tmp; - if (__tmp == __last2) - return find(__first1, __last1, *__first2); - - // General case. - - _ForwardIter2 __p1, __p; - - __p1 = __first2; ++__p1; - - _ForwardIter1 __current = __first1; - - while (__first1 != __last1) { - __first1 = find(__first1, __last1, *__first2); - if (__first1 == __last1) - return __last1; - - __p = __p1; - __current = __first1; - if (++__current == __last1) - return __last1; - - while (*__current == *__p) { - if (++__p == __last2) - return __first1; - if (++__current == __last1) - return __last1; - } - - ++__first1; - } - return __first1; -} - -template -_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - _BinaryPred __predicate) -{ - // Test for empty ranges - if (__first1 == __last1 || __first2 == __last2) - return __first1; - - // Test for a pattern of length 1. - _ForwardIter2 __tmp(__first2); - ++__tmp; - if (__tmp == __last2) - return find(__first1, __last1, *__first2); - - // General case. - - _ForwardIter2 __p1, __p; - - __p1 = __first2; ++__p1; - - _ForwardIter1 __current = __first1; - - while (__first1 != __last1) { - while (__first1 != __last1) { - if (__predicate(*__first1, *__first2)) - break; - ++__first1; - } - while (__first1 != __last1 && !__predicate(*__first1, *__first2)) - ++__first1; - if (__first1 == __last1) - return __last1; - - __p = __p1; - __current = __first1; - if (++__current == __last1) return __last1; - - while (__predicate(*__current, *__p)) { - if (++__p == __last2) - return __first1; - if (++__current == __last1) - return __last1; - } - - ++__first1; - } - return __first1; -} - -// search_n. Search for __count consecutive copies of __val. - -template -_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, - _Integer __count, const _Tp& __val) { - if (__count <= 0) - return __first; - else { - __first = find(__first, __last, __val); - while (__first != __last) { - _Integer __n = __count - 1; - _ForwardIter __i = __first; - ++__i; - while (__i != __last && __n != 0 && *__i == __val) { - ++__i; - --__n; - } - if (__n == 0) - return __first; - else - __first = find(__i, __last, __val); - } - return __last; - } -} - -template -_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, - _Integer __count, const _Tp& __val, - _BinaryPred __binary_pred) { - if (__count <= 0) - return __first; - else { - while (__first != __last) { - if (__binary_pred(*__first, __val)) - break; - ++__first; - } - while (__first != __last) { - _Integer __n = __count - 1; - _ForwardIter __i = __first; - ++__i; - while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) { - ++__i; - --__n; - } - if (__n == 0) - return __first; - else { - while (__i != __last) { - if (__binary_pred(*__i, __val)) - break; - ++__i; - } - __first = __i; - } - } - return __last; - } -} - -// swap_ranges - -template -_ForwardIter2 swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2) { - for ( ; __first1 != __last1; ++__first1, ++__first2) - iter_swap(__first1, __first2); - return __first2; -} - -// transform - -template -_OutputIter transform(_InputIter __first, _InputIter __last, - _OutputIter __result, _UnaryOperation __oper) { - for ( ; __first != __last; ++__first, ++__result) - *__result = __oper(*__first); - return __result; -} - -template -_OutputIter transform(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _OutputIter __result, - _BinaryOperation __binary_op) { - for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result) - *__result = __binary_op(*__first1, *__first2); - return __result; -} - -// replace, replace_if, replace_copy, replace_copy_if - -template -void replace(_ForwardIter __first, _ForwardIter __last, - const _Tp& __old_value, const _Tp& __new_value) { - for ( ; __first != __last; ++__first) - if (*__first == __old_value) - *__first = __new_value; -} - -template -void replace_if(_ForwardIter __first, _ForwardIter __last, - _Predicate __pred, const _Tp& __new_value) { - for ( ; __first != __last; ++__first) - if (__pred(*__first)) - *__first = __new_value; -} - -template -_OutputIter replace_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - const _Tp& __old_value, const _Tp& __new_value) { - for ( ; __first != __last; ++__first, ++__result) - *__result = *__first == __old_value ? __new_value : *__first; - return __result; -} - -template -_OutputIter replace_copy_if(Iterator __first, Iterator __last, - _OutputIter __result, - _Predicate __pred, const _Tp& __new_value) { - for ( ; __first != __last; ++__first, ++__result) - *__result = __pred(*__first) ? __new_value : *__first; - return __result; -} - -// generate and generate_n - -template -void generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) { - for ( ; __first != __last; ++__first) - *__first = __gen(); -} - -template -_OutputIter generate_n(_OutputIter __first, _Size __n, _Generator __gen) { - for ( ; __n > 0; --__n, ++__first) - *__first = __gen(); - return __first; -} - -// remove, remove_if, remove_copy, remove_copy_if - -template -_OutputIter remove_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, const _Tp& __value) { - for ( ; __first != __last; ++__first) - if (*__first != __value) { - *__result = *__first; - ++__result; - } - return __result; -} - -template -_OutputIter remove_copy_if(_InputIter __first, _InputIter __last, - _OutputIter __result, _Predicate __pred) { - for ( ; __first != __last; ++__first) - if (!__pred(*__first)) { - *__result = *__first; - ++__result; - } - return __result; -} - -template -_ForwardIter remove(_ForwardIter __first, _ForwardIter __last, - const _Tp& __value) { - __first = find(__first, __last, __value); - _ForwardIter __i = __first; - return __first == __last ? __first - : remove_copy(++__i, __last, __first, __value); -} - -template -_ForwardIter remove_if(_ForwardIter __first, _ForwardIter __last, - _Predicate __pred) { - __first = find_if(__first, __last, __pred); - _ForwardIter __i = __first; - return __first == __last ? __first - : remove_copy_if(++__i, __last, __first, __pred); -} - -// unique and unique_copy - -template -_OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, _Tp*) { - _Tp __value = *__first; - *__result = __value; - while (++__first != __last) - if (__value != *__first) { - __value = *__first; - *++__result = __value; - } - return ++__result; -} - -template -inline _OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - output_iterator_tag) { - return __unique_copy(__first, __last, __result, __VALUE_TYPE(__first)); -} - -template -_ForwardIter __unique_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result, forward_iterator_tag) { - *__result = *__first; - while (++__first != __last) - if (*__result != *__first) *++__result = *__first; - return ++__result; -} - -template -inline _OutputIter unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result) { - if (__first == __last) return __result; - return __unique_copy(__first, __last, __result, - __ITERATOR_CATEGORY(__result)); -} - -template -_OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - _BinaryPredicate __binary_pred, _Tp*) { - _Tp __value = *__first; - *__result = __value; - while (++__first != __last) - if (!__binary_pred(__value, *__first)) { - __value = *__first; - *++__result = __value; - } - return ++__result; -} - -template -inline _OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - _BinaryPredicate __binary_pred, - output_iterator_tag) { - return __unique_copy(__first, __last, __result, __binary_pred, - __VALUE_TYPE(__first)); -} - -template -_ForwardIter __unique_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result, - _BinaryPredicate __binary_pred, - forward_iterator_tag) { - *__result = *__first; - while (++__first != __last) - if (!__binary_pred(*__result, *__first)) *++__result = *__first; - return ++__result; -} - -template -inline _OutputIter unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - _BinaryPredicate __binary_pred) { - if (__first == __last) return __result; - return __unique_copy(__first, __last, __result, __binary_pred, - __ITERATOR_CATEGORY(__result)); -} - -template -_ForwardIter unique(_ForwardIter __first, _ForwardIter __last) { - __first = adjacent_find(__first, __last); - return unique_copy(__first, __last, __first); -} - -template -_ForwardIter unique(_ForwardIter __first, _ForwardIter __last, - _BinaryPredicate __binary_pred) { - __first = adjacent_find(__first, __last, __binary_pred); - return unique_copy(__first, __last, __first, __binary_pred); -} - -// reverse and reverse_copy, and their auxiliary functions - -template -void __reverse(_BidirectionalIter __first, _BidirectionalIter __last, - bidirectional_iterator_tag) { - while (true) - if (__first == __last || __first == --__last) - return; - else - iter_swap(__first++, __last); -} - -template -void __reverse(_RandomAccessIter __first, _RandomAccessIter __last, - random_access_iterator_tag) { - while (__first < __last) - iter_swap(__first++, --__last); -} - -template -inline void reverse(_BidirectionalIter __first, _BidirectionalIter __last) { - __reverse(__first, __last, __ITERATOR_CATEGORY(__first)); -} - -template -_OutputIter reverse_copy(_BidirectionalIter __first, - _BidirectionalIter __last, - _OutputIter __result) { - while (__first != __last) { - --__last; - *__result = *__last; - ++__result; - } - return __result; -} - -// rotate and rotate_copy, and their auxiliary functions - -template -_EuclideanRingElement __gcd(_EuclideanRingElement __m, - _EuclideanRingElement __n) -{ - while (__n != 0) { - _EuclideanRingElement __t = __m % __n; - __m = __n; - __n = __t; - } - return __m; -} - -template -_ForwardIter __rotate(_ForwardIter __first, - _ForwardIter __middle, - _ForwardIter __last, - _Distance*, - forward_iterator_tag) { - if (__first == __middle) - return __last; - if (__last == __middle) - return __first; - - _ForwardIter __first2 = __middle; - do { - swap(*__first++, *__first2++); - if (__first == __middle) - __middle = __first2; - } while (__first2 != __last); - - _ForwardIter __new_middle = __first; - - __first2 = __middle; - - while (__first2 != __last) { - swap (*__first++, *__first2++); - if (__first == __middle) - __middle = __first2; - else if (__first2 == __last) - __first2 = __middle; - } - - return __new_middle; -} - - -template -_BidirectionalIter __rotate(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance*, - bidirectional_iterator_tag) { - if (__first == __middle) - return __last; - if (__last == __middle) - return __first; - - __reverse(__first, __middle, bidirectional_iterator_tag()); - __reverse(__middle, __last, bidirectional_iterator_tag()); - - while (__first != __middle && __middle != __last) - swap (*__first++, *--__last); - - if (__first == __middle) { - __reverse(__middle, __last, bidirectional_iterator_tag()); - return __last; - } - else { - __reverse(__first, __middle, bidirectional_iterator_tag()); - return __first; - } -} - -template -_RandomAccessIter __rotate(_RandomAccessIter __first, - _RandomAccessIter __middle, - _RandomAccessIter __last, - _Distance *, _Tp *) { - - _Distance __n = __last - __first; - _Distance __k = __middle - __first; - _Distance __l = __n - __k; - _RandomAccessIter __result = __first + (__last - __middle); - - if (__k == __l) { - swap_ranges(__first, __middle, __middle); - return __result; - } - - _Distance __d = __gcd(__n, __k); - - for (_Distance __i = 0; __i < __d; __i++) { - _Tp __tmp = *__first; - _RandomAccessIter __p = __first; - - if (__k < __l) { - for (_Distance __j = 0; __j < __l/__d; __j++) { - if (__p > __first + __l) { - *__p = *(__p - __l); - __p -= __l; - } - - *__p = *(__p + __k); - __p += __k; - } - } - - else { - for (_Distance __j = 0; __j < __k/__d - 1; __j ++) { - if (__p < __last - __k) { - *__p = *(__p + __k); - __p += __k; - } - - *__p = * (__p - __l); - __p -= __l; - } - } - - *__p = __tmp; - ++__first; - } - - return __result; -} - -template -inline _ForwardIter rotate(_ForwardIter __first, _ForwardIter __middle, - _ForwardIter __last) { - return __rotate(__first, __middle, __last, - __DISTANCE_TYPE(__first), - __ITERATOR_CATEGORY(__first)); -} - -template -_OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle, - _ForwardIter __last, _OutputIter __result) { - return copy(__first, __middle, copy(__middle, __last, __result)); -} - -// Return a random number in the range [0, __n). This function encapsulates -// whether we're using rand (part of the standard C library) or lrand48 -// (not standard, but a much better choice whenever it's available). - -template -inline _Distance __random_number(_Distance __n) { -#ifdef __STL_NO_DRAND48 - return rand() % __n; -#else - return lrand48() % __n; -#endif -} - -// random_shuffle - -template -inline void random_shuffle(_RandomAccessIter __first, - _RandomAccessIter __last) { - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - iter_swap(__i, __first + __random_number((__i - __first) + 1)); -} - -template -void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last, - _RandomNumberGenerator& __rand) { - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - iter_swap(__i, __first + __rand((__i - __first) + 1)); -} - -// random_sample and random_sample_n (extensions, not part of the standard). - -template -_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, - _OutputIter __out, const _Distance __n) -{ - _Distance __remaining = 0; - distance(__first, __last, __remaining); - _Distance __m = min(__n, __remaining); - - while (__m > 0) { - if (__random_number(__remaining) < __m) { - *__out = *__first; - ++__out; - --__m; - } - - --__remaining; - ++__first; - } - return __out; -} - -template -_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, - _OutputIter __out, const _Distance __n, - _RandomNumberGenerator& __rand) -{ - _Distance __remaining = 0; - distance(__first, __last, __remaining); - _Distance __m = min(__n, __remaining); - - while (__m > 0) { - if (__rand(__remaining) < __m) { - *__out = *__first; - ++__out; - --__m; - } - - --__remaining; - ++__first; - } - return __out; -} - -template -_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out, - const _Distance __n) -{ - _Distance __m = 0; - _Distance __t = __n; - for ( ; __first != __last && __m < __n; ++__m, ++__first) - __out[__m] = *__first; - - while (__first != __last) { - ++__t; - _Distance __M = __random_number(__t); - if (__M < __n) - __out[__M] = *__first; - ++__first; - } - - return __out + __m; -} - -template -_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out, - _RandomNumberGenerator& __rand, - const _Distance __n) -{ - _Distance __m = 0; - _Distance __t = __n; - for ( ; __first != __last && __m < __n; ++__m, ++__first) - __out[__m] = *__first; - - while (__first != __last) { - ++__t; - _Distance __M = __rand(__t); - if (__M < __n) - __out[__M] = *__first; - ++__first; - } - - return __out + __m; -} - -template -inline _RandomAccessIter -random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out_first, _RandomAccessIter __out_last) -{ - return __random_sample(__first, __last, - __out_first, __out_last - __out_first); -} - - -template -inline _RandomAccessIter -random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out_first, _RandomAccessIter __out_last, - _RandomNumberGenerator& __rand) -{ - return __random_sample(__first, __last, - __out_first, __rand, - __out_last - __out_first); -} - -// partition, stable_partition, and their auxiliary functions - -template -_ForwardIter __partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred, - forward_iterator_tag) { - if (__first == __last) return __first; - - while (__pred(*__first)) - if (++__first == __last) return __first; - - _ForwardIter __next = __first; - - while (++__next != __last) - if (__pred(*__next)) { - swap(*__first, *__next); - ++__first; - } - - return __first; -} - -template -_BidirectionalIter __partition(_BidirectionalIter __first, - _BidirectionalIter __last, - _Predicate __pred, - bidirectional_iterator_tag) { - while (true) { - while (true) - if (__first == __last) - return __first; - else if (__pred(*__first)) - ++__first; - else - break; - --__last; - while (true) - if (__first == __last) - return __first; - else if (!__pred(*__last)) - --__last; - else - break; - iter_swap(__first, __last); - ++__first; - } -} - -template -inline _ForwardIter partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred) { - return __partition(__first, __last, __pred, __ITERATOR_CATEGORY(__first)); -} - - -template -_ForwardIter __inplace_stable_partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred, _Distance __len) { - if (__len == 1) - return __pred(*__first) ? __last : __first; - _ForwardIter __middle = __first; - advance(__middle, __len / 2); - return rotate(__inplace_stable_partition(__first, __middle, __pred, - __len / 2), - __middle, - __inplace_stable_partition(__middle, __last, __pred, - __len - __len / 2)); -} - -template -_ForwardIter __stable_partition_adaptive(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred, _Distance __len, - _Pointer __buffer, - _Distance __buffer_size) -{ - if (__len <= __buffer_size) { - _ForwardIter __result1 = __first; - _Pointer __result2 = __buffer; - for ( ; __first != __last ; ++__first) - if (__pred(*__first)) { - *__result1 = *__first; - ++__result1; - } - else { - *__result2 = *__first; - ++__result2; - } - copy(__buffer, __result2, __result1); - return __result1; - } - else { - _ForwardIter __middle = __first; - advance(__middle, __len / 2); - return rotate(__stable_partition_adaptive( - __first, __middle, __pred, - __len / 2, __buffer, __buffer_size), - __middle, - __stable_partition_adaptive( - __middle, __last, __pred, - __len - __len / 2, __buffer, __buffer_size)); - } -} - -template -inline _ForwardIter -__stable_partition_aux(_ForwardIter __first, _ForwardIter __last, - _Predicate __pred, _Tp*, _Distance*) -{ - _Temporary_buffer<_ForwardIter, _Tp> __buf(__first, __last); - if (__buf.size() > 0) - return __stable_partition_adaptive(__first, __last, __pred, - _Distance(__buf.requested_size()), - __buf.begin(), __buf.size()); - else - return __inplace_stable_partition(__first, __last, __pred, - _Distance(__buf.requested_size())); -} - -template -inline _ForwardIter stable_partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred) { - if (__first == __last) - return __first; - else - return __stable_partition_aux(__first, __last, __pred, - __VALUE_TYPE(__first), - __DISTANCE_TYPE(__first)); -} - -template -_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, - _RandomAccessIter __last, - _Tp __pivot) -{ - while (true) { - while (*__first < __pivot) - ++__first; - --__last; - while (__pivot < *__last) - --__last; - if (!(__first < __last)) - return __first; - iter_swap(__first, __last); - ++__first; - } -} - -template -_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, - _RandomAccessIter __last, - _Tp __pivot, _Compare __comp) -{ - while (true) { - while (__comp(*__first, __pivot)) - ++__first; - --__last; - while (__comp(__pivot, *__last)) - --__last; - if (!(__first < __last)) - return __first; - iter_swap(__first, __last); - ++__first; - } -} - -const int __stl_threshold = 16; - -// sort() and its auxiliary functions. - -template -void __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val) { - _RandomAccessIter __next = __last; - --__next; - while (__val < *__next) { - *__last = *__next; - __last = __next; - --__next; - } - *__last = __val; -} - -template -void __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val, - _Compare __comp) { - _RandomAccessIter __next = __last; - --__next; - while (__comp(__val, *__next)) { - *__last = *__next; - __last = __next; - --__next; - } - *__last = __val; -} - -template -inline void __linear_insert(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*) { - _Tp __val = *__last; - if (__val < *__first) { - copy_backward(__first, __last, __last + 1); - *__first = __val; - } - else - __unguarded_linear_insert(__last, __val); -} - -template -inline void __linear_insert(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, _Compare __comp) { - _Tp __val = *__last; - if (__comp(__val, *__first)) { - copy_backward(__first, __last, __last + 1); - *__first = __val; - } - else - __unguarded_linear_insert(__last, __val, __comp); -} - -template -void __insertion_sort(_RandomAccessIter __first, _RandomAccessIter __last) { - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - __linear_insert(__first, __i, __VALUE_TYPE(__first)); -} - -template -void __insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - __linear_insert(__first, __i, __VALUE_TYPE(__first), __comp); -} - -template -void __unguarded_insertion_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*) { - for (_RandomAccessIter __i = __first; __i != __last; ++__i) - __unguarded_linear_insert(__i, _Tp(*__i)); -} - -template -inline void __unguarded_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - __unguarded_insertion_sort_aux(__first, __last, __VALUE_TYPE(__first)); -} - -template -void __unguarded_insertion_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, - _Tp*, _Compare __comp) { - for (_RandomAccessIter __i = __first; __i != __last; ++__i) - __unguarded_linear_insert(__i, _Tp(*__i), __comp); -} - -template -inline void __unguarded_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, - _Compare __comp) { - __unguarded_insertion_sort_aux(__first, __last, __VALUE_TYPE(__first), - __comp); -} - -template -void __final_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - if (__last - __first > __stl_threshold) { - __insertion_sort(__first, __first + __stl_threshold); - __unguarded_insertion_sort(__first + __stl_threshold, __last); - } - else - __insertion_sort(__first, __last); -} - -template -void __final_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - if (__last - __first > __stl_threshold) { - __insertion_sort(__first, __first + __stl_threshold, __comp); - __unguarded_insertion_sort(__first + __stl_threshold, __last, __comp); - } - else - __insertion_sort(__first, __last, __comp); -} - -template -inline _Size __lg(_Size __n) { - _Size __k; - for (__k = 0; __n != 1; __n >>= 1) ++__k; - return __k; -} - -template -void __introsort_loop(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, - _Size __depth_limit) -{ - while (__last - __first > __stl_threshold) { - if (__depth_limit == 0) { - partial_sort(__first, __last, __last); - return; - } - --__depth_limit; - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1)))); - __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit); - __last = __cut; - } -} - -template -void __introsort_loop(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, - _Size __depth_limit, _Compare __comp) -{ - while (__last - __first > __stl_threshold) { - if (__depth_limit == 0) { - partial_sort(__first, __last, __last, __comp); - return; - } - --__depth_limit; - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1), __comp)), - __comp); - __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit, __comp); - __last = __cut; - } -} - -template -inline void sort(_RandomAccessIter __first, _RandomAccessIter __last) { - if (__first != __last) { - __introsort_loop(__first, __last, - __VALUE_TYPE(__first), - __lg(__last - __first) * 2); - __final_insertion_sort(__first, __last); - } -} - -template -inline void sort(_RandomAccessIter __first, _RandomAccessIter __last, - _Compare __comp) { - if (__first != __last) { - __introsort_loop(__first, __last, - __VALUE_TYPE(__first), - __lg(__last - __first) * 2, - __comp); - __final_insertion_sort(__first, __last, __comp); - } -} - -// stable_sort() and its auxiliary functions. - -template -void __inplace_stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - if (__last - __first < 15) { - __insertion_sort(__first, __last); - return; - } - _RandomAccessIter __middle = __first + (__last - __first) / 2; - __inplace_stable_sort(__first, __middle); - __inplace_stable_sort(__middle, __last); - __merge_without_buffer(__first, __middle, __last, - __middle - __first, - __last - __middle); -} - -template -void __inplace_stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - if (__last - __first < 15) { - __insertion_sort(__first, __last, __comp); - return; - } - _RandomAccessIter __middle = __first + (__last - __first) / 2; - __inplace_stable_sort(__first, __middle, __comp); - __inplace_stable_sort(__middle, __last, __comp); - __merge_without_buffer(__first, __middle, __last, - __middle - __first, - __last - __middle, - __comp); -} - -template -void __merge_sort_loop(_RandomAccessIter1 __first, - _RandomAccessIter1 __last, - _RandomAccessIter2 __result, _Distance __step_size) { - _Distance __two_step = 2 * __step_size; - - while (__last - __first >= __two_step) { - __result = merge(__first, __first + __step_size, - __first + __step_size, __first + __two_step, - __result); - __first += __two_step; - } - - __step_size = min(_Distance(__last - __first), __step_size); - merge(__first, __first + __step_size, __first + __step_size, __last, - __result); -} - -template -void __merge_sort_loop(_RandomAccessIter1 __first, - _RandomAccessIter1 __last, - _RandomAccessIter2 __result, _Distance __step_size, - _Compare __comp) { - _Distance __two_step = 2 * __step_size; - - while (__last - __first >= __two_step) { - __result = merge(__first, __first + __step_size, - __first + __step_size, __first + __two_step, - __result, - __comp); - __first += __two_step; - } - __step_size = min(_Distance(__last - __first), __step_size); - - merge(__first, __first + __step_size, - __first + __step_size, __last, - __result, - __comp); -} - -const int __stl_chunk_size = 7; - -template -void __chunk_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Distance __chunk_size) -{ - while (__last - __first >= __chunk_size) { - __insertion_sort(__first, __first + __chunk_size); - __first += __chunk_size; - } - __insertion_sort(__first, __last); -} - -template -void __chunk_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, - _Distance __chunk_size, _Compare __comp) -{ - while (__last - __first >= __chunk_size) { - __insertion_sort(__first, __first + __chunk_size, __comp); - __first += __chunk_size; - } - __insertion_sort(__first, __last, __comp); -} - -template -void __merge_sort_with_buffer(_RandomAccessIter __first, - _RandomAccessIter __last, - _Pointer __buffer, _Distance*) { - _Distance __len = __last - __first; - _Pointer __buffer_last = __buffer + __len; - - _Distance __step_size = __stl_chunk_size; - __chunk_insertion_sort(__first, __last, __step_size); - - while (__step_size < __len) { - __merge_sort_loop(__first, __last, __buffer, __step_size); - __step_size *= 2; - __merge_sort_loop(__buffer, __buffer_last, __first, __step_size); - __step_size *= 2; - } -} - -template -void __merge_sort_with_buffer(_RandomAccessIter __first, - _RandomAccessIter __last, _Pointer __buffer, - _Distance*, _Compare __comp) { - _Distance __len = __last - __first; - _Pointer __buffer_last = __buffer + __len; - - _Distance __step_size = __stl_chunk_size; - __chunk_insertion_sort(__first, __last, __step_size, __comp); - - while (__step_size < __len) { - __merge_sort_loop(__first, __last, __buffer, __step_size, __comp); - __step_size *= 2; - __merge_sort_loop(__buffer, __buffer_last, __first, __step_size, __comp); - __step_size *= 2; - } -} - -template -void __stable_sort_adaptive(_RandomAccessIter __first, - _RandomAccessIter __last, _Pointer __buffer, - _Distance __buffer_size) { - _Distance __len = (__last - __first + 1) / 2; - _RandomAccessIter __middle = __first + __len; - if (__len > __buffer_size) { - __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size); - __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size); - } - else { - __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0); - __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0); - } - __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), - _Distance(__last - __middle), __buffer, __buffer_size); -} - -template -void __stable_sort_adaptive(_RandomAccessIter __first, - _RandomAccessIter __last, _Pointer __buffer, - _Distance __buffer_size, _Compare __comp) { - _Distance __len = (__last - __first + 1) / 2; - _RandomAccessIter __middle = __first + __len; - if (__len > __buffer_size) { - __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size, - __comp); - __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size, - __comp); - } - else { - __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0, - __comp); - __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0, - __comp); - } - __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), - _Distance(__last - __middle), __buffer, __buffer_size, - __comp); -} - -template -inline void __stable_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, _Distance*) { - _Temporary_buffer<_RandomAccessIter, _Tp> buf(__first, __last); - if (buf.begin() == 0) - __inplace_stable_sort(__first, __last); - else - __stable_sort_adaptive(__first, __last, buf.begin(), - _Distance(buf.size())); -} - -template -inline void __stable_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, _Distance*, - _Compare __comp) { - _Temporary_buffer<_RandomAccessIter, _Tp> buf(__first, __last); - if (buf.begin() == 0) - __inplace_stable_sort(__first, __last, __comp); - else - __stable_sort_adaptive(__first, __last, buf.begin(), - _Distance(buf.size()), - __comp); -} - -template -inline void stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - __stable_sort_aux(__first, __last, - __VALUE_TYPE(__first), - __DISTANCE_TYPE(__first)); -} - -template -inline void stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - __stable_sort_aux(__first, __last, - __VALUE_TYPE(__first), - __DISTANCE_TYPE(__first), - __comp); -} - -// partial_sort, partial_sort_copy, and auxiliary functions. - -template -void __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, - _RandomAccessIter __last, _Tp*) { - make_heap(__first, __middle); - for (_RandomAccessIter __i = __middle; __i < __last; ++__i) - if (*__i < *__first) - __pop_heap(__first, __middle, __i, _Tp(*__i), - __DISTANCE_TYPE(__first)); - sort_heap(__first, __middle); -} - -template -inline void partial_sort(_RandomAccessIter __first, - _RandomAccessIter __middle, - _RandomAccessIter __last) { - __partial_sort(__first, __middle, __last, __VALUE_TYPE(__first)); -} - -template -void __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, - _RandomAccessIter __last, _Tp*, _Compare __comp) { - make_heap(__first, __middle, __comp); - for (_RandomAccessIter __i = __middle; __i < __last; ++__i) - if (__comp(*__i, *__first)) - __pop_heap(__first, __middle, __i, _Tp(*__i), __comp, - __DISTANCE_TYPE(__first)); - sort_heap(__first, __middle, __comp); -} - -template -inline void partial_sort(_RandomAccessIter __first, - _RandomAccessIter __middle, - _RandomAccessIter __last, _Compare __comp) { - __partial_sort(__first, __middle, __last, __VALUE_TYPE(__first), __comp); -} - -template -_RandomAccessIter __partial_sort_copy(_InputIter __first, - _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last, - _Distance*, _Tp*) { - if (__result_first == __result_last) return __result_last; - _RandomAccessIter __result_real_last = __result_first; - while(__first != __last && __result_real_last != __result_last) { - *__result_real_last = *__first; - ++__result_real_last; - ++__first; - } - make_heap(__result_first, __result_real_last); - while (__first != __last) { - if (*__first < *__result_first) - __adjust_heap(__result_first, _Distance(0), - _Distance(__result_real_last - __result_first), - _Tp(*__first)); - ++__first; - } - sort_heap(__result_first, __result_real_last); - return __result_real_last; -} - -template -inline _RandomAccessIter -partial_sort_copy(_InputIter __first, _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last) { - return __partial_sort_copy(__first, __last, __result_first, __result_last, - __DISTANCE_TYPE(__result_first), - __VALUE_TYPE(__first)); -} - -template -_RandomAccessIter __partial_sort_copy(_InputIter __first, - _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last, - _Compare __comp, _Distance*, _Tp*) { - if (__result_first == __result_last) return __result_last; - _RandomAccessIter __result_real_last = __result_first; - while(__first != __last && __result_real_last != __result_last) { - *__result_real_last = *__first; - ++__result_real_last; - ++__first; - } - make_heap(__result_first, __result_real_last, __comp); - while (__first != __last) { - if (__comp(*__first, *__result_first)) - __adjust_heap(__result_first, _Distance(0), - _Distance(__result_real_last - __result_first), - _Tp(*__first), - __comp); - ++__first; - } - sort_heap(__result_first, __result_real_last, __comp); - return __result_real_last; -} - -template -inline _RandomAccessIter -partial_sort_copy(_InputIter __first, _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last, _Compare __comp) { - return __partial_sort_copy(__first, __last, __result_first, __result_last, - __comp, - __DISTANCE_TYPE(__result_first), - __VALUE_TYPE(__first)); -} - -// nth_element() and its auxiliary functions. - -template -void __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last, _Tp*) { - while (__last - __first > 3) { - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1)))); - if (__cut <= __nth) - __first = __cut; - else - __last = __cut; - } - __insertion_sort(__first, __last); -} - -template -inline void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last) { - __nth_element(__first, __nth, __last, __VALUE_TYPE(__first)); -} - -template -void __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last, _Tp*, _Compare __comp) { - while (__last - __first > 3) { - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1), - __comp)), - __comp); - if (__cut <= __nth) - __first = __cut; - else - __last = __cut; - } - __insertion_sort(__first, __last, __comp); -} - -template -inline void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last, _Compare __comp) { - __nth_element(__first, __nth, __last, __VALUE_TYPE(__first), __comp); -} - - -// Binary search (lower_bound, upper_bound, equal_range, binary_search). - -template -_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (*__middle < __val) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; -} - -template -inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val) { - return __lower_bound(__first, __last, __val, - __DISTANCE_TYPE(__first)); -} - -template -_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__comp(*__middle, __val)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; -} - -template -inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp) { - return __lower_bound(__first, __last, __val, __comp, - __DISTANCE_TYPE(__first)); -} - -template -_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__val < *__middle) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; -} - -template -inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val) { - return __upper_bound(__first, __last, __val, - __DISTANCE_TYPE(__first)); -} - -template -_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__comp(__val, *__middle)) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; -} - -template -inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp) { - return __upper_bound(__first, __last, __val, __comp, - __DISTANCE_TYPE(__first)); -} - -template -pair<_ForwardIter, _ForwardIter> -__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, - _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle, __left, __right; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (*__middle < __val) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else if (__val < *__middle) - __len = __half; - else { - __left = lower_bound(__first, __middle, __val); - advance(__first, __len); - __right = upper_bound(++__middle, __first, __val); - return pair<_ForwardIter, _ForwardIter>(__left, __right); - } - } - return pair<_ForwardIter, _ForwardIter>(__first, __first); -} - -template -inline pair<_ForwardIter, _ForwardIter> -equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { - return __equal_range(__first, __last, __val, - __DISTANCE_TYPE(__first)); -} - -template -pair<_ForwardIter, _ForwardIter> -__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, - _Compare __comp, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle, __left, __right; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__comp(*__middle, __val)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else if (__comp(__val, *__middle)) - __len = __half; - else { - __left = lower_bound(__first, __middle, __val, __comp); - advance(__first, __len); - __right = upper_bound(++__middle, __first, __val, __comp); - return pair<_ForwardIter, _ForwardIter>(__left, __right); - } - } - return pair<_ForwardIter, _ForwardIter>(__first, __first); -} - -template -inline pair<_ForwardIter, _ForwardIter> -equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, - _Compare __comp) { - return __equal_range(__first, __last, __val, __comp, - __DISTANCE_TYPE(__first)); -} - -template -bool binary_search(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val) { - _ForwardIter __i = lower_bound(__first, __last, __val); - return __i != __last && !(__val < *__i); -} - -template -bool binary_search(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, - _Compare __comp) { - _ForwardIter __i = lower_bound(__first, __last, __val, __comp); - return __i != __last && !__comp(__val, *__i); -} - -// merge, with and without an explicitly supplied comparison function. - -template -_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - while (__first1 != __last1 && __first2 != __last2) { - if (*__first2 < *__first1) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - while (__first1 != __last1 && __first2 != __last2) { - if (__comp(*__first2, *__first1)) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -// inplace_merge and its auxiliary functions. - -template -void __merge_without_buffer(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2) { - if (__len1 == 0 || __len2 == 0) - return; - if (__len1 + __len2 == 2) { - if (*__middle < *__first) - iter_swap(__first, __middle); - return; - } - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle - = rotate(__first_cut, __middle, __second_cut); - __merge_without_buffer(__first, __first_cut, __new_middle, - __len11, __len22); - __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22); -} - -template -void __merge_without_buffer(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2, - _Compare __comp) { - if (__len1 == 0 || __len2 == 0) - return; - if (__len1 + __len2 == 2) { - if (__comp(*__middle, *__first)) - iter_swap(__first, __middle); - return; - } - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut, __comp); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut, __comp); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle - = rotate(__first_cut, __middle, __second_cut); - __merge_without_buffer(__first, __first_cut, __new_middle, __len11, __len22, - __comp); - __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22, __comp); -} - -template -_BidirectionalIter1 __rotate_adaptive(_BidirectionalIter1 __first, - _BidirectionalIter1 __middle, - _BidirectionalIter1 __last, - _Distance __len1, _Distance __len2, - _BidirectionalIter2 __buffer, - _Distance __buffer_size) { - _BidirectionalIter2 __buffer_end; - if (__len1 > __len2 && __len2 <= __buffer_size) { - __buffer_end = copy(__middle, __last, __buffer); - copy_backward(__first, __middle, __last); - return copy(__buffer, __buffer_end, __first); - } - else if (__len1 <= __buffer_size) { - __buffer_end = copy(__first, __middle, __buffer); - copy(__middle, __last, __first); - return copy_backward(__buffer, __buffer_end, __last); - } - else - return rotate(__first, __middle, __last); -} - -template -_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1, - _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, - _BidirectionalIter2 __last2, - _BidirectionalIter3 __result) { - if (__first1 == __last1) - return copy_backward(__first2, __last2, __result); - if (__first2 == __last2) - return copy_backward(__first1, __last1, __result); - --__last1; - --__last2; - while (true) { - if (*__last2 < *__last1) { - *--__result = *__last1; - if (__first1 == __last1) - return copy_backward(__first2, ++__last2, __result); - --__last1; - } - else { - *--__result = *__last2; - if (__first2 == __last2) - return copy_backward(__first1, ++__last1, __result); - --__last2; - } - } -} - -template -_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1, - _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, - _BidirectionalIter2 __last2, - _BidirectionalIter3 __result, - _Compare __comp) { - if (__first1 == __last1) - return copy_backward(__first2, __last2, __result); - if (__first2 == __last2) - return copy_backward(__first1, __last1, __result); - --__last1; - --__last2; - while (true) { - if (__comp(*__last2, *__last1)) { - *--__result = *__last1; - if (__first1 == __last1) - return copy_backward(__first2, ++__last2, __result); - --__last1; - } - else { - *--__result = *__last2; - if (__first2 == __last2) - return copy_backward(__first1, ++__last1, __result); - --__last2; - } - } -} - -template -void __merge_adaptive(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2, - _Pointer __buffer, _Distance __buffer_size) { - if (__len1 <= __len2 && __len1 <= __buffer_size) { - _Pointer __buffer_end = copy(__first, __middle, __buffer); - merge(__buffer, __buffer_end, __middle, __last, __first); - } - else if (__len2 <= __buffer_size) { - _Pointer __buffer_end = copy(__middle, __last, __buffer); - __merge_backward(__first, __middle, __buffer, __buffer_end, __last); - } - else { - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle = - __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11, - __len22, __buffer, __buffer_size); - __merge_adaptive(__first, __first_cut, __new_middle, __len11, - __len22, __buffer, __buffer_size); - __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22, __buffer, __buffer_size); - } -} - -template -void __merge_adaptive(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2, - _Pointer __buffer, _Distance __buffer_size, - _Compare __comp) { - if (__len1 <= __len2 && __len1 <= __buffer_size) { - _Pointer __buffer_end = copy(__first, __middle, __buffer); - merge(__buffer, __buffer_end, __middle, __last, __first, __comp); - } - else if (__len2 <= __buffer_size) { - _Pointer __buffer_end = copy(__middle, __last, __buffer); - __merge_backward(__first, __middle, __buffer, __buffer_end, __last, - __comp); - } - else { - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut, __comp); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut, __comp); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle = - __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11, - __len22, __buffer, __buffer_size); - __merge_adaptive(__first, __first_cut, __new_middle, __len11, - __len22, __buffer, __buffer_size, __comp); - __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22, __buffer, __buffer_size, __comp); - } -} - -template -inline void __inplace_merge_aux(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, _Tp*, _Distance*) { - _Distance __len1 = 0; - distance(__first, __middle, __len1); - _Distance __len2 = 0; - distance(__middle, __last, __len2); - - _Temporary_buffer<_BidirectionalIter, _Tp> __buf(__first, __last); - if (__buf.begin() == 0) - __merge_without_buffer(__first, __middle, __last, __len1, __len2); - else - __merge_adaptive(__first, __middle, __last, __len1, __len2, - __buf.begin(), _Distance(__buf.size())); -} - -template -inline void __inplace_merge_aux(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, _Tp*, _Distance*, - _Compare __comp) { - _Distance __len1 = 0; - distance(__first, __middle, __len1); - _Distance __len2 = 0; - distance(__middle, __last, __len2); - - _Temporary_buffer<_BidirectionalIter, _Tp> __buf(__first, __last); - if (__buf.begin() == 0) - __merge_without_buffer(__first, __middle, __last, __len1, __len2, __comp); - else - __merge_adaptive(__first, __middle, __last, __len1, __len2, - __buf.begin(), _Distance(__buf.size()), - __comp); -} - -template -inline void inplace_merge(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last) { - if (__first == __middle || __middle == __last) - return; - __inplace_merge_aux(__first, __middle, __last, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template -inline void inplace_merge(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, _Compare __comp) { - if (__first == __middle || __middle == __last) - return; - __inplace_merge_aux(__first, __middle, __last, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first), - __comp); -} - -// Set algorithms: includes, set_union, set_intersection, set_difference, -// set_symmetric_difference. All of these algorithms have the precondition -// that their input ranges are sorted and the postcondition that their output -// ranges are sorted. - -template -bool includes(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) { - while (__first1 != __last1 && __first2 != __last2) - if (*__first2 < *__first1) - return false; - else if(*__first1 < *__first2) - ++__first1; - else - ++__first1, ++__first2; - - return __first2 == __last2; -} - -template -bool includes(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, _Compare __comp) { - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first2, *__first1)) - return false; - else if(__comp(*__first1, *__first2)) - ++__first1; - else - ++__first1, ++__first2; - - return __first2 == __last2; -} - -template -_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - while (__first1 != __last1 && __first2 != __last2) { - if (*__first1 < *__first2) { - *__result = *__first1; - ++__first1; - } - else if (*__first2 < *__first1) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - ++__first2; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - while (__first1 != __last1 && __first2 != __last2) { - if (__comp(*__first1, *__first2)) { - *__result = *__first1; - ++__first1; - } - else if (__comp(*__first2, *__first1)) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - ++__first2; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - while (__first1 != __last1 && __first2 != __last2) - if (*__first1 < *__first2) - ++__first1; - else if (*__first2 < *__first1) - ++__first2; - else { - *__result = *__first1; - ++__first1; - ++__first2; - ++__result; - } - return __result; -} - -template -_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first1, *__first2)) - ++__first1; - else if (__comp(*__first2, *__first1)) - ++__first2; - else { - *__result = *__first1; - ++__first1; - ++__first2; - ++__result; - } - return __result; -} - -template -_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - while (__first1 != __last1 && __first2 != __last2) - if (*__first1 < *__first2) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (*__first2 < *__first1) - ++__first2; - else { - ++__first1; - ++__first2; - } - return copy(__first1, __last1, __result); -} - -template -_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first1, *__first2)) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (__comp(*__first2, *__first1)) - ++__first2; - else { - ++__first1; - ++__first2; - } - return copy(__first1, __last1, __result); -} - -template -_OutputIter -set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - while (__first1 != __last1 && __first2 != __last2) - if (*__first1 < *__first2) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (*__first2 < *__first1) { - *__result = *__first2; - ++__first2; - ++__result; - } - else { - ++__first1; - ++__first2; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter -set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, - _Compare __comp) { - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first1, *__first2)) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (__comp(*__first2, *__first1)) { - *__result = *__first2; - ++__first2; - ++__result; - } - else { - ++__first1; - ++__first2; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -// min_element and max_element, with and without an explicitly supplied -// comparison function. - -template -_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last) { - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (*__result < *__first) - __result = __first; - return __result; -} - -template -_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last, - _Compare __comp) { - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (__comp(*__result, *__first)) __result = __first; - return __result; -} - -template -_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last) { - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (*__first < *__result) - __result = __first; - return __result; -} - -template -_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last, - _Compare __comp) { - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (__comp(*__first, *__result)) - __result = __first; - return __result; -} - -// next_permutation and prev_permutation, with and without an explicitly -// supplied comparison function. - -template -bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last) { - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (*__i < *__ii) { - _BidirectionalIter __j = __last; - while (!(*__i < *--__j)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -template -bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last, - _Compare __comp) { - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (__comp(*__i, *__ii)) { - _BidirectionalIter __j = __last; - while (!__comp(*__i, *--__j)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -template -bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last) { - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (*__ii < *__i) { - _BidirectionalIter __j = __last; - while (!(*--__j < *__i)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -template -bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last, - _Compare __comp) { - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (__comp(*__ii, *__i)) { - _BidirectionalIter __j = __last; - while (!__comp(*--__j, *__i)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -// find_first_of, with and without an explicitly supplied comparison function. - -template -_InputIter find_first_of(_InputIter __first1, _InputIter __last1, - _ForwardIter __first2, _ForwardIter __last2) -{ - for ( ; __first1 != __last1; ++__first1) - for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter) - if (*__first1 == *__iter) - return __first1; - return __last1; -} - -template -_InputIter find_first_of(_InputIter __first1, _InputIter __last1, - _ForwardIter __first2, _ForwardIter __last2, - _BinaryPredicate __comp) -{ - for ( ; __first1 != __last1; ++__first1) - for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter) - if (__comp(*__first1, *__iter)) - return __first1; - return __last1; -} - - -// find_end, with and without an explicitly supplied comparison function. -// Search [first2, last2) as a subsequence in [first1, last1), and return -// the *last* possible match. Note that find_end for bidirectional iterators -// is much faster than for forward iterators. - -// find_end for forward iterators. -template -_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - forward_iterator_tag, forward_iterator_tag) -{ - if (__first2 == __last2) - return __last1; - else { - _ForwardIter1 __result = __last1; - while (1) { - _ForwardIter1 __new_result - = search(__first1, __last1, __first2, __last2); - if (__new_result == __last1) - return __result; - else { - __result = __new_result; - __first1 = __new_result; - ++__first1; - } - } - } -} - -template -_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - forward_iterator_tag, forward_iterator_tag, - _BinaryPredicate __comp) -{ - if (__first2 == __last2) - return __last1; - else { - _ForwardIter1 __result = __last1; - while (1) { - _ForwardIter1 __new_result - = search(__first1, __last1, __first2, __last2, __comp); - if (__new_result == __last1) - return __result; - else { - __result = __new_result; - __first1 = __new_result; - ++__first1; - } - } - } -} - -// find_end for bidirectional iterators. Requires partial specialization. -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -_BidirectionalIter1 -__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, _BidirectionalIter2 __last2, - bidirectional_iterator_tag, bidirectional_iterator_tag) -{ - typedef reverse_iterator<_BidirectionalIter1> _RevIter1; - typedef reverse_iterator<_BidirectionalIter2> _RevIter2; - - _RevIter1 __rlast1(__first1); - _RevIter2 __rlast2(__first2); - _RevIter1 __rresult = search(_RevIter1(__last1), __rlast1, - _RevIter2(__last2), __rlast2); - - if (__rresult == __rlast1) - return __last1; - else { - _BidirectionalIter1 __result = __rresult.base(); - advance(__result, -distance(__first2, __last2)); - return __result; - } -} - -template -_BidirectionalIter1 -__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, _BidirectionalIter2 __last2, - bidirectional_iterator_tag, bidirectional_iterator_tag, - _BinaryPredicate __comp) -{ - typedef reverse_iterator<_BidirectionalIter1> _RevIter1; - typedef reverse_iterator<_BidirectionalIter2> _RevIter2; - - _RevIter1 __rlast1(__first1); - _RevIter2 __rlast2(__first2); - _RevIter1 __rresult = search(_RevIter1(__last1), __rlast1, - _RevIter2(__last2), __rlast2, - __comp); - - if (__rresult == __rlast1) - return __last1; - else { - _BidirectionalIter1 __result = __rresult.base(); - advance(__result, -distance(__first2, __last2)); - return __result; - } -} -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// Dispatching functions for find_end. - -template -inline _ForwardIter1 -find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2) -{ - return __find_end(__first1, __last1, __first2, __last2, - __ITERATOR_CATEGORY(__first1), - __ITERATOR_CATEGORY(__first2)); -} - -template -inline _ForwardIter1 -find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - _BinaryPredicate __comp) -{ - return __find_end(__first1, __last1, __first2, __last2, - __ITERATOR_CATEGORY(__first1), - __ITERATOR_CATEGORY(__first2), - __comp); -} - -// is_heap, a predicate testing whether or not a range is -// a heap. This function is an extension, not part of the C++ -// standard. - -template -bool __is_heap(_RandomAccessIter __first, _Distance __n) -{ - _Distance __parent = 0; - for (_Distance __child = 1; __child < __n; ++__child) { - if (__first[__parent] < __first[__child]) - return false; - if ((__child & 1) == 0) - ++__parent; - } - return true; -} - -template -bool __is_heap(_RandomAccessIter __first, _StrictWeakOrdering __comp, - _Distance __n) -{ - _Distance __parent = 0; - for (_Distance __child = 1; __child < __n; ++__child) { - if (__comp(__first[__parent], __first[__child])) - return false; - if ((__child & 1) == 0) - ++__parent; - } - return true; -} - -template -inline bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last) -{ - return __is_heap(__first, __last - __first); -} - - -template -inline bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last, - _StrictWeakOrdering __comp) -{ - return __is_heap(__first, __comp, __last - __first); -} - -// is_sorted, a predicated testing whether a range is sorted in -// nondescending order. This is an extension, not part of the C++ -// standard. - -template -bool is_sorted(_ForwardIter __first, _ForwardIter __last) -{ - if (__first == __last) - return true; - - _ForwardIter __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (*__next < *__first) - return false; - } - - return true; -} - -template -bool is_sorted(_ForwardIter __first, _ForwardIter __last, - _StrictWeakOrdering __comp) -{ - if (__first == __last) - return true; - - _ForwardIter __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (__comp(*__next, *__first)) - return false; - } - - return true; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1209 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_ALGO_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_algobase.h b/libstdc++/stl/stl_algobase.h deleted file mode 100644 index 15e535f483d..00000000000 --- a/libstdc++/stl/stl_algobase.h +++ /dev/null @@ -1,526 +0,0 @@ -/* - * - * 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-1998 - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - - -#ifndef __SGI_STL_INTERNAL_ALGOBASE_H -#define __SGI_STL_INTERNAL_ALGOBASE_H - -#ifndef __STL_CONFIG_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_RELOPS -#include -#endif -#ifndef __SGI_STL_INTERNAL_PAIR_H -#include -#endif -#ifndef __TYPE_TRAITS_H_ -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifndef __SGI_STL_INTERNAL_ITERATOR_H -#include -#endif - -__STL_BEGIN_NAMESPACE - -// swap and iter_swap - -template -inline void __iter_swap(_ForwardIter1 __a, _ForwardIter2 __b, _Tp*) { - _Tp __tmp = *__a; - *__a = *__b; - *__b = __tmp; -} - -template -inline void iter_swap(_ForwardIter1 __a, _ForwardIter2 __b) { - __iter_swap(__a, __b, __VALUE_TYPE(__a)); -} - -template -inline void swap(_Tp& __a, _Tp& __b) { - _Tp __tmp = __a; - __a = __b; - __b = __tmp; -} - -//-------------------------------------------------- -// min and max - -#ifndef __BORLANDC__ - -#undef min -#undef max - -template -inline const _Tp& min(const _Tp& __a, const _Tp& __b) { - return __b < __a ? __b : __a; -} - -template -inline const _Tp& max(const _Tp& __a, const _Tp& __b) { - return __a < __b ? __b : __a; -} - -#endif /* __BORLANDC__ */ - -template -inline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { - return __comp(__b, __a) ? __b : __a; -} - -template -inline const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) { - return __comp(__a, __b) ? __b : __a; -} - -//-------------------------------------------------- -// copy - -// All of these auxiliary functions serve two purposes. (1) Replace -// calls to copy with memmove whenever possible. (Memmove, not memcpy, -// because the input and output ranges are permitted to overlap.) -// (2) If we're using random access iterators, then write the loop as -// a for loop with an explicit count. The auxiliary class __copy_dispatch -// is a workaround for compilers that don't support partial ordering of -// function templates. - -template -inline _OutputIter __copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - input_iterator_tag, _Distance*) -{ - for ( ; __first != __last; ++__result, ++__first) - *__result = *__first; - return __result; -} - -template -inline _OutputIter -__copy(_RandomAccessIter __first, _RandomAccessIter __last, - _OutputIter __result, random_access_iterator_tag, _Distance*) -{ - for (_Distance __n = __last - __first; __n > 0; --__n) { - *__result = *__first; - ++__first; - ++__result; - } - return __result; -} - -template -inline _Tp* -__copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result) { - memmove(__result, __first, sizeof(_Tp) * (__last - __first)); - return __result + (__last - __first); -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -struct __copy_dispatch { - static _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) { - typedef typename iterator_traits<_InputIter>::iterator_category _Category; - typedef typename iterator_traits<_InputIter>::difference_type _Distance; - return __copy(__first, __last, __result, _Category(), (_Distance*) 0); - } -}; - -template -struct __copy_dispatch<_Tp*, _Tp*, __true_type> -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - return __copy_trivial(__first, __last, __result); - } -}; - -template -struct __copy_dispatch -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - return __copy_trivial(__first, __last, __result); - } -}; - -template -inline _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) { - typedef typename iterator_traits<_InputIter>::value_type _Tp; - typedef typename __type_traits<_Tp>::has_trivial_assignment_operator - _Trivial; - return __copy_dispatch<_InputIter, _OutputIter, _Trivial> - ::copy(__first, __last, __result); -} - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) -{ - return __copy(__first, __last, __result, - __ITERATOR_CATEGORY(__first), - __DISTANCE_TYPE(__first)); -} - -inline char* copy(const char* __first, const char* __last, char* __result) { - memmove(__result, __first, __last - __first); - return __result + (__last - __first); -} - -inline wchar_t* copy(const wchar_t* __first, const wchar_t* __last, - wchar_t* __result) { - memmove(__result, __first, sizeof(wchar_t) * (__last - __first)); - return __result + (__last - __first); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -//-------------------------------------------------- -// copy_backward - -template -inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first, - _BidirectionalIter1 __last, - _BidirectionalIter2 __result, - bidirectional_iterator_tag, - _Distance*) -{ - while (__first != __last) - *--__result = *--__last; - return __result; -} - -template -inline _BidirectionalIter __copy_backward(_RandomAccessIter __first, - _RandomAccessIter __last, - _BidirectionalIter __result, - random_access_iterator_tag, - _Distance*) -{ - for (_Distance __n = __last - __first; __n > 0; --__n) - *--__result = *--__last; - return __result; -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -// This dispatch class is a workaround for compilers that do not -// have partial ordering of function templates. All we're doing is -// creating a specialization so that we can turn a call to copy_backward -// into a memmove whenever possible. - -template -struct __copy_backward_dispatch -{ - typedef typename iterator_traits<_BidirectionalIter1>::iterator_category - _Cat; - typedef typename iterator_traits<_BidirectionalIter1>::difference_type - _Distance; - - static _BidirectionalIter2 copy(_BidirectionalIter1 __first, - _BidirectionalIter1 __last, - _BidirectionalIter2 __result) { - return __copy_backward(__first, __last, __result, _Cat(), (_Distance*) 0); - } -}; - -template -struct __copy_backward_dispatch<_Tp*, _Tp*, __true_type> -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - const ptrdiff_t _Num = __last - __first; - memmove(__result - _Num, __first, sizeof(_Tp) * _Num); - return __result - _Num; - } -}; - -template -struct __copy_backward_dispatch -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - return __copy_backward_dispatch<_Tp*, _Tp*, __true_type> - ::copy(__first, __last, __result); - } -}; - -template -inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) { - typedef typename __type_traits::value_type> - ::has_trivial_assignment_operator - _Trivial; - return __copy_backward_dispatch<_BI1, _BI2, _Trivial> - ::copy(__first, __last, __result); -} - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) { - return __copy_backward(__first, __last, __result, - __ITERATOR_CATEGORY(__first), - __DISTANCE_TYPE(__first)); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -//-------------------------------------------------- -// copy_n (not part of the C++ standard) - -template -pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count, - _OutputIter __result, - input_iterator_tag) { - for ( ; __count > 0; --__count) { - *__result = *__first; - ++__first; - ++__result; - } - return pair<_InputIter, _OutputIter>(__first, __result); -} - -template -inline pair<_RAIter, _OutputIter> -__copy_n(_RAIter __first, _Size __count, - _OutputIter __result, - random_access_iterator_tag) { - _RAIter __last = __first + __count; - return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result)); -} - -template -inline pair<_InputIter, _OutputIter> -__copy_n(_InputIter __first, _Size __count, _OutputIter __result) { - return __copy_n(__first, __count, __result, - __ITERATOR_CATEGORY(__first)); -} - -template -inline pair<_InputIter, _OutputIter> -copy_n(_InputIter __first, _Size __count, _OutputIter __result) { - return __copy_n(__first, __count, __result); -} - -//-------------------------------------------------- -// fill and fill_n - - -template -void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value) { - for ( ; __first != __last; ++__first) - *__first = __value; -} - -template -_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __value) { - for ( ; __n > 0; --__n, ++__first) - *__first = __value; - return __first; -} - -//-------------------------------------------------- -// equal and mismatch - -template -pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, - _InputIter1 __last1, - _InputIter2 __first2) { - while (__first1 != __last1 && *__first1 == *__first2) { - ++__first1; - ++__first2; - } - return pair<_InputIter1, _InputIter2>(__first1, __first2); -} - -template -pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, - _InputIter1 __last1, - _InputIter2 __first2, - _BinaryPredicate __binary_pred) { - while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) { - ++__first1; - ++__first2; - } - return pair<_InputIter1, _InputIter2>(__first1, __first2); -} - -template -inline bool equal(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2) { - for ( ; __first1 != __last1; ++__first1, ++__first2) - if (*__first1 != *__first2) - return false; - return true; -} - -template -inline bool equal(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _BinaryPredicate __binary_pred) { - for ( ; __first1 != __last1; ++__first1, ++__first2) - if (!__binary_pred(*__first1, *__first2)) - return false; - return true; -} - -//-------------------------------------------------- -// lexicographical_compare and lexicographical_compare_3way. -// (the latter is not part of the C++ standard.) - -template -bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) { - for ( ; __first1 != __last1 && __first2 != __last2 - ; ++__first1, ++__first2) { - if (*__first1 < *__first2) - return true; - if (*__first2 < *__first1) - return false; - } - return __first1 == __last1 && __first2 != __last2; -} - -template -bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _Compare __comp) { - for ( ; __first1 != __last1 && __first2 != __last2 - ; ++__first1, ++__first2) { - if (__comp(*__first1, *__first2)) - return true; - if (__comp(*__first2, *__first1)) - return false; - } - return __first1 == __last1 && __first2 != __last2; -} - -inline bool -lexicographical_compare(const unsigned char* __first1, - const unsigned char* __last1, - const unsigned char* __first2, - const unsigned char* __last2) -{ - const size_t __len1 = __last1 - __first1; - const size_t __len2 = __last2 - __first2; - const int __result = memcmp(__first1, __first2, min(__len1, __len2)); - return __result != 0 ? __result < 0 : __len1 < __len2; -} - -inline bool lexicographical_compare(const char* __first1, const char* __last1, - const char* __first2, const char* __last2) -{ -#if CHAR_MAX == SCHAR_MAX - return lexicographical_compare((const signed char*) __first1, - (const signed char*) __last1, - (const signed char*) __first2, - (const signed char*) __last2); -#else /* CHAR_MAX == SCHAR_MAX */ - return lexicographical_compare((const unsigned char*) __first1, - (const unsigned char*) __last1, - (const unsigned char*) __first2, - (const unsigned char*) __last2); -#endif /* CHAR_MAX == SCHAR_MAX */ -} - -template -int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) -{ - while (__first1 != __last1 && __first2 != __last2) { - if (*__first1 < *__first2) - return -1; - if (*__first2 < *__first1) - return 1; - ++__first1; - ++__first2; - } - if (__first2 == __last2) { - return !(__first1 == __last1); - } - else { - return -1; - } -} - -inline int -__lexicographical_compare_3way(const unsigned char* __first1, - const unsigned char* __last1, - const unsigned char* __first2, - const unsigned char* __last2) -{ - const ptrdiff_t __len1 = __last1 - __first1; - const ptrdiff_t __len2 = __last2 - __first2; - const int __result = memcmp(__first1, __first2, min(__len1, __len2)); - return __result != 0 ? __result - : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1)); -} - -inline int -__lexicographical_compare_3way(const char* __first1, const char* __last1, - const char* __first2, const char* __last2) -{ -#if CHAR_MAX == SCHAR_MAX - return __lexicographical_compare_3way( - (const signed char*) __first1, - (const signed char*) __last1, - (const signed char*) __first2, - (const signed char*) __last2); -#else - return __lexicographical_compare_3way((const unsigned char*) __first1, - (const unsigned char*) __last1, - (const unsigned char*) __first2, - (const unsigned char*) __last2); -#endif -} - -template -int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) -{ - return __lexicographical_compare_3way(__first1, __last1, __first2, __last2); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_ALGOBASE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_alloc.h b/libstdc++/stl/stl_alloc.h deleted file mode 100644 index 208309a389b..00000000000 --- a/libstdc++/stl/stl_alloc.h +++ /dev/null @@ -1,1057 +0,0 @@ -/* - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ALLOC_H -#define __SGI_STL_INTERNAL_ALLOC_H - -#ifdef __SUNPRO_CC -# define __PRIVATE public - // Extra access restrictions prevent us from really making some things - // private. -#else -# define __PRIVATE private -#endif - -#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG -# define __USE_MALLOC -#endif - - -// This implements some standard node allocators. These are -// NOT the same as the allocators in the C++ draft standard or in -// in the original STL. They do not encapsulate different pointer -// types; indeed we assume that there is only one pointer type. -// The allocation primitives are intended to allocate individual objects, -// not larger arenas as with the original STL allocators. - -#if 0 -# include -# define __THROW_BAD_ALLOC throw bad_alloc() -#elif !defined(__THROW_BAD_ALLOC) -# include -# define __THROW_BAD_ALLOC cerr << "out of memory" << endl; exit(1) -#endif - -#ifdef __STL_WIN32THREADS -# include -#endif - -#include -#include -#include -#include -#ifndef __RESTRICT -# define __RESTRICT -#endif - -#if !defined(__STL_PTHREADS) && !defined(__STL_SOLTHREADS) \ - && !defined(_NOTHREADS) \ - && !defined(__STL_SGI_THREADS) && !defined(__STL_WIN32THREADS) -# define _NOTHREADS -#endif - -# ifdef __STL_PTHREADS - // POSIX Threads - // This is dubious, since this is likely to be a high contention - // lock. Performance may not be adequate. -# include -# define __NODE_ALLOCATOR_LOCK \ - if (threads) pthread_mutex_lock(&_S_node_allocator_lock) -# define __NODE_ALLOCATOR_UNLOCK \ - if (threads) pthread_mutex_unlock(&_S_node_allocator_lock) -# define __NODE_ALLOCATOR_THREADS true -# define __VOLATILE volatile // Needed at -O3 on SGI -# endif -# ifdef __STL_SOLTHREADS -# include -# define __NODE_ALLOCATOR_LOCK \ - if (threads) mutex_lock(&_S_node_allocator_lock) -# define __NODE_ALLOCATOR_UNLOCK \ - if (threads) mutex_unlock(&_S_node_allocator_lock) -# define __NODE_ALLOCATOR_THREADS true -# define __VOLATILE -# endif -# ifdef __STL_WIN32THREADS - // The lock needs to be initialized by constructing an allocator - // objects of the right type. We do that here explicitly for alloc. -# define __NODE_ALLOCATOR_LOCK \ - EnterCriticalSection(&_S_node_allocator_lock) -# define __NODE_ALLOCATOR_UNLOCK \ - LeaveCriticalSection(&_S_node_allocator_lock) -# define __NODE_ALLOCATOR_THREADS true -# define __VOLATILE volatile // may not be needed -# endif /* WIN32THREADS */ -# ifdef __STL_SGI_THREADS - // This should work without threads, with sproc threads, or with - // pthreads. It is suboptimal in all cases. - // It is unlikely to even compile on nonSGI machines. - - extern "C" { - extern int __us_rsthread_malloc; - } - // The above is copied from malloc.h. Including - // would be cleaner but fails with certain levels of standard - // conformance. -# define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \ - { _S_lock(&_S_node_allocator_lock); } -# define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \ - { _S_unlock(&_S_node_allocator_lock); } -# define __NODE_ALLOCATOR_THREADS true -# define __VOLATILE volatile // Needed at -O3 on SGI -# endif -# ifdef _NOTHREADS -// Thread-unsafe -# define __NODE_ALLOCATOR_LOCK -# define __NODE_ALLOCATOR_UNLOCK -# define __NODE_ALLOCATOR_THREADS false -# define __VOLATILE -# endif - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#endif - -// Malloc-based allocator. Typically slower than default alloc below. -// Typically thread-safe and more storage efficient. -#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG -# ifdef __DECLARE_GLOBALS_HERE - void (* __malloc_alloc_oom_handler)() = 0; - // g++ 2.7.2 does not handle static template data members. -# else - extern void (* __malloc_alloc_oom_handler)(); -# endif -#endif - -template -class __malloc_alloc_template { - -private: - - static void* _S_oom_malloc(size_t); - static void* _S_oom_realloc(void*, size_t); - -#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG - static void (* __malloc_alloc_oom_handler)(); -#endif - -public: - - static void* allocate(size_t __n) - { - void* __result = malloc(__n); - if (0 == __result) __result = _S_oom_malloc(__n); - return __result; - } - - static void deallocate(void* __p, size_t /* __n */) - { - free(__p); - } - - static void* reallocate(void* __p, size_t /* old_sz */, size_t __new_sz) - { - void* __result = realloc(__p, __new_sz); - if (0 == __result) __result = _S_oom_realloc(__p, __new_sz); - return __result; - } - - static void (* __set_malloc_handler(void (*__f)()))() - { - void (* __old)() = __malloc_alloc_oom_handler; - __malloc_alloc_oom_handler = __f; - return(__old); - } - -}; - -// malloc_alloc out-of-memory handling - -#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG -template -void (* __malloc_alloc_template<__inst>::__malloc_alloc_oom_handler)() = 0; -#endif - -template -void* -__malloc_alloc_template<__inst>::_S_oom_malloc(size_t __n) -{ - void (* __my_malloc_handler)(); - void* __result; - - for (;;) { - __my_malloc_handler = __malloc_alloc_oom_handler; - if (0 == __my_malloc_handler) { __THROW_BAD_ALLOC; } - (*__my_malloc_handler)(); - __result = malloc(__n); - if (__result) return(__result); - } -} - -template -void* __malloc_alloc_template<__inst>::_S_oom_realloc(void* __p, size_t __n) -{ - void (* __my_malloc_handler)(); - void* __result; - - for (;;) { - __my_malloc_handler = __malloc_alloc_oom_handler; - if (0 == __my_malloc_handler) { __THROW_BAD_ALLOC; } - (*__my_malloc_handler)(); - __result = realloc(__p, __n); - if (__result) return(__result); - } -} - -typedef __malloc_alloc_template<0> malloc_alloc; - -template -class simple_alloc { - -public: - static _Tp* allocate(size_t __n) - { return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); } - static _Tp* allocate(void) - { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); } - static void deallocate(_Tp* __p, size_t __n) - { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); } - static void deallocate(_Tp* __p) - { _Alloc::deallocate(__p, sizeof (_Tp)); } -}; - -// Allocator adaptor to check size arguments for debugging. -// Reports errors using assert. Checking can be disabled with -// NDEBUG, but it's far better to just use the underlying allocator -// instead when no checking is desired. -// There is some evidence that this can confuse Purify. -template -class debug_alloc { - -private: - - enum {_S_extra = 8}; // Size of space used to store size. Note - // that this must be large enough to preserve - // alignment. - -public: - - static void* allocate(size_t __n) - { - char* __result = (char*)_Alloc::allocate(__n + _S_extra); - *(size_t*)__result = __n; - return __result + _S_extra; - } - - static void deallocate(void* __p, size_t __n) - { - char* __real_p = (char*)__p - _S_extra; - assert(*(size_t*)__real_p == __n); - _Alloc::deallocate(__real_p, __n + _S_extra); - } - - static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz) - { - char* __real_p = (char*)__p - _S_extra; - assert(*(size_t*)__real_p == __old_sz); - char* __result = (char*) - _Alloc::reallocate(__real_p, __old_sz + _S_extra, __new_sz + _S_extra); - *(size_t*)__result = __new_sz; - return __result + _S_extra; - } - -}; - - -# ifdef __USE_MALLOC - -typedef malloc_alloc alloc; -typedef malloc_alloc single_client_alloc; - -# else - - -// Default node allocator. -// With a reasonable compiler, this should be roughly as fast as the -// original STL class-specific allocators, but with less fragmentation. -// Default_alloc_template parameters are experimental and MAY -// DISAPPEAR in the future. Clients should just use alloc for now. -// -// Important implementation properties: -// 1. If the client request an object of size > _MAX_BYTES, the resulting -// object will be obtained directly from malloc. -// 2. In all other cases, we allocate an object of size exactly -// _S_round_up(requested_size). Thus the client has enough size -// information that we can return the object to the proper free list -// without permanently losing part of the object. -// - -// The first template parameter specifies whether more than one thread -// may use this allocator. It is safe to allocate an object from -// one instance of a default_alloc and deallocate it with another -// one. This effectively transfers its ownership to the second one. -// This may have undesirable effects on reference locality. -// The second parameter is unreferenced and serves only to allow the -// creation of multiple default_alloc instances. -// Node that containers built on different allocator instances have -// different types, limiting the utility of this approach. -#ifdef __SUNPRO_CC -// breaks if we make these template class members: - enum {_ALIGN = 8}; - enum {_MAX_BYTES = 128}; - enum {_NFREELISTS = _MAX_BYTES/_ALIGN}; -#endif - -template -class __default_alloc_template { - -private: - // Really we should use static const int x = N - // instead of enum { x = N }, but few compilers accept the former. -# ifndef __SUNPRO_CC - enum {_ALIGN = 8}; - enum {_MAX_BYTES = 128}; - enum {_NFREELISTS = _MAX_BYTES/_ALIGN}; -# endif - static size_t - _S_round_up(size_t __bytes) - { return (((__bytes) + _ALIGN-1) & ~(_ALIGN - 1)); } - -__PRIVATE: - union _Obj { - union _Obj* _M_free_list_link; - char _M_client_data[1]; /* The client sees this. */ - }; -private: -# ifdef __SUNPRO_CC - static _Obj* __VOLATILE _S_free_list[]; - // Specifying a size results in duplicate def for 4.1 -# else - static _Obj* __VOLATILE _S_free_list[_NFREELISTS]; -# endif - static size_t _S_freelist_index(size_t __bytes) { - return (((__bytes) + _ALIGN-1)/_ALIGN - 1); - } - - // Returns an object of size __n, and optionally adds to size __n free list. - static void* _S_refill(size_t __n); - // Allocates a chunk for nobjs of size "size". nobjs may be reduced - // if it is inconvenient to allocate the requested number. - static char* _S_chunk_alloc(size_t __size, int& __nobjs); - - // Chunk allocation state. - static char* _S_start_free; - static char* _S_end_free; - static size_t _S_heap_size; - -# ifdef __STL_SGI_THREADS - static volatile unsigned long _S_node_allocator_lock; - static void _S_lock(volatile unsigned long*); - static inline void _S_unlock(volatile unsigned long*); -# endif - -# ifdef __STL_PTHREADS - static pthread_mutex_t _S_node_allocator_lock; -# endif - -# ifdef __STL_SOLTHREADS - static mutex_t _S_node_allocator_lock; -# endif - -# ifdef __STL_WIN32THREADS - static CRITICAL_SECTION _S_node_allocator_lock; - static bool _S_node_allocator_lock_initialized; - - public: - __default_alloc_template() { - // This assumes the first constructor is called before threads - // are started. - if (!_S_node_allocator_lock_initialized) { - InitializeCriticalSection(&_S_node_allocator_lock); - _S_node_allocator_lock_initialized = true; - } - } - private: -# endif - - class _Lock { - public: - _Lock() { __NODE_ALLOCATOR_LOCK; } - ~_Lock() { __NODE_ALLOCATOR_UNLOCK; } - }; - friend class _Lock; - -public: - - /* __n must be > 0 */ - static void* allocate(size_t __n) - { - _Obj* __VOLATILE* __my_free_list; - _Obj* __RESTRICT __result; - - if (__n > (size_t) _MAX_BYTES) { - return(malloc_alloc::allocate(__n)); - } - __my_free_list = _S_free_list + _S_freelist_index(__n); - // Acquire the lock here with a constructor call. - // This ensures that it is released in exit or during stack - // unwinding. -# ifndef _NOTHREADS - /*REFERENCED*/ - _Lock __lock_instance; -# endif - __result = *__my_free_list; - if (__result == 0) { - void* __r = _S_refill(_S_round_up(__n)); - return __r; - } - *__my_free_list = __result -> _M_free_list_link; - return (__result); - }; - - /* __p may not be 0 */ - static void deallocate(void* __p, size_t __n) - { - _Obj* __q = (_Obj*)__p; - _Obj* __VOLATILE* __my_free_list; - - if (__n > (size_t) _MAX_BYTES) { - malloc_alloc::deallocate(__p, __n); - return; - } - __my_free_list = _S_free_list + _S_freelist_index(__n); - // acquire lock -# ifndef _NOTHREADS - /*REFERENCED*/ - _Lock __lock_instance; -# endif /* _NOTHREADS */ - __q -> _M_free_list_link = *__my_free_list; - *__my_free_list = __q; - // lock is released here - } - - static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz); - -} ; - -typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc; -typedef __default_alloc_template single_client_alloc; - - - -/* We allocate memory in large chunks in order to avoid fragmenting */ -/* the malloc heap too much. */ -/* We assume that size is properly aligned. */ -/* We hold the allocation lock. */ -template -char* -__default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size, - int& __nobjs) -{ - char* __result; - size_t __total_bytes = __size * __nobjs; - size_t __bytes_left = _S_end_free - _S_start_free; - - if (__bytes_left >= __total_bytes) { - __result = _S_start_free; - _S_start_free += __total_bytes; - return(__result); - } else if (__bytes_left >= __size) { - __nobjs = (int)(__bytes_left/__size); - __total_bytes = __size * __nobjs; - __result = _S_start_free; - _S_start_free += __total_bytes; - return(__result); - } else { - size_t __bytes_to_get = - 2 * __total_bytes + _S_round_up(_S_heap_size >> 4); - // Try to make use of the left-over piece. - if (__bytes_left > 0) { - _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; - } - _S_start_free = (char*)malloc(__bytes_to_get); - if (0 == _S_start_free) { - size_t __i; - _Obj* __VOLATILE* __my_free_list; - _Obj* __p; - // Try to make do with what we have. That can't - // hurt. We do not try smaller requests, since that tends - // to result in disaster on multi-process machines. - for (__i = __size; __i <= _MAX_BYTES; __i += _ALIGN) { - __my_free_list = _S_free_list + _S_freelist_index(__i); - __p = *__my_free_list; - if (0 != __p) { - *__my_free_list = __p -> _M_free_list_link; - _S_start_free = (char*)__p; - _S_end_free = _S_start_free + __i; - return(_S_chunk_alloc(__size, __nobjs)); - // Any leftover piece will eventually make it to the - // right free list. - } - } - _S_end_free = 0; // In case of exception. - _S_start_free = (char*)malloc_alloc::allocate(__bytes_to_get); - // This should either throw an - // exception or remedy the situation. Thus we assume it - // succeeded. - } - _S_heap_size += __bytes_to_get; - _S_end_free = _S_start_free + __bytes_to_get; - return(_S_chunk_alloc(__size, __nobjs)); - } -} - - -/* Returns an object of size __n, and optionally adds to size __n free list.*/ -/* We assume that __n is properly aligned. */ -/* We hold the allocation lock. */ -template -void* -__default_alloc_template<__threads, __inst>::_S_refill(size_t __n) -{ - int __nobjs = 20; - char* __chunk = _S_chunk_alloc(__n, __nobjs); - _Obj* __VOLATILE* __my_free_list; - _Obj* __result; - _Obj* __current_obj; - _Obj* __next_obj; - int __i; - - if (1 == __nobjs) return(__chunk); - __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); - for (__i = 1; ; __i++) { - __current_obj = __next_obj; - __next_obj = (_Obj*)((char*)__next_obj + __n); - if (__nobjs - 1 == __i) { - __current_obj -> _M_free_list_link = 0; - break; - } else { - __current_obj -> _M_free_list_link = __next_obj; - } - } - return(__result); -} - -template -void* -__default_alloc_template::reallocate(void* __p, - size_t __old_sz, - size_t __new_sz) -{ - void* __result; - size_t __copy_sz; - - if (__old_sz > (size_t) _MAX_BYTES && __new_sz > (size_t) _MAX_BYTES) { - return(realloc(__p, __new_sz)); - } - if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p); - __result = allocate(__new_sz); - __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz; - memcpy(__result, __p, __copy_sz); - deallocate(__p, __old_sz); - return(__result); -} - -#ifdef __STL_PTHREADS - template - pthread_mutex_t - __default_alloc_template<__threads, __inst>::_S_node_allocator_lock - = PTHREAD_MUTEX_INITIALIZER; -#endif - -#ifdef __STL_SOLTHREADS - template - mutex_t - __default_alloc_template<__threads, __inst>::_S_node_allocator_lock - = DEFAULTMUTEX; -#endif - -#ifdef __STL_WIN32THREADS - template - CRITICAL_SECTION - __default_alloc_template<__threads, __inst>:: - _S_node_allocator_lock; - - template - bool - __default_alloc_template<__threads, __inst>:: - _S_node_allocator_lock_initialized - = false; -#endif - -#ifdef __STL_SGI_THREADS -__STL_END_NAMESPACE -#include -#include /* XXX should use */ -__STL_BEGIN_NAMESPACE -// Somewhat generic lock implementations. We need only test-and-set -// and some way to sleep. These should work with both SGI pthreads -// and sproc threads. They may be useful on other systems. -template -volatile unsigned long -__default_alloc_template<__threads, __inst>::_S_node_allocator_lock = 0; - -#if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) || defined(__GNUC__) -# define __test_and_set(l,v) test_and_set(l,v) -#endif - -template -void -__default_alloc_template<__threads, __inst>:: - _S_lock(volatile unsigned long* __lock) -{ - const unsigned __low_spin_max = 30; // spins if we suspect uniprocessor - const unsigned __high_spin_max = 1000; // spins for multiprocessor - static unsigned __spin_max = __low_spin_max; - unsigned __my_spin_max; - static unsigned __last_spins = 0; - unsigned __my_last_spins; - unsigned __junk; -# define __ALLOC_PAUSE \ - __junk *= __junk; __junk *= __junk; __junk *= __junk; __junk *= __junk - int __i; - - if (!__test_and_set((unsigned long*)__lock, 1)) { - return; - } - __my_spin_max = __spin_max; - __my_last_spins = __last_spins; - for (__i = 0; __i < __my_spin_max; __i++) { - if (__i < __my_last_spins/2 || *__lock) { - __ALLOC_PAUSE; - continue; - } - if (!__test_and_set((unsigned long*)__lock, 1)) { - // got it! - // Spinning worked. Thus we're probably not being scheduled - // against the other process with which we were contending. - // Thus it makes sense to spin longer the next time. - __last_spins = __i; - __spin_max = __high_spin_max; - return; - } - } - // We are probably being scheduled against the other process. Sleep. - __spin_max = __low_spin_max; - for (__i = 0 ;; ++__i) { - struct timespec __ts; - int __log_nsec = __i + 6; - - if (!__test_and_set((unsigned long *)__lock, 1)) { - return; - } - if (__log_nsec > 27) __log_nsec = 27; - /* Max sleep is 2**27nsec ~ 60msec */ - __ts.tv_sec = 0; - __ts.tv_nsec = 1 << __log_nsec; - nanosleep(&__ts, 0); - } -} - -template -inline void -__default_alloc_template<__threads, __inst>::_S_unlock( - volatile unsigned long* __lock) -{ -# if defined(__GNUC__) && __mips >= 3 - asm("sync"); - *__lock = 0; -# elif __mips >= 3 && (defined (_ABIN32) || defined(_ABI64)) - __lock_release(__lock); -# else - *__lock = 0; - // This is not sufficient on many multiprocessors, since - // writes to protected variables and the lock may be reordered. -# endif -} -#endif - -template -char* __default_alloc_template<__threads, __inst>::_S_start_free = 0; - -template -char* __default_alloc_template<__threads, __inst>::_S_end_free = 0; - -template -size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0; - -template -__default_alloc_template<__threads, __inst>::_Obj* __VOLATILE -__default_alloc_template<__threads, __inst> ::_S_free_list[ - _NFREELISTS -] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -// The 16 zeros are necessary to make version 4.1 of the SunPro -// compiler happy. Otherwise it appears to allocate too little -// space for the array. - -# ifdef __STL_WIN32THREADS - // Create one to get critical section initialized. - // We do this onece per file, but only the first constructor - // does anything. - static alloc __node_allocator_dummy_instance; -# endif - -#endif /* ! __USE_MALLOC */ - -// This implements allocators as specified in the C++ standard. -// -// Note that standard-conforming allocators use many language features -// that are not yet widely implemented. In particular, they rely on -// member templates, partial specialization, partial ordering of function -// templates, the typename keyword, and the use of the template keyword -// to refer to a template member of a dependent type. - -#ifdef __STL_USE_STD_ALLOCATORS - -template -class allocator { - typedef alloc _Alloc; // The underlying allocator. -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef const _Tp* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; - typedef _Tp value_type; - - template struct rebind { - typedef allocator<_Tp1> other; - }; - - allocator() __STL_NOTHROW {} - allocator(const allocator&) __STL_NOTHROW {} - template allocator(const allocator<_Tp1>&) __STL_NOTHROW {} - ~allocator() __STL_NOTHROW {} - - pointer address(reference __x) const { return &__x; } - const_pointer address(const_reference __x) const { return &__x; } - - // __n is permitted to be 0. The C++ standard says nothing about what - // the return value is when __n == 0. - _Tp* allocate(size_type __n, const void* = 0) { - return __n != 0 ? static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp))) - : 0; - } - - // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type __n) - { _Alloc::deallocate(__p, __n * sizeof(_Tp)); } - - size_type max_size() const __STL_NOTHROW - { return size_t(-1) / sizeof(_Tp); } - - void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); } - void destroy(pointer __p) { __p->~_Tp(); } -}; - -template<> -class allocator { - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; - typedef const void* const_pointer; - typedef void value_type; - - template struct rebind { - typedef allocator<_Tp1> other; - }; -}; - - -template -inline bool operator==(const allocator<_T1>&, const allocator<_T2>&) -{ - return true; -} - -template -inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&) -{ - return false; -} - -// Allocator adaptor to turn an SGI-style allocator (e.g. alloc, malloc_alloc) -// into a standard-conforming allocator. Note that this adaptor does -// *not* assume that all objects of the underlying alloc class are -// identical, nor does it assume that all of the underlying alloc's -// member functions are static member functions. Note, also, that -// __allocator<_Tp, alloc> is essentially the same thing as allocator<_Tp>. - -template -struct __allocator { - _Alloc __underlying_alloc; - - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef const _Tp* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; - typedef _Tp value_type; - - template struct rebind { - typedef __allocator<_Tp1, _Alloc> other; - }; - - __allocator() __STL_NOTHROW {} - __allocator(const __allocator& __a) __STL_NOTHROW - : __underlying_alloc(__a.__underlying_alloc) {} - template - __allocator(const __allocator<_Tp1, _Alloc>& __a) __STL_NOTHROW - : __underlying_alloc(__a.__underlying_alloc) {} - ~__allocator() __STL_NOTHROW {} - - pointer address(reference __x) const { return &__x; } - const_pointer address(const_reference __x) const { return &__x; } - - // __n is permitted to be 0. - _Tp* allocate(size_type __n, const void* = 0) { - return __n != 0 - ? static_cast<_Tp*>(__underlying_alloc.allocate(__n * sizeof(_Tp))) - : 0; - } - - // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type __n) - { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); } - - size_type max_size() const __STL_NOTHROW - { return size_t(-1) / sizeof(_Tp); } - - void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); } - void destroy(pointer __p) { __p->~_Tp(); } -}; - -template -class __allocator { - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; - typedef const void* const_pointer; - typedef void value_type; - - template struct rebind { - typedef __allocator<_Tp1, _Alloc> other; - }; -}; - -template -inline bool operator==(const __allocator<_Tp, _Alloc>& __a1, - const __allocator<_Tp, _Alloc>& __a2) -{ - return __a1.__underlying_alloc == __a2.__underlying_alloc; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const __allocator<_Tp, _Alloc>& __a1, - const __allocator<_Tp, _Alloc>& __a2) -{ - return __a1.__underlying_alloc != __a2.__underlying_alloc; -} -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Comparison operators for all of the predifined SGI-style allocators. -// This ensures that __allocator (for example) will -// work correctly. - -template -inline bool operator==(const __malloc_alloc_template&, - const __malloc_alloc_template&) -{ - return true; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const __malloc_alloc_template<__inst>&, - const __malloc_alloc_template<__inst>&) -{ - return false; -} -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#ifndef __USE_MALLOC -template -inline bool operator==(const __default_alloc_template<__threads, __inst>&, - const __default_alloc_template<__threads, __inst>&) -{ - return true; -} - -# ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const __default_alloc_template<__threads, __inst>&, - const __default_alloc_template<__threads, __inst>&) -{ - return false; -} -# endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ -#endif - -template -inline bool operator==(const debug_alloc<_Alloc>&, - const debug_alloc<_Alloc>&) { - return true; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const debug_alloc<_Alloc>&, - const debug_alloc<_Alloc>&) { - return false; -} -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Another allocator adaptor: _Alloc_traits. This serves two -// purposes. First, make it possible to write containers that can use -// either SGI-style allocators or standard-conforming allocator. -// Second, provide a mechanism so that containers can query whether or -// not the allocator has distinct instances. If not, the container -// can avoid wasting a word of memory to store an empty object. - -// This adaptor uses partial specialization. The general case of -// _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a -// standard-conforming allocator, possibly with non-equal instances -// and non-static members. (It still behaves correctly even if _Alloc -// has static member and if all instances are equal. Refinements -// affect performance, not correctness.) - -// There are always two members: allocator_type, which is a standard- -// conforming allocator type for allocating objects of type _Tp, and -// _S_instanceless, a static const member of type bool. If -// _S_instanceless is true, this means that there is no difference -// between any two instances of type allocator_type. Furthermore, if -// _S_instanceless is true, then _Alloc_traits has one additional -// member: _Alloc_type. This type encapsulates allocation and -// deallocation of objects of type _Tp through a static interface; it -// has two member functions, whose signatures are -// static _Tp* allocate(size_t) -// static void deallocate(_Tp*, size_t) - -// The fully general version. - -template -struct _Alloc_traits -{ - static const bool _S_instanceless = false; - typedef typename _Allocator::__STL_TEMPLATE rebind<_Tp>::other - allocator_type; -}; - -template -const bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless; - -// The version for the default allocator. - -template -struct _Alloc_traits<_Tp, allocator<_Tp1> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, alloc> _Alloc_type; - typedef allocator<_Tp> allocator_type; -}; - -// Versions for the predefined SGI-style allocators. - -template -struct _Alloc_traits<_Tp, __malloc_alloc_template<__inst> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type; - typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type; -}; - -#ifndef __USE_MALLOC -template -struct _Alloc_traits<_Tp, __default_alloc_template<__threads, __inst> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __default_alloc_template<__threads, __inst> > - _Alloc_type; - typedef __allocator<_Tp, __default_alloc_template<__threads, __inst> > - allocator_type; -}; -#endif - -template -struct _Alloc_traits<_Tp, debug_alloc<_Alloc> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type; - typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type; -}; - -// Versions for the __allocator adaptor used with the predefined -// SGI-style allocators. - -template -struct _Alloc_traits<_Tp, - __allocator<_Tp1, __malloc_alloc_template<__inst> > > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type; - typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type; -}; - -#ifndef __USE_MALLOC -template -struct _Alloc_traits<_Tp, - __allocator<_Tp1, - __default_alloc_template<__thr, __inst> > > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __default_alloc_template<__thr,__inst> > - _Alloc_type; - typedef __allocator<_Tp, __default_alloc_template<__thr,__inst> > - allocator_type; -}; -#endif - -template -struct _Alloc_traits<_Tp, __allocator<_Tp1, debug_alloc<_Alloc> > > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type; - typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type; -}; - - -#endif /* __STL_USE_STD_ALLOCATORS */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#endif - -__STL_END_NAMESPACE - -#undef __PRIVATE - -#endif /* __SGI_STL_INTERNAL_ALLOC_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_bvector.h b/libstdc++/stl/stl_bvector.h deleted file mode 100644 index 0d0cdb6c828..00000000000 --- a/libstdc++/stl/stl_bvector.h +++ /dev/null @@ -1,838 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_BVECTOR_H -#define __SGI_STL_INTERNAL_BVECTOR_H - -__STL_BEGIN_NAMESPACE - -static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int)); - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -struct _Bit_reference { - unsigned int* _M_p; - unsigned int _M_mask; - _Bit_reference(unsigned int* __x, unsigned int __y) - : _M_p(__x), _M_mask(__y) {} - -public: - _Bit_reference() : _M_p(0), _M_mask(0) {} - operator bool() const { return !(!(*_M_p & _M_mask)); } - _Bit_reference& operator=(bool __x) - { - if (__x) *_M_p |= _M_mask; - else *_M_p &= ~_M_mask; - return *this; - } - _Bit_reference& operator=(const _Bit_reference& __x) - { return *this = bool(__x); } - bool operator==(const _Bit_reference& __x) const - { return bool(*this) == bool(__x); } - bool operator<(const _Bit_reference& __x) const { - return !bool(*this) && bool(__x); - } - 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 : public random_access_iterator { - typedef _Bit_reference reference; - typedef _Bit_reference* pointer; - typedef _Bit_iterator iterator; - - unsigned int* _M_p; - unsigned int _M_offset; - void bump_up() { - if (_M_offset++ == __WORD_BIT - 1) { - _M_offset = 0; - ++_M_p; - } - } - void bump_down() { - if (_M_offset-- == 0) { - _M_offset = __WORD_BIT - 1; - --_M_p; - } - } - - _Bit_iterator() : _M_p(0), _M_offset(0) {} - _Bit_iterator(unsigned int* __x, unsigned int __y) - : _M_p(__x), _M_offset(__y) {} - reference operator*() const { return reference(_M_p, 1U << _M_offset); } - iterator& operator++() { - bump_up(); - return *this; - } - iterator operator++(int) { - iterator __tmp = *this; - bump_up(); - return __tmp; - } - iterator& operator--() { - bump_down(); - return *this; - } - iterator operator--(int) { - iterator __tmp = *this; - bump_down(); - return __tmp; - } - iterator& operator+=(difference_type __i) { - difference_type __n = __i + _M_offset; - _M_p += __n / __WORD_BIT; - __n = __n % __WORD_BIT; - if (__n < 0) { - _M_offset = (unsigned int) __n + __WORD_BIT; - --_M_p; - } else - _M_offset = (unsigned int) __n; - return *this; - } - iterator& operator-=(difference_type __i) { - *this += -__i; - return *this; - } - iterator operator+(difference_type __i) const { - iterator __tmp = *this; - return __tmp += __i; - } - iterator operator-(difference_type __i) const { - iterator __tmp = *this; - return __tmp -= __i; - } - difference_type operator-(iterator __x) const { - return __WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset; - } - reference operator[](difference_type __i) { return *(*this + __i); } - bool operator==(const iterator& __x) const { - return _M_p == __x._M_p && _M_offset == __x._M_offset; - } - bool operator!=(const iterator& __x) const { - return _M_p != __x._M_p || _M_offset != __x._M_offset; - } - bool operator<(iterator __x) const { - return _M_p < __x._M_p || (_M_p == __x._M_p && _M_offset < __x._M_offset); - } -}; - -struct _Bit_const_iterator - : public random_access_iterator -{ - typedef bool reference; - typedef bool const_reference; - typedef const bool* pointer; - typedef _Bit_const_iterator const_iterator; - - unsigned int* _M_p; - unsigned int _M_offset; - void bump_up() { - if (_M_offset++ == __WORD_BIT - 1) { - _M_offset = 0; - ++_M_p; - } - } - void bump_down() { - if (_M_offset-- == 0) { - _M_offset = __WORD_BIT - 1; - --_M_p; - } - } - - _Bit_const_iterator() : _M_p(0), _M_offset(0) {} - _Bit_const_iterator(unsigned int* __x, unsigned int __y) - : _M_p(__x), _M_offset(__y) {} - _Bit_const_iterator(const _Bit_iterator& __x) - : _M_p(__x._M_p), _M_offset(__x._M_offset) {} - const_reference operator*() const { - return _Bit_reference(_M_p, 1U << _M_offset); - } - const_iterator& operator++() { - bump_up(); - return *this; - } - const_iterator operator++(int) { - const_iterator __tmp = *this; - bump_up(); - return __tmp; - } - const_iterator& operator--() { - bump_down(); - return *this; - } - const_iterator operator--(int) { - const_iterator __tmp = *this; - bump_down(); - return __tmp; - } - const_iterator& operator+=(difference_type __i) { - difference_type __n = __i + _M_offset; - _M_p += __n / __WORD_BIT; - __n = __n % __WORD_BIT; - if (__n < 0) { - _M_offset = (unsigned int) __n + __WORD_BIT; - --_M_p; - } else - _M_offset = (unsigned int) __n; - return *this; - } - const_iterator& operator-=(difference_type __i) { - *this += -__i; - return *this; - } - const_iterator operator+(difference_type __i) const { - const_iterator __tmp = *this; - return __tmp += __i; - } - const_iterator operator-(difference_type __i) const { - const_iterator __tmp = *this; - return __tmp -= __i; - } - difference_type operator-(const_iterator __x) const { - return __WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset; - } - const_reference operator[](difference_type __i) { - return *(*this + __i); - } - bool operator==(const const_iterator& __x) const { - return _M_p == __x._M_p && _M_offset == __x._M_offset; - } - bool operator!=(const const_iterator& __x) const { - return _M_p != __x._M_p || _M_offset != __x._M_offset; - } - bool operator<(const_iterator __x) const { - return _M_p < __x._M_p || (_M_p == __x._M_p && _M_offset < __x._M_offset); - } -}; - -// Bit-vector base class, which encapsulates the difference between -// old SGI-style allocators and standard-conforming allocators. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base class for ordinary allocators. -template -class _Bvector_alloc_base { -public: - typedef typename _Alloc_traits::allocator_type - allocator_type; - allocator_type get_allocator() const { return _M_data_allocator; } - - _Bvector_alloc_base(const allocator_type& __a) - : _M_data_allocator(__a), _M_start(), _M_finish(), _M_end_of_storage(0) {} - -protected: - unsigned int* _M_bit_alloc(size_t __n) - { return _M_data_allocator.allocate((__n + __WORD_BIT - 1)/__WORD_BIT); } - void _M_deallocate() { - if (_M_start._M_p) - _M_data_allocator.deallocate(_M_start._M_p, - _M_end_of_storage - _M_start._M_p); - } - - typename _Alloc_traits::allocator_type - _M_data_allocator; - _Bit_iterator _M_start; - _Bit_iterator _M_finish; - unsigned int* _M_end_of_storage; -}; - -// Specialization for instanceless allocators. -template -class _Bvector_alloc_base<_Allocator, true> { -public: - typedef typename _Alloc_traits::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Bvector_alloc_base(const allocator_type&) - : _M_start(), _M_finish(), _M_end_of_storage(0) {} - -protected: - typedef typename _Alloc_traits::_Alloc_type - _Alloc_type; - - unsigned int* _M_bit_alloc(size_t __n) - { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); } - void _M_deallocate() { - if (_M_start._M_p) - _Alloc_type::deallocate(_M_start._M_p, - _M_end_of_storage - _M_start._M_p); - } - - _Bit_iterator _M_start; - _Bit_iterator _M_finish; - unsigned int* _M_end_of_storage; -}; - -template -class _Bvector_base - : public _Bvector_alloc_base<_Alloc, - _Alloc_traits::_S_instanceless> -{ - typedef _Bvector_alloc_base<_Alloc, - _Alloc_traits::_S_instanceless> - _Base; -public: - typedef typename _Base::allocator_type allocator_type; - - _Bvector_base(const allocator_type& __a) : _Base(__a) {} - ~_Bvector_base() { _Base::_M_deallocate(); } -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _Bvector_base -{ -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Bvector_base(const allocator_type&) - : _M_start(), _M_finish(), _M_end_of_storage(0) {} - ~_Bvector_base() { _M_deallocate(); } - -protected: - typedef simple_alloc _Alloc_type; - - unsigned int* _M_bit_alloc(size_t __n) - { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); } - void _M_deallocate() { - if (_M_start._M_p) - _Alloc_type::deallocate(_M_start._M_p, - _M_end_of_storage - _M_start._M_p); - } - - _Bit_iterator _M_start; - _Bit_iterator _M_finish; - unsigned int* _M_end_of_storage; -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -// The next few lines are confusing. What we're doing is declaring a -// partial specialization of vector if we have the necessary -// compiler support. Otherwise, we define a class bit_vector which uses -// the default allocator. - -#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && !defined(__STL_NO_BOOL) -#define __SGI_STL_VECBOOL_TEMPLATE -#define __BVECTOR vector -#else -#undef __SGI_STL_VECBOOL_TEMPLATE -#define __BVECTOR bit_vector -#endif - -# ifdef __SGI_STL_VECBOOL_TEMPLATE - __STL_END_NAMESPACE -# include - __STL_BEGIN_NAMESPACE -template class vector - : public _Bvector_base<_Alloc> -# else /* __SGI_STL_VECBOOL_TEMPLATE */ -class bit_vector - : public _Bvector_base<__STL_DEFAULT_ALLOCATOR(bool) > -# endif /* __SGI_STL_VECBOOL_TEMPLATE */ -{ -# ifdef __SGI_STL_VECBOOL_TEMPLATE - typedef _Bvector_base<_Alloc> _Base; -# else /* __SGI_STL_VECBOOL_TEMPLATE */ - typedef _Bvector_base<__STL_DEFAULT_ALLOCATOR(bool) > _Base; -# endif /* __SGI_STL_VECBOOL_TEMPLATE */ -public: - typedef bool value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Bit_reference reference; - typedef bool const_reference; - typedef _Bit_reference* pointer; - typedef const bool* const_pointer; - - typedef _Bit_iterator iterator; - typedef _Bit_const_iterator const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -protected: -#ifdef __STL_USE_NAMESPACES - using _Base::_M_bit_alloc; - using _Base::_M_deallocate; - using _Base::_M_start; - using _Base::_M_finish; - using _Base::_M_end_of_storage; -#endif /* __STL_USE_NAMESPACES */ - -protected: - void _M_initialize(size_type __n) { - unsigned int* __q = _M_bit_alloc(__n); - _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - _M_finish = _M_start + difference_type(__n); - } - void _M_insert_aux(iterator __position, bool __x) { - if (_M_finish._M_p != _M_end_of_storage) { - copy_backward(__position, _M_finish, _M_finish + 1); - *__position = __x; - ++_M_finish; - } - else { - size_type __len = size() ? 2 * size() : __WORD_BIT; - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - *__i++ = __x; - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - -#ifdef __STL_MEMBER_TEMPLATES - template - void _M_initialize_range(_InputIterator __first, _InputIterator __last, - input_iterator_tag) { - _M_start = iterator(); - _M_finish = iterator(); - _M_end_of_storage = 0; - for ( ; __first != __last; ++__first) - push_back(*__first); - } - - template - void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize(__n); - copy(__first, __last, _M_start); - } - - template - void _M_insert_range(iterator __pos, - _InputIterator __first, _InputIterator __last, - input_iterator_tag) { - for ( ; __first != __last; ++__first) { - __pos = insert(__pos, *__first); - ++__pos; - } - } - - template - void _M_insert_range(iterator __position, - _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - if (__first != __last) { - size_type __n = 0; - distance(__first, __last, __n); - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + difference_type(__n)); - copy(__first, __last, __position); - _M_finish += difference_type(__n); - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - __i = copy(__first, __last, __i); - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - iterator begin() { return _M_start; } - const_iterator begin() const { return _M_start; } - iterator end() { return _M_finish; } - const_iterator end() const { return _M_finish; } - - 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()); - } - - size_type size() const { return size_type(end() - begin()); } - size_type max_size() const { return size_type(-1); } - size_type capacity() const { - return size_type(const_iterator(_M_end_of_storage, 0) - begin()); - } - bool empty() const { return begin() == end(); } - reference operator[](size_type __n) { - return *(begin() + difference_type(__n)); - } - const_reference operator[](size_type __n) const { - return *(begin() + difference_type(__n)); - } - - explicit __BVECTOR(const allocator_type& __a = allocator_type()) - : _Base(__a) {} - - __BVECTOR(size_type __n, bool __value, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { - _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, __value ? ~0 : 0); - } - - explicit __BVECTOR(size_type __n) - : _Base(allocator_type()) - { - _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, 0); - } - - __BVECTOR(const __BVECTOR& __x) : _Base(__x.get_allocator()) { - _M_initialize(__x.size()); - copy(__x.begin(), __x.end(), _M_start); - } - -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - template - __BVECTOR(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_initialize_dispatch(__first, __last, _Integral()); - } - - template - void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { - _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); - } - - template - void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, - __false_type) { - _M_initialize_range(__first, __last, __ITERATOR_CATEGORY(__first)); - } -#else /* __STL_MEMBER_TEMPLATES */ - __BVECTOR(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize(__n); - copy(__first, __last, _M_start); - } - __BVECTOR(const bool* __first, const bool* __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize(__n); - copy(__first, __last, _M_start); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - ~__BVECTOR() { } - - __BVECTOR& operator=(const __BVECTOR& __x) { - if (&__x == this) return *this; - if (__x.size() > capacity()) { - _M_deallocate(); - _M_initialize(__x.size()); - } - copy(__x.begin(), __x.end(), begin()); - _M_finish = begin() + difference_type(__x.size()); - return *this; - } - - // 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 assign(size_t __n, bool __x) { - if (__n > size()) { - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); - insert(end(), __n - size(), __x); - } - else { - erase(begin() + __n, end()); - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); - } - } - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { assign((size_t) __n, (bool) __val); } - - template - void _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type) - { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); } - - template - void _M_assign_aux(_InputIterator __first, _InputIterator __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 - void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - size_type __len = 0; - distance(__first, __last, __len); - if (__len < size()) - erase(copy(__first, __last, begin()), end()); - else { - _ForwardIterator __mid = __first; - advance(__mid, size()); - copy(__first, __mid, begin()); - insert(end(), __mid, __last); - } - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - void reserve(size_type __n) { - if (capacity() < __n) { - unsigned int* __q = _M_bit_alloc(__n); - _M_finish = copy(begin(), end(), iterator(__q, 0)); - _M_deallocate(); - _M_start = iterator(__q, 0); - _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT; - } - } - - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - reference back() { return *(end() - 1); } - const_reference back() const { return *(end() - 1); } - void push_back(bool __x) { - if (_M_finish._M_p != _M_end_of_storage) - *_M_finish++ = __x; - else - _M_insert_aux(end(), __x); - } - void swap(__BVECTOR& __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); - } - iterator insert(iterator __position, bool __x = bool()) { - difference_type __n = __position - begin(); - if (_M_finish._M_p != _M_end_of_storage && __position == end()) - *_M_finish++ = __x; - else - _M_insert_aux(__position, __x); - return begin() + __n; - } - -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - template - void insert(iterator __position, - _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__position, __first, __last, _Integral()); - } - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) { - insert(__pos, (size_type) __n, (bool) __x); - } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) { - _M_insert_range(__pos, __first, __last, __ITERATOR_CATEGORY(__first)); - } -#else /* __STL_MEMBER_TEMPLATES */ - void insert(iterator __position, - const_iterator __first, const_iterator __last) { - if (__first == __last) return; - size_type __n = 0; - distance(__first, __last, __n); - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + __n); - copy(__first, __last, __position); - _M_finish += __n; - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - __i = copy(__first, __last, __i); - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - - void insert(iterator __position, const bool* __first, const bool* __last) { - if (__first == __last) return; - size_type __n = 0; - distance(__first, __last, __n); - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + __n); - copy(__first, __last, __position); - _M_finish += __n; - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - __i = copy(__first, __last, __i); - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } -#endif /* __STL_MEMBER_TEMPLATES */ - - void insert(iterator __position, size_type __n, bool __x) { - if (__n == 0) return; - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + difference_type(__n)); - fill(__position, __position + difference_type(__n), __x); - _M_finish += difference_type(__n); - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - fill_n(__i, __n, __x); - _M_finish = copy(__position, end(), __i + difference_type(__n)); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - - void pop_back() { --_M_finish; } - iterator erase(iterator __position) { - if (__position + 1 != end()) - copy(__position + 1, end(), __position); - --_M_finish; - return __position; - } - iterator erase(iterator __first, iterator __last) { - _M_finish = copy(__last, end(), __first); - return __first; - } - void resize(size_type __new_size, bool __x = bool()) { - if (__new_size < size()) - erase(begin() + difference_type(__new_size), end()); - else - insert(end(), __new_size - size(), __x); - } - void clear() { erase(begin(), end()); } -}; - -#ifdef __SGI_STL_VECBOOL_TEMPLATE - -typedef vector bit_vector; - -#else /* __SGI_STL_VECBOOL_TEMPLATE */ - -inline bool -operator==(const bit_vector& __x, const bit_vector& __y) -{ - return (__x.size() == __y.size() && - equal(__x.begin(), __x.end(), __y.begin())); -} - -inline bool -operator<(const bit_vector& __x, const bit_vector& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#endif /* __SGI_STL_VECBOOL_TEMPLATE */ - -#undef __SGI_STL_VECBOOL_TEMPLATE -#undef __BVECTOR - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_BVECTOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_config.h b/libstdc++/stl/stl_config.h deleted file mode 100644 index bffce401def..00000000000 --- a/libstdc++/stl/stl_config.h +++ /dev/null @@ -1,359 +0,0 @@ -/* - * - * 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 - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __STL_CONFIG_H -# define __STL_CONFIG_H - -// Flags: -// * __STL_NO_BOOL: defined if the compiler doesn't have bool as a builtin -// type. -// * __STL_HAS_WCHAR_T: defined if the compier has wchar_t as a builtin type. -// * __STL_NO_DRAND48: defined if the compiler doesn't have the drand48 -// function. -// * __STL_STATIC_TEMPLATE_MEMBER_BUG: defined if the compiler can't handle -// static members of template classes. -// * __STL_CLASS_PARTIAL_SPECIALIZATION: defined if the compiler supports -// partial specialization of template classes. -// * __STL_PARTIAL_SPECIALIZATION_SYNTAX: defined if the compiler -// supports partial specialization syntax for full specialization of -// class templates. (Even if it doesn't actually support partial -// specialization itself.) -// * __STL_FUNCTION_TMPL_PARTIAL_ORDER: defined if the compiler supports -// partial ordering of function templates. (a.k.a partial specialization -// of function templates.) -// * __STL_MEMBER_TEMPLATES: defined if the compiler supports template -// member functions of classes. -// * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports -// nested classes that are member templates of other classes. -// * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler -// supports calling a function template by providing its template -// arguments explicitly. -// * __STL_LIMITED_DEFAULT_TEMPLATES: defined if the compiler is unable -// to handle default template parameters that depend on previous template -// parameters. -// * __STL_NON_TYPE_TMPL_PARAM_BUG: defined if the compiler has trouble with -// function template argument deduction for non-type template parameters. -// * __SGI_STL_NO_ARROW_OPERATOR: defined if the compiler is unable -// to support the -> operator for iterators. -// * __STL_USE_EXCEPTIONS: defined if the compiler (in the current compilation -// mode) supports exceptions. -// * __STL_USE_NAMESPACES: defined if the compiler has the necessary -// support for namespaces. -// * __STL_NO_EXCEPTION_HEADER: defined if the compiler does not have a -// standard-conforming header . -// * __STL_SGI_THREADS: defined if this is being compiled for an SGI IRIX -// system in multithreaded mode, using native SGI threads instead of -// pthreads. -// * __STL_WIN32THREADS: defined if this is being compiled on a WIN32 -// compiler in multithreaded mode. -// * __STL_LONG_LONG if the compiler has long long and unsigned long long -// types. (They're not in the C++ standard, but they are expected to be -// included in the forthcoming C9X standard.) - - -// User-settable macros that control compilation: -// * __STL_USE_SGI_ALLOCATORS: if defined, then the STL will use older -// SGI-style allocators, instead of standard-conforming allocators, -// even if the compiler supports all of the language features needed -// for standard-conforming allocators. -// * __STL_NO_NAMESPACES: if defined, don't put the library in namespace -// std, even if the compiler supports namespaces. -// * __STL_ASSERTIONS: if defined, then enable runtime checking through the -// __stl_assert macro. -// * _PTHREADS: if defined, use Posix threads for multithreading support. -// * _NOTHREADS: if defined, don't use any multithreading support. - - -// Other macros defined by this file: - -// * bool, true, and false, if __STL_NO_BOOL is defined. -// * typename, as a null macro if it's not already a keyword. -// * explicit, as a null macro if it's not already a keyword. -// * namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.) -// * exception-related macros (__STL_TRY, __STL_UNWIND, etc.) -// * __stl_assert, either as a test or as a null macro, depending on -// whether or not __STL_ASSERTIONS is defined. - -#ifdef _PTHREADS -# define __STL_PTHREADS -#endif -#ifdef _SOLTHREADS -# define __STL_SOLTHREADS -#endif - -# if defined(__sgi) && !defined(__GNUC__) -# if !defined(_BOOL) -# define __STL_NO_BOOL -# endif -# if defined(_WCHAR_T_IS_KEYWORD) -# define __STL_HAS_WCHAR_T -# endif -# if !defined(_TYPENAME_IS_KEYWORD) -# define __STL_NEED_TYPENAME -# endif -# ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# endif -# ifdef _MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# endif -# if defined(_MEMBER_TEMPLATE_KEYWORD) -# define __STL_MEMBER_TEMPLATE_KEYWORD -# endif -# if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32 -# define __STL_MEMBER_TEMPLATE_KEYWORD -# endif -# if !defined(_EXPLICIT_IS_KEYWORD) -# define __STL_NEED_EXPLICIT -# endif -# ifdef __EXCEPTIONS -# define __STL_USE_EXCEPTIONS -# endif -# if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES) -# define __STL_HAS_NAMESPACES -# endif -# if (_COMPILER_VERSION < 721) -# define __STL_NO_EXCEPTION_HEADER -# endif -# if !defined(_NOTHREADS) && !defined(__STL_PTHREADS) -# define __STL_SGI_THREADS -# endif -# if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI -# define __STL_LONG_LONG -# endif -# endif - -# ifdef __GNUC__ -# include <_G_config.h> -# define __STL_HAS_WCHAR_T -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __STL_STATIC_TEMPLATE_MEMBER_BUG -# define __STL_NEED_TYPENAME -# define __STL_NEED_EXPLICIT -# else -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_HAS_NAMESPACES -# define __STL_NO_NAMESPACES -# define __SGI_STL_USE_AUTO_PTR_CONVERSIONS -# define __STL_USE_NAMESPACES -# endif -# if defined(__linux__) - /* glibc pre 2.0 is very buggy. We have to disable thread for it. - It should be upgraded to glibc 2.0 or later. */ -# if !defined(_NOTHREADS) && __GLIBC__ >= 2 && defined(_G_USING_THUNKS) -# define __STL_PTHREADS -# ifdef __STRICT_ANSI__ - /* Work around a bug in the glibc 2.0.x pthread.h. */ -# define sigset_t __sigset_t -# endif -# endif -# endif -# ifdef __EXCEPTIONS -# define __STL_USE_EXCEPTIONS -# endif -# ifndef __STRICT_ANSI__ -# define __STL_LONG_LONG -# endif -# endif - -# if defined(__SUNPRO_CC) -# define __STL_NO_BOOL -# define __STL_NEED_TYPENAME -# define __STL_NEED_EXPLICIT -# define __STL_USE_EXCEPTIONS -# endif - -# if defined(__COMO__) -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_USE_EXCEPTIONS -# define __STL_HAS_NAMESPACES -# endif - -# if defined(__MINGW32__) -# define __STL_NO_DRAND48 -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# endif - -# if defined(__CYGWIN__) -# define __STL_NO_DRAND48 -# endif - -# if defined(_MSC_VER) -# define __STL_NO_DRAND48 -# define __STL_NEED_TYPENAME -# if _MSC_VER < 1100 /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */ -# define __STL_NEED_EXPLICIT -# define __STL_NO_BOOL -# if _MSC_VER > 1000 -# include -# define __STL_DONT_USE_BOOL_TYPEDEF -# endif -# endif -# define __STL_NON_TYPE_TMPL_PARAM_BUG -# define __SGI_STL_NO_ARROW_OPERATOR -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# if _MSC_VER >= 1200 -# define __STL_PARTIAL_SPECIALIZATION_SYNTAX -# define __STL_HAS_NAMESPACES -# define __STL_NO_NAMESPACES -# endif -# endif - -# if defined(__BORLANDC__) -# define __STL_NO_DRAND48 -# define __STL_NEED_TYPENAME -# define __STL_LIMITED_DEFAULT_TEMPLATES -# define __SGI_STL_NO_ARROW_OPERATOR -# define __STL_NON_TYPE_TMPL_PARAM_BUG -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef __MT__ -# define __STL_WIN32THREADS -# endif -# endif - -# if defined(__STL_NO_BOOL) && !defined(__STL_DONT_USE_BOOL_TYPEDEF) - typedef int bool; -# define true 1 -# define false 0 -# endif - -# ifdef __STL_NEED_TYPENAME -# define typename -# endif - -# ifdef __STL_MEMBER_TEMPLATE_KEYWORD -# define __STL_TEMPLATE template -# else -# define __STL_TEMPLATE -# endif - -# ifdef __STL_NEED_EXPLICIT -# define explicit -# endif - -# ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_NULL_TMPL_ARGS <> -# else -# define __STL_NULL_TMPL_ARGS -# endif - -# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \ - || defined (__STL_PARTIAL_SPECIALIZATION_SYNTAX) -# define __STL_TEMPLATE_NULL template<> -# else -# define __STL_TEMPLATE_NULL -# endif - -// Use standard-conforming allocators if we have the necessary language -// features. __STL_USE_SGI_ALLOCATORS is a hook so that users can -// disable new-style allocators, and continue to use the same kind of -// allocators as before, without having to edit library headers. -# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && \ - defined(__STL_MEMBER_TEMPLATES) && \ - defined(__STL_MEMBER_TEMPLATE_CLASSES) && \ - !defined(__STL_NO_BOOL) && \ - !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) && \ - !defined(__STL_LIMITED_DEFAULT_TEMPLATES) && \ - !defined(__STL_USE_SGI_ALLOCATORS) -# define __STL_USE_STD_ALLOCATORS -# endif - -# ifndef __STL_DEFAULT_ALLOCATOR -# ifdef __STL_USE_STD_ALLOCATORS -# define __STL_DEFAULT_ALLOCATOR(T) allocator -# else -# define __STL_DEFAULT_ALLOCATOR(T) alloc -# endif -# endif - -// __STL_NO_NAMESPACES is a hook so that users can disable namespaces -// without having to edit library headers. -# if defined(__STL_HAS_NAMESPACES) && !defined(__STL_NO_NAMESPACES) -# define __STD std -# define __STL_BEGIN_NAMESPACE namespace std { -# define __STL_END_NAMESPACE } -# define __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE namespace std { -# define __STL_END_RELOPS_NAMESPACE } -# define __STD_RELOPS std -# define __STL_USE_NAMESPACES -# else -# define __STD -# define __STL_BEGIN_NAMESPACE -# define __STL_END_NAMESPACE -# undef __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE -# define __STL_END_RELOPS_NAMESPACE -# define __STD_RELOPS -# undef __STL_USE_NAMESPACES -# endif - -# ifdef __STL_USE_EXCEPTIONS -# define __STL_TRY try -# define __STL_CATCH_ALL catch(...) -# define __STL_THROW(x) throw x -# define __STL_RETHROW throw -# define __STL_NOTHROW throw() -# define __STL_UNWIND(action) catch(...) { action; throw; } -# else -# define __STL_TRY -# define __STL_CATCH_ALL if (false) -# define __STL_THROW(x) -# define __STL_RETHROW -# define __STL_NOTHROW -# define __STL_UNWIND(action) -# endif - -#ifdef __STL_ASSERTIONS -# include -# define __stl_assert(expr) \ - if (!(expr)) { fprintf(stderr, "%s:%d STL assertion failure: %s\n", \ - __FILE__, __LINE__, # expr); abort(); } -#else -# define __stl_assert(expr) -#endif - -#endif /* __STL_CONFIG_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_construct.h b/libstdc++/stl/stl_construct.h deleted file mode 100644 index 761784d57da..00000000000 --- a/libstdc++/stl/stl_construct.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H -#define __SGI_STL_INTERNAL_CONSTRUCT_H - -#include - -__STL_BEGIN_NAMESPACE - -// construct and destroy. These functions are not part of the C++ standard, -// and are provided for backward compatibility with the HP STL. - -template -inline void destroy(_Tp* __pointer) { - __pointer->~_Tp(); -} - -template -inline void construct(_T1* __p, const _T2& __value) { - new (__p) _T1(__value); -} - -template -inline void construct(_T1* __p) { - new (__p) _T1(); -} - -template -inline void -__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) -{ - for ( ; __first != __last; ++__first) - destroy(&*__first); -} - -template -inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {} - -template -inline void -__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) -{ - typedef typename __type_traits<_Tp>::has_trivial_destructor - _Trivial_destructor; - __destroy_aux(__first, __last, _Trivial_destructor()); -} - -template -inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { - __destroy(__first, __last, __VALUE_TYPE(__first)); -} - -inline void destroy(char*, char*) {} -inline void destroy(wchar_t*, wchar_t*) {} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_deque.h b/libstdc++/stl/stl_deque.h deleted file mode 100644 index af240af2efa..00000000000 --- a/libstdc++/stl/stl_deque.h +++ /dev/null @@ -1,1698 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_DEQUE_H -#define __SGI_STL_INTERNAL_DEQUE_H - -/* Class invariants: - * For any nonsingular iterator i: - * i.node is the address of an element in the map array. The - * contents of i.node is a pointer to the beginning of a node. - * i.first == *(i.node) - * 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, and that a deque - * with N elements, where N is the buffer size, must have two nodes. - * 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]. - */ - - -/* - * In previous versions of deque, node_size was fixed by the - * implementation. In this version, however, users can select - * the node size. Deque has three template parameters; the third, - * a number of type size_t, is the number of elements per node. - * If the third template parameter is 0 (which is the default), - * then deque will use a default node size. - * - * The only reason for using an alternate node size is if your application - * requires a different performance tradeoff than the default. If, - * for example, your program contains many deques each of which contains - * only a few elements, then you might want to save memory (possibly - * by sacrificing some speed) by using smaller nodes. - * - * Unfortunately, some compilers have trouble with non-type template - * parameters; stl_config.h defines __STL_NON_TYPE_TMPL_PARAM_BUG if - * that is the case. If your compiler is one of them, then you will - * not be able to use alternate node sizes; you will have to use the - * default value. - */ - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Note: this function is simply a kludge to work around several compilers' -// bugs in handling constant expressions. -inline size_t -__deque_buf_size(size_t __n, size_t __size) -{ - return __n != 0 ? __n : (__size < 512 ? size_t(512 / __size) : size_t(1)); -} - -#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG -template -struct _Deque_iterator { - typedef _Deque_iterator<_Tp,_Tp&,_Tp*,__bufsiz> iterator; - typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*,__bufsiz> const_iterator; - static size_t - _S_buffer_size() { return __deque_buf_size(__bufsiz, sizeof(_Tp)); } -#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */ -template -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(0, sizeof(_Tp)); } -#endif - - 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; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return _M_cur; } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - difference_type operator-(const _Self& __x) const { - return difference_type(_S_buffer_size()) * (_M_node - __x._M_node - 1) + - (_M_cur - _M_first) + (__x._M_last - __x._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); } - - bool operator==(const _Self& __x) const { return _M_cur == __x._M_cur; } - bool operator!=(const _Self& __x) const { return !(*this == __x); } - bool operator<(const _Self& __x) const { - return (_M_node == __x._M_node) ? - (_M_cur < __x._M_cur) : (_M_node < __x._M_node); - } - - 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()); - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG - -template -inline random_access_iterator_tag -iterator_category(const _Deque_iterator<_Tp,_Ref,_Ptr,__bufsiz>&) { - return random_access_iterator_tag(); -} - -template -inline _Tp* -value_type(const _Deque_iterator<_Tp,_Ref,_Ptr,__bufsiz>&) { - return 0; -} - -template -inline ptrdiff_t* -distance_type(const _Deque_iterator<_Tp,_Ref,_Ptr,__bufsiz>&) { - return 0; -} - -#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */ - -template -inline random_access_iterator_tag -iterator_category(const _Deque_iterator<_Tp,_Ref,_Ptr>&) -{ - return random_access_iterator_tag(); -} - -template -inline _Tp* -value_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) { return 0; } - -template -inline ptrdiff_t* -distance_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) { - return 0; -} - -#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// 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. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base class for ordinary allocators. -template -class _Deque_alloc_base { -public: - typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return node_allocator; } - - _Deque_alloc_base(const allocator_type& __a) - : node_allocator(__a), map_allocator(__a), _M_map(0), _M_map_size(0) - {} - -protected: - typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type - map_allocator_type; - - allocator_type node_allocator; - map_allocator_type map_allocator; - - _Tp* _M_allocate_node() { - return node_allocator.allocate(__deque_buf_size(__bufsiz,sizeof(_Tp))); - } - void _M_deallocate_node(_Tp* __p) { - node_allocator.deallocate(__p, __deque_buf_size(__bufsiz,sizeof(_Tp))); - } - _Tp** _M_allocate_map(size_t __n) - { return map_allocator.allocate(__n); } - void _M_deallocate_map(_Tp** __p, size_t __n) - { map_allocator.deallocate(__p, __n); } - - _Tp** _M_map; - size_t _M_map_size; -}; - -// Specialization for instanceless allocators. -template -class _Deque_alloc_base<_Tp, _Alloc, __bufsiz, 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(__bufsiz, - sizeof(_Tp))); } - void _M_deallocate_node(_Tp* __p) - { _Node_alloc_type::deallocate(__p, __deque_buf_size(__bufsiz, - sizeof(_Tp))); } - _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; -}; - -template -class _Deque_base - : public _Deque_alloc_base<_Tp,_Alloc,__bufsiz, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ -public: - typedef _Deque_alloc_base<_Tp,_Alloc,__bufsiz, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - typedef _Deque_iterator<_Tp,_Tp&,_Tp*,__bufsiz> iterator; - typedef _Deque_iterator<_Tp,const _Tp&,const _Tp&, __bufsiz> 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; -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _Deque_base { -public: -#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG - typedef _Deque_iterator<_Tp,_Tp&,_Tp*,__bufsiz> iterator; - typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*, __bufsiz> const_iterator; -#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */ - typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator; - typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; -#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ - - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Deque_base(const allocator_type&, size_t __num_elements) - : _M_map(0), _M_map_size(0), _M_start(), _M_finish() { - _M_initialize_map(__num_elements); - } - _Deque_base(const allocator_type&) - : _M_map(0), _M_map_size(0), _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: - _Tp** _M_map; - size_t _M_map_size; - iterator _M_start; - iterator _M_finish; - - typedef simple_alloc<_Tp, _Alloc> _Node_alloc_type; - typedef simple_alloc<_Tp*, _Alloc> _Map_alloc_type; - - _Tp* _M_allocate_node() - { return _Node_alloc_type::allocate(__deque_buf_size(__bufsiz, - sizeof(_Tp))); } - void _M_deallocate_node(_Tp* __p) - { _Node_alloc_type::deallocate(__p, __deque_buf_size(__bufsiz, - sizeof(_Tp))); } - _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); } -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -// Non-inline member functions from _Deque_base. - -template -_Deque_base<_Tp,_Alloc,__bufsiz>::~_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); - } -} - -template -void -_Deque_base<_Tp,_Alloc,__bufsiz>::_M_initialize_map(size_t __num_elements) -{ - size_t __num_nodes = - __num_elements / __deque_buf_size(__bufsiz, 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; - - __STL_TRY { - _M_create_nodes(__nstart, __nfinish); - } - __STL_UNWIND((_M_deallocate_map(_M_map, _M_map_size), - _M_map = 0, _M_map_size = 0)); - _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(__bufsiz, sizeof(_Tp)); -} - -template -void -_Deque_base<_Tp,_Alloc,__bufsiz>::_M_create_nodes(_Tp** __nstart, - _Tp** __nfinish) -{ - _Tp** __cur; - __STL_TRY { - for (__cur = __nstart; __cur < __nfinish; ++__cur) - *__cur = _M_allocate_node(); - } - __STL_UNWIND(_M_destroy_nodes(__nstart, __cur)); -} - -template -void -_Deque_base<_Tp,_Alloc,__bufsiz>::_M_destroy_nodes(_Tp** __nstart, - _Tp** __nfinish) -{ - for (_Tp** __n = __nstart; __n < __nfinish; ++__n) - _M_deallocate_node(*__n); -} - -// See __deque_buf_size(). The only reason that the default value is 0 -// is as a workaround for bugs in the way that some compilers handle -// constant expressions. -template -class deque : protected _Deque_base<_Tp, _Alloc, __bufsiz> { - typedef _Deque_base<_Tp, _Alloc, __bufsiz> _Base; -public: // Basic types - 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(); } - -public: // Iterators - typedef typename _Base::iterator iterator; - typedef typename _Base::const_iterator const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_iterator - const_reverse_iterator; - typedef reverse_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -protected: // Internal typedefs - typedef pointer* _Map_pointer; - static size_t _S_buffer_size() - { return __deque_buf_size(__bufsiz, sizeof(_Tp)); } - -protected: -#ifdef __STL_USE_NAMESPACES - 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; - - using _Base::_M_map; - using _Base::_M_map_size; - using _Base::_M_start; - using _Base::_M_finish; -#endif /* __STL_USE_NAMESPACES */ - -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)]; } - - 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()); } - -#ifdef __STL_MEMBER_TEMPLATES - - // Check whether it's an integral type. If so, it's not an iterator. - template - deque(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) : _Base(__a) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_initialize_dispatch(__first, __last, _Integral()); - } - - template - void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { - _M_initialize_map(__n); - _M_fill_initialize(__x); - } - - template - void _M_initialize_dispatch(_InputIter __first, _InputIter __last, - __false_type) { - _M_range_initialize(__first, __last, __ITERATOR_CATEGORY(__first)); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - deque(const value_type* __first, const value_type* __last, - const allocator_type& __a = allocator_type()) - : _Base(__a, __last - __first) - { uninitialized_copy(__first, __last, _M_start); } - deque(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a, __last - __first) - { uninitialized_copy(__first, __last, _M_start); } - -#endif /* __STL_MEMBER_TEMPLATES */ - - ~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 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); - } - } - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - -private: // helper functions for assign() - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type) { - _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); - } - - template - void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - size_type __len = 0; - distance(__first, __last, __len); - if (__len > size()) { - _ForwardIterator __mid = __first; - advance(__mid, size()); - copy(__first, __mid, begin()); - insert(end(), __mid, __last); - } - else - erase(copy(__first, __last, begin()), end()); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: // push_* and pop_* - - 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() { - 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) { - if (_M_start._M_cur != _M_start._M_first) { - construct(_M_start._M_cur - 1, __t); - --_M_start._M_cur; - } - else - _M_push_front_aux(__t); - } - - void push_front() { - if (_M_start._M_cur != _M_start._M_first) { - construct(_M_start._M_cur - 1); - --_M_start._M_cur; - } - else - _M_push_front_aux(); - } - - - 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(); - } - - void pop_front() { - if (_M_start._M_cur != _M_start._M_last - 1) { - destroy(_M_start._M_cur); - ++_M_start._M_cur; - } - else - _M_pop_front_aux(); - } - -public: // Insert - - iterator 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); - } - } - - iterator insert(iterator __position) - { return insert(__position, value_type()); } - - void insert(iterator __pos, size_type __n, const value_type& __x); - -#ifdef __STL_MEMBER_TEMPLATES - - // Check whether it's an integral type. If so, it's not an iterator. - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__pos, __first, __last, _Integral()); - } - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) { - insert(__pos, (size_type) __n, (value_type) __x); - } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) { - insert(__pos, __first, __last, __ITERATOR_CATEGORY(__first)); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void insert(iterator __pos, - const value_type* __first, const value_type* __last); - void insert(iterator __pos, - const_iterator __first, const_iterator __last); - -#endif /* __STL_MEMBER_TEMPLATES */ - - 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; - difference_type __index = __pos - _M_start; - if (static_cast(__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); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void _M_range_initialize(_InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ - -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 - -#ifdef __STL_MEMBER_TEMPLATES - - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void insert(iterator __pos, - _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ - - 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); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void _M_insert_aux(iterator __pos, - _ForwardIterator __first, _ForwardIterator __last, - size_type __n); - -#else /* __STL_MEMBER_TEMPLATES */ - - void _M_insert_aux(iterator __pos, - const value_type* __first, const value_type* __last, - size_type __n); - - void _M_insert_aux(iterator __pos, - const_iterator __first, const_iterator __last, - size_type __n); - -#endif /* __STL_MEMBER_TEMPLATES */ - - 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); - -#ifdef __STL_NON_TYPE_TMPL_PARAM_BUG -public: - bool operator==(const deque<_Tp,_Alloc,0>& __x) const { - return size() == __x.size() && equal(begin(), end(), __x.begin()); - } - bool operator!=(const deque<_Tp,_Alloc,0>& __x) const { - return size() != __x.size() || !equal(begin(), end(), __x.begin()); - } - bool operator<(const deque<_Tp,_Alloc,0>& __x) const { - return lexicographical_compare(begin(), end(), __x.begin(), __x.end()); - } -#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ -}; - -// Non-inline member functions - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void deque<_Tp, _Alloc, __bufsize> - ::_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); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void -deque<_Tp, _Alloc, __bufsize>::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); - uninitialized_fill(__new_start, _M_start, __x); - _M_start = __new_start; - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - uninitialized_fill(_M_finish, __new_finish, __x); - _M_finish = __new_finish; - } - else - _M_insert_aux(__pos, __n, __x); -} - -#ifndef __STL_MEMBER_TEMPLATES - -template -void deque<_Tp, _Alloc, __bufsize>::insert(iterator __pos, - const value_type* __first, - const value_type* __last) { - size_type __n = __last - __first; - if (__pos._M_cur == _M_start._M_cur) { - iterator __new_start = _M_reserve_elements_at_front(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __new_start); - _M_start = __new_start; - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - __STL_TRY { - uninitialized_copy(__first, __last, _M_finish); - _M_finish = __new_finish; - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } - else - _M_insert_aux(__pos, __first, __last, __n); -} - -template -void deque<_Tp,_Alloc,__bufsize>::insert(iterator __pos, - const_iterator __first, - const_iterator __last) -{ - size_type __n = __last - __first; - if (__pos._M_cur == _M_start._M_cur) { - iterator __new_start = _M_reserve_elements_at_front(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __new_start); - _M_start = __new_start; - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - __STL_TRY { - uninitialized_copy(__first, __last, _M_finish); - _M_finish = __new_finish; - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } - else - _M_insert_aux(__pos, __first, __last, __n); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -deque<_Tp,_Alloc,__bufsize>::iterator -deque<_Tp,_Alloc,__bufsize>::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(__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(__new_start._M_node, _M_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 -void deque<_Tp,_Alloc,__bufsize>::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; -} - -// Precondition: _M_start and _M_finish have already been initialized, -// but none of the deque's elements have yet been constructed. -template -void -deque<_Tp,_Alloc,__bufsize>::_M_fill_initialize(const value_type& __value) { - _Map_pointer __cur; - __STL_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); - } - __STL_UNWIND(destroy(_M_start, iterator(*__cur, __cur))); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void -deque<_Tp,_Alloc,__bufsize>::_M_range_initialize(_InputIterator __first, - _InputIterator __last, - input_iterator_tag) -{ - _M_initialize_map(0); - for ( ; __first != __last; ++__first) - push_back(*__first); -} - -template -template -void -deque<_Tp,_Alloc,__bufsize>::_M_range_initialize(_ForwardIterator __first, - _ForwardIterator __last, - forward_iterator_tag) -{ - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize_map(__n); - - _Map_pointer __cur_node; - __STL_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); - } - __STL_UNWIND(destroy(_M_start, iterator(*__cur_node, __cur_node))); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -// Called only if _M_finish._M_cur == _M_finish._M_last - 1. -template -void -deque<_Tp,_Alloc,__bufsize>::_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(); - __STL_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; - } - __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1))); -} - -// Called only if _M_finish._M_cur == _M_finish._M_last - 1. -template -void -deque<_Tp,_Alloc,__bufsize>::_M_push_back_aux() -{ - _M_reserve_map_at_back(); - *(_M_finish._M_node + 1) = _M_allocate_node(); - __STL_TRY { - construct(_M_finish._M_cur); - _M_finish._M_set_node(_M_finish._M_node + 1); - _M_finish._M_cur = _M_finish._M_first; - } - __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1))); -} - -// Called only if _M_start._M_cur == _M_start._M_first. -template -void -deque<_Tp,_Alloc,__bufsize>::_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(); - __STL_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); - } - __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1)))); -} - -// Called only if _M_start._M_cur == _M_start._M_first. -template -void -deque<_Tp,_Alloc,__bufsize>::_M_push_front_aux() -{ - _M_reserve_map_at_front(); - *(_M_start._M_node - 1) = _M_allocate_node(); - __STL_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); - } - __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1)))); -} - -// Called only if _M_finish._M_cur == _M_finish._M_first. -template -void -deque<_Tp,_Alloc,__bufsize>::_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 -void -deque<_Tp,_Alloc,__bufsize>::_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; -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void -deque<_Tp,_Alloc,__bufsize>::insert(iterator __pos, - _InputIterator __first, - _InputIterator __last, - input_iterator_tag) -{ - copy(__first, __last, inserter(*this, __pos)); -} - -template -template -void -deque<_Tp,_Alloc,__bufsize>::insert(iterator __pos, - _ForwardIterator __first, - _ForwardIterator __last, - forward_iterator_tag) { - size_type __n = 0; - distance(__first, __last, __n); - if (__pos._M_cur == _M_start._M_cur) { - iterator __new_start = _M_reserve_elements_at_front(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __new_start); - _M_start = __new_start; - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - __STL_TRY { - uninitialized_copy(__first, __last, _M_finish); - _M_finish = __new_finish; - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } - else - _M_insert_aux(__pos, __first, __last, __n); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -typename deque<_Tp, _Alloc, __bufsize>::iterator -deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos, - const value_type& __x) -{ - difference_type __index = __pos - _M_start; - value_type __x_copy = __x; - if (static_cast(__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 -typename deque<_Tp,_Alloc,__bufsize>::iterator -deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos) -{ - difference_type __index = __pos - _M_start; - if (static_cast(__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 -void -deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos, - size_type __n, - const value_type& __x) -{ - const difference_type __elems_before = __pos - _M_start; - size_type __length = size(); - value_type __x_copy = __x; - if (static_cast(__elems_before) < __length / 2) { - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elems_before; - __STL_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); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - 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; - __STL_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); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void -deque<_Tp,_Alloc,__bufsize>::_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(__elemsbefore) < __length / 2) { - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elemsbefore; - __STL_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); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - 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; - __STL_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); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos, - const value_type* __first, - const value_type* __last, - size_type __n) -{ - const difference_type __elemsbefore = __pos - _M_start; - size_type __length = size(); - if (__elemsbefore < __length / 2) { - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elemsbefore; - __STL_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 { - const value_type* __mid = - __first + (difference_type(__n) - __elemsbefore); - __uninitialized_copy_copy(_M_start, __pos, __first, __mid, - __new_start); - _M_start = __new_start; - copy(__mid, __last, __old_start); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - 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; - __STL_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 { - const value_type* __mid = __first + __elemsafter; - __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish); - _M_finish = __new_finish; - copy(__first, __mid, __pos); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -template -void -deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos, - const_iterator __first, - const_iterator __last, - size_type __n) -{ - const difference_type __elemsbefore = __pos - _M_start; - size_type __length = size(); - if (__elemsbefore < __length / 2) { - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elemsbefore; - __STL_TRY { - if (__elemsbefore >= __n) { - iterator __start_n = _M_start + __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 { - const_iterator __mid = __first + (__n - __elemsbefore); - __uninitialized_copy_copy(_M_start, __pos, __first, __mid, - __new_start); - _M_start = __new_start; - copy(__mid, __last, __old_start); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else { - iterator __new_finish = _M_reserve_elements_at_back(__n); - iterator __old_finish = _M_finish; - const difference_type __elemsafter = __length - __elemsbefore; - __pos = _M_finish - __elemsafter; - __STL_TRY { - if (__elemsafter > __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 { - const_iterator __mid = __first + __elemsafter; - __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish); - _M_finish = __new_finish; - copy(__first, __mid, __pos); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void -deque<_Tp,_Alloc,__bufsize>::_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; - __STL_TRY { - for (__i = 1; __i <= __new_nodes; ++__i) - *(_M_start._M_node - __i) = _M_allocate_node(); - } -# ifdef __STL_USE_EXCEPTIONS - catch(...) { - for (size_type __j = 1; __j < __i; ++__j) - _M_deallocate_node(*(_M_start._M_node - __j)); - throw; - } -# endif /* __STL_USE_EXCEPTIONS */ -} - -template -void -deque<_Tp,_Alloc,__bufsize>::_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; - __STL_TRY { - for (__i = 1; __i <= __new_nodes; ++__i) - *(_M_finish._M_node + __i) = _M_allocate_node(); - } -# ifdef __STL_USE_EXCEPTIONS - catch(...) { - for (size_type __j = 1; __j < __i; ++__j) - _M_deallocate_node(*(_M_finish._M_node + __j)); - throw; - } -# endif /* __STL_USE_EXCEPTIONS */ -} - -template -void -deque<_Tp,_Alloc,__bufsize>::_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); -} - - -// Nonmember functions. - -#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG - -template -bool operator==(const deque<_Tp, _Alloc, __bufsiz>& __x, - const deque<_Tp, _Alloc, __bufsiz>& __y) -{ - return __x.size() == __y.size() && - equal(__x.begin(), __x.end(), __y.begin()); -} - -template -bool operator<(const deque<_Tp, _Alloc, __bufsiz>& __x, - const deque<_Tp, _Alloc, __bufsiz>& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ - -#if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) && \ - !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) - -template -inline void -swap(deque<_Tp,_Alloc,__bufsiz>& __x, deque<_Tp,_Alloc,__bufsiz>& __y) -{ - __x.swap(__y); -} - -#endif - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_DEQUE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_function.h b/libstdc++/stl/stl_function.h deleted file mode 100644 index a5a8486576e..00000000000 --- a/libstdc++/stl/stl_function.h +++ /dev/null @@ -1,700 +0,0 @@ -/* - * - * 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-1998 - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_FUNCTION_H -#define __SGI_STL_INTERNAL_FUNCTION_H - -__STL_BEGIN_NAMESPACE - -template -struct unary_function { - typedef _Arg argument_type; - typedef _Result result_type; -}; - -template -struct binary_function { - typedef _Arg1 first_argument_type; - typedef _Arg2 second_argument_type; - typedef _Result result_type; -}; - -template -struct plus : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; } -}; - -template -struct minus : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; } -}; - -template -struct multiplies : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; } -}; - -template -struct divides : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; } -}; - -// identity_element (not part of the C++ standard). - -template inline _Tp identity_element(plus<_Tp>) { - return _Tp(0); -} -template inline _Tp identity_element(multiplies<_Tp>) { - return _Tp(1); -} - -template -struct modulus : public binary_function<_Tp,_Tp,_Tp> -{ - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; } -}; - -template -struct negate : public unary_function<_Tp,_Tp> -{ - _Tp operator()(const _Tp& __x) const { return -__x; } -}; - -template -struct equal_to : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; } -}; - -template -struct not_equal_to : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; } -}; - -template -struct greater : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; } -}; - -template -struct less : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } -}; - -template -struct greater_equal : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; } -}; - -template -struct less_equal : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; } -}; - -template -struct logical_and : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; } -}; - -template -struct logical_or : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; } -}; - -template -struct logical_not : public unary_function<_Tp,bool> -{ - bool operator()(const _Tp& __x) const { return !__x; } -}; - -template -class unary_negate - : public unary_function { -protected: - _Predicate _M_pred; -public: - explicit unary_negate(const _Predicate& __x) : _M_pred(__x) {} - bool operator()(const typename _Predicate::argument_type& __x) const { - return !_M_pred(__x); - } -}; - -template -inline unary_negate<_Predicate> -not1(const _Predicate& __pred) -{ - return unary_negate<_Predicate>(__pred); -} - -template -class binary_negate - : public binary_function { -protected: - _Predicate _M_pred; -public: - explicit binary_negate(const _Predicate& __x) : _M_pred(__x) {} - bool operator()(const typename _Predicate::first_argument_type& __x, - const typename _Predicate::second_argument_type& __y) const - { - return !_M_pred(__x, __y); - } -}; - -template -inline binary_negate<_Predicate> -not2(const _Predicate& __pred) -{ - return binary_negate<_Predicate>(__pred); -} - -template -class binder1st - : public unary_function { -protected: - _Operation op; - typename _Operation::first_argument_type value; -public: - binder1st(const _Operation& __x, - const typename _Operation::first_argument_type& __y) - : op(__x), value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::second_argument_type& __x) const { - return op(value, __x); - } -}; - -template -inline binder1st<_Operation> -bind1st(const _Operation& __oper, const _Tp& __x) -{ - typedef typename _Operation::first_argument_type _Arg1_type; - return binder1st<_Operation>(__oper, _Arg1_type(__x)); -} - -template -class binder2nd - : public unary_function { -protected: - _Operation op; - typename _Operation::second_argument_type value; -public: - binder2nd(const _Operation& __x, - const typename _Operation::second_argument_type& __y) - : op(__x), value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::first_argument_type& __x) const { - return op(__x, value); - } -}; - -template -inline binder2nd<_Operation> -bind2nd(const _Operation& __oper, const _Tp& __x) -{ - typedef typename _Operation::second_argument_type _Arg2_type; - return binder2nd<_Operation>(__oper, _Arg2_type(__x)); -} - -// unary_compose and binary_compose (extensions, not part of the standard). - -template -class unary_compose - : public unary_function -{ -protected: - _Operation1 __op1; - _Operation2 __op2; -public: - unary_compose(const _Operation1& __x, const _Operation2& __y) - : __op1(__x), __op2(__y) {} - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { - return __op1(__op2(__x)); - } -}; - -template -inline unary_compose<_Operation1,_Operation2> -compose1(const _Operation1& __op1, const _Operation2& __op2) -{ - return unary_compose<_Operation1,_Operation2>(__op1, __op2); -} - -template -class binary_compose - : public unary_function { -protected: - _Operation1 _M_op1; - _Operation2 _M_op2; - _Operation3 _M_op3; -public: - binary_compose(const _Operation1& __x, const _Operation2& __y, - const _Operation3& __z) - : _M_op1(__x), _M_op2(__y), _M_op3(__z) { } - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { - return _M_op1(_M_op2(__x), _M_op3(__x)); - } -}; - -template -inline binary_compose<_Operation1, _Operation2, _Operation3> -compose2(const _Operation1& __op1, const _Operation2& __op2, - const _Operation3& __op3) -{ - return binary_compose<_Operation1,_Operation2,_Operation3> - (__op1, __op2, __op3); -} - -template -class pointer_to_unary_function : public unary_function<_Arg, _Result> { -protected: - _Result (*_M_ptr)(_Arg); -public: - pointer_to_unary_function() {} - explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {} - _Result operator()(_Arg __x) const { return _M_ptr(__x); } -}; - -template -inline pointer_to_unary_function<_Arg, _Result> ptr_fun(_Result (*__x)(_Arg)) -{ - return pointer_to_unary_function<_Arg, _Result>(__x); -} - -template -class pointer_to_binary_function : - public binary_function<_Arg1,_Arg2,_Result> { -protected: - _Result (*_M_ptr)(_Arg1, _Arg2); -public: - pointer_to_binary_function() {} - explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) - : _M_ptr(__x) {} - _Result operator()(_Arg1 __x, _Arg2 __y) const { - return _M_ptr(__x, __y); - } -}; - -template -inline pointer_to_binary_function<_Arg1,_Arg2,_Result> -ptr_fun(_Result (*__x)(_Arg1, _Arg2)) { - return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__x); -} - -// identity is an extensions: it is not part of the standard. -template -struct _Identity : public unary_function<_Tp,_Tp> { - const _Tp& operator()(const _Tp& __x) const { return __x; } -}; - -template struct identity : public _Identity<_Tp> {}; - -// select1st and select2nd are extensions: they are not part of the standard. -template -struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { - const typename _Pair::first_type& operator()(const _Pair& __x) const { - return __x.first; - } -}; - -template -struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> -{ - const typename _Pair::second_type& operator()(const _Pair& __x) const { - return __x.second; - } -}; - -template struct select1st : public _Select1st<_Pair> {}; -template struct select2nd : public _Select2nd<_Pair> {}; - -// project1st and project2nd are extensions: they are not part of the standard -template -struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> { - _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; } -}; - -template -struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> { - _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; } -}; - -template -struct project1st : public _Project1st<_Arg1, _Arg2> {}; - -template -struct project2nd : public _Project2nd<_Arg1, _Arg2> {}; - -// constant_void_fun, constant_unary_fun, and constant_binary_fun are -// extensions: they are not part of the standard. (The same, of course, -// is true of the helper functions constant0, constant1, and constant2.) -template -struct constant_void_fun -{ - typedef _Result result_type; - result_type __val; - constant_void_fun(const result_type& __v) : __val(__v) {} - const result_type& operator()() const { return __val; } -}; - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template -#else -template -#endif -struct constant_unary_fun : public unary_function<_Argument, _Result> { - _Result _M_val; - constant_unary_fun(const _Result& __v) : _M_val(__v) {} - const _Result& operator()(const _Argument&) const { return _M_val; } -}; - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template -#else -template -#endif -struct constant_binary_fun : public binary_function<_Arg1, _Arg2, _Result> { - _Result _M_val; - constant_binary_fun(const _Result& __v) : _M_val(__v) {} - const _Result& operator()(const _Arg1&, const _Arg2&) const { - return _M_val; - } -}; - -template -inline constant_void_fun<_Result> constant0(const _Result& __val) -{ - return constant_void_fun<_Result>(__val); -} - -template -inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val) -{ - return constant_unary_fun<_Result,_Result>(__val); -} - -template -inline constant_binary_fun<_Result,_Result,_Result> -constant2(const _Result& __val) -{ - return constant_binary_fun<_Result,_Result,_Result>(__val); -} - -// subtractive_rng is an extension: it is not part of the standard. -// Note: this code assumes that int is 32 bits. -class subtractive_rng : public unary_function { -private: - unsigned int _M_table[55]; - size_t _M_index1; - size_t _M_index2; -public: - unsigned int operator()(unsigned int __limit) { - _M_index1 = (_M_index1 + 1) % 55; - _M_index2 = (_M_index2 + 1) % 55; - _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2]; - return _M_table[_M_index1] % __limit; - } - - void _M_initialize(unsigned int __seed) - { - unsigned int __k = 1; - _M_table[54] = __seed; - size_t __i; - for (__i = 0; __i < 54; __i++) { - size_t __ii = (21 * (__i + 1) % 55) - 1; - _M_table[__ii] = __k; - __k = __seed - __k; - __seed = _M_table[__ii]; - } - for (int __loop = 0; __loop < 4; __loop++) { - for (__i = 0; __i < 55; __i++) - _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55]; - } - _M_index1 = 0; - _M_index2 = 31; - } - - subtractive_rng(unsigned int __seed) { _M_initialize(__seed); } - subtractive_rng() { _M_initialize(161803398u); } -}; - - -// Adaptor function objects: pointers to member functions. - -// There are a total of 16 = 2^4 function objects in this family. -// (1) Member functions taking no arguments vs member functions taking -// one argument. -// (2) Call through pointer vs call through reference. -// (3) Member function with void return type vs member function with -// non-void return type. -// (4) Const vs non-const member function. - -// Note that choice (3) is nothing more than a workaround: according -// to the draft, compilers should handle void and non-void the same way. -// This feature is not yet widely implemented, though. You can only use -// member functions returning void if your compiler supports partial -// specialization. - -// All of this complexity is in the function objects themselves. You can -// ignore it by using the helper function mem_fun and mem_fun_ref, -// which create whichever type of adaptor is appropriate. -// (mem_fun1 and mem_fun1_ref are no longer part of the C++ standard, -// but they are provided for backward compatibility.) - - -template -class mem_fun_t : public unary_function<_Tp*,_Ret> { -public: - explicit mem_fun_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {} - _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); } -private: - _Ret (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_t : public unary_function { -public: - explicit const_mem_fun_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {} - _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); } -private: - _Ret (_Tp::*_M_f)() const; -}; - - -template -class mem_fun_ref_t : public unary_function<_Tp,_Ret> { -public: - explicit mem_fun_ref_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {} - _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); } -private: - _Ret (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> { -public: - explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {} - _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); } -private: - _Ret (_Tp::*_M_f)() const; -}; - -template -class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> { -public: - explicit mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_t : public binary_function { -public: - explicit const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - _Ret operator()(const _Tp* __p, _Arg __x) const - { return (__p->*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg) const; -}; - -template -class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { -public: - explicit mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { -public: - explicit const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg) const; -}; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -class mem_fun_t : public unary_function<_Tp*,void> { -public: - explicit mem_fun_t(void (_Tp::*__pf)()) : _M_f(__pf) {} - void operator()(_Tp* __p) const { (__p->*_M_f)(); } -private: - void (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_t : public unary_function { -public: - explicit const_mem_fun_t(void (_Tp::*__pf)() const) : _M_f(__pf) {} - void operator()(const _Tp* __p) const { (__p->*_M_f)(); } -private: - void (_Tp::*_M_f)() const; -}; - -template -class mem_fun_ref_t : public unary_function<_Tp,void> { -public: - explicit mem_fun_ref_t(void (_Tp::*__pf)()) : _M_f(__pf) {} - void operator()(_Tp& __r) const { (__r.*_M_f)(); } -private: - void (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_ref_t : public unary_function<_Tp,void> { -public: - explicit const_mem_fun_ref_t(void (_Tp::*__pf)() const) : _M_f(__pf) {} - void operator()(const _Tp& __r) const { (__r.*_M_f)(); } -private: - void (_Tp::*_M_f)() const; -}; - -template -class mem_fun1_t : public binary_function<_Tp*,_Arg,void> { -public: - explicit mem_fun1_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_t - : public binary_function { -public: - explicit const_mem_fun1_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg) const; -}; - -template -class mem_fun1_ref_t - : public binary_function<_Tp,_Arg,void> { -public: - explicit mem_fun1_ref_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_ref_t - : public binary_function<_Tp,_Arg,void> { -public: - explicit const_mem_fun1_ref_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg) const; -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// Mem_fun adaptor helper functions. There are only two: -// mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref -// are provided for backward compatibility, but they are no longer -// part of the C++ standard.) - -template -inline mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)()) - { return mem_fun_t<_Ret,_Tp>(__f); } - -template -inline const_mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)() const) - { return const_mem_fun_t<_Ret,_Tp>(__f); } - -template -inline mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)()) - { return mem_fun_ref_t<_Ret,_Tp>(__f); } - -template -inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const) - { return const_mem_fun_ref_t<_Ret,_Tp>(__f); } - -template -inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun_ref(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg> -mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -template -inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun1_ref(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg> -mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_FUNCTION_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_hash_fun.h b/libstdc++/stl/stl_hash_fun.h deleted file mode 100644 index 44ab9bb5679..00000000000 --- a/libstdc++/stl/stl_hash_fun.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1996-1998 - * 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. - * - * - * 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. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_HASH_FUN_H -#define __SGI_STL_HASH_FUN_H - -#include - -__STL_BEGIN_NAMESPACE - -template struct hash { }; - -inline size_t __stl_hash_string(const char* __s) -{ - unsigned long __h = 0; - for ( ; *__s; ++__s) - __h = 5*__h + *__s; - - return size_t(__h); -} - -__STL_TEMPLATE_NULL struct hash -{ - size_t operator()(const char* __s) const { return __stl_hash_string(__s); } -}; - -__STL_TEMPLATE_NULL struct hash -{ - size_t operator()(const char* __s) const { return __stl_hash_string(__s); } -}; - -__STL_TEMPLATE_NULL struct hash { - size_t operator()(char __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned char __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned char __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(short __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned short __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(int __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned int __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(long __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned long __x) const { return __x; } -}; - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_HASH_FUN_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_hash_map.h b/libstdc++/stl/stl_hash_map.h deleted file mode 100644 index bf16f60ecad..00000000000 --- a/libstdc++/stl/stl_hash_map.h +++ /dev/null @@ -1,416 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HASH_MAP_H -#define __SGI_STL_INTERNAL_HASH_MAP_H - - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _EqualKey = equal_to<_Key>, - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -#else -template -#endif -class hash_map -{ -private: - typedef hashtable,_Key,_HashFcn, - _Select1st >,_EqualKey,_Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_map(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_map(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_map(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - -#else - hash_map(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - - hash_map(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); } - friend bool - operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&); - - iterator begin() { return _M_ht.begin(); } - iterator end() { return _M_ht.end(); } - const_iterator begin() const { return _M_ht.begin(); } - const_iterator end() const { return _M_ht.end(); } - -public: - pair insert(const value_type& __obj) - { return _M_ht.insert_unique(__obj); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_unique(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_unique(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - { _M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - pair insert_noresize(const value_type& __obj) - { return _M_ht.insert_unique_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - const_iterator find(const key_type& __key) const - { return _M_ht.find(__key); } - - _Tp& operator[](const key_type& __key) { - return _M_ht.find_or_insert(value_type(__key, _Tp())).second; - } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) - { return _M_ht.equal_range(__key); } - pair - equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - return __hm1._M_ht == __hm2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void -swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - __hm1.swap(__hm2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _EqualKey = equal_to<_Key>, - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -#else -template -#endif -class hash_multimap -{ -private: - typedef hashtable, _Key, _HashFcn, - _Select1st >, _EqualKey, _Alloc> - _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_multimap(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_multimap(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - -#else - hash_multimap(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - - hash_multimap(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); } - friend bool - operator== __STL_NULL_TMPL_ARGS (const hash_multimap&, - const hash_multimap&); - - iterator begin() { return _M_ht.begin(); } - iterator end() { return _M_ht.end(); } - const_iterator begin() const { return _M_ht.begin(); } - const_iterator end() const { return _M_ht.end(); } - -public: - iterator insert(const value_type& __obj) - { return _M_ht.insert_equal(__obj); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_equal(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_equal(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - iterator insert_noresize(const value_type& __obj) - { return _M_ht.insert_equal_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - const_iterator find(const key_type& __key) const - { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) - { return _M_ht.equal_range(__key); } - pair - equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, - const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) -{ - return __hm1._M_ht == __hm2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void -swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - __hm1.swap(__hm2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HASH_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_hash_set.h b/libstdc++/stl/stl_hash_set.h deleted file mode 100644 index b623a642cfc..00000000000 --- a/libstdc++/stl/stl_hash_set.h +++ /dev/null @@ -1,401 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HASH_SET_H -#define __SGI_STL_INTERNAL_HASH_SET_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _EqualKey = equal_to<_Value>, - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) > -#else -template -#endif -class hash_set -{ -private: - typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, - _EqualKey, _Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::const_pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::const_reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::const_iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_set() - : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_set(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_set(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_set(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } -#else - - hash_set(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - - hash_set(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); } - friend bool operator== __STL_NULL_TMPL_ARGS (const hash_set&, - const hash_set&); - - iterator begin() const { return _M_ht.begin(); } - iterator end() const { return _M_ht.end(); } - -public: - pair insert(const value_type& __obj) - { - pair __p = _M_ht.insert_unique(__obj); - return pair(__p.first, __p.second); - } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_unique(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_unique(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - {_M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - pair insert_noresize(const value_type& __obj) - { - pair __p = - _M_ht.insert_unique_noresize(__obj); - return pair(__p.first, __p.second); - } - - iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - return __hs1._M_ht == __hs2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void -swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - __hs1.swap(__hs2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _EqualKey = equal_to<_Value>, - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) > -#else -template -#endif -class hash_multiset -{ -private: - typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, - _EqualKey, _Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::const_pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::const_reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::const_iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_multiset() - : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_multiset(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_multiset(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_multiset(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } -#else - - hash_multiset(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - - hash_multiset(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); } - friend bool operator== __STL_NULL_TMPL_ARGS (const hash_multiset&, - const hash_multiset&); - - iterator begin() const { return _M_ht.begin(); } - iterator end() const { return _M_ht.end(); } - -public: - iterator insert(const value_type& __obj) - { return _M_ht.insert_equal(__obj); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_equal(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_equal(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - iterator insert_noresize(const value_type& __obj) - { return _M_ht.insert_equal_noresize(__obj); } - - iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - return __hs1._M_ht == __hs2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void -swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) { - __hs1.swap(__hs2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HASH_SET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_hashtable.h b/libstdc++/stl/stl_hashtable.h deleted file mode 100644 index 78b36c1d5a0..00000000000 --- a/libstdc++/stl/stl_hashtable.h +++ /dev/null @@ -1,1039 +0,0 @@ -/* - * 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. - * - * - * 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. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#define __SGI_STL_INTERNAL_HASHTABLE_H - -// Hashtable class, used to implement the hashed associative containers -// hash_set, hash_map, hash_multiset, and hash_multimap. - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -__STL_BEGIN_NAMESPACE - -template -struct _Hashtable_node -{ - _Hashtable_node* _M_next; - _Val _M_val; -}; - -template -class hashtable; - -template -struct _Hashtable_iterator; - -template -struct _Hashtable_const_iterator; - -template -struct _Hashtable_iterator { - typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - typedef _Val& reference; - typedef _Val* pointer; - - _Node* _M_cur; - _Hashtable* _M_ht; - - _Hashtable_iterator(_Node* __n, _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) {} - _Hashtable_iterator() {} - reference operator*() const { return _M_cur->_M_val; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - iterator& operator++(); - iterator operator++(int); - bool operator==(const iterator& __it) const - { return _M_cur == __it._M_cur; } - bool operator!=(const iterator& __it) const - { return _M_cur != __it._M_cur; } -}; - - -template -struct _Hashtable_const_iterator { - typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val,_Key,_HashFcn, - _ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - typedef const _Val& reference; - typedef const _Val* pointer; - - const _Node* _M_cur; - const _Hashtable* _M_ht; - - _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) {} - _Hashtable_const_iterator() {} - _Hashtable_const_iterator(const iterator& __it) - : _M_cur(__it._M_cur), _M_ht(__it._M_ht) {} - reference operator*() const { return _M_cur->_M_val; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - const_iterator& operator++(); - const_iterator operator++(int); - bool operator==(const const_iterator& __it) const - { return _M_cur == __it._M_cur; } - bool operator!=(const const_iterator& __it) const - { return _M_cur != __it._M_cur; } -}; - -// Note: assumes long is at least 32 bits. -static const int __stl_num_primes = 28; -static const unsigned long __stl_prime_list[__stl_num_primes] = -{ - 53ul, 97ul, 193ul, 389ul, 769ul, - 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, - 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, - 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, - 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, - 1610612741ul, 3221225473ul, 4294967291ul -}; - -inline unsigned long __stl_next_prime(unsigned long __n) -{ - const unsigned long* __first = __stl_prime_list; - const unsigned long* __last = __stl_prime_list + __stl_num_primes; - const unsigned long* pos = lower_bound(__first, __last, __n); - return pos == __last ? *(__last - 1) : *pos; -} - -// Forward declaration of operator==. - -template -class hashtable; - -template -bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2); - - -// Hashtables handle allocators a bit differently than other containers -// do. If we're using standard-conforming allocators, then a hashtable -// unconditionally has a member variable to hold its allocator, even if -// it so happens that all instances of the allocator type are identical. -// This is because, for hashtables, this extra storage is negligible. -// Additionally, a base class wouldn't serve any other purposes; it -// wouldn't, for example, simplify the exception-handling code. - -template -class hashtable { -public: - typedef _Key key_type; - typedef _Val value_type; - typedef _HashFcn hasher; - typedef _EqualKey key_equal; - - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - - hasher hash_funct() const { return _M_hash; } - key_equal key_eq() const { return _M_equals; } - -private: - typedef _Hashtable_node<_Val> _Node; - -#ifdef __STL_USE_STD_ALLOCATORS -public: - typedef typename _Alloc_traits<_Val,_Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } -private: - typename _Alloc_traits<_Node, _Alloc>::allocator_type _M_node_allocator; - _Node* _M_get_node() { return _M_node_allocator.allocate(1); } - void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); } -# define __HASH_ALLOC_INIT(__a) _M_node_allocator(__a), -#else /* __STL_USE_STD_ALLOCATORS */ -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } -private: - typedef simple_alloc<_Node, _Alloc> _M_node_allocator_type; - _Node* _M_get_node() { return _M_node_allocator_type::allocate(1); } - void _M_put_node(_Node* __p) { _M_node_allocator_type::deallocate(__p, 1); } -# define __HASH_ALLOC_INIT(__a) -#endif /* __STL_USE_STD_ALLOCATORS */ - -private: - hasher _M_hash; - key_equal _M_equals; - _ExtractKey _M_get_key; - vector<_Node*,_Alloc> _M_buckets; - size_type _M_num_elements; - -public: - typedef _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey, - _Alloc> - const_iterator; - - friend struct - _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; - friend struct - _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; - -public: - hashtable(size_type __n, - const _HashFcn& __hf, - const _EqualKey& __eql, - const _ExtractKey& __ext, - const allocator_type& __a = allocator_type()) - : __HASH_ALLOC_INIT(__a) - _M_hash(__hf), - _M_equals(__eql), - _M_get_key(__ext), - _M_buckets(__a), - _M_num_elements(0) - { - _M_initialize_buckets(__n); - } - - hashtable(size_type __n, - const _HashFcn& __hf, - const _EqualKey& __eql, - const allocator_type& __a = allocator_type()) - : __HASH_ALLOC_INIT(__a) - _M_hash(__hf), - _M_equals(__eql), - _M_get_key(_ExtractKey()), - _M_buckets(__a), - _M_num_elements(0) - { - _M_initialize_buckets(__n); - } - - hashtable(const hashtable& __ht) - : __HASH_ALLOC_INIT(__ht.get_allocator()) - _M_hash(__ht._M_hash), - _M_equals(__ht._M_equals), - _M_get_key(__ht._M_get_key), - _M_buckets(__ht.get_allocator()), - _M_num_elements(0) - { - _M_copy_from(__ht); - } - -#undef __HASH_ALLOC_INIT - - hashtable& operator= (const hashtable& __ht) - { - if (&__ht != this) { - clear(); - _M_hash = __ht._M_hash; - _M_equals = __ht._M_equals; - _M_get_key = __ht._M_get_key; - _M_copy_from(__ht); - } - return *this; - } - - ~hashtable() { clear(); } - - size_type size() const { return _M_num_elements; } - size_type max_size() const { return size_type(-1); } - bool empty() const { return size() == 0; } - - void swap(hashtable& __ht) - { - __STD::swap(_M_hash, __ht._M_hash); - __STD::swap(_M_equals, __ht._M_equals); - __STD::swap(_M_get_key, __ht._M_get_key); - _M_buckets.swap(__ht._M_buckets); - __STD::swap(_M_num_elements, __ht._M_num_elements); - } - - iterator begin() - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return iterator(_M_buckets[__n], this); - return end(); - } - - iterator end() { return iterator(0, this); } - - const_iterator begin() const - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return const_iterator(_M_buckets[__n], this); - return end(); - } - - const_iterator end() const { return const_iterator(0, this); } - - friend bool - operator== __STL_NULL_TMPL_ARGS (const hashtable&, const hashtable&); - -public: - - size_type bucket_count() const { return _M_buckets.size(); } - - size_type max_bucket_count() const - { return __stl_prime_list[__stl_num_primes - 1]; } - - size_type elems_in_bucket(size_type __bucket) const - { - size_type __result = 0; - for (_Node* __cur = _M_buckets[__bucket]; __cur; __cur = __cur->_M_next) - __result += 1; - return __result; - } - - pair insert_unique(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_unique_noresize(__obj); - } - - iterator insert_equal(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_equal_noresize(__obj); - } - - pair insert_unique_noresize(const value_type& __obj); - iterator insert_equal_noresize(const value_type& __obj); - -#ifdef __STL_MEMBER_TEMPLATES - template - void insert_unique(_InputIterator __f, _InputIterator __l) - { - insert_unique(__f, __l, __ITERATOR_CATEGORY(__f)); - } - - template - void insert_equal(_InputIterator __f, _InputIterator __l) - { - insert_equal(__f, __l, __ITERATOR_CATEGORY(__f)); - } - - template - void insert_unique(_InputIterator __f, _InputIterator __l, - input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_unique(*__f); - } - - template - void insert_equal(_InputIterator __f, _InputIterator __l, - input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_equal(*__f); - } - - template - void insert_unique(_ForwardIterator __f, _ForwardIterator __l, - forward_iterator_tag) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } - - template - void insert_equal(_ForwardIterator __f, _ForwardIterator __l, - forward_iterator_tag) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } - -#else /* __STL_MEMBER_TEMPLATES */ - void insert_unique(const value_type* __f, const value_type* __l) - { - size_type __n = __l - __f; - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } - - void insert_equal(const value_type* __f, const value_type* __l) - { - size_type __n = __l - __f; - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } - - void insert_unique(const_iterator __f, const_iterator __l) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } - - void insert_equal(const_iterator __f, const_iterator __l) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } -#endif /*__STL_MEMBER_TEMPLATES */ - - reference find_or_insert(const value_type& __obj); - - iterator find(const key_type& __key) - { - size_type __n = _M_bkt_num_key(__key); - _Node* __first; - for ( __first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - {} - return iterator(__first, this); - } - - const_iterator find(const key_type& __key) const - { - size_type __n = _M_bkt_num_key(__key); - const _Node* __first; - for ( __first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - {} - return const_iterator(__first, this); - } - - size_type count(const key_type& __key) const - { - const size_type __n = _M_bkt_num_key(__key); - size_type __result = 0; - - for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), __key)) - ++__result; - return __result; - } - - pair - equal_range(const key_type& __key); - - pair - equal_range(const key_type& __key) const; - - size_type erase(const key_type& __key); - void erase(const iterator& __it); - void erase(iterator __first, iterator __last); - - void erase(const const_iterator& __it); - void erase(const_iterator __first, const_iterator __last); - - void resize(size_type __num_elements_hint); - void clear(); - -private: - size_type _M_next_size(size_type __n) const - { return __stl_next_prime(__n); } - - void _M_initialize_buckets(size_type __n) - { - const size_type __n_buckets = _M_next_size(__n); - _M_buckets.reserve(__n_buckets); - _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); - _M_num_elements = 0; - } - - size_type _M_bkt_num_key(const key_type& __key) const - { - return _M_bkt_num_key(__key, _M_buckets.size()); - } - - size_type _M_bkt_num(const value_type& __obj) const - { - return _M_bkt_num_key(_M_get_key(__obj)); - } - - size_type _M_bkt_num_key(const key_type& __key, size_t __n) const - { - return _M_hash(__key) % __n; - } - - size_type _M_bkt_num(const value_type& __obj, size_t __n) const - { - return _M_bkt_num_key(_M_get_key(__obj), __n); - } - - _Node* _M_new_node(const value_type& __obj) - { - _Node* __n = _M_get_node(); - __n->_M_next = 0; - __STL_TRY { - construct(&__n->_M_val, __obj); - return __n; - } - __STL_UNWIND(_M_put_node(__n)); - } - - void _M_delete_node(_Node* __n) - { - destroy(&__n->_M_val); - _M_put_node(__n); - } - - void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); - void _M_erase_bucket(const size_type __n, _Node* __last); - - void _M_copy_from(const hashtable& __ht); - -}; - -template -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() -{ - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; -} - -template -inline _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) -{ - iterator __tmp = *this; - ++*this; - return __tmp; -} - -template -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() -{ - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; -} - -template -inline _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) -{ - const_iterator __tmp = *this; - ++*this; - return __tmp; -} - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline forward_iterator_tag -iterator_category(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return forward_iterator_tag(); -} - -template -inline _Val* -value_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (_Val*) 0; -} - -template -inline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type* -distance_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*) 0; -} - -template -inline forward_iterator_tag -iterator_category(const _Hashtable_const_iterator<_Val,_Key,_HF, - _ExK,_EqK,_All>&) -{ - return forward_iterator_tag(); -} - -template -inline _Val* -value_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (_Val*) 0; -} - -template -inline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type* -distance_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*) 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) -{ - typedef typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::_Node _Node; - if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) - return false; - for (int __n = 0; __n < __ht1._M_buckets.size(); ++__n) { - _Node* __cur1 = __ht1._M_buckets[__n]; - _Node* __cur2 = __ht2._M_buckets[__n]; - for ( ; __cur1 && __cur2 && __cur1->_M_val == __cur2->_M_val; - __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) - {} - if (__cur1 || __cur2) - return false; - } - return true; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, - hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) { - __ht1.swap(__ht2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template -pair::iterator, bool> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::insert_unique_noresize(const value_type& __obj) -{ - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return pair(iterator(__cur, this), false); - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return pair(iterator(__tmp, this), true); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::insert_equal_noresize(const value_type& __obj) -{ - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) { - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __cur->_M_next; - __cur->_M_next = __tmp; - ++_M_num_elements; - return iterator(__tmp, this); - } - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return iterator(__tmp, this); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::reference -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::find_or_insert(const value_type& __obj) -{ - resize(_M_num_elements + 1); - - size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return __cur->_M_val; - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return __tmp->_M_val; -} - -template -pair::iterator, - typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::equal_range(const key_type& __key) -{ - typedef pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (_Node* __first = _M_buckets[__n]; __first; __first = __first->_M_next) - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - for (_Node* __cur = __first->_M_next; __cur; __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(iterator(__first, this), iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(iterator(__first, this), - iterator(_M_buckets[__m], this)); - return _Pii(iterator(__first, this), end()); - } - return _Pii(end(), end()); -} - -template -pair::const_iterator, - typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_iterator> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::equal_range(const key_type& __key) const -{ - typedef pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (const _Node* __first = _M_buckets[__n] ; - __first; - __first = __first->_M_next) { - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - for (const _Node* __cur = __first->_M_next; - __cur; - __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(const_iterator(__first, this), - const_iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(const_iterator(__first, this), - const_iterator(_M_buckets[__m], this)); - return _Pii(const_iterator(__first, this), end()); - } - } - return _Pii(end(), end()); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::size_type -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const key_type& __key) -{ - const size_type __n = _M_bkt_num_key(__key); - _Node* __first = _M_buckets[__n]; - size_type __erased = 0; - - if (__first) { - _Node* __cur = __first; - _Node* __next = __cur->_M_next; - while (__next) { - if (_M_equals(_M_get_key(__next->_M_val), __key)) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - ++__erased; - --_M_num_elements; - } - else { - __cur = __next; - __next = __cur->_M_next; - } - } - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - _M_buckets[__n] = __first->_M_next; - _M_delete_node(__first); - ++__erased; - --_M_num_elements; - } - } - return __erased; -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const iterator& __it) -{ - if (_Node* const __p = __it._M_cur) { - const size_type __n = _M_bkt_num(__p->_M_val); - _Node* __cur = _M_buckets[__n]; - - if (__cur == __p) { - _M_buckets[__n] = __cur->_M_next; - _M_delete_node(__cur); - --_M_num_elements; - } - else { - _Node* __next = __cur->_M_next; - while (__next) { - if (__next == __p) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - --_M_num_elements; - break; - } - else { - __cur = __next; - __next = __cur->_M_next; - } - } - } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::erase(iterator __first, iterator __last) -{ - size_type __f_bucket = __first._M_cur ? - _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size(); - size_type __l_bucket = __last._M_cur ? - _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size(); - - if (__first._M_cur == __last._M_cur) - return; - else if (__f_bucket == __l_bucket) - _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); - else { - _M_erase_bucket(__f_bucket, __first._M_cur, 0); - for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) - _M_erase_bucket(__n, 0); - if (__l_bucket != _M_buckets.size()) - _M_erase_bucket(__l_bucket, __last._M_cur); - } -} - -template -inline void -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const_iterator __first, - const_iterator __last) -{ - erase(iterator(const_cast<_Node*>(__first._M_cur), - const_cast(__first._M_ht)), - iterator(const_cast<_Node*>(__last._M_cur), - const_cast(__last._M_ht))); -} - -template -inline void -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const const_iterator& __it) -{ - erase(iterator(const_cast<_Node*>(__it._M_cur), - const_cast(__it._M_ht))); -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::resize(size_type __num_elements_hint) -{ - const size_type __old_n = _M_buckets.size(); - if (__num_elements_hint > __old_n) { - const size_type __n = _M_next_size(__num_elements_hint); - if (__n > __old_n) { - vector<_Node*, _All> __tmp(__n, (_Node*)(0), - _M_buckets.get_allocator()); - __STL_TRY { - for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) { - _Node* __first = _M_buckets[__bucket]; - while (__first) { - size_type __new_bucket = _M_bkt_num(__first->_M_val, __n); - _M_buckets[__bucket] = __first->_M_next; - __first->_M_next = __tmp[__new_bucket]; - __tmp[__new_bucket] = __first; - __first = _M_buckets[__bucket]; - } - } - _M_buckets.swap(__tmp); - } -# ifdef __STL_USE_EXCEPTIONS - catch(...) { - for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) { - while (__tmp[__bucket]) { - _Node* __next = __tmp[__bucket]->_M_next; - _M_delete_node(__tmp[__bucket]); - __tmp[__bucket] = __next; - } - } - throw; - } -# endif /* __STL_USE_EXCEPTIONS */ - } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) -{ - _Node* __cur = _M_buckets[__n]; - if (__cur == __first) - _M_erase_bucket(__n, __last); - else { - _Node* __next; - for (__next = __cur->_M_next; - __next != __first; - __cur = __next, __next = __cur->_M_next) - ; - while (__next) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - --_M_num_elements; - } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_erase_bucket(const size_type __n, _Node* __last) -{ - _Node* __cur = _M_buckets[__n]; - while (__cur != __last) { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; - _M_buckets[__n] = __cur; - --_M_num_elements; - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::clear() -{ - for (size_type __i = 0; __i < _M_buckets.size(); ++__i) { - _Node* __cur = _M_buckets[__i]; - while (__cur != 0) { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; - } - _M_buckets[__i] = 0; - } - _M_num_elements = 0; -} - - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_copy_from(const hashtable& __ht) -{ - _M_buckets.clear(); - _M_buckets.reserve(__ht._M_buckets.size()); - _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); - __STL_TRY { - for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { - if (const _Node* __cur = __ht._M_buckets[__i]) { - _Node* __copy = _M_new_node(__cur->_M_val); - _M_buckets[__i] = __copy; - - for (_Node* __next = __cur->_M_next; - __next; - __cur = __next, __next = __cur->_M_next) { - __copy->_M_next = _M_new_node(__next->_M_val); - __copy = __copy->_M_next; - } - } - } - _M_num_elements = __ht._M_num_elements; - } - __STL_UNWIND(clear()); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HASHTABLE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_heap.h b/libstdc++/stl/stl_heap.h deleted file mode 100644 index 62f142ec970..00000000000 --- a/libstdc++/stl/stl_heap.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HEAP_H -#define __SGI_STL_INTERNAL_HEAP_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1209 -#endif - -// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap. - -template -void -__push_heap(_RandomAccessIterator __first, - _Distance __holeIndex, _Distance __topIndex, _Tp __value) -{ - _Distance __parent = (__holeIndex - 1) / 2; - while (__holeIndex > __topIndex && *(__first + __parent) < __value) { - *(__first + __holeIndex) = *(__first + __parent); - __holeIndex = __parent; - __parent = (__holeIndex - 1) / 2; - } - *(__first + __holeIndex) = __value; -} - -template -inline void -__push_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Distance*, _Tp*) -{ - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), - _Tp(*(__last - 1))); -} - -template -inline void -push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __push_heap_aux(__first, __last, - __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); -} - -template -void -__push_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __topIndex, _Tp __value, _Compare __comp) -{ - _Distance __parent = (__holeIndex - 1) / 2; - while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) { - *(__first + __holeIndex) = *(__first + __parent); - __holeIndex = __parent; - __parent = (__holeIndex - 1) / 2; - } - *(__first + __holeIndex) = __value; -} - -template -inline void -__push_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp, - _Distance*, _Tp*) -{ - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), - _Tp(*(__last - 1)), __comp); -} - -template -inline void -push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp) -{ - __push_heap_aux(__first, __last, __comp, - __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); -} - -template -void -__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __len, _Tp __value) -{ - _Distance __topIndex = __holeIndex; - _Distance __secondChild = 2 * __holeIndex + 2; - while (__secondChild < __len) { - if (*(__first + __secondChild) < *(__first + (__secondChild - 1))) - __secondChild--; - *(__first + __holeIndex) = *(__first + __secondChild); - __holeIndex = __secondChild; - __secondChild = 2 * (__secondChild + 1); - } - if (__secondChild == __len) { - *(__first + __holeIndex) = *(__first + (__secondChild - 1)); - __holeIndex = __secondChild - 1; - } - __push_heap(__first, __holeIndex, __topIndex, __value); -} - -template -inline void -__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _RandomAccessIterator __result, _Tp __value, _Distance*) -{ - *__result = *__first; - __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value); -} - -template -inline void -__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Tp*) -{ - __pop_heap(__first, __last - 1, __last - 1, - _Tp(*(__last - 1)), __DISTANCE_TYPE(__first)); -} - -template -inline void pop_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last) -{ - __pop_heap_aux(__first, __last, __VALUE_TYPE(__first)); -} - -template -void -__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __len, _Tp __value, _Compare __comp) -{ - _Distance __topIndex = __holeIndex; - _Distance __secondChild = 2 * __holeIndex + 2; - while (__secondChild < __len) { - if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) - __secondChild--; - *(__first + __holeIndex) = *(__first + __secondChild); - __holeIndex = __secondChild; - __secondChild = 2 * (__secondChild + 1); - } - if (__secondChild == __len) { - *(__first + __holeIndex) = *(__first + (__secondChild - 1)); - __holeIndex = __secondChild - 1; - } - __push_heap(__first, __holeIndex, __topIndex, __value, __comp); -} - -template -inline void -__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _RandomAccessIterator __result, _Tp __value, _Compare __comp, - _Distance*) -{ - *__result = *__first; - __adjust_heap(__first, _Distance(0), _Distance(__last - __first), - __value, __comp); -} - -template -inline void -__pop_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Tp*, _Compare __comp) -{ - __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp, - __DISTANCE_TYPE(__first)); -} - -template -inline void -pop_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp); -} - -template -void -__make_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Tp*, _Distance*) -{ - if (__last - __first < 2) return; - _Distance __len = __last - __first; - _Distance __parent = (__len - 2)/2; - - while (true) { - __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent))); - if (__parent == 0) return; - __parent--; - } -} - -template -inline void -make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __make_heap(__first, __last, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template -void -__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp, _Tp*, _Distance*) -{ - if (__last - __first < 2) return; - _Distance __len = __last - __first; - _Distance __parent = (__len - 2)/2; - - while (true) { - __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)), - __comp); - if (__parent == 0) return; - __parent--; - } -} - -template -inline void -make_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __make_heap(__first, __last, __comp, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template -void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - while (__last - __first > 1) - pop_heap(__first, __last--); -} - -template -void -sort_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - while (__last - __first > 1) - pop_heap(__first, __last--, __comp); -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1209 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HEAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_iterator.h b/libstdc++/stl/stl_iterator.h deleted file mode 100644 index 517bc5feda1..00000000000 --- a/libstdc++/stl/stl_iterator.h +++ /dev/null @@ -1,913 +0,0 @@ -/* - * - * 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-1998 - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ITERATOR_H -#define __SGI_STL_INTERNAL_ITERATOR_H - -__STL_BEGIN_NAMESPACE - -struct input_iterator_tag {}; -struct output_iterator_tag {}; -struct forward_iterator_tag : public input_iterator_tag {}; -struct bidirectional_iterator_tag : public forward_iterator_tag {}; -struct random_access_iterator_tag : public bidirectional_iterator_tag {}; - -// The base classes input_iterator, output_iterator, forward_iterator, -// bidirectional_iterator, and random_access_iterator are not part of -// the C++ standard. (they have been replaced by struct iterator.) -// They are included for backward compatibility with the HP STL. - -template struct input_iterator { - typedef input_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -struct output_iterator { - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; -}; - -template struct forward_iterator { - typedef forward_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - - -template struct bidirectional_iterator { - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template struct random_access_iterator { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template -struct iterator { - typedef _Category iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Pointer pointer; - typedef _Reference reference; -}; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -struct iterator_traits { - typedef typename _Iterator::iterator_category iterator_category; - typedef typename _Iterator::value_type value_type; - typedef typename _Iterator::difference_type difference_type; - typedef typename _Iterator::pointer pointer; - typedef typename _Iterator::reference reference; -}; - -template -struct iterator_traits<_Tp*> { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template -struct iterator_traits { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef ptrdiff_t difference_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; -}; - -// The overloaded functions iterator_category, distance_type, and -// value_type are not part of the C++ standard. (They have been -// replaced by struct iterator_traits.) They are included for -// backward compatibility with the HP STL. - -// We introduce internal names for these functions. - -template -inline typename iterator_traits<_Iter>::iterator_category -__iterator_category(const _Iter&) -{ - typedef typename iterator_traits<_Iter>::iterator_category _Category; - return _Category(); -} - -template -inline typename iterator_traits<_Iter>::difference_type* -__distance_type(const _Iter&) -{ - return static_cast::difference_type*>(0); -} - -template -inline typename iterator_traits<_Iter>::value_type* -__value_type(const _Iter&) -{ - return static_cast::value_type*>(0); -} - -template -inline typename iterator_traits<_Iter>::iterator_category -iterator_category(const _Iter& __i) { return __iterator_category(__i); } - - -template -inline typename iterator_traits<_Iter>::difference_type* -distance_type(const _Iter& __i) { return __distance_type(__i); } - -template -inline typename iterator_traits<_Iter>::value_type* -value_type(const _Iter& __i) { return __value_type(__i); } - -#define __ITERATOR_CATEGORY(__i) __iterator_category(__i) -#define __DISTANCE_TYPE(__i) __distance_type(__i) -#define __VALUE_TYPE(__i) __value_type(__i) - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline input_iterator_tag -iterator_category(const input_iterator<_Tp, _Distance>&) - { return input_iterator_tag(); } - -inline output_iterator_tag iterator_category(const output_iterator&) - { return output_iterator_tag(); } - -template -inline forward_iterator_tag -iterator_category(const forward_iterator<_Tp, _Distance>&) - { return forward_iterator_tag(); } - -template -inline bidirectional_iterator_tag -iterator_category(const bidirectional_iterator<_Tp, _Distance>&) - { return bidirectional_iterator_tag(); } - -template -inline random_access_iterator_tag -iterator_category(const random_access_iterator<_Tp, _Distance>&) - { return random_access_iterator_tag(); } - -template -inline random_access_iterator_tag iterator_category(const _Tp*) - { return random_access_iterator_tag(); } - -template -inline _Tp* value_type(const input_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const forward_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const bidirectional_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const random_access_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const _Tp*) { return (_Tp*)(0); } - -template -inline _Distance* distance_type(const input_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline _Distance* distance_type(const forward_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline _Distance* -distance_type(const bidirectional_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline _Distance* -distance_type(const random_access_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline ptrdiff_t* distance_type(const _Tp*) { return (ptrdiff_t*)(0); } - -// Without partial specialization we can't use iterator_traits, so -// we must keep the old iterator query functions around. - -#define __ITERATOR_CATEGORY(__i) iterator_category(__i) -#define __DISTANCE_TYPE(__i) distance_type(__i) -#define __VALUE_TYPE(__i) value_type(__i) - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline void __distance(_InputIterator __first, _InputIterator __last, - _Distance& __n, input_iterator_tag) -{ - while (__first != __last) { ++__first; ++__n; } -} - -template -inline void __distance(_RandomAccessIterator __first, - _RandomAccessIterator __last, - _Distance& __n, random_access_iterator_tag) -{ - __n += __last - __first; -} - -template -inline void distance(_InputIterator __first, - _InputIterator __last, _Distance& __n) -{ - __distance(__first, __last, __n, iterator_category(__first)); -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline typename iterator_traits<_InputIterator>::difference_type -__distance(_InputIterator __first, _InputIterator __last, input_iterator_tag) -{ - typename iterator_traits<_InputIterator>::difference_type __n = 0; - while (__first != __last) { - ++__first; ++__n; - } - return __n; -} - -template -inline typename iterator_traits<_RandomAccessIterator>::difference_type -__distance(_RandomAccessIterator __first, _RandomAccessIterator __last, - random_access_iterator_tag) { - return __last - __first; -} - -template -inline typename iterator_traits<_InputIterator>::difference_type -distance(_InputIterator __first, _InputIterator __last) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _Category; - return __distance(__first, __last, _Category()); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag) { - while (__n--) ++__i; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1183 -#endif - -template -inline void __advance(_BidirectionalIterator& __i, _Distance __n, - bidirectional_iterator_tag) { - if (__n >= 0) - while (__n--) ++__i; - else - while (__n++) --__i; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1183 -#endif - -template -inline void __advance(_RandomAccessIterator& __i, _Distance __n, - random_access_iterator_tag) { - __i += __n; -} - -template -inline void advance(_InputIterator& __i, _Distance __n) { - __advance(__i, __n, iterator_category(__i)); -} - -template -class back_insert_iterator { -protected: - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit back_insert_iterator(_Container& __x) : container(&__x) {} - back_insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->push_back(__value); - return *this; - } - back_insert_iterator<_Container>& operator*() { return *this; } - back_insert_iterator<_Container>& operator++() { return *this; } - back_insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const back_insert_iterator<_Container>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline back_insert_iterator<_Container> back_inserter(_Container& __x) { - return back_insert_iterator<_Container>(__x); -} - -template -class front_insert_iterator { -protected: - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit front_insert_iterator(_Container& __x) : container(&__x) {} - front_insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->push_front(__value); - return *this; - } - front_insert_iterator<_Container>& operator*() { return *this; } - front_insert_iterator<_Container>& operator++() { return *this; } - front_insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const front_insert_iterator<_Container>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline front_insert_iterator<_Container> front_inserter(_Container& __x) { - return front_insert_iterator<_Container>(__x); -} - -template -class insert_iterator { -protected: - _Container* container; - typename _Container::iterator iter; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x, typename _Container::iterator __i) - : container(&__x), iter(__i) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - iter = container->insert(iter, __value); - ++iter; - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const insert_iterator<_Container>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline -insert_iterator<_Container> inserter(_Container& __x, _Iterator __i) -{ - typedef typename _Container::iterator __iter; - return insert_iterator<_Container>(__x, __iter(__i)); -} - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template -#else -template -#endif -class reverse_bidirectional_iterator { - typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, - _Reference, _Distance> _Self; -protected: - _BidirectionalIterator current; -public: - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Reference reference; - - reverse_bidirectional_iterator() {} - explicit reverse_bidirectional_iterator(_BidirectionalIterator __x) - : current(__x) {} - _BidirectionalIterator base() const { return current; } - _Reference operator*() const { - _BidirectionalIterator __tmp = current; - return *--__tmp; - } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - _Self& operator++() { - --current; - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - --current; - return __tmp; - } - _Self& operator--() { - ++current; - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - ++current; - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline bidirectional_iterator_tag -iterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator, - _Tp, _Reference, - _Distance>&) -{ - return bidirectional_iterator_tag(); -} - -template -inline _Tp* -value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, - _Reference, _Distance>&) -{ - return (_Tp*) 0; -} - -template -inline _Distance* -distance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, - _Tp, - _Reference, _Distance>&) -{ - return (_Distance*) 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline bool operator==( - const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __x, - const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __y) -{ - return __x.base() == __y.base(); -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -// This is the new version of reverse_iterator, as defined in the -// draft C++ standard. It relies on the iterator_traits template, -// which in turn relies on partial specialization. The class -// reverse_bidirectional_iterator is no longer part of the draft -// standard, but it is retained for backward compatibility. - -template -class reverse_iterator -{ -protected: - _Iterator current; -public: - typedef typename iterator_traits<_Iterator>::iterator_category - iterator_category; - typedef typename iterator_traits<_Iterator>::value_type - value_type; - typedef typename iterator_traits<_Iterator>::difference_type - difference_type; - typedef typename iterator_traits<_Iterator>::pointer - pointer; - typedef typename iterator_traits<_Iterator>::reference - reference; - - typedef _Iterator iterator_type; - typedef reverse_iterator<_Iterator> _Self; - -public: - reverse_iterator() {} - explicit reverse_iterator(iterator_type __x) : current(__x) {} - - reverse_iterator(const _Self& __x) : current(__x.current) {} -#ifdef __STL_MEMBER_TEMPLATES - template - reverse_iterator(const reverse_iterator<_Iter>& __x) - : current(__x.base()) {} -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator_type base() const { return current; } - reference operator*() const { - _Iterator __tmp = current; - return *--__tmp; - } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() { - --current; - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - --current; - return __tmp; - } - _Self& operator--() { - ++current; - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - ++current; - return __tmp; - } - - _Self operator+(difference_type __n) const { - return _Self(current - __n); - } - _Self& operator+=(difference_type __n) { - current -= __n; - return *this; - } - _Self operator-(difference_type __n) const { - return _Self(current + __n); - } - _Self& operator-=(difference_type __n) { - current += __n; - return *this; - } - reference operator[](difference_type __n) const { return *(*this + __n); } -}; - -template -inline bool operator==(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return __x.base() == __y.base(); -} - -template -inline bool operator<(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return __y.base() < __x.base(); -} - -template -inline typename reverse_iterator<_Iterator>::difference_type -operator-(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return __y.base() - __x.base(); -} - -template -inline reverse_iterator<_Iterator> -operator+(typename reverse_iterator<_Iterator>::difference_type __n, - const reverse_iterator<_Iterator>& __x) { - return reverse_iterator<_Iterator>(__x.base() - __n); -} - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// This is the old version of reverse_iterator, as found in the original -// HP STL. It does not use partial specialization. - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template -#else -template -#endif -class reverse_iterator { - typedef reverse_iterator<_RandomAccessIterator, _Tp, _Reference, _Distance> - _Self; -protected: - _RandomAccessIterator current; -public: - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Reference reference; - - reverse_iterator() {} - explicit reverse_iterator(_RandomAccessIterator __x) : current(__x) {} - _RandomAccessIterator base() const { return current; } - _Reference operator*() const { return *(current - 1); } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - _Self& operator++() { - --current; - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - --current; - return __tmp; - } - _Self& operator--() { - ++current; - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - ++current; - return __tmp; - } - _Self operator+(_Distance __n) const { - return _Self(current - __n); - } - _Self& operator+=(_Distance __n) { - current -= __n; - return *this; - } - _Self operator-(_Distance __n) const { - return _Self(current + __n); - } - _Self& operator-=(_Distance __n) { - current += __n; - return *this; - } - _Reference operator[](_Distance __n) const { return *(*this + __n); } -}; - -template -inline random_access_iterator_tag -iterator_category(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>&) -{ - return random_access_iterator_tag(); -} - -template -inline _Tp* value_type(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>&) -{ - return (_Tp*) 0; -} - -template -inline _Distance* -distance_type(const reverse_iterator<_RandomAccessIterator, - _Tp, _Reference, _Distance>&) -{ - return (_Distance*) 0; -} - - -template -inline bool -operator==(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) -{ - return __x.base() == __y.base(); -} - -template -inline bool -operator<(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) -{ - return __y.base() < __x.base(); -} - -template -inline _Distance -operator-(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) -{ - return __y.base() - __x.base(); -} - -template -inline reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist> -operator+(_Dist __n, - const reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist>& __x) -{ - return reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist>(__x.base() - __n); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// When we have templatized iostreams, istream_iterator and ostream_iterator -// must be rewritten. - -template -class istream_iterator { - friend bool operator== __STL_NULL_TMPL_ARGS (const istream_iterator&, - const istream_iterator&); -protected: - istream* _M_stream; - _Tp _M_value; - bool _M_end_marker; - void _M_read() { - _M_end_marker = (*_M_stream) ? true : false; - if (_M_end_marker) *_M_stream >> _M_value; - _M_end_marker = (*_M_stream) ? true : false; - } -public: - typedef input_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Dist difference_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; - - istream_iterator() : _M_stream(&cin), _M_end_marker(false) {} - istream_iterator(istream& __s) : _M_stream(&__s) { _M_read(); } - reference operator*() const { return _M_value; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - istream_iterator<_Tp, _Dist>& operator++() { - _M_read(); - return *this; - } - istream_iterator<_Tp, _Dist> operator++(int) { - istream_iterator<_Tp, _Dist> __tmp = *this; - _M_read(); - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline input_iterator_tag -iterator_category(const istream_iterator<_Tp, _Dist>&) -{ - return input_iterator_tag(); -} - -template -inline _Tp* -value_type(const istream_iterator<_Tp, _Dist>&) { return (_Tp*) 0; } - -template -inline _Dist* -distance_type(const istream_iterator<_Tp, _Dist>&) { return (_Dist*)0; } - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline bool operator==(const istream_iterator<_Tp, _Distance>& __x, - const istream_iterator<_Tp, _Distance>& __y) { - return (__x._M_stream == __y._M_stream && - __x._M_end_marker == __y._M_end_marker) || - __x._M_end_marker == false && __y._M_end_marker == false; -} - -template -class ostream_iterator { -protected: - ostream* _M_stream; - const char* _M_string; -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - ostream_iterator(ostream& __s) : _M_stream(&__s), _M_string(0) {} - ostream_iterator(ostream& __s, const char* __c) - : _M_stream(&__s), _M_string(__c) {} - ostream_iterator<_Tp>& operator=(const _Tp& __value) { - *_M_stream << __value; - if (_M_string) *_M_stream << _M_string; - return *this; - } - ostream_iterator<_Tp>& operator*() { return *this; } - ostream_iterator<_Tp>& operator++() { return *this; } - ostream_iterator<_Tp>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const ostream_iterator<_Tp>&) { - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_ITERATOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_list.h b/libstdc++/stl/stl_list.h deleted file mode 100644 index 5d95d641e52..00000000000 --- a/libstdc++/stl/stl_list.h +++ /dev/null @@ -1,840 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_LIST_H -#define __SGI_STL_INTERNAL_LIST_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -template -struct _List_node { - typedef void* _Void_pointer; - _Void_pointer _M_next; - _Void_pointer _M_prev; - _Tp _M_data; -}; - -template -struct _List_iterator { - 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 bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Ptr pointer; - typedef _Ref reference; - typedef _List_node<_Tp> _Node; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - _Node* _M_node; - - _List_iterator(_Node* __x) : _M_node(__x) {} - _List_iterator() {} - _List_iterator(const iterator& __x) : _M_node(__x._M_node) {} - - bool operator==(const _Self& __x) const { return _M_node == __x._M_node; } - bool operator!=(const _Self& __x) const { return _M_node != __x._M_node; } - reference operator*() const { return (*_M_node)._M_data; } - -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() { - _M_node = (_Node*)(_M_node->_M_next); - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - ++*this; - return __tmp; - } - _Self& operator--() { - _M_node = (_Node*)(_M_node->_M_prev); - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - --*this; - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline bidirectional_iterator_tag -iterator_category(const _List_iterator<_Tp, _Ref, _Ptr>&) -{ - return bidirectional_iterator_tag(); -} - -template -inline _Tp* -value_type(const _List_iterator<_Tp, _Ref, _Ptr>&) -{ - return 0; -} - -template -inline ptrdiff_t* -distance_type(const _List_iterator<_Tp, _Ref, _Ptr>&) -{ - return 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - -// 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. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base for general standard-conforming allocators. -template -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. - -template -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: - 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 -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) { - _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(); -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _List_base -{ -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _List_base(const allocator_type&) { - _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(); - -protected: - typedef simple_alloc<_List_node<_Tp>, _Alloc> _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; -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -void -_List_base<_Tp,_Alloc>::clear() -{ - _List_node<_Tp>* __cur = (_List_node<_Tp>*) _M_node->_M_next; - while (__cur != _M_node) { - _List_node<_Tp>* __tmp = __cur; - __cur = (_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 -class list : protected _List_base<_Tp, _Alloc> { - 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; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -public: - typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator; - typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_bidirectional_iterator - const_reverse_iterator; - typedef reverse_bidirectional_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -protected: -#ifdef __STL_HAS_NAMESPACES - using _Base::_M_node; - using _Base::_M_put_node; - using _Base::_M_get_node; -#endif /* __STL_HAS_NAMESPACES */ - -protected: - _Node* _M_create_node(const _Tp& __x) - { - _Node* __p = _M_get_node(); - __STL_TRY { - construct(&__p->_M_data, __x); - } - __STL_UNWIND(_M_put_node(__p)); - return __p; - } - - _Node* _M_create_node() - { - _Node* __p = _M_get_node(); - __STL_TRY { - construct(&__p->_M_data); - } - __STL_UNWIND(_M_put_node(__p)); - return __p; - } - -public: - explicit list(const allocator_type& __a = allocator_type()) : _Base(__a) {} - - iterator begin() { return (_Node*)(_M_node->_M_next); } - const_iterator begin() const { return (_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 { - size_type __result = 0; - distance(begin(), end(), __result); - return __result; - } - 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()); } - - void swap(list<_Tp, _Alloc>& __x) { __STD::swap(_M_node, __x._M_node); } - - iterator insert(iterator __position, const _Tp& __x) { - _Node* __tmp = _M_create_node(__x); - __tmp->_M_next = __position._M_node; - __tmp->_M_prev = __position._M_node->_M_prev; - ((_Node*) (__position._M_node->_M_prev))->_M_next = __tmp; - __position._M_node->_M_prev = __tmp; - return __tmp; - } - iterator insert(iterator __position) { return insert(__position, _Tp()); } -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) { - insert(__pos, (size_type) __n, (_Tp) __x); - } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type); - - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__pos, __first, __last, _Integral()); - } - -#else /* __STL_MEMBER_TEMPLATES */ - void insert(iterator __position, const _Tp* __first, const _Tp* __last); - void insert(iterator __position, - const_iterator __first, const_iterator __last); -#endif /* __STL_MEMBER_TEMPLATES */ - void 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); } - void push_back() {insert(end());} - - iterator erase(iterator __position) { - _Node* __next_node = (_Node*) (__position._M_node->_M_next); - _Node* __prev_node = (_Node*) (__position._M_node->_M_prev); - __prev_node->_M_next = __next_node; - __next_node->_M_prev = __prev_node; - destroy(&__position._M_node->_M_data); - _M_put_node(__position._M_node); - return iterator(__next_node); - } - 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) { resize(__new_size, _Tp()); } - - void pop_front() { erase(begin()); } - 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()); } - -#ifdef __STL_MEMBER_TEMPLATES - - // We don't need any dispatching tricks here, because insert does all of - // that anyway. - template - list(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { insert(begin(), __first, __last); } - -#else /* __STL_MEMBER_TEMPLATES */ - - list(const _Tp* __first, const _Tp* __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { insert(begin(), __first, __last); } - list(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { insert(begin(), __first, __last); } - -#endif /* __STL_MEMBER_TEMPLATES */ - 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. - - void assign(size_type __n, const _Tp& __val); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type); - -#endif /* __STL_MEMBER_TEMPLATES */ - -protected: - void transfer(iterator __position, iterator __first, iterator __last) { - if (__position != __last) { - // Remove [first, last) from its old position. - ((_Node*) (__last._M_node->_M_prev))->_M_next = __position._M_node; - ((_Node*) (__first._M_node->_M_prev))->_M_next = __last._M_node; - ((_Node*) (__position._M_node->_M_prev))->_M_next = __first._M_node; - - // Splice [first, last) into its new position. - _Node* __tmp = (_Node*) (__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; - } - } - -public: - void splice(iterator __position, list& __x) { - if (!__x.empty()) - transfer(__position, __x.begin(), __x.end()); - } - void splice(iterator __position, list&, iterator __i) { - iterator __j = __i; - ++__j; - if (__position == __i || __position == __j) return; - transfer(__position, __i, __j); - } - void splice(iterator __position, list&, iterator __first, iterator __last) { - if (__first != __last) - transfer(__position, __first, __last); - } - void remove(const _Tp& __value); - void unique(); - void merge(list& __x); - void reverse(); - void sort(); - -#ifdef __STL_MEMBER_TEMPLATES - template void remove_if(_Predicate); - template void unique(_BinaryPredicate); - template void merge(list&, _StrictWeakOrdering); - template void sort(_StrictWeakOrdering); -#endif /* __STL_MEMBER_TEMPLATES */ - - friend bool operator== __STL_NULL_TMPL_ARGS ( - const list& __x, const list& __y); -}; - -template -inline bool operator==(const list<_Tp,_Alloc>& __x, - const list<_Tp,_Alloc>& __y) -{ - typedef typename list<_Tp,_Alloc>::_Node _Node; - _Node* __e1 = __x._M_node; - _Node* __e2 = __y._M_node; - _Node* __n1 = (_Node*) __e1->_M_next; - _Node* __n2 = (_Node*) __e2->_M_next; - for ( ; __n1 != __e1 && __n2 != __e2 ; - __n1 = (_Node*) __n1->_M_next, __n2 = (_Node*) __n2->_M_next) - if (__n1->_M_data != __n2->_M_data) - return false; - return __n1 == __e1 && __n2 == __e2; -} - -template -inline bool operator<(const list<_Tp,_Alloc>& __x, - const list<_Tp,_Alloc>& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void -swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) -{ - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void -list<_Tp, _Alloc>::_M_insert_dispatch(iterator __position, - _InputIter __first, _InputIter __last, - __false_type) -{ - for ( ; __first != __last; ++__first) - insert(__position, *__first); -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -list<_Tp, _Alloc>::insert(iterator __position, - const _Tp* __first, const _Tp* __last) -{ - for ( ; __first != __last; ++__first) - insert(__position, *__first); -} - -template -void -list<_Tp, _Alloc>::insert(iterator __position, - const_iterator __first, const_iterator __last) -{ - for ( ; __first != __last; ++__first) - insert(__position, *__first); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void -list<_Tp, _Alloc>::insert(iterator __position, size_type __n, const _Tp& __x) -{ - for ( ; __n > 0; --__n) - insert(__position, __x); -} - -template -list<_Tp,_Alloc>::iterator list<_Tp, _Alloc>::erase(iterator __first, - iterator __last) -{ - while (__first != __last) - erase(__first++); - return __last; -} - -template -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 -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 -void list<_Tp, _Alloc>::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()); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -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); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -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 -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 -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; - transfer(__first1, __first2, ++__next); - __first2 = __next; - } - else - ++__first1; - if (__first2 != __last2) transfer(__last1, __first2, __last2); -} - -template -void list<_Tp, _Alloc>::reverse() -{ - // Do nothing if the list has length 0 or 1. - if (_M_node->_M_next != _M_node && - ((_Node*) (_M_node->_M_next))->_M_next != _M_node) { - iterator __first = begin(); - ++__first; - while (__first != end()) { - iterator __old = __first; - ++__first; - transfer(begin(), __old, __first); - } - } -} - -template -void list<_Tp, _Alloc>::sort() -{ - // Do nothing if the list has length 0 or 1. - if (_M_node->_M_next != _M_node && - ((_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]); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -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 template -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 template -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; - transfer(__first1, __first2, ++__next); - __first2 = __next; - } - else - ++__first1; - if (__first2 != __last2) transfer(__last1, __first2, __last2); -} - -template template -void list<_Tp, _Alloc>::sort(_StrictWeakOrdering __comp) -{ - // Do nothing if the list has length 0 or 1. - if (_M_node->_M_next != _M_node && - ((_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]); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_LIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_map.h b/libstdc++/stl/stl_map.h deleted file mode 100644 index a702e8023ef..00000000000 --- a/libstdc++/stl/stl_map.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_MAP_H -#define __SGI_STL_INTERNAL_MAP_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -#else -template -#endif -class map { -public: - -// typedefs: - - typedef _Key key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef pair value_type; - typedef _Compare key_compare; - - class value_compare - : public binary_function { - friend class map<_Key,_Tp,_Compare,_Alloc>; - protected : - _Compare _M_comp; - value_compare(_Compare __c) : _M_comp(__c) {} - public: - bool operator()(const value_type& __x, const value_type& __y) const { - return _M_comp(__x.first, __y.first); - } - }; - -private: - typedef _Rb_tree, 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) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - map(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - template - map(_InputIterator __first, _InputIterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } -#else - map(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - map(const value_type* __first, - const value_type* __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } - - map(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - map(const_iterator __first, const_iterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } - -#endif /* __STL_MEMBER_TEMPLATES */ - - 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(); } - - iterator begin() { return _M_t.begin(); } - const_iterator begin() const { return _M_t.begin(); } - iterator end() { return _M_t.end(); } - const_iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() { return _M_t.rbegin(); } - const_reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() { return _M_t.rend(); } - const_reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - size_type max_size() const { return _M_t.max_size(); } - _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 - - pair insert(const value_type& __x) - { return _M_t.insert_unique(__x); } - iterator insert(iterator position, const value_type& __x) - { return _M_t.insert_unique(position, __x); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_unique(__first, __last); - } -#else - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_unique(__first, __last); - } - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_unique(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - void erase(iterator __position) { _M_t.erase(__position); } - size_type erase(const key_type& __x) { return _M_t.erase(__x); } - void erase(iterator __first, iterator __last) - { _M_t.erase(__first, __last); } - void clear() { _M_t.clear(); } - - // map operations: - - iterator find(const key_type& __x) { return _M_t.find(__x); } - const_iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { return _M_t.count(__x); } - iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); } - const_iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); } - const_iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - - pair equal_range(const key_type& __x) { - return _M_t.equal_range(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - friend bool operator== __STL_NULL_TMPL_ARGS (const map&, const map&); - friend bool operator< __STL_NULL_TMPL_ARGS (const map&, const map&); -}; - -template -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 -inline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(map<_Key,_Tp,_Compare,_Alloc>& __x, - map<_Key,_Tp,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_multimap.h b/libstdc++/stl/stl_multimap.h deleted file mode 100644 index b7d3b87e52d..00000000000 --- a/libstdc++/stl/stl_multimap.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_MULTIMAP_H -#define __SGI_STL_INTERNAL_MULTIMAP_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -#else -template -#endif -class multimap { -public: - -// typedefs: - - typedef _Key key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef pair value_type; - typedef _Compare key_compare; - - class value_compare : public binary_function { - friend class multimap<_Key,_Tp,_Compare,_Alloc>; - protected: - _Compare _M_comp; - value_compare(_Compare __c) : _M_comp(__c) {} - public: - bool operator()(const value_type& __x, const value_type& __y) const { - return _M_comp(__x.first, __y.first); - } - }; - -private: - typedef _Rb_tree, 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) { } - -#ifdef __STL_MEMBER_TEMPLATES - template - multimap(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - template - multimap(_InputIterator __first, _InputIterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } -#else - multimap(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - multimap(const value_type* __first, const value_type* __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - - multimap(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - multimap(const_iterator __first, const_iterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } -#endif /* __STL_MEMBER_TEMPLATES */ - - 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(); } - - iterator begin() { return _M_t.begin(); } - const_iterator begin() const { return _M_t.begin(); } - iterator end() { return _M_t.end(); } - const_iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() { return _M_t.rbegin(); } - const_reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() { return _M_t.rend(); } - const_reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - 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 - - iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); } - iterator insert(iterator __position, const value_type& __x) { - return _M_t.insert_equal(__position, __x); - } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_equal(__first, __last); - } -#else - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_equal(__first, __last); - } - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_equal(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - void erase(iterator __position) { _M_t.erase(__position); } - size_type erase(const key_type& __x) { return _M_t.erase(__x); } - void erase(iterator __first, iterator __last) - { _M_t.erase(__first, __last); } - void clear() { _M_t.clear(); } - - // multimap operations: - - iterator find(const key_type& __x) { return _M_t.find(__x); } - const_iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { return _M_t.count(__x); } - iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); } - const_iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); } - const_iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - pair equal_range(const key_type& __x) { - return _M_t.equal_range(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - friend bool operator== __STL_NULL_TMPL_ARGS (const multimap&, - const multimap&); - friend bool operator< __STL_NULL_TMPL_ARGS (const multimap&, - const multimap&); -}; - -template -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 -inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, - multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_MULTIMAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_multiset.h b/libstdc++/stl/stl_multiset.h deleted file mode 100644 index 7378e43f8b3..00000000000 --- a/libstdc++/stl/stl_multiset.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_MULTISET_H -#define __SGI_STL_INTERNAL_MULTISET_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) > -#else -template -#endif -class multiset { -public: - // typedefs: - - typedef _Key key_type; - typedef _Key value_type; - typedef _Compare key_compare; - typedef _Compare value_compare; -private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; - _Rep_type _M_t; // red-black tree representing multiset -public: - typedef typename _Rep_type::const_pointer pointer; - typedef typename _Rep_type::const_pointer const_pointer; - typedef typename _Rep_type::const_reference reference; - typedef typename _Rep_type::const_reference const_reference; - typedef typename _Rep_type::const_iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::const_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 - - multiset() : _M_t(_Compare(), allocator_type()) {} - explicit multiset(const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - - template - multiset(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - template - multiset(_InputIterator __first, _InputIterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - -#else - - multiset(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - multiset(const value_type* __first, const value_type* __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - - multiset(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - multiset(const_iterator __first, const_iterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - -#endif /* __STL_MEMBER_TEMPLATES */ - - multiset(const multiset<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {} - multiset<_Key,_Compare,_Alloc>& - operator=(const multiset<_Key,_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 _M_t.key_comp(); } - allocator_type get_allocator() const { return _M_t.get_allocator(); } - - iterator begin() const { return _M_t.begin(); } - iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - size_type max_size() const { return _M_t.max_size(); } - void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } - - // insert/erase - iterator insert(const value_type& __x) { - return _M_t.insert_equal(__x); - } - iterator insert(iterator __position, const value_type& __x) { - typedef typename _Rep_type::iterator _Rep_iterator; - return _M_t.insert_equal((_Rep_iterator&)__position, __x); - } - -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_equal(__first, __last); - } -#else - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_equal(__first, __last); - } - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_equal(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - void erase(iterator __position) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__position); - } - size_type erase(const key_type& __x) { - return _M_t.erase(__x); - } - void erase(iterator __first, iterator __last) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); - } - void clear() { _M_t.clear(); } - - // multiset operations: - - iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { return _M_t.count(__x); } - iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - friend bool operator== __STL_NULL_TMPL_ARGS (const multiset&, - const multiset&); - friend bool operator< __STL_NULL_TMPL_ARGS (const multiset&, - const multiset&); -}; - -template -inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return __x._M_t == __y._M_t; -} - -template -inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(multiset<_Key,_Compare,_Alloc>& __x, - multiset<_Key,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_MULTISET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_numeric.h b/libstdc++/stl/stl_numeric.h deleted file mode 100644 index 392515a3d87..00000000000 --- a/libstdc++/stl/stl_numeric.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - - -#ifndef __SGI_STL_INTERNAL_NUMERIC_H -#define __SGI_STL_INTERNAL_NUMERIC_H - -__STL_BEGIN_NAMESPACE - -template -_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) -{ - for ( ; __first != __last; ++__first) - __init = __init + *__first; - return __init; -} - -template -_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, - _BinaryOperation __binary_op) -{ - for ( ; __first != __last; ++__first) - __init = __binary_op(__init, *__first); - return __init; -} - -template -_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _Tp __init) -{ - for ( ; __first1 != __last1; ++__first1, ++__first2) - __init = __init + (*__first1 * *__first2); - return __init; -} - -template -_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _Tp __init, - _BinaryOperation1 __binary_op1, - _BinaryOperation2 __binary_op2) -{ - for ( ; __first1 != __last1; ++__first1, ++__first2) - __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); - return __init; -} - -template -_OutputIterator -__partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*) -{ - _Tp __value = *__first; - while (++__first != __last) { - __value = __value + *__first; - *++__result = __value; - } - return ++__result; -} - -template -_OutputIterator -partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result) -{ - if (__first == __last) return __result; - *__result = *__first; - return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first)); -} - -template -_OutputIterator -__partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*, _BinaryOperation __binary_op) -{ - _Tp __value = *__first; - while (++__first != __last) { - __value = __binary_op(__value, *__first); - *++__result = __value; - } - return ++__result; -} - -template -_OutputIterator -partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _BinaryOperation __binary_op) -{ - if (__first == __last) return __result; - *__result = *__first; - return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first), - __binary_op); -} - -template -_OutputIterator -__adjacent_difference(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*) -{ - _Tp __value = *__first; - while (++__first != __last) { - _Tp __tmp = *__first; - *++__result = __tmp - __value; - __value = __tmp; - } - return ++__result; -} - -template -_OutputIterator -adjacent_difference(_InputIterator __first, - _InputIterator __last, _OutputIterator __result) -{ - if (__first == __last) return __result; - *__result = *__first; - return __adjacent_difference(__first, __last, __result, - __VALUE_TYPE(__first)); -} - -template -_OutputIterator -__adjacent_difference(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*, - _BinaryOperation __binary_op) { - _Tp __value = *__first; - while (++__first != __last) { - _Tp __tmp = *__first; - *++__result = __binary_op(__tmp, __value); - __value = __tmp; - } - return ++__result; -} - -template -_OutputIterator -adjacent_difference(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _BinaryOperation __binary_op) -{ - if (__first == __last) return __result; - *__result = *__first; - return __adjacent_difference(__first, __last, __result, - __VALUE_TYPE(__first), - __binary_op); -} - -// Returns __x ** __n, where __n >= 0. _Note that "multiplication" -// is required to be associative, but not necessarily commutative. - - -template -_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __oper) -{ - if (__n == 0) - return identity_element(__oper); - else { - while ((__n & 1) == 0) { - __n >>= 1; - __x = __oper(__x, __x); - } - - _Tp __result = __x; - __n >>= 1; - while (__n != 0) { - __x = __oper(__x, __x); - if ((__n & 1) != 0) - __result = __oper(__result, __x); - __n >>= 1; - } - return __result; - } -} - -template -inline _Tp __power(_Tp __x, _Integer __n) -{ - return __power(__x, __n, multiplies<_Tp>()); -} - -// Alias for the internal name __power. Note that power is an extension, -// not part of the C++ standard. - -template -inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __oper) -{ - return __power(__x, __n, __oper); -} - -template -inline _Tp power(_Tp __x, _Integer __n) -{ - return __power(__x, __n); -} - -// iota is not part of the C++ standard. It is an extension. - -template -void -iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) -{ - while (__first != __last) - *__first++ = __value++; -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_NUMERIC_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_pair.h b/libstdc++/stl/stl_pair.h deleted file mode 100644 index 3aa290b59ed..00000000000 --- a/libstdc++/stl/stl_pair.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_PAIR_H -#define __SGI_STL_INTERNAL_PAIR_H - -__STL_BEGIN_NAMESPACE - -template -struct pair { - typedef _T1 first_type; - typedef _T2 second_type; - - _T1 first; - _T2 second; - pair() : first(_T1()), second(_T2()) {} - pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} -#endif -}; - -template -inline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) -{ - return __x.first == __y.first && __x.second == __y.second; -} - -template -inline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) -{ - return __x.first < __y.first || - (!(__y.first < __x.first) && __x.second < __y.second); -} - -template -inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y) -{ - return pair<_T1, _T2>(__x, __y); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_PAIR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_queue.h b/libstdc++/stl/stl_queue.h deleted file mode 100644 index c1e2b698440..00000000000 --- a/libstdc++/stl/stl_queue.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_QUEUE_H -#define __SGI_STL_INTERNAL_QUEUE_H - -__STL_BEGIN_NAMESPACE - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template > -#else -template -#endif -class queue { - friend bool operator== __STL_NULL_TMPL_ARGS (const queue&, const queue&); - friend bool operator< __STL_NULL_TMPL_ARGS (const queue&, const queue&); -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: - queue() : c() {} - explicit queue(const _Sequence& __c) : 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 -bool -operator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return __x.c == __y.c; -} - -template -bool -operator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return __x.c < __y.c; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -bool -operator!=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return !(__x == __y); -} - -template -bool -operator>(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return __y < __x; -} - -template -bool -operator<=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return !(__y < __x); -} - -template -bool -operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _Compare = less > -#else -template -#endif -class priority_queue { -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: - priority_queue() : c() {} - explicit priority_queue(const _Compare& __x) : c(), comp(__x) {} - priority_queue(const _Compare& __x, const _Sequence& __s) - : c(__s), comp(__x) - { make_heap(c.begin(), c.end(), comp); } - -#ifdef __STL_MEMBER_TEMPLATES - template - priority_queue(_InputIterator __first, _InputIterator __last) - : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } - - template - priority_queue(_InputIterator __first, - _InputIterator __last, const _Compare& __x) - : c(__first, __last), comp(__x) - { make_heap(c.begin(), c.end(), comp); } - - template - priority_queue(_InputIterator __first, _InputIterator __last, - const _Compare& __x, const _Sequence& __s) - : c(__s), comp(__x) - { - c.insert(c.end(), __first, __last); - make_heap(c.begin(), c.end(), comp); - } - -#else /* __STL_MEMBER_TEMPLATES */ - priority_queue(const value_type* __first, const value_type* __last) - : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } - - priority_queue(const value_type* __first, const value_type* __last, - const _Compare& __x) - : c(__first, __last), comp(__x) - { make_heap(c.begin(), c.end(), comp); } - - priority_queue(const value_type* __first, const value_type* __last, - const _Compare& __x, const _Sequence& __c) - : c(__c), comp(__x) - { - c.insert(c.end(), __first, __last); - make_heap(c.begin(), c.end(), comp); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - 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) { - __STL_TRY { - c.push_back(__x); - push_heap(c.begin(), c.end(), comp); - } - __STL_UNWIND(c.clear()); - } - void pop() { - __STL_TRY { - pop_heap(c.begin(), c.end(), comp); - c.pop_back(); - } - __STL_UNWIND(c.clear()); - } -}; - -// no equality is provided - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_QUEUE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_raw_storage_iter.h b/libstdc++/stl/stl_raw_storage_iter.h deleted file mode 100644 index 6f3951cb8af..00000000000 --- a/libstdc++/stl/stl_raw_storage_iter.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H -#define __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H - -__STL_BEGIN_NAMESPACE - -template -class raw_storage_iterator { -protected: - _ForwardIterator _M_iter; -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {} - raw_storage_iterator& operator*() { return *this; } - raw_storage_iterator& operator=(const _Tp& __element) { - construct(&*_M_iter, __element); - return *this; - } - raw_storage_iterator<_ForwardIterator, _Tp>& operator++() { - ++_M_iter; - return *this; - } - raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) { - raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this; - ++_M_iter; - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const raw_storage_iterator<_ForwardIterator, _Tp>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_relops.h b/libstdc++/stl/stl_relops.h deleted file mode 100644 index 16cad1b84e2..00000000000 --- a/libstdc++/stl/stl_relops.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * 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 - * - * 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. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_RELOPS -#define __SGI_STL_INTERNAL_RELOPS - -__STL_BEGIN_RELOPS_NAMESPACE - -template -inline bool operator!=(const _Tp& __x, const _Tp& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const _Tp& __x, const _Tp& __y) { - return __y < __x; -} - -template -inline bool operator<=(const _Tp& __x, const _Tp& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const _Tp& __x, const _Tp& __y) { - return !(__x < __y); -} - -__STL_END_RELOPS_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_RELOPS */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_rope.h b/libstdc++/stl/stl_rope.h deleted file mode 100644 index 0d8766a43bc..00000000000 --- a/libstdc++/stl/stl_rope.h +++ /dev/null @@ -1,2540 +0,0 @@ -/* - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -// rope<_CharT,_Alloc> is a sequence of _CharT. -// Ropes appear to be mutable, but update operations -// really copy enough of the data structure to leave the original -// valid. Thus ropes can be logically copied by just copying -// a pointer value. - -#ifndef __SGI_STL_INTERNAL_ROPE_H -# define __SGI_STL_INTERNAL_ROPE_H - -# ifdef __GC -# define __GC_CONST const -# else -# define __GC_CONST // constant except for deallocation -# endif -# ifdef __STL_SGI_THREADS -# include -# endif - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#endif - -// The _S_eos function is used for those functions that -// convert to/from C-like strings to detect the end of the string. - -// The end-of-C-string character. -// This is what the draft standard says it should be. -template -inline _CharT _S_eos(_CharT*) { return _CharT(); } - -// Test for basic character types. -// For basic character types leaves having a trailing eos. -template -inline bool _S_is_basic_char_type(_CharT*) { return false; } -template -inline bool _S_is_one_byte_char_type(_CharT*) { return false; } - -inline bool _S_is_basic_char_type(char*) { return true; } -inline bool _S_is_one_byte_char_type(char*) { return true; } -inline bool _S_is_basic_char_type(wchar_t*) { return true; } - -// Store an eos iff _CharT is a basic character type. -// Do not reference _S_eos if it isn't. -template -inline void _S_cond_store_eos(_CharT&) {} - -inline void _S_cond_store_eos(char& __c) { __c = 0; } -inline void _S_cond_store_eos(wchar_t& __c) { __c = 0; } - -// char_producers are logically functions that generate a section of -// a string. These can be convereted to ropes. The resulting rope -// invokes the char_producer on demand. This allows, for example, -// files to be viewed as ropes without reading the entire file. -template -class char_producer { - public: - virtual ~char_producer() {}; - virtual void operator()(size_t __start_pos, size_t __len, - _CharT* __buffer) = 0; - // Buffer should really be an arbitrary output iterator. - // That way we could flatten directly into an ostream, etc. - // This is thoroughly impossible, since iterator types don't - // have runtime descriptions. -}; - -// Sequence buffers: -// -// Sequence must provide an append operation that appends an -// array to the sequence. Sequence buffers are useful only if -// appending an entire array is cheaper than appending element by element. -// This is true for many string representations. -// This should perhaps inherit from ostream -// and be implemented correspondingly, so that they can be used -// for formatted. For the sake of portability, we don't do this yet. -// -// For now, sequence buffers behave as output iterators. But they also -// behave a little like basic_ostringstream and a -// little like containers. - -template -// The 3rd parameter works around a common compiler bug. -class sequence_buffer : public output_iterator { - public: -# ifndef __TYPEDEF_WORKAROUND - typedef typename _Sequence::value_type value_type; -# else - typedef _V value_type; -# endif - protected: - _Sequence* _M_prefix; - value_type _M_buffer[_Buf_sz]; - size_t _M_buf_count; - public: - void flush() { - _M_prefix->append(_M_buffer, _M_buffer + _M_buf_count); - _M_buf_count = 0; - } - ~sequence_buffer() { flush(); } - sequence_buffer() : _M_prefix(0), _M_buf_count(0) {} - sequence_buffer(const sequence_buffer& __x) { - _M_prefix = __x._M_prefix; - _M_buf_count = __x._M_buf_count; - copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); - } - sequence_buffer(sequence_buffer& __x) { - __x.flush(); - _M_prefix = __x._M_prefix; - _M_buf_count = 0; - } - sequence_buffer(_Sequence& __s) : _M_prefix(&__s), _M_buf_count(0) {} - sequence_buffer& operator= (sequence_buffer& __x) { - __x.flush(); - _M_prefix = __x._M_prefix; - _M_buf_count = 0; - return *this; - } - sequence_buffer& operator= (const sequence_buffer& __x) { - _M_prefix = __x._M_prefix; - _M_buf_count = __x._M_buf_count; - copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); - return *this; - } - void push_back(value_type __x) - { - if (_M_buf_count < _Buf_sz) { - _M_buffer[_M_buf_count] = __x; - ++_M_buf_count; - } else { - flush(); - _M_buffer[0] = __x; - _M_buf_count = 1; - } - } - void append(value_type* __s, size_t __len) - { - if (__len + _M_buf_count <= _Buf_sz) { - size_t __i = _M_buf_count; - size_t __j = 0; - for (; __j < __len; __i++, __j++) { - _M_buffer[__i] = __s[__j]; - } - _M_buf_count += __len; - } else if (0 == _M_buf_count) { - _M_prefix->append(__s, __s + __len); - } else { - flush(); - append(__s, __len); - } - } - sequence_buffer& write(value_type* __s, size_t __len) - { - append(__s, __len); - return *this; - } - sequence_buffer& put(value_type __x) - { - push_back(__x); - return *this; - } - sequence_buffer& operator=(const value_type& __rhs) - { - push_back(__rhs); - return *this; - } - sequence_buffer& operator*() { return *this; } - sequence_buffer& operator++() { return *this; } - sequence_buffer& operator++(int) { return *this; } -}; - -// The following should be treated as private, at least for now. -template -class _Rope_char_consumer { - public: - // If we had member templates, these should not be virtual. - // For now we need to use run-time parametrization where - // compile-time would do. _Hence this should all be private - // for now. - // The symmetry with char_producer is accidental and temporary. - virtual ~_Rope_char_consumer() {}; - virtual bool operator()(const _CharT* __buffer, size_t __len) = 0; -}; - -// -// What follows should really be local to rope. Unfortunately, -// that doesn't work, since it makes it impossible to define generic -// equality on rope iterators. According to the draft standard, the -// template parameters for such an equality operator cannot be inferred -// from the occurence of a member class as a parameter. -// (SGI compilers in fact allow this, but the __result wouldn't be -// portable.) -// Similarly, some of the static member functions are member functions -// only to avoid polluting the global namespace, and to circumvent -// restrictions on type inference for template functions. -// - -template class rope; -template struct _Rope_RopeConcatenation; -template struct _Rope_RopeLeaf; -template struct _Rope_RopeFunction; -template struct _Rope_RopeSubstring; -template class _Rope_iterator; -template class _Rope_const_iterator; -template class _Rope_char_ref_proxy; -template class _Rope_char_ptr_proxy; - -// -// The internal data structure for representing a rope. This is -// private to the implementation. A rope is really just a pointer -// to one of these. -// -// A few basic functions for manipulating this data structure -// are members of _RopeRep. Most of the more complex algorithms -// are implemented as rope members. -// -// Some of the static member functions of _RopeRep have identically -// named functions in rope that simply invoke the _RopeRep versions. -// -// A macro to introduce various allocation and deallocation functions -// These need to be defined differently depending on whether or not -// we are using standard conforming allocators, and whether the allocator -// instances have real state. Thus this macro is invoked repeatedly -// with different definitions of __ROPE_DEFINE_ALLOC. -// __ROPE_DEFINE_ALLOC(type,name) defines -// type * name_allocate(size_t) and -// void name_deallocate(tipe *, size_t) -// Both functions may or may not be static. - -#define __ROPE_DEFINE_ALLOCS(__a) \ - __ROPE_DEFINE_ALLOC(_CharT,_Data) /* character data */ \ - typedef _Rope_RopeConcatenation<_CharT,__a> __C; \ - __ROPE_DEFINE_ALLOC(__C,_C) \ - typedef _Rope_RopeLeaf<_CharT,__a> __L; \ - __ROPE_DEFINE_ALLOC(__L,_L) \ - typedef _Rope_RopeFunction<_CharT,__a> __F; \ - __ROPE_DEFINE_ALLOC(__F,_F) \ - typedef _Rope_RopeSubstring<_CharT,__a> __S; \ - __ROPE_DEFINE_ALLOC(__S,_S) - -// Internal rope nodes potentially store a copy of the allocator -// instance used to allocate them. This is mostly redundant. -// But the alternative would be to pass allocator instances around -// in some form to nearly all internal functions, since any pointer -// assignment may result in a zero reference count and thus require -// deallocation. -// The _Rope_rep_base class encapsulates -// the differences between SGI-style allocators and standard-conforming -// allocators. - -#ifdef __STL_USE_STD_ALLOCATORS - -#define __STATIC_IF_SGI_ALLOC /* not static */ - -// Base class for ordinary allocators. -template -class _Rope_rep_alloc_base { -public: - typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return _M_data_allocator; } - _Rope_rep_alloc_base(size_t __size, const allocator_type& __a) - : _M_size(__size), _M_data_allocator(__a) {} - size_t _M_size; // This is here only to avoid wasting space - // for an otherwise empty base class. - - -protected: - allocator_type _M_data_allocator; - -# define __ROPE_DEFINE_ALLOC(_Tp, __name) \ - typedef typename \ - _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \ - /*static*/ _Tp * __name##_allocate(size_t __n) \ - { return __name##Allocator(_M_data_allocator).allocate(__n); } \ - void __name##_deallocate(_Tp* __p, size_t __n) \ - { __name##Allocator(_M_data_allocator).deallocate(__p, __n); } - __ROPE_DEFINE_ALLOCS(_Allocator); -# undef __ROPE_DEFINE_ALLOC -}; - -// Specialization for allocators that have the property that we don't -// actually have to store an allocator object. -template -class _Rope_rep_alloc_base<_CharT,_Allocator,true> { -public: - typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - _Rope_rep_alloc_base(size_t __size, const allocator_type&) - : _M_size(__size) {} - size_t _M_size; - -protected: - -# define __ROPE_DEFINE_ALLOC(_Tp, __name) \ - typedef typename \ - _Alloc_traits<_Tp,_Allocator>::_Alloc_type __name##Alloc; \ - typedef typename \ - _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \ - static _Tp* __name##_allocate(size_t __n) \ - { return __name##Alloc::allocate(__n); } \ - void __name##_deallocate(_Tp *__p, size_t __n) \ - { __name##Alloc::deallocate(__p, __n); } - __ROPE_DEFINE_ALLOCS(_Allocator); -# undef __ROPE_DEFINE_ALLOC -}; - -template -struct _Rope_rep_base - : public _Rope_rep_alloc_base<_CharT,_Alloc, - _Alloc_traits<_CharT,_Alloc>::_S_instanceless> -{ - typedef _Rope_rep_alloc_base<_CharT,_Alloc, - _Alloc_traits<_CharT,_Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - _Rope_rep_base(size_t __size, const allocator_type& __a) - : _Base(__size, __a) {} -}; - -#else /* !__STL_USE_STD_ALLOCATORS */ - -#define __STATIC_IF_SGI_ALLOC static - -template -class _Rope_rep_base { -public: - typedef _Alloc allocator_type; - static allocator_type get_allocator() { return allocator_type(); } - _Rope_rep_base(size_t __size, const allocator_type&) : _M_size(__size) {} - size_t _M_size; - -protected: - -# define __ROPE_DEFINE_ALLOC(_Tp, __name) \ - typedef simple_alloc<_Tp, _Alloc> __name##Alloc; \ - static _Tp* __name##_allocate(size_t __n) \ - { return __name##Alloc::allocate(__n); } \ - static void __name##_deallocate(_Tp* __p, size_t __n) \ - { __name##Alloc::deallocate(__p, __n); } - __ROPE_DEFINE_ALLOCS(_Alloc); -# undef __ROPE_DEFINE_ALLOC -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - - -template -struct _Rope_RopeRep : public _Rope_rep_base<_CharT,_Alloc> { - public: - enum { _S_max_rope_depth = 45 }; - enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function}; - _Tag _M_tag:8; - bool _M_is_balanced:8; - unsigned char _M_depth; - __GC_CONST _CharT* _M_c_string; - /* Flattened version of string, if needed. */ - /* typically 0. */ - /* If it's not 0, then the memory is owned */ - /* by this node. */ - /* In the case of a leaf, this may point to */ - /* the same memory as the data field. */ - typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type; - _Rope_RopeRep(_Tag __t, int __d, bool __b, size_t __size, - allocator_type __a) - : _Rope_rep_base<_CharT,_Alloc>(__size, __a), - _M_tag(__t), _M_depth(__d), _M_is_balanced(__b), _M_c_string(0) - { -# ifndef __GC - _M_refcount = 1; - _M_init_refcount_lock(); -# endif - } -# ifndef __GC -# if defined(__STL_WIN32THREADS) - long _M_refcount; // InterlockedIncrement wants a long * -# else - size_t _M_refcount; -# endif - // We count references from rope instances - // and references from other rope nodes. We - // do not count const_iterator references. - // Iterator references are counted so that rope modifications - // can be detected after the fact. - // Generally function results are counted, i.__e. - // a pointer returned by a function is included at the - // point at which the pointer is returned. - // The recipient should decrement the count if the - // __result is not needed. - // Generally function arguments are not reflected - // in the reference count. The callee should increment - // the count before saving the argument someplace that - // will outlive the call. -# endif -# ifndef __GC -# ifdef __STL_SGI_THREADS - // Reference counting with multiple threads and no - // hardware or thread package support is pretty awful. - // Mutexes are normally too expensive. - // We'll assume a COMPARE_AND_SWAP(destp, __old, new) - // operation, which might be cheaper. -# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) -# define __add_and_fetch(l,v) add_then_test((unsigned long*)l,v) -# endif - void _M_init_refcount_lock() {} - void _M_incr_refcount () - { - __add_and_fetch(&_M_refcount, 1); - } - size_t _M_decr_refcount () - { - return __add_and_fetch(&_M_refcount, (size_t)(-1)); - } -# elif defined(__STL_WIN32THREADS) - void _M_init_refcount_lock() {} - void _M_incr_refcount () - { - InterlockedIncrement(&_M_refcount); - } - size_t _M_decr_refcount () - { - return InterlockedDecrement(&_M_refcount); - } -# elif defined(__STL_PTHREADS) - // This should be portable, but performance is expected - // to be quite awful. This really needs platform specific - // code. - pthread_mutex_t _M_refcount_lock; - void _M_init_refcount_lock() { - pthread_mutex_init(&_M_refcount_lock, 0); - } - void _M_incr_refcount () - { - pthread_mutex_lock(&_M_refcount_lock); - ++_M_refcount; - pthread_mutex_unlock(&_M_refcount_lock); - } - size_t _M_decr_refcount () - { - size_t __result; - pthread_mutex_lock(&_M_refcount_lock); - __result = --_M_refcount; - pthread_mutex_unlock(&_M_refcount_lock); - return __result; - } -# else - void _M_init_refcount_lock() {} - void _M_incr_refcount () - { - ++_M_refcount; - } - size_t _M_decr_refcount () - { - --_M_refcount; - return _M_refcount; - } -# endif -# else - void _M_incr_refcount () {} -# endif -# ifdef __STL_USE_STD_ALLOCATORS - static void _S_free_string(__GC_CONST _CharT*, size_t __len, - allocator_type __a); -# define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l, __a); -# else - static void _S_free_string(__GC_CONST _CharT*, size_t __len); -# define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l); -# endif - // Deallocate data section of a leaf. - // This shouldn't be a member function. - // But its hard to do anything else at the - // moment, because it's templatized w.r.t. - // an allocator. - // Does nothing if __GC is defined. -# ifndef __GC - void _M_free_c_string(); - void _M_free_tree(); - // Deallocate t. Assumes t is not 0. - void _M_unref_nonnil() - { - if (0 == _M_decr_refcount()) _M_free_tree(); - } - void _M_ref_nonnil() - { - _M_incr_refcount(); - } - static void _S_unref(_Rope_RopeRep* __t) - { - if (0 != __t) { - __t->_M_unref_nonnil(); - } - } - static void _S_ref(_Rope_RopeRep* __t) - { - if (0 != __t) __t->_M_incr_refcount(); - } - static void _S_free_if_unref(_Rope_RopeRep* __t) - { - if (0 != __t && 0 == __t->_M_refcount) __t->_M_free_tree(); - } -# else /* __GC */ - void _M_unref_nonnil() {} - void _M_ref_nonnil() {} - static void _S_unref(_Rope_RopeRep*) {} - static void _S_ref(_Rope_RopeRep*) {} - static void _S_free_if_unref(_Rope_RopeRep*) {} -# endif - -}; - -template -struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> { - public: - // Apparently needed by VC++ - // The data fields of leaves are allocated with some - // extra space, to accomodate future growth and for basic - // character types, to hold a trailing eos character. - enum { _S_alloc_granularity = 8 }; - static size_t _S_rounded_up_size(size_t __n) { - size_t __size_with_eos; - - if (_S_is_basic_char_type((_CharT*)0)) { - __size_with_eos = __n + 1; - } else { - __size_with_eos = __n; - } -# ifdef __GC - return __size_with_eos; -# else - // Allow slop for in-place expansion. - return (__size_with_eos + _S_alloc_granularity-1) - &~ (_S_alloc_granularity-1); -# endif - } - __GC_CONST _CharT* _M_data; /* Not necessarily 0 terminated. */ - /* The allocated size is */ - /* _S_rounded_up_size(size), except */ - /* in the GC case, in which it */ - /* doesn't matter. */ - typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type; - _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_t __size, allocator_type __a) - : _Rope_RopeRep<_CharT,_Alloc>(_S_leaf, 0, true, __size, __a), - _M_data(__d) - { - __stl_assert(__size > 0); - if (_S_is_basic_char_type((_CharT *)0)) { - // already eos terminated. - _M_c_string = __d; - } - } - // The constructor assumes that d has been allocated with - // the proper allocator and the properly padded size. - // In contrast, the destructor deallocates the data: -# ifndef __GC - ~_Rope_RopeLeaf() { - if (_M_data != _M_c_string) { - _M_free_c_string(); - } - __STL_FREE_STRING(_M_data, _M_size, get_allocator()); - } -# endif -}; - -template -struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT,_Alloc> { - public: - _Rope_RopeRep<_CharT,_Alloc>* _M_left; - _Rope_RopeRep<_CharT,_Alloc>* _M_right; - typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type; - _Rope_RopeConcatenation(_Rope_RopeRep<_CharT,_Alloc>* __l, - _Rope_RopeRep<_CharT,_Alloc>* __r, - allocator_type __a) - : _Rope_RopeRep<_CharT,_Alloc>( - _S_concat, max(__l->_M_depth, __r->_M_depth) + 1, false, - __l->_M_size + __r->_M_size, __a), - _M_left(__l), _M_right(__r) - {} -# ifndef __GC - ~_Rope_RopeConcatenation() { - _M_free_c_string(); - _M_left->_M_unref_nonnil(); - _M_right->_M_unref_nonnil(); - } -# endif -}; - -template -struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT,_Alloc> { - public: - char_producer<_CharT>* _M_fn; -# ifndef __GC - bool _M_delete_when_done; // Char_producer is owned by the - // rope and should be explicitly - // deleted when the rope becomes - // inaccessible. -# else - // In the GC case, we either register the rope for - // finalization, or not. Thus the field is unnecessary; - // the information is stored in the collector data structures. - // We do need a finalization procedure to be invoked by the - // collector. - static void _S_fn_finalization_proc(void * __tree, void *) { - delete ((_Rope_RopeFunction *)__tree) -> _M_fn; - } -# endif - typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type; - _Rope_RopeFunction(char_producer<_CharT>* __f, size_t __size, - bool __d, allocator_type __a) - :_Rope_RopeRep<_CharT,_Alloc>(_S_function, 0, true, __size, __a), - _M_fn(__f) -# ifndef __GC - , _M_delete_when_done(__d) -# endif - { - __stl_assert(__size > 0); -# ifdef __GC - if (__d) { - GC_REGISTER_FINALIZER( - this, _Rope_RopeFunction::_S_fn_finalization_proc, 0, 0, 0); - } -# endif - } -# ifndef __GC - ~_Rope_RopeFunction() { - _M_free_c_string(); - if (_M_delete_when_done) { - delete _M_fn; - } - } -# endif -}; -// Substring results are usually represented using just -// concatenation nodes. But in the case of very long flat ropes -// or ropes with a functional representation that isn't practical. -// In that case, we represent the __result as a special case of -// RopeFunction, whose char_producer points back to the rope itself. -// In all cases except repeated substring operations and -// deallocation, we treat the __result as a RopeFunction. -template -struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>, - public char_producer<_CharT> { - public: - // XXX this whole class should be rewritten. - _Rope_RopeRep<_CharT,_Alloc>* _M_base; // not 0 - size_t _M_start; - virtual void operator()(size_t __start_pos, size_t __req_len, - _CharT* __buffer) { - switch(_M_base->_M_tag) { - case _S_function: - case _S_substringfn: - { - char_producer<_CharT>* __fn = - ((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn; - __stl_assert(__start_pos + __req_len <= _M_size); - __stl_assert(_M_start + _M_size <= _M_base->_M_size); - (*__fn)(__start_pos + _M_start, __req_len, __buffer); - } - break; - case _S_leaf: - { - __GC_CONST _CharT* __s = - ((_Rope_RopeLeaf<_CharT,_Alloc>*)_M_base)->_M_data; - uninitialized_copy_n(__s + __start_pos + _M_start, __req_len, - __buffer); - } - break; - default: - __stl_assert(false); - } - } - typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type; - _Rope_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s, - size_t __l, allocator_type __a) - : _Rope_RopeFunction<_CharT,_Alloc>(this, __l, false, __a), _M_base(__b), _M_start(__s) - { - __stl_assert(__l > 0); - __stl_assert(__s + __l <= __b->_M_size); -# ifndef __GC - _M_base->_M_ref_nonnil(); -# endif - _M_tag = _S_substringfn; - } - virtual ~_Rope_RopeSubstring() - { -# ifndef __GC - _M_base->_M_unref_nonnil(); - // _M_free_c_string(); -- done by parent class -# endif - } -}; - - -// Self-destructing pointers to Rope_rep. -// These are not conventional smart pointers. Their -// only purpose in life is to ensure that unref is called -// on the pointer either at normal exit or if an exception -// is raised. It is the caller's responsibility to -// adjust reference counts when these pointers are initialized -// or assigned to. (This convention significantly reduces -// the number of potentially expensive reference count -// updates.) -#ifndef __GC - template - struct _Rope_self_destruct_ptr { - _Rope_RopeRep<_CharT,_Alloc>* _M_ptr; - ~_Rope_self_destruct_ptr() - { _Rope_RopeRep<_CharT,_Alloc>::_S_unref(_M_ptr); } -# ifdef __STL_USE_EXCEPTIONS - _Rope_self_destruct_ptr() : _M_ptr(0) {}; -# else - _Rope_self_destruct_ptr() {}; -# endif - _Rope_self_destruct_ptr(_Rope_RopeRep<_CharT,_Alloc>* __p) : _M_ptr(__p) {} - _Rope_RopeRep<_CharT,_Alloc>& operator*() { return *_M_ptr; } - _Rope_RopeRep<_CharT,_Alloc>* operator->() { return _M_ptr; } - operator _Rope_RopeRep<_CharT,_Alloc>*() { return _M_ptr; } - _Rope_self_destruct_ptr& operator= (_Rope_RopeRep<_CharT,_Alloc>* __x) - { _M_ptr = __x; return *this; } - }; -#endif - -// Dereferencing a nonconst iterator has to return something -// that behaves almost like a reference. It's not possible to -// return an actual reference since assignment requires extra -// work. And we would get into the same problems as with the -// CD2 version of basic_string. -template -class _Rope_char_ref_proxy { - friend class rope<_CharT,_Alloc>; - friend class _Rope_iterator<_CharT,_Alloc>; - friend class _Rope_char_ptr_proxy<_CharT,_Alloc>; -# ifdef __GC - typedef _Rope_RopeRep<_CharT,_Alloc>* _Self_destruct_ptr; -# else - typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr; -# endif - typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; - typedef rope<_CharT,_Alloc> _My_rope; - size_t _M_pos; - _CharT _M_current; - bool _M_current_valid; - _My_rope* _M_root; // The whole rope. - public: - _Rope_char_ref_proxy(_My_rope* __r, size_t __p) : - _M_pos(__p), _M_current_valid(false), _M_root(__r) {} - _Rope_char_ref_proxy(const _Rope_char_ref_proxy& __x) : - _M_pos(__x._M_pos), _M_current_valid(false), _M_root(__x._M_root) {} - // Don't preserve cache if the reference can outlive the - // expression. We claim that's not possible without calling - // a copy constructor or generating reference to a proxy - // reference. We declare the latter to have undefined semantics. - _Rope_char_ref_proxy(_My_rope* __r, size_t __p, - _CharT __c) : - _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) {} - inline operator _CharT () const; - _Rope_char_ref_proxy& operator= (_CharT __c); - _Rope_char_ptr_proxy<_CharT,_Alloc> operator& () const; - _Rope_char_ref_proxy& operator= (const _Rope_char_ref_proxy& __c) { - return operator=((_CharT)__c); - } -}; - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - template - inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a, - _Rope_char_ref_proxy <_CharT, __Alloc > __b) { - _CharT __tmp = __a; - __a = __b; - __b = __tmp; - } -#else -// There is no really acceptable way to handle this. The default -// definition of swap doesn't work for proxy references. -// It can't really be made to work, even with ugly hacks, since -// the only unusual operation it uses is the copy constructor, which -// is needed for other purposes. We provide a macro for -// full specializations, and instantiate the most common case. -# define _ROPE_SWAP_SPECIALIZATION(_CharT, __Alloc) \ - inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a, \ - _Rope_char_ref_proxy <_CharT, __Alloc > __b) { \ - _CharT __tmp = __a; \ - __a = __b; \ - __b = __tmp; \ - } - -_ROPE_SWAP_SPECIALIZATION(char,__STL_DEFAULT_ALLOCATOR(char)) - -#endif /* !__STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -class _Rope_char_ptr_proxy { - // XXX this class should be rewritten. - friend class _Rope_char_ref_proxy<_CharT,_Alloc>; - size_t _M_pos; - rope<_CharT,_Alloc>* _M_root; // The whole rope. - public: - _Rope_char_ptr_proxy(const _Rope_char_ref_proxy<_CharT,_Alloc>& __x) - : _M_pos(__x._M_pos), _M_root(__x._M_root) {} - _Rope_char_ptr_proxy(const _Rope_char_ptr_proxy& __x) - : _M_pos(__x._M_pos), _M_root(__x._M_root) {} - _Rope_char_ptr_proxy() {} - _Rope_char_ptr_proxy(_CharT* __x) : _M_root(0), _M_pos(0) { - __stl_assert(0 == __x); - } - _Rope_char_ptr_proxy& - operator= (const _Rope_char_ptr_proxy& __x) { - _M_pos = __x._M_pos; - _M_root = __x._M_root; - return *this; - } - friend bool operator== __STL_NULL_TMPL_ARGS - (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x, - const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y); - - _Rope_char_ref_proxy<_CharT,_Alloc> operator*() const { - return _Rope_char_ref_proxy<_CharT,_Alloc>(_M_root, _M_pos); - } -}; - - -// Rope iterators: -// Unlike in the C version, we cache only part of the stack -// for rope iterators, since they must be efficiently copyable. -// When we run out of cache, we have to reconstruct the iterator -// value. -// Pointers from iterators are not included in reference counts. -// Iterators are assumed to be thread private. Ropes can -// be shared. - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1375 -#endif - -template -class _Rope_iterator_base - : public random_access_iterator<_CharT, ptrdiff_t> { - friend class rope<_CharT,_Alloc>; - public: - typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; - // Borland doesnt want this to be protected. - protected: - enum { _S_path_cache_len = 4 }; // Must be <= 9. - enum { _S_iterator_buf_len = 15 }; - size_t _M_current_pos; - _RopeRep* _M_root; // The whole rope. - size_t _M_leaf_pos; // Starting position for current leaf - __GC_CONST _CharT* _M_buf_start; - // Buffer possibly - // containing current char. - __GC_CONST _CharT* _M_buf_ptr; - // Pointer to current char in buffer. - // != 0 ==> buffer valid. - __GC_CONST _CharT* _M_buf_end; - // One past __last valid char in buffer. - // What follows is the path cache. We go out of our - // way to make this compact. - // Path_end contains the bottom section of the path from - // the root to the current leaf. - const _RopeRep* _M_path_end[_S_path_cache_len]; - int _M_leaf_index; // Last valid __pos in path_end; - // _M_path_end[0] ... _M_path_end[leaf_index-1] - // point to concatenation nodes. - unsigned char _M_path_directions; - // (path_directions >> __i) & 1 is 1 - // iff we got from _M_path_end[leaf_index - __i - 1] - // to _M_path_end[leaf_index - __i] by going to the - // __right. Assumes path_cache_len <= 9. - _CharT _M_tmp_buf[_S_iterator_buf_len]; - // Short buffer for surrounding chars. - // This is useful primarily for - // RopeFunctions. We put the buffer - // here to avoid locking in the - // multithreaded case. - // The cached path is generally assumed to be valid - // only if the buffer is valid. - static void _S_setbuf(_Rope_iterator_base& __x); - // Set buffer contents given - // path cache. - static void _S_setcache(_Rope_iterator_base& __x); - // Set buffer contents and - // path cache. - static void _S_setcache_for_incr(_Rope_iterator_base& __x); - // As above, but assumes path - // cache is valid for previous posn. - _Rope_iterator_base() {} - _Rope_iterator_base(_RopeRep* __root, size_t __pos) - : _M_root(__root), _M_current_pos(__pos), _M_buf_ptr(0) {} - void _M_incr(size_t __n); - void _M_decr(size_t __n); - public: - size_t index() const { return _M_current_pos; } - _Rope_iterator_base(const _Rope_iterator_base& __x) { - if (0 != __x._M_buf_ptr) { - *this = __x; - } else { - _M_current_pos = __x._M_current_pos; - _M_root = __x._M_root; - _M_buf_ptr = 0; - } - } -}; - -template class _Rope_iterator; - -template -class _Rope_const_iterator : public _Rope_iterator_base<_CharT,_Alloc> { - friend class rope<_CharT,_Alloc>; - protected: - _Rope_const_iterator(const _RopeRep* __root, size_t __pos): - _Rope_iterator_base<_CharT,_Alloc>( - const_cast<_RopeRep*>(__root), __pos) - // Only nonconst iterators modify root ref count - {} - public: - typedef _CharT reference; // Really a value. Returning a reference - // Would be a mess, since it would have - // to be included in refcount. - typedef const _CharT* pointer; - - public: - _Rope_const_iterator() {}; - _Rope_const_iterator(const _Rope_const_iterator& __x) : - _Rope_iterator_base<_CharT,_Alloc>(__x) { } - _Rope_const_iterator(const _Rope_iterator<_CharT,_Alloc>& __x); - _Rope_const_iterator(const rope<_CharT,_Alloc>& __r, size_t __pos) : - _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos) {} - _Rope_const_iterator& operator= (const _Rope_const_iterator& __x) { - if (0 != __x._M_buf_ptr) { - *(static_cast<_Rope_iterator_base<_CharT,_Alloc>*>(this)) = __x; - } else { - _M_current_pos = __x._M_current_pos; - _M_root = __x._M_root; - _M_buf_ptr = 0; - } - return(*this); - } - reference operator*() { - if (0 == _M_buf_ptr) _S_setcache(*this); - return *_M_buf_ptr; - } - _Rope_const_iterator& operator++() { - __GC_CONST _CharT* __next; - if (0 != _M_buf_ptr && (__next = _M_buf_ptr + 1) < _M_buf_end) { - _M_buf_ptr = __next; - ++_M_current_pos; - } else { - _M_incr(1); - } - return *this; - } - _Rope_const_iterator& operator+=(ptrdiff_t __n) { - if (__n >= 0) { - _M_incr(__n); - } else { - _M_decr(-__n); - } - return *this; - } - _Rope_const_iterator& operator--() { - _M_decr(1); - return *this; - } - _Rope_const_iterator& operator-=(ptrdiff_t __n) { - if (__n >= 0) { - _M_decr(__n); - } else { - _M_incr(-__n); - } - return *this; - } - _Rope_const_iterator operator++(int) { - size_t __old_pos = _M_current_pos; - _M_incr(1); - return _Rope_const_iterator<_CharT,_Alloc>(_M_root, __old_pos); - // This makes a subsequent dereference expensive. - // Perhaps we should instead copy the iterator - // if it has a valid cache? - } - _Rope_const_iterator operator--(int) { - size_t __old_pos = _M_current_pos; - _M_decr(1); - return _Rope_const_iterator<_CharT,_Alloc>(_M_root, __old_pos); - } - friend _Rope_const_iterator<_CharT,_Alloc> operator- __STL_NULL_TMPL_ARGS - (const _Rope_const_iterator<_CharT,_Alloc>& __x, - ptrdiff_t __n); - friend _Rope_const_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS - (const _Rope_const_iterator<_CharT,_Alloc>& __x, - ptrdiff_t __n); - friend _Rope_const_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS - (ptrdiff_t __n, - const _Rope_const_iterator<_CharT,_Alloc>& __x); - reference operator[](size_t __n) { - return rope<_CharT,_Alloc>::_S_fetch(_M_root, _M_current_pos + __n); - } - friend bool operator== __STL_NULL_TMPL_ARGS - (const _Rope_const_iterator<_CharT,_Alloc>& __x, - const _Rope_const_iterator<_CharT,_Alloc>& __y); - friend bool operator< __STL_NULL_TMPL_ARGS - (const _Rope_const_iterator<_CharT,_Alloc>& __x, - const _Rope_const_iterator<_CharT,_Alloc>& __y); - friend ptrdiff_t operator- __STL_NULL_TMPL_ARGS - (const _Rope_const_iterator<_CharT,_Alloc>& __x, - const _Rope_const_iterator<_CharT,_Alloc>& __y); -}; - -template -class _Rope_iterator : public _Rope_iterator_base<_CharT,_Alloc> { - friend class rope<_CharT,_Alloc>; - protected: - rope<_CharT,_Alloc>* _M_root_rope; - // root is treated as a cached version of this, - // and is used to detect changes to the underlying - // rope. - // Root is included in the reference count. - // This is necessary so that we can detect changes reliably. - // Unfortunately, it requires careful bookkeeping for the - // nonGC case. - _Rope_iterator(rope<_CharT,_Alloc>* __r, size_t __pos) - : _Rope_iterator_base<_CharT,_Alloc>(__r->_M_tree_ptr, __pos), - _M_root_rope(__r) - { _RopeRep::_S_ref(_M_root); } - - void _M_check(); - public: - typedef _Rope_char_ref_proxy<_CharT,_Alloc> reference; - typedef _Rope_char_ref_proxy<_CharT,_Alloc>* pointer; - - public: - rope<_CharT,_Alloc>& container() { return *_M_root_rope; } - _Rope_iterator() { - _M_root = 0; // Needed for reference counting. - }; - _Rope_iterator(const _Rope_iterator& __x) : - _Rope_iterator_base<_CharT,_Alloc>(__x) { - _M_root_rope = __x._M_root_rope; - _RopeRep::_S_ref(_M_root); - } - _Rope_iterator(rope<_CharT,_Alloc>& __r, size_t __pos); - ~_Rope_iterator() { - _RopeRep::_S_unref(_M_root); - } - _Rope_iterator& operator= (const _Rope_iterator& __x) { - _RopeRep* __old = _M_root; - - _RopeRep::_S_ref(__x._M_root); - if (0 != __x._M_buf_ptr) { - _M_root_rope = __x._M_root_rope; - *(static_cast<_Rope_iterator_base<_CharT,_Alloc>*>(this)) = __x; - } else { - _M_current_pos = __x._M_current_pos; - _M_root = __x._M_root; - _M_root_rope = __x._M_root_rope; - _M_buf_ptr = 0; - } - _RopeRep::_S_unref(__old); - return(*this); - } - reference operator*() { - _M_check(); - if (0 == _M_buf_ptr) { - return _Rope_char_ref_proxy<_CharT,_Alloc>( - _M_root_rope, _M_current_pos); - } else { - return _Rope_char_ref_proxy<_CharT,_Alloc>( - _M_root_rope, _M_current_pos, *_M_buf_ptr); - } - } - _Rope_iterator& operator++() { - _M_incr(1); - return *this; - } - _Rope_iterator& operator+=(difference_type __n) { - if (__n >= 0) { - _M_incr(__n); - } else { - _M_decr(-__n); - } - return *this; - } - _Rope_iterator& operator--() { - _M_decr(1); - return *this; - } - _Rope_iterator& operator-=(difference_type __n) { - if (__n >= 0) { - _M_decr(__n); - } else { - _M_incr(-__n); - } - return *this; - } - _Rope_iterator operator++(int) { - size_t __old_pos = _M_current_pos; - _M_incr(1); - return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos); - } - _Rope_iterator operator--(int) { - size_t __old_pos = _M_current_pos; - _M_decr(1); - return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos); - } - reference operator[](ptrdiff_t __n) { - return _Rope_char_ref_proxy<_CharT,_Alloc>( - _M_root_rope, _M_current_pos + __n); - } - friend bool operator== __STL_NULL_TMPL_ARGS - (const _Rope_iterator<_CharT,_Alloc>& __x, - const _Rope_iterator<_CharT,_Alloc>& __y); - friend bool operator< __STL_NULL_TMPL_ARGS - (const _Rope_iterator<_CharT,_Alloc>& __x, - const _Rope_iterator<_CharT,_Alloc>& __y); - friend ptrdiff_t operator- __STL_NULL_TMPL_ARGS - (const _Rope_iterator<_CharT,_Alloc>& __x, - const _Rope_iterator<_CharT,_Alloc>& __y); - friend _Rope_iterator<_CharT,_Alloc> operator- __STL_NULL_TMPL_ARGS - (const _Rope_iterator<_CharT,_Alloc>& __x, - ptrdiff_t __n); - friend _Rope_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS - (const _Rope_iterator<_CharT,_Alloc>& __x, - ptrdiff_t __n); - friend _Rope_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS - (ptrdiff_t __n, - const _Rope_iterator<_CharT,_Alloc>& __x); - -}; - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1375 -#endif - -// The rope base class encapsulates -// the differences between SGI-style allocators and standard-conforming -// allocators. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base class for ordinary allocators. -template -class _Rope_alloc_base { -public: - typedef _Rope_RopeRep<_CharT,_Allocator> _RopeRep; - typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return _M_data_allocator; } - _Rope_alloc_base(_RopeRep *__t, const allocator_type& __a) - : _M_tree_ptr(__t), _M_data_allocator(__a) {} - _Rope_alloc_base(const allocator_type& __a) - : _M_data_allocator(__a) {} - -protected: - // The only data members of a rope: - allocator_type _M_data_allocator; - _RopeRep* _M_tree_ptr; - -# define __ROPE_DEFINE_ALLOC(_Tp, __name) \ - typedef typename \ - _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \ - _Tp* __name##_allocate(size_t __n) const \ - { return __name##Allocator(_M_data_allocator).allocate(__n); } \ - void __name##_deallocate(_Tp *__p, size_t __n) const \ - { __name##Allocator(_M_data_allocator).deallocate(__p, __n); } - __ROPE_DEFINE_ALLOCS(_Allocator) -# undef __ROPE_DEFINE_ALLOC -}; - -// Specialization for allocators that have the property that we don't -// actually have to store an allocator object. -template -class _Rope_alloc_base<_CharT,_Allocator,true> { -public: - typedef _Rope_RopeRep<_CharT,_Allocator> _RopeRep; - typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - _Rope_alloc_base(_RopeRep *__t, const allocator_type&) - : _M_tree_ptr(__t) {} - _Rope_alloc_base(const allocator_type&) {} - -protected: - // The only data member of a rope: - _RopeRep *_M_tree_ptr; - -# define __ROPE_DEFINE_ALLOC(_Tp, __name) \ - typedef typename \ - _Alloc_traits<_Tp,_Allocator>::_Alloc_type __name##Alloc; \ - typedef typename \ - _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \ - static _Tp* __name##_allocate(size_t __n) \ - { return __name##Alloc::allocate(__n); } \ - static void __name##_deallocate(_Tp *__p, size_t __n) \ - { __name##Alloc::deallocate(__p, __n); } - __ROPE_DEFINE_ALLOCS(_Allocator) -# undef __ROPE_DEFINE_ALLOC -}; - -template -struct _Rope_base - : public _Rope_alloc_base<_CharT,_Alloc, - _Alloc_traits<_CharT,_Alloc>::_S_instanceless> -{ - typedef _Rope_alloc_base<_CharT,_Alloc, - _Alloc_traits<_CharT,_Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - _Rope_base(_RopeRep* __t, const allocator_type& __a) : _Base(__t, __a) {} - _Rope_base(const allocator_type& __a) : _Base(__a) {} -}; - -#else /* !__STL_USE_STD_ALLOCATORS */ - -template -class _Rope_base { -public: - typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; - typedef _Alloc allocator_type; - static allocator_type get_allocator() { return allocator_type(); } - _Rope_base(_RopeRep * __t, const allocator_type&) : _M_tree_ptr(__t) {} - _Rope_base(const allocator_type&) {} - -protected: - // The only data member of a rope: - _RopeRep* _M_tree_ptr; - -# define __ROPE_DEFINE_ALLOC(_Tp, __name) \ - typedef simple_alloc<_Tp, _Alloc> __name##Alloc; \ - static _Tp* __name##_allocate(size_t __n) \ - { return __name##Alloc::allocate(__n); } \ - static void __name##_deallocate(_Tp *__p, size_t __n) \ - { __name##Alloc::deallocate(__p, __n); } - __ROPE_DEFINE_ALLOCS(_Alloc) -# undef __ROPE_DEFINE_ALLOC -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - - -template -class rope : public _Rope_base<_CharT,_Alloc> { - public: - typedef _CharT value_type; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - typedef _CharT const_reference; - typedef const _CharT* const_pointer; - typedef _Rope_iterator<_CharT,_Alloc> iterator; - typedef _Rope_const_iterator<_CharT,_Alloc> const_iterator; - typedef _Rope_char_ref_proxy<_CharT,_Alloc> reference; - typedef _Rope_char_ptr_proxy<_CharT,_Alloc> pointer; - - friend class _Rope_iterator<_CharT,_Alloc>; - friend class _Rope_const_iterator<_CharT,_Alloc>; - friend struct _Rope_RopeRep<_CharT,_Alloc>; - friend class _Rope_iterator_base<_CharT,_Alloc>; - friend class _Rope_char_ptr_proxy<_CharT,_Alloc>; - friend class _Rope_char_ref_proxy<_CharT,_Alloc>; - friend struct _Rope_RopeSubstring<_CharT,_Alloc>; - - protected: - typedef _Rope_base<_CharT,_Alloc> _Base; - typedef typename _Base::allocator_type allocator_type; -# ifdef __STL_USE_NAMESPACES - using _Base::_M_tree_ptr; -# endif - typedef __GC_CONST _CharT* _Cstrptr; -# ifdef __STL_SGI_THREADS - static _Cstrptr _S_atomic_swap(_Cstrptr* __p, _Cstrptr __q) { -# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) - return (_Cstrptr) test_and_set((unsigned long*)__p, - (unsigned long)__q); -# else - return (_Cstrptr) __test_and_set((unsigned long*)__p, - (unsigned long)__q); -# endif - } -# elif defined(__STL_WIN32THREADS) - static _Cstrptr _S_atomic_swap(_Cstrptr* __p, _Cstrptr __q) { - return (_Cstrptr) InterlockedExchange( - (LPLONG)__p, (LONG)__q); - } -# elif defined(__STL_PTHREADS) - // This should be portable, but performance is expected - // to be quite awful. This really needs platform specific - // code. - static pthread_mutex_t _S_swap_lock; - static _Cstrptr _S_atomic_swap(_Cstrptr* __p, _Cstrptr __q) { - pthread_mutex_lock(&_S_swap_lock); - _Cstrptr __result = *__p; - *__p = __q; - pthread_mutex_unlock(&_S_swap_lock); - return __result; - } -# else - static _Cstrptr _S_atomic_swap(_Cstrptr* __p, _Cstrptr __q) { - _Cstrptr __result = *__p; - *__p = __q; - return __result; - } -# endif - - static _CharT _S_empty_c_str[1]; - - static bool _S_is0(_CharT __c) { return __c == _S_eos((_CharT*)0); } - enum { _S_copy_max = 23 }; - // For strings shorter than _S_copy_max, we copy to - // concatenate. - - typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; - typedef _Rope_RopeConcatenation<_CharT,_Alloc> _RopeConcatenation; - typedef _Rope_RopeLeaf<_CharT,_Alloc> _RopeLeaf; - typedef _Rope_RopeFunction<_CharT,_Alloc> _RopeFunction; - typedef _Rope_RopeSubstring<_CharT,_Alloc> _RopeSubstring; - - // Retrieve a character at the indicated position. - static _CharT _S_fetch(_RopeRep* __r, size_type __pos); - -# ifndef __GC - // Obtain a pointer to the character at the indicated position. - // The pointer can be used to change the character. - // If such a pointer cannot be produced, as is frequently the - // case, 0 is returned instead. - // (Returns nonzero only if all nodes in the path have a refcount - // of 1.) - static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos); -# endif - - static bool _S_apply_to_pieces( - // should be template parameter - _Rope_char_consumer<_CharT>& __c, - const _RopeRep* __r, - size_t __begin, size_t __end); - // begin and end are assumed to be in range. - -# ifndef __GC - static void _S_unref(_RopeRep* __t) - { - _RopeRep::_S_unref(__t); - } - static void _S_ref(_RopeRep* __t) - { - _RopeRep::_S_ref(__t); - } -# else /* __GC */ - static void _S_unref(_RopeRep*) {} - static void _S_ref(_RopeRep*) {} -# endif - - -# ifdef __GC - typedef _Rope_RopeRep<_CharT,_Alloc>* _Self_destruct_ptr; -# else - typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr; -# endif - - // _Result is counted in refcount. - static _RopeRep* _S_substring(_RopeRep* __base, - size_t __start, size_t __endp1); - - static _RopeRep* _S_concat_char_iter(_RopeRep* __r, - const _CharT* __iter, size_t __slen); - // Concatenate rope and char ptr, copying __s. - // Should really take an arbitrary iterator. - // Result is counted in refcount. - static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r, - const _CharT* __iter, size_t __slen) - // As above, but one reference to __r is about to be - // destroyed. Thus the pieces may be recycled if all - // relevent reference counts are 1. -# ifdef __GC - // We can't really do anything since refcounts are unavailable. - { return _S_concat_char_iter(__r, __iter, __slen); } -# else - ; -# endif - - static _RopeRep* _S_concat(_RopeRep* __left, _RopeRep* __right); - // General concatenation on _RopeRep. _Result - // has refcount of 1. Adjusts argument refcounts. - - public: - void apply_to_pieces( size_t __begin, size_t __end, - _Rope_char_consumer<_CharT>& __c) const { - _S_apply_to_pieces(__c, _M_tree_ptr, __begin, __end); - } - - - protected: - - static size_t _S_rounded_up_size(size_t __n) { - return _RopeLeaf::_S_rounded_up_size(__n); - } - - static size_t _S_allocated_capacity(size_t __n) { - if (_S_is_basic_char_type((_CharT*)0)) { - return _S_rounded_up_size(__n) - 1; - } else { - return _S_rounded_up_size(__n); - } - } - - // Allocate and construct a RopeLeaf using the supplied allocator - // Takes ownership of s instead of copying. - static _RopeLeaf* _S_new_RopeLeaf(__GC_CONST _CharT *__s, - size_t __size, allocator_type __a) - { -# ifdef __STL_USE_STD_ALLOCATORS - _RopeLeaf* __space = _LAllocator(__a).allocate(1); -# else - _RopeLeaf* __space = _L_allocate(1); -# endif - return new(__space) _RopeLeaf(__s, __size, __a); - } - - static _RopeConcatenation* _S_new_RopeConcatenation( - _RopeRep* __left, _RopeRep* __right, - allocator_type __a) - { -# ifdef __STL_USE_STD_ALLOCATORS - _RopeConcatenation* __space = _CAllocator(__a).allocate(1); -# else - _RopeConcatenation* __space = _C_allocate(1); -# endif - return new(__space) _RopeConcatenation(__left, __right, __a); - } - - static _RopeFunction* _S_new_RopeFunction(char_producer<_CharT>* __f, - size_t __size, bool __d, allocator_type __a) - { -# ifdef __STL_USE_STD_ALLOCATORS - _RopeFunction* __space = _FAllocator(__a).allocate(1); -# else - _RopeFunction* __space = _F_allocate(1); -# endif - return new(__space) _RopeFunction(__f, __size, __d, __a); - } - - static _RopeSubstring* _S_new_RopeSubstring( - _Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s, - size_t __l, allocator_type __a) - { -# ifdef __STL_USE_STD_ALLOCATORS - _RopeSubstring* __space = _SAllocator(__a).allocate(1); -# else - _RopeSubstring* __space = _S_allocate(1); -# endif - return new(__space) _RopeSubstring(__b, __s, __l, __a); - } - -# ifdef __STL_USE_STD_ALLOCATORS - static - _RopeLeaf* _S_RopeLeaf_from_unowned_char_ptr(const _CharT *__s, - size_t __size, allocator_type __a) -# define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \ - _S_RopeLeaf_from_unowned_char_ptr(__s, __size, __a) -# else - static - _RopeLeaf* _S_RopeLeaf_from_unowned_char_ptr2(const _CharT* __s, - size_t __size) -# define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \ - _S_RopeLeaf_from_unowned_char_ptr2(__s, __size) -# endif - { - if (0 == __size) return 0; -# ifdef __STL_USE_STD_ALLOCATORS - _CharT* __buf = __a.allocate(_S_rounded_up_size(__size)); -# else - _CharT* __buf = _Data_allocate(_S_rounded_up_size(__size)); - allocator_type __a = allocator_type(); -# endif - - uninitialized_copy_n(__s, __size, __buf); - _S_cond_store_eos(__buf[__size]); - __STL_TRY { - return _S_new_RopeLeaf(__buf, __size, __a); - } - __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, __size, __a)) - } - - - // Concatenation of nonempty strings. - // Always builds a concatenation node. - // Rebalances if the result is too deep. - // Result has refcount 1. - // Does not increment left and right ref counts even though - // they are referenced. - static _RopeRep* - _S_tree_concat(_RopeRep* __left, _RopeRep* __right); - - // Concatenation helper functions - static _RopeLeaf* - _S_leaf_concat_char_iter(_RopeLeaf* __r, - const _CharT* __iter, size_t __slen); - // Concatenate by copying leaf. - // should take an arbitrary iterator - // result has refcount 1. -# ifndef __GC - static _RopeLeaf* _S_destr_leaf_concat_char_iter - (_RopeLeaf* __r, const _CharT* __iter, size_t __slen); - // A version that potentially clobbers __r if __r->_M_refcount == 1. -# endif - - // A helper function for exponentiating strings. - // This uses a nonstandard refcount convention. - // The result has refcount 0. - struct _Concat_fn - : public binary_function, - rope<_CharT,_Alloc>, - rope<_CharT,_Alloc> > { - rope operator() (const rope& __x, const rope& __y) { - return __x + __y; - } - }; - - // Needed by the call to "power" used to build ropes - // consisting of n copies of a character. - friend rope identity_element(_Concat_fn) - { return rope<_CharT,_Alloc>(); } - - static size_t _S_char_ptr_len(const _CharT* __s); - // slightly generalized strlen - - rope(_RopeRep* __t, const allocator_type& __a = allocator_type()) - : _Base(__t,__a) { } - - - // Copy __r to the _CharT buffer. - // Returns __buffer + __r->_M_size. - // Assumes that buffer is uninitialized. - static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer); - - // Again, with explicit starting position and length. - // Assumes that buffer is uninitialized. - static _CharT* _S_flatten(_RopeRep* __r, - size_t __start, size_t __len, - _CharT* __buffer); - - static const unsigned long - _S_min_len[_RopeRep::_S_max_rope_depth + 1]; - - static bool _S_is_balanced(_RopeRep* __r) - { return (__r->_M_size >= _S_min_len[__r->_M_depth]); } - - static bool _S_is_almost_balanced(_RopeRep* __r) - { return (__r->_M_depth == 0 || - __r->_M_size >= _S_min_len[__r->_M_depth - 1]); } - - static bool _S_is_roughly_balanced(_RopeRep* __r) - { return (__r->_M_depth <= 1 || - __r->_M_size >= _S_min_len[__r->_M_depth - 2]); } - - // Assumes the result is not empty. - static _RopeRep* _S_concat_and_set_balanced(_RopeRep* __left, - _RopeRep* __right) - { - _RopeRep* __result = _S_concat(__left, __right); - if (_S_is_balanced(__result)) __result->_M_is_balanced = true; - return __result; - } - - // The basic rebalancing operation. Logically copies the - // rope. The result has refcount of 1. The client will - // usually decrement the reference count of __r. - // The result is within height 2 of balanced by the above - // definition. - static _RopeRep* _S_balance(_RopeRep* __r); - - // Add all unbalanced subtrees to the forest of balanceed trees. - // Used only by balance. - static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest); - - // Add __r to forest, assuming __r is already balanced. - static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest); - - // Print to stdout, exposing structure - static void _S_dump(_RopeRep* __r, int __indent = 0); - - // Return -1, 0, or 1 if __x < __y, __x == __y, or __x > __y resp. - static int _S_compare(const _RopeRep* __x, const _RopeRep* __y); - - public: - bool empty() const { return 0 == _M_tree_ptr; } - - // Comparison member function. This is public only for those - // clients that need a ternary comparison. Others - // should use the comparison operators below. - int compare(const rope& __y) const { - return _S_compare(_M_tree_ptr, __y._M_tree_ptr); - } - - rope(const _CharT* __s, const allocator_type& __a = allocator_type()) - : _Base(__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, _S_char_ptr_len(__s), - __a),__a) - { } - - rope(const _CharT* __s, size_t __len, - const allocator_type& __a = allocator_type()) - : _Base(__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __len, __a), __a) - { } - - // Should perhaps be templatized with respect to the iterator type - // and use Sequence_buffer. (It should perhaps use sequence_buffer - // even now.) - rope(const _CharT *__s, const _CharT *__e, - const allocator_type& __a = allocator_type()) - : _Base(__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __e - __s, __a), __a) - { } - - rope(const const_iterator& __s, const const_iterator& __e, - const allocator_type& __a = allocator_type()) - : _Base(_S_substring(__s._M_root, __s._M_current_pos, - __e._M_current_pos), __a) - { } - - rope(const iterator& __s, const iterator& __e, - const allocator_type& __a = allocator_type()) - : _Base(_S_substring(__s._M_root, __s._M_current_pos, - __e._M_current_pos), __a) - { } - - rope(_CharT __c, const allocator_type& __a = allocator_type()) - : _Base(__a) - { - _CharT* __buf = _Data_allocate(_S_rounded_up_size(1)); - - construct(__buf, __c); - __STL_TRY { - _M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a); - } - __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, 1, __a)) - } - - rope(size_t __n, _CharT __c, - const allocator_type& __a = allocator_type()); - - rope(const allocator_type& __a = allocator_type()) - : _Base(0, __a) {} - - // Construct a rope from a function that can compute its members - rope(char_producer<_CharT> *__fn, size_t __len, bool __delete_fn, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { - _M_tree_ptr = (0 == __len) ? - 0 : _S_new_RopeFunction(__fn, __len, __delete_fn, __a); - } - - rope(const rope& __x, const allocator_type& __a = allocator_type()) - : _Base(__x._M_tree_ptr, __a) - { - _S_ref(_M_tree_ptr); - } - - ~rope() - { - _S_unref(_M_tree_ptr); - } - - rope& operator=(const rope& __x) - { - _RopeRep* __old = _M_tree_ptr; -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(get_allocator() == __x.get_allocator()); -# endif - _M_tree_ptr = __x._M_tree_ptr; - _S_ref(_M_tree_ptr); - _S_unref(__old); - return(*this); - } - - void push_back(_CharT __x) - { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = _S_concat_char_iter(_M_tree_ptr, &__x, 1); - _S_unref(__old); - } - - void pop_back() - { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = - _S_substring(_M_tree_ptr, 0, _M_tree_ptr->_M_size - 1); - _S_unref(__old); - } - - _CharT back() const - { - return _S_fetch(_M_tree_ptr, _M_tree_ptr->_M_size - 1); - } - - void push_front(_CharT __x) - { - _RopeRep* __old = _M_tree_ptr; - _RopeRep* __left = - __STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, get_allocator()); - __STL_TRY { - _M_tree_ptr = _S_concat(__left, _M_tree_ptr); - _S_unref(__old); - _S_unref(__left); - } - __STL_UNWIND(_S_unref(__left)) - } - - void pop_front() - { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = _S_substring(_M_tree_ptr, 1, _M_tree_ptr->_M_size); - _S_unref(__old); - } - - _CharT front() const - { - return _S_fetch(_M_tree_ptr, 0); - } - - void balance() - { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = _S_balance(_M_tree_ptr); - _S_unref(__old); - } - - void copy(_CharT* __buffer) const { - destroy(__buffer, __buffer + size()); - _S_flatten(_M_tree_ptr, __buffer); - } - - // This is the copy function from the standard, but - // with the arguments reordered to make it consistent with the - // rest of the interface. - // Note that this guaranteed not to compile if the draft standard - // order is assumed. - size_type copy(size_type __pos, size_type __n, _CharT* __buffer) const - { - size_t __size = size(); - size_t __len = (__pos + __n > __size? __size - __pos : __n); - - destroy(__buffer, __buffer + __len); - _S_flatten(_M_tree_ptr, __pos, __len, __buffer); - return __len; - } - - // Print to stdout, exposing structure. May be useful for - // performance debugging. - void dump() { - _S_dump(_M_tree_ptr); - } - - // Convert to 0 terminated string in new allocated memory. - // Embedded 0s in the input do not terminate the copy. - const _CharT* c_str() const; - - // As above, but lso use the flattened representation as the - // the new rope representation. - const _CharT* replace_with_c_str(); - - // Reclaim memory for the c_str generated flattened string. - // Intentionally undocumented, since it's hard to say when this - // is safe for multiple threads. - void delete_c_str () { - if (0 == _M_tree_ptr) return; - if (_RopeRep::_S_leaf == _M_tree_ptr->_M_tag && - ((_RopeLeaf*)_M_tree_ptr)->_M_data == - _M_tree_ptr->_M_c_string) { - // Representation shared - return; - } -# ifndef __GC - _M_tree_ptr->_M_free_c_string(); -# endif - _M_tree_ptr->_M_c_string = 0; - } - - _CharT operator[] (size_type __pos) const { - return _S_fetch(_M_tree_ptr, __pos); - } - - _CharT at(size_type __pos) const { - // if (__pos >= size()) throw out_of_range; // XXX - return (*this)[__pos]; - } - - const_iterator begin() const { - return(const_iterator(_M_tree_ptr, 0)); - } - - // An easy way to get a const iterator from a non-const container. - const_iterator const_begin() const { - return(const_iterator(_M_tree_ptr, 0)); - } - - const_iterator end() const { - return(const_iterator(_M_tree_ptr, size())); - } - - const_iterator const_end() const { - return(const_iterator(_M_tree_ptr, size())); - } - - size_type size() const { - return(0 == _M_tree_ptr? 0 : _M_tree_ptr->_M_size); - } - - size_type length() const { - return size(); - } - - size_type max_size() const { - return _S_min_len[_RopeRep::_S_max_rope_depth-1] - 1; - // Guarantees that the result can be sufficirntly - // balanced. Longer ropes will probably still work, - // but it's harder to make guarantees. - } - -# ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef reverse_iterator const_reverse_iterator; -# else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_iterator const_reverse_iterator; -# endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - - const_reverse_iterator const_rbegin() const { - return const_reverse_iterator(end()); - } - - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - const_reverse_iterator const_rend() const { - return const_reverse_iterator(begin()); - } - - friend rope<_CharT,_Alloc> - operator+ __STL_NULL_TMPL_ARGS (const rope<_CharT,_Alloc>& __left, - const rope<_CharT,_Alloc>& __right); - - friend rope<_CharT,_Alloc> - operator+ __STL_NULL_TMPL_ARGS (const rope<_CharT,_Alloc>& __left, - const _CharT* __right); - - friend rope<_CharT,_Alloc> - operator+ __STL_NULL_TMPL_ARGS (const rope<_CharT,_Alloc>& __left, - _CharT __right); - - // The symmetric cases are intentionally omitted, since they're presumed - // to be less common, and we don't handle them as well. - - // The following should really be templatized. - // The first argument should be an input iterator or - // forward iterator with value_type _CharT. - rope& append(const _CharT* __iter, size_t __n) { - _RopeRep* __result = - _S_destr_concat_char_iter(_M_tree_ptr, __iter, __n); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - return *this; - } - - rope& append(const _CharT* __c_string) { - size_t __len = _S_char_ptr_len(__c_string); - append(__c_string, __len); - return(*this); - } - - rope& append(const _CharT* __s, const _CharT* __e) { - _RopeRep* __result = - _S_destr_concat_char_iter(_M_tree_ptr, __s, __e - __s); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - return *this; - } - - rope& append(const_iterator __s, const_iterator __e) { - __stl_assert(__s._M_root == __e._M_root); -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(get_allocator() == __s._M_root->get_allocator()); -# endif - _Self_destruct_ptr __appendee(_S_substring( - __s._M_root, __s._M_current_pos, __e._M_current_pos)); - _RopeRep* __result = - _S_concat(_M_tree_ptr, (_RopeRep*)__appendee); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - return *this; - } - - rope& append(_CharT __c) { - _RopeRep* __result = - _S_destr_concat_char_iter(_M_tree_ptr, &__c, 1); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - return *this; - } - - rope& append() { return append(_CharT()); } // XXX why? - - rope& append(const rope& __y) { -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(__y.get_allocator() == get_allocator()); -# endif - _RopeRep* __result = _S_concat(_M_tree_ptr, __y._M_tree_ptr); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - return *this; - } - - rope& append(size_t __n, _CharT __c) { - rope<_CharT,_Alloc> __last(__n, __c); - return append(__last); - } - - void swap(rope& __b) { -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(get_allocator() == __b.get_allocator()); -# endif - _RopeRep* __tmp = _M_tree_ptr; - _M_tree_ptr = __b._M_tree_ptr; - __b._M_tree_ptr = __tmp; - } - - - protected: - // Result is included in refcount. - static _RopeRep* replace(_RopeRep* __old, size_t __pos1, - size_t __pos2, _RopeRep* __r) { - if (0 == __old) { _S_ref(__r); return __r; } - _Self_destruct_ptr __left( - _S_substring(__old, 0, __pos1)); - _Self_destruct_ptr __right( - _S_substring(__old, __pos2, __old->_M_size)); - _RopeRep* __result; - -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(__old->get_allocator() == __r->get_allocator()); -# endif - if (0 == __r) { - __result = _S_concat(__left, __right); - } else { - _Self_destruct_ptr __left_result(_S_concat(__left, __r)); - __result = _S_concat(__left_result, __right); - } - return __result; - } - - public: - void insert(size_t __p, const rope& __r) { - _RopeRep* __result = - replace(_M_tree_ptr, __p, __p, __r._M_tree_ptr); -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(get_allocator() == __r.get_allocator()); -# endif - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - } - - void insert(size_t __p, size_t __n, _CharT __c) { - rope<_CharT,_Alloc> __r(__n,__c); - insert(__p, __r); - } - - void insert(size_t __p, const _CharT* __i, size_t __n) { - _Self_destruct_ptr __left(_S_substring(_M_tree_ptr, 0, __p)); - _Self_destruct_ptr __right(_S_substring(_M_tree_ptr, __p, size())); - _Self_destruct_ptr __left_result( - _S_concat_char_iter(__left, __i, __n)); - _RopeRep* __result = _S_concat(__left_result, __right); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - } - - void insert(size_t __p, const _CharT* __c_string) { - insert(__p, __c_string, _S_char_ptr_len(__c_string)); - } - - void insert(size_t __p, _CharT __c) { - insert(__p, &__c, 1); - } - - void insert(size_t __p) { - _CharT __c = _CharT(); - insert(__p, &__c, 1); - } - - void insert(size_t __p, const _CharT* __i, const _CharT* __j) { - rope __r(__i, __j); - insert(__p, __r); - } - - void insert(size_t __p, const const_iterator& __i, - const const_iterator& __j) { - rope __r(__i, __j); - insert(__p, __r); - } - - void insert(size_t __p, const iterator& __i, - const iterator& __j) { - rope __r(__i, __j); - insert(__p, __r); - } - - // (position, length) versions of replace operations: - - void replace(size_t __p, size_t __n, const rope& __r) { - _RopeRep* __result = - replace(_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - } - - void replace(size_t __p, size_t __n, - const _CharT* __i, size_t __i_len) { - rope __r(__i, __i_len); - replace(__p, __n, __r); - } - - void replace(size_t __p, size_t __n, _CharT __c) { - rope __r(__c); - replace(__p, __n, __r); - } - - void replace(size_t __p, size_t __n, const _CharT* __c_string) { - rope __r(__c_string); - replace(__p, __n, __r); - } - - void replace(size_t __p, size_t __n, - const _CharT* __i, const _CharT* __j) { - rope __r(__i, __j); - replace(__p, __n, __r); - } - - void replace(size_t __p, size_t __n, - const const_iterator& __i, const const_iterator& __j) { - rope __r(__i, __j); - replace(__p, __n, __r); - } - - void replace(size_t __p, size_t __n, - const iterator& __i, const iterator& __j) { - rope __r(__i, __j); - replace(__p, __n, __r); - } - - // Single character variants: - void replace(size_t __p, _CharT __c) { - iterator __i(this, __p); - *__i = __c; - } - - void replace(size_t __p, const rope& __r) { - replace(__p, 1, __r); - } - - void replace(size_t __p, const _CharT* __i, size_t __i_len) { - replace(__p, 1, __i, __i_len); - } - - void replace(size_t __p, const _CharT* __c_string) { - replace(__p, 1, __c_string); - } - - void replace(size_t __p, const _CharT* __i, const _CharT* __j) { - replace(__p, 1, __i, __j); - } - - void replace(size_t __p, const const_iterator& __i, - const const_iterator& __j) { - replace(__p, 1, __i, __j); - } - - void replace(size_t __p, const iterator& __i, - const iterator& __j) { - replace(__p, 1, __i, __j); - } - - // Erase, (position, size) variant. - void erase(size_t __p, size_t __n) { - _RopeRep* __result = replace(_M_tree_ptr, __p, __p + __n, 0); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; - } - - // Erase, single character - void erase(size_t __p) { - erase(__p, __p + 1); - } - - // Insert, iterator variants. - iterator insert(const iterator& __p, const rope& __r) - { insert(__p.index(), __r); return __p; } - iterator insert(const iterator& __p, size_t __n, _CharT __c) - { insert(__p.index(), __n, __c); return __p; } - iterator insert(const iterator& __p, _CharT __c) - { insert(__p.index(), __c); return __p; } - iterator insert(const iterator& __p ) - { insert(__p.index()); return __p; } - iterator insert(const iterator& __p, const _CharT* c_string) - { insert(__p.index(), c_string); return __p; } - iterator insert(const iterator& __p, const _CharT* __i, size_t __n) - { insert(__p.index(), __i, __n); return __p; } - iterator insert(const iterator& __p, const _CharT* __i, - const _CharT* __j) - { insert(__p.index(), __i, __j); return __p; } - iterator insert(const iterator& __p, - const const_iterator& __i, const const_iterator& __j) - { insert(__p.index(), __i, __j); return __p; } - iterator insert(const iterator& __p, - const iterator& __i, const iterator& __j) - { insert(__p.index(), __i, __j); return __p; } - - // Replace, range variants. - void replace(const iterator& __p, const iterator& __q, - const rope& __r) - { replace(__p.index(), __q.index() - __p.index(), __r); } - void replace(const iterator& __p, const iterator& __q, _CharT __c) - { replace(__p.index(), __q.index() - __p.index(), __c); } - void replace(const iterator& __p, const iterator& __q, - const _CharT* __c_string) - { replace(__p.index(), __q.index() - __p.index(), __c_string); } - void replace(const iterator& __p, const iterator& __q, - const _CharT* __i, size_t __n) - { replace(__p.index(), __q.index() - __p.index(), __i, __n); } - void replace(const iterator& __p, const iterator& __q, - const _CharT* __i, const _CharT* __j) - { replace(__p.index(), __q.index() - __p.index(), __i, __j); } - void replace(const iterator& __p, const iterator& __q, - const const_iterator& __i, const const_iterator& __j) - { replace(__p.index(), __q.index() - __p.index(), __i, __j); } - void replace(const iterator& __p, const iterator& __q, - const iterator& __i, const iterator& __j) - { replace(__p.index(), __q.index() - __p.index(), __i, __j); } - - // Replace, iterator variants. - void replace(const iterator& __p, const rope& __r) - { replace(__p.index(), __r); } - void replace(const iterator& __p, _CharT __c) - { replace(__p.index(), __c); } - void replace(const iterator& __p, const _CharT* __c_string) - { replace(__p.index(), __c_string); } - void replace(const iterator& __p, const _CharT* __i, size_t __n) - { replace(__p.index(), __i, __n); } - void replace(const iterator& __p, const _CharT* __i, const _CharT* __j) - { replace(__p.index(), __i, __j); } - void replace(const iterator& __p, const_iterator __i, - const_iterator __j) - { replace(__p.index(), __i, __j); } - void replace(const iterator& __p, iterator __i, iterator __j) - { replace(__p.index(), __i, __j); } - - // Iterator and range variants of erase - iterator erase(const iterator& __p, const iterator& __q) { - size_t __p_index = __p.index(); - erase(__p_index, __q.index() - __p_index); - return iterator(this, __p_index); - } - iterator erase(const iterator& __p) { - size_t __p_index = __p.index(); - erase(__p_index, 1); - return iterator(this, __p_index); - } - - rope substr(size_t __start, size_t __len = 1) const { - return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __start, __start + __len)); - } - - rope substr(iterator __start, iterator __end) const { - return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __start.index(), __end.index())); - } - - rope substr(iterator __start) const { - size_t __pos = __start.index(); - return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __pos, __pos + 1)); - } - - rope substr(const_iterator __start, const_iterator __end) const { - // This might eventually take advantage of the cache in the - // iterator. - return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __start.index(), __end.index())); - } - - rope<_CharT,_Alloc> substr(const_iterator __start) { - size_t __pos = __start.index(); - return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __pos, __pos + 1)); - } - - static const size_type npos; - - size_type find(_CharT __c, size_type __pos = 0) const; - size_type find(_CharT* __s, size_type __pos = 0) const { - size_type __result_pos; - const_iterator __result = search(const_begin() + __pos, const_end(), - __s, __s + _S_char_ptr_len(__s)); - __result_pos = __result.index(); -# ifndef __STL_OLD_ROPE_SEMANTICS - if (__result_pos == size()) __result_pos = npos; -# endif - return __result_pos; - } - - iterator mutable_begin() { - return(iterator(this, 0)); - } - - iterator mutable_end() { - return(iterator(this, size())); - } - -# ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef reverse_iterator reverse_iterator; -# else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_iterator reverse_iterator; -# endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - reverse_iterator mutable_rbegin() { - return reverse_iterator(mutable_end()); - } - - reverse_iterator mutable_rend() { - return reverse_iterator(mutable_begin()); - } - - reference mutable_reference_at(size_type __pos) { - return reference(this, __pos); - } - -# ifdef __STD_STUFF - reference operator[] (size_type __pos) { - return _char_ref_proxy(this, __pos); - } - - reference at(size_type __pos) { - // if (__pos >= size()) throw out_of_range; // XXX - return (*this)[__pos]; - } - - void resize(size_type __n, _CharT __c) {} - void resize(size_type __n) {} - void reserve(size_type __res_arg = 0) {} - size_type capacity() const { - return max_size(); - } - - // Stuff below this line is dangerous because it's error prone. - // I would really like to get rid of it. - // copy function with funny arg ordering. - size_type copy(_CharT* __buffer, size_type __n, - size_type __pos = 0) const { - return copy(__pos, __n, __buffer); - } - - iterator end() { return mutable_end(); } - - iterator begin() { return mutable_begin(); } - - reverse_iterator rend() { return mutable_rend(); } - - reverse_iterator rbegin() { return mutable_rbegin(); } - -# else - - const_iterator end() { return const_end(); } - - const_iterator begin() { return const_begin(); } - - const_reverse_iterator rend() { return const_rend(); } - - const_reverse_iterator rbegin() { return const_rbegin(); } - -# endif - -}; - -template -const rope<_CharT, _Alloc>::size_type rope<_CharT, _Alloc>::npos = - (size_type)(-1); - -template -inline bool operator== (const _Rope_const_iterator<_CharT,_Alloc>& __x, - const _Rope_const_iterator<_CharT,_Alloc>& __y) { - return (__x._M_current_pos == __y._M_current_pos && - __x._M_root == __y._M_root); -} - -template -inline bool operator< (const _Rope_const_iterator<_CharT,_Alloc>& __x, - const _Rope_const_iterator<_CharT,_Alloc>& __y) { - return (__x._M_current_pos < __y._M_current_pos); -} - -template -inline ptrdiff_t operator-(const _Rope_const_iterator<_CharT,_Alloc>& __x, - const _Rope_const_iterator<_CharT,_Alloc>& __y) { - return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; -} - -template -inline _Rope_const_iterator<_CharT,_Alloc> -operator-(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n) { - return _Rope_const_iterator<_CharT,_Alloc>( - __x._M_root, __x._M_current_pos - __n); -} - -template -inline _Rope_const_iterator<_CharT,_Alloc> -operator+(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n) { - return _Rope_const_iterator<_CharT,_Alloc>( - __x._M_root, __x._M_current_pos + __n); -} - -template -inline _Rope_const_iterator<_CharT,_Alloc> -operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT,_Alloc>& __x) { - return _Rope_const_iterator<_CharT,_Alloc>( - __x._M_root, __x._M_current_pos + __n); -} - -template -inline bool operator== (const _Rope_iterator<_CharT,_Alloc>& __x, - const _Rope_iterator<_CharT,_Alloc>& __y) { - return (__x._M_current_pos == __y._M_current_pos && - __x._M_root_rope == __y._M_root_rope); -} - -template -inline bool operator< (const _Rope_iterator<_CharT,_Alloc>& __x, - const _Rope_iterator<_CharT,_Alloc>& __y) { - return (__x._M_current_pos < __y._M_current_pos); -} - -template -inline ptrdiff_t operator-(const _Rope_iterator<_CharT,_Alloc>& __x, - const _Rope_iterator<_CharT,_Alloc>& __y) { - return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; -} - -template -inline _Rope_iterator<_CharT,_Alloc> -operator-(const _Rope_iterator<_CharT,_Alloc>& __x, - ptrdiff_t __n) { - return _Rope_iterator<_CharT,_Alloc>( - __x._M_root_rope, __x._M_current_pos - __n); -} - -template -inline _Rope_iterator<_CharT,_Alloc> -operator+(const _Rope_iterator<_CharT,_Alloc>& __x, - ptrdiff_t __n) { - return _Rope_iterator<_CharT,_Alloc>( - __x._M_root_rope, __x._M_current_pos + __n); -} - -template -inline _Rope_iterator<_CharT,_Alloc> -operator+(ptrdiff_t __n, const _Rope_iterator<_CharT,_Alloc>& __x) { - return _Rope_iterator<_CharT,_Alloc>( - __x._M_root_rope, __x._M_current_pos + __n); -} - -template -inline -rope<_CharT,_Alloc> -operator+ (const rope<_CharT,_Alloc>& __left, - const rope<_CharT,_Alloc>& __right) -{ -# ifdef __STL_USE_STD_ALLOCATORS - __stl_assert(__left.get_allocator() == __right.get_allocator()); -# endif - return rope<_CharT,_Alloc>( - rope<_CharT,_Alloc>::_S_concat(__left._M_tree_ptr, __right._M_tree_ptr)); - // Inlining this should make it possible to keep __left and - // __right in registers. -} - -template -inline -rope<_CharT,_Alloc>& -operator+= (rope<_CharT,_Alloc>& __left, - const rope<_CharT,_Alloc>& __right) -{ - __left.append(__right); - return __left; -} - -template -inline -rope<_CharT,_Alloc> -operator+ (const rope<_CharT,_Alloc>& __left, - const _CharT* __right) { - size_t __rlen = rope<_CharT,_Alloc>::_S_char_ptr_len(__right); - return rope<_CharT,_Alloc>( - rope<_CharT,_Alloc>::_S_concat_char_iter( - __left._M_tree_ptr, __right, __rlen)); -} - -template -inline -rope<_CharT,_Alloc>& -operator+= (rope<_CharT,_Alloc>& __left, - const _CharT* __right) { - __left.append(__right); - return __left; -} - -template -inline -rope<_CharT,_Alloc> -operator+ (const rope<_CharT,_Alloc>& __left, _CharT __right) { - return rope<_CharT,_Alloc>( - rope<_CharT,_Alloc>::_S_concat_char_iter( - __left._M_tree_ptr, &__right, 1)); -} - -template -inline -rope<_CharT,_Alloc>& -operator+= (rope<_CharT,_Alloc>& __left, _CharT __right) { - __left.append(__right); - return __left; -} - -template -bool -operator< (const rope<_CharT,_Alloc>& __left, - const rope<_CharT,_Alloc>& __right) { - return __left.compare(__right) < 0; -} - -template -bool -operator== (const rope<_CharT,_Alloc>& __left, - const rope<_CharT,_Alloc>& __right) { - return __left.compare(__right) == 0; -} - -template -inline bool operator== (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x, - const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y) { - return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root); -} - -template -ostream& operator<< (ostream& __o, const rope<_CharT,_Alloc>& __r); - -typedef rope crope; -typedef rope wrope; - -inline crope::reference __mutable_reference_at(crope& __c, size_t __i) -{ - return __c.mutable_reference_at(__i); -} - -inline wrope::reference __mutable_reference_at(wrope& __c, size_t __i) -{ - return __c.mutable_reference_at(__i); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(rope<_CharT,_Alloc>& __x, rope<_CharT,_Alloc>& __y) { - __x.swap(__y); -} - -#else - -inline void swap(crope __x, crope __y) { __x.swap(__y); } -inline void swap(wrope __x, wrope __y) { __x.swap(__y); } - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Hash functions should probably be revisited later: -__STL_TEMPLATE_NULL struct hash -{ - size_t operator()(const crope& __str) const - { - size_t __size = __str.size(); - - if (0 == __size) return 0; - return 13*__str[0] + 5*__str[__size - 1] + __size; - } -}; - - -__STL_TEMPLATE_NULL struct hash -{ - size_t operator()(const wrope& __str) const - { - size_t __size = __str.size(); - - if (0 == __size) return 0; - return 13*__str[0] + 5*__str[__size - 1] + __size; - } -}; - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#endif - -__STL_END_NAMESPACE - -# include - -# endif /* __SGI_STL_INTERNAL_ROPE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_set.h b/libstdc++/stl/stl_set.h deleted file mode 100644 index 003069cb074..00000000000 --- a/libstdc++/stl/stl_set.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_SET_H -#define __SGI_STL_INTERNAL_SET_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template , - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) > -#else -template -#endif -class set { -public: - // typedefs: - - typedef _Key key_type; - typedef _Key value_type; - typedef _Compare key_compare; - typedef _Compare value_compare; -private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; - _Rep_type _M_t; // red-black tree representing set -public: - typedef typename _Rep_type::const_pointer pointer; - typedef typename _Rep_type::const_pointer const_pointer; - typedef typename _Rep_type::const_reference reference; - typedef typename _Rep_type::const_reference const_reference; - typedef typename _Rep_type::const_iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::const_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 - - set() : _M_t(_Compare(), allocator_type()) {} - explicit set(const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - set(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - template - set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } -#else - set(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - set(const value_type* __first, - const value_type* __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } - - set(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - set(const_iterator __first, const_iterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } -#endif /* __STL_MEMBER_TEMPLATES */ - - set(const set<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {} - set<_Key,_Compare,_Alloc>& operator=(const set<_Key, _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 _M_t.key_comp(); } - allocator_type get_allocator() const { return _M_t.get_allocator(); } - - iterator begin() const { return _M_t.begin(); } - iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - size_type max_size() const { return _M_t.max_size(); } - void swap(set<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } - - // insert/erase - pair insert(const value_type& __x) { - pair __p = _M_t.insert_unique(__x); - return pair(__p.first, __p.second); - } - iterator insert(iterator __position, const value_type& __x) { - typedef typename _Rep_type::iterator _Rep_iterator; - return _M_t.insert_unique((_Rep_iterator&)__position, __x); - } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_unique(__first, __last); - } -#else - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_unique(__first, __last); - } - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_unique(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - void erase(iterator __position) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__position); - } - size_type erase(const key_type& __x) { - return _M_t.erase(__x); - } - void erase(iterator __first, iterator __last) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); - } - void clear() { _M_t.clear(); } - - // set operations: - - iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { return _M_t.count(__x); } - iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - friend bool operator== __STL_NULL_TMPL_ARGS (const set&, const set&); - friend bool operator< __STL_NULL_TMPL_ARGS (const set&, const set&); -}; - -template -inline bool operator==(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return __x._M_t == __y._M_t; -} - -template -inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(set<_Key,_Compare,_Alloc>& __x, - set<_Key,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_SET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_slist.h b/libstdc++/stl/stl_slist.h deleted file mode 100644 index 6da234d92c2..00000000000 --- a/libstdc++/stl/stl_slist.h +++ /dev/null @@ -1,945 +0,0 @@ -/* - * 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. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_SLIST_H -#define __SGI_STL_INTERNAL_SLIST_H - - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -struct _Slist_node_base -{ - _Slist_node_base* _M_next; -}; - -inline _Slist_node_base* -__slist_make_link(_Slist_node_base* __prev_node, - _Slist_node_base* __new_node) -{ - __new_node->_M_next = __prev_node->_M_next; - __prev_node->_M_next = __new_node; - return __new_node; -} - -inline _Slist_node_base* -__slist_previous(_Slist_node_base* __head, - const _Slist_node_base* __node) -{ - while (__head && __head->_M_next != __node) - __head = __head->_M_next; - return __head; -} - -inline const _Slist_node_base* -__slist_previous(const _Slist_node_base* __head, - const _Slist_node_base* __node) -{ - while (__head && __head->_M_next != __node) - __head = __head->_M_next; - return __head; -} - -inline void __slist_splice_after(_Slist_node_base* __pos, - _Slist_node_base* __before_first, - _Slist_node_base* __before_last) -{ - if (__pos != __before_first && __pos != __before_last) { - _Slist_node_base* __first = __before_first->_M_next; - _Slist_node_base* __after = __pos->_M_next; - __before_first->_M_next = __before_last->_M_next; - __pos->_M_next = __first; - __before_last->_M_next = __after; - } -} - -inline _Slist_node_base* __slist_reverse(_Slist_node_base* __node) -{ - _Slist_node_base* __result = __node; - __node = __node->_M_next; - __result->_M_next = 0; - while(__node) { - _Slist_node_base* __next = __node->_M_next; - __node->_M_next = __result; - __result = __node; - __node = __next; - } - return __result; -} - -inline size_t __slist_size(_Slist_node_base* __node) -{ - size_t __result = 0; - for ( ; __node != 0; __node = __node->_M_next) - ++__result; - return __result; -} - -template -struct _Slist_node : public _Slist_node_base -{ - _Tp _M_data; -}; - -struct _Slist_iterator_base -{ - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef forward_iterator_tag iterator_category; - - _Slist_node_base* _M_node; - - _Slist_iterator_base(_Slist_node_base* __x) : _M_node(__x) {} - void _M_incr() { _M_node = _M_node->_M_next; } - - bool operator==(const _Slist_iterator_base& __x) const { - return _M_node == __x._M_node; - } - bool operator!=(const _Slist_iterator_base& __x) const { - return _M_node != __x._M_node; - } -}; - -template -struct _Slist_iterator : public _Slist_iterator_base -{ - typedef _Slist_iterator<_Tp, _Tp&, _Tp*> iterator; - typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; - typedef _Slist_iterator<_Tp, _Ref, _Ptr> _Self; - - typedef _Tp value_type; - typedef _Ptr pointer; - typedef _Ref reference; - typedef _Slist_node<_Tp> _Node; - - _Slist_iterator(_Node* __x) : _Slist_iterator_base(__x) {} - _Slist_iterator() : _Slist_iterator_base(0) {} - _Slist_iterator(const iterator& __x) : _Slist_iterator_base(__x._M_node) {} - - reference operator*() const { return ((_Node*) _M_node)->_M_data; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() - { - _M_incr(); - return *this; - } - _Self operator++(int) - { - _Self __tmp = *this; - _M_incr(); - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -inline ptrdiff_t* distance_type(const _Slist_iterator_base&) { - return 0; -} - -inline forward_iterator_tag iterator_category(const _Slist_iterator_base&) { - return forward_iterator_tag(); -} - -template -inline _Tp* value_type(const _Slist_iterator<_Tp, _Ref, _Ptr>&) { - return 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// 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. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base for general standard-conforming allocators. -template -class _Slist_alloc_base { -public: - typedef typename _Alloc_traits<_Tp,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } - - _Slist_alloc_base(const allocator_type& __a) : _M_node_allocator(__a) {} - -protected: - _Slist_node<_Tp>* _M_get_node() - { return _M_node_allocator.allocate(1); } - void _M_put_node(_Slist_node<_Tp>* __p) - { _M_node_allocator.deallocate(__p, 1); } - -protected: - typename _Alloc_traits<_Slist_node<_Tp>,_Allocator>::allocator_type - _M_node_allocator; - _Slist_node_base _M_head; -}; - -// Specialization for instanceless allocators. -template -class _Slist_alloc_base<_Tp,_Allocator, true> { -public: - typedef typename _Alloc_traits<_Tp,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Slist_alloc_base(const allocator_type&) {} - -protected: - typedef typename _Alloc_traits<_Slist_node<_Tp>, _Allocator>::_Alloc_type - _Alloc_type; - _Slist_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); } - void _M_put_node(_Slist_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); } - -protected: - _Slist_node_base _M_head; -}; - - -template -struct _Slist_base - : public _Slist_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ - typedef _Slist_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - - _Slist_base(const allocator_type& __a) : _Base(__a) { _M_head._M_next = 0; } - ~_Slist_base() { _M_erase_after(&_M_head, 0); } - -protected: - - _Slist_node_base* _M_erase_after(_Slist_node_base* __pos) - { - _Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next); - _Slist_node_base* __next_next = __next->_M_next; - __pos->_M_next = __next_next; - destroy(&__next->_M_data); - _M_put_node(__next); - return __next_next; - } - _Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*); -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -struct _Slist_base { - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Slist_base(const allocator_type&) { _M_head._M_next = 0; } - ~_Slist_base() { _M_erase_after(&_M_head, 0); } - -protected: - typedef simple_alloc<_Slist_node<_Tp>, _Alloc> _Alloc_type; - _Slist_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); } - void _M_put_node(_Slist_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); } - - _Slist_node_base* _M_erase_after(_Slist_node_base* __pos) - { - _Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next); - _Slist_node_base* __next_next = __next->_M_next; - __pos->_M_next = __next_next; - destroy(&__next->_M_data); - _M_put_node(__next); - return __next_next; - } - _Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*); - -protected: - _Slist_node_base _M_head; -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -_Slist_node_base* -_Slist_base<_Tp,_Alloc>::_M_erase_after(_Slist_node_base* __before_first, - _Slist_node_base* __last_node) { - _Slist_node<_Tp>* __cur = (_Slist_node<_Tp>*) (__before_first->_M_next); - while (__cur != __last_node) { - _Slist_node<_Tp>* __tmp = __cur; - __cur = (_Slist_node<_Tp>*) __cur->_M_next; - destroy(&__tmp->_M_data); - _M_put_node(__tmp); - } - __before_first->_M_next = __last_node; - return __last_node; -} - -template -class slist : private _Slist_base<_Tp,_Alloc> -{ -private: - typedef _Slist_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 _Slist_iterator<_Tp, _Tp&, _Tp*> iterator; - typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; - - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -private: - typedef _Slist_node<_Tp> _Node; - typedef _Slist_node_base _Node_base; - typedef _Slist_iterator_base _Iterator_base; - - _Node* _M_create_node(const value_type& __x) { - _Node* __node = _M_get_node(); - __STL_TRY { - construct(&__node->_M_data, __x); - __node->_M_next = 0; - } - __STL_UNWIND(_M_put_node(__node)); - return __node; - } - - _Node* _M_create_node() { - _Node* __node = _M_get_node(); - __STL_TRY { - construct(&__node->_M_data); - __node->_M_next = 0; - } - __STL_UNWIND(_M_put_node(__node)); - return __node; - } - -private: -#ifdef __STL_USE_NAMESPACES - using _Base::_M_get_node; - using _Base::_M_put_node; - using _Base::_M_erase_after; - using _Base::_M_head; -#endif /* __STL_USE_NAMESPACES */ - -public: - explicit slist(const allocator_type& __a = allocator_type()) : _Base(__a) {} - - slist(size_type __n, const value_type& __x, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_fill(&_M_head, __n, __x); } - - explicit slist(size_type __n) : _Base(allocator_type()) - { _M_insert_after_fill(&_M_head, __n, value_type()); } - -#ifdef __STL_MEMBER_TEMPLATES - // We don't need any dispatching tricks here, because _M_insert_after_range - // already does them. - template - slist(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_range(&_M_head, __first, __last); } - -#else /* __STL_MEMBER_TEMPLATES */ - slist(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_range(&_M_head, __first, __last); } - slist(const value_type* __first, const value_type* __last, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_range(&_M_head, __first, __last); } -#endif /* __STL_MEMBER_TEMPLATES */ - - slist(const slist& __x) : _Base(__x.get_allocator()) - { _M_insert_after_range(&_M_head, __x.begin(), __x.end()); } - - slist& operator= (const slist& __x); - - ~slist() {} - -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 assign(size_type __n, const _Tp& __val); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type); - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - - iterator begin() { return iterator((_Node*)_M_head._M_next); } - const_iterator begin() const - { return const_iterator((_Node*)_M_head._M_next);} - - iterator end() { return iterator(0); } - const_iterator end() const { return const_iterator(0); } - - size_type size() const { return __slist_size(_M_head._M_next); } - - size_type max_size() const { return size_type(-1); } - - bool empty() const { return _M_head._M_next == 0; } - - void swap(slist& __x) { __STD::swap(_M_head._M_next, __x._M_head._M_next); } - -public: - friend bool operator== __STL_NULL_TMPL_ARGS (const slist<_Tp,_Alloc>& _SL1, - const slist<_Tp,_Alloc>& _SL2); - -public: - - reference front() { return ((_Node*) _M_head._M_next)->_M_data; } - const_reference front() const - { return ((_Node*) _M_head._M_next)->_M_data; } - void push_front(const value_type& __x) { - __slist_make_link(&_M_head, _M_create_node(__x)); - } - void push_front() { __slist_make_link(&_M_head, _M_create_node());} - void pop_front() { - _Node* __node = (_Node*) _M_head._M_next; - _M_head._M_next = __node->_M_next; - destroy(&__node->_M_data); - _M_put_node(__node); - } - - iterator previous(const_iterator __pos) { - return iterator((_Node*) __slist_previous(&_M_head, __pos._M_node)); - } - const_iterator previous(const_iterator __pos) const { - return const_iterator((_Node*) __slist_previous(&_M_head, __pos._M_node)); - } - -private: - _Node* _M_insert_after(_Node_base* __pos, const value_type& __x) { - return (_Node*) (__slist_make_link(__pos, _M_create_node(__x))); - } - - _Node* _M_insert_after(_Node_base* __pos) { - return (_Node*) (__slist_make_link(__pos, _M_create_node())); - } - - void _M_insert_after_fill(_Node_base* __pos, - size_type __n, const value_type& __x) { - for (size_type __i = 0; __i < __n; ++__i) - __pos = __slist_make_link(__pos, _M_create_node(__x)); - } - -#ifdef __STL_MEMBER_TEMPLATES - - // Check whether it's an integral type. If so, it's not an iterator. - template - void _M_insert_after_range(_Node_base* __pos, - _InIter __first, _InIter __last) { - typedef typename _Is_integer<_InIter>::_Integral _Integral; - _M_insert_after_range(__pos, __first, __last, _Integral()); - } - - template - void _M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x, - __true_type) { - _M_insert_after_fill(__pos, __n, __x); - } - - template - void _M_insert_after_range(_Node_base* __pos, - _InIter __first, _InIter __last, - __false_type) { - while (__first != __last) { - __pos = __slist_make_link(__pos, _M_create_node(*__first)); - ++__first; - } - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void _M_insert_after_range(_Node_base* __pos, - const_iterator __first, const_iterator __last) { - while (__first != __last) { - __pos = __slist_make_link(__pos, _M_create_node(*__first)); - ++__first; - } - } - void _M_insert_after_range(_Node_base* __pos, - const value_type* __first, - const value_type* __last) { - while (__first != __last) { - __pos = __slist_make_link(__pos, _M_create_node(*__first)); - ++__first; - } - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - - iterator insert_after(iterator __pos, const value_type& __x) { - return iterator(_M_insert_after(__pos._M_node, __x)); - } - - iterator insert_after(iterator __pos) { - return insert_after(__pos, value_type()); - } - - void insert_after(iterator __pos, size_type __n, const value_type& __x) { - _M_insert_after_fill(__pos._M_node, __n, __x); - } - -#ifdef __STL_MEMBER_TEMPLATES - - // We don't need any dispatching tricks here, because _M_insert_after_range - // already does them. - template - void insert_after(iterator __pos, _InIter __first, _InIter __last) { - _M_insert_after_range(__pos._M_node, __first, __last); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void insert_after(iterator __pos, - const_iterator __first, const_iterator __last) { - _M_insert_after_range(__pos._M_node, __first, __last); - } - void insert_after(iterator __pos, - const value_type* __first, const value_type* __last) { - _M_insert_after_range(__pos._M_node, __first, __last); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator insert(iterator __pos, const value_type& __x) { - return iterator(_M_insert_after(__slist_previous(&_M_head, __pos._M_node), - __x)); - } - - iterator insert(iterator __pos) { - return iterator(_M_insert_after(__slist_previous(&_M_head, __pos._M_node), - value_type())); - } - - void insert(iterator __pos, size_type __n, const value_type& __x) { - _M_insert_after_fill(__slist_previous(&_M_head, __pos._M_node), __n, __x); - } - -#ifdef __STL_MEMBER_TEMPLATES - - // We don't need any dispatching tricks here, because _M_insert_after_range - // already does them. - template - void insert(iterator __pos, _InIter __first, _InIter __last) { - _M_insert_after_range(__slist_previous(&_M_head, __pos._M_node), - __first, __last); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void insert(iterator __pos, const_iterator __first, const_iterator __last) { - _M_insert_after_range(__slist_previous(&_M_head, __pos._M_node), - __first, __last); - } - void insert(iterator __pos, const value_type* __first, - const value_type* __last) { - _M_insert_after_range(__slist_previous(&_M_head, __pos._M_node), - __first, __last); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - -public: - iterator erase_after(iterator __pos) { - return iterator((_Node*) _M_erase_after(__pos._M_node)); - } - iterator erase_after(iterator __before_first, iterator __last) { - return iterator((_Node*) _M_erase_after(__before_first._M_node, - __last._M_node)); - } - - iterator erase(iterator __pos) { - return (_Node*) _M_erase_after(__slist_previous(&_M_head, - __pos._M_node)); - } - iterator erase(iterator __first, iterator __last) { - return (_Node*) _M_erase_after( - __slist_previous(&_M_head, __first._M_node), __last._M_node); - } - - void resize(size_type new_size, const _Tp& __x); - void resize(size_type new_size) { resize(new_size, _Tp()); } - void clear() { _M_erase_after(&_M_head, 0); } - -public: - // Moves the range [__before_first + 1, __before_last + 1) to *this, - // inserting it immediately after __pos. This is constant time. - void splice_after(iterator __pos, - iterator __before_first, iterator __before_last) - { - if (__before_first != __before_last) - __slist_splice_after(__pos._M_node, __before_first._M_node, - __before_last._M_node); - } - - // Moves the element that follows __prev to *this, inserting it immediately - // after __pos. This is constant time. - void splice_after(iterator __pos, iterator __prev) - { - __slist_splice_after(__pos._M_node, - __prev._M_node, __prev._M_node->_M_next); - } - - - // Linear in distance(begin(), __pos), and linear in __x.size(). - void splice(iterator __pos, slist& __x) { - if (__x._M_head._M_next) - __slist_splice_after(__slist_previous(&_M_head, __pos._M_node), - &__x._M_head, __slist_previous(&__x._M_head, 0)); - } - - // Linear in distance(begin(), __pos), and in distance(__x.begin(), __i). - void splice(iterator __pos, slist& __x, iterator __i) { - __slist_splice_after(__slist_previous(&_M_head, __pos._M_node), - __slist_previous(&__x._M_head, __i._M_node), - __i._M_node); - } - - // Linear in distance(begin(), __pos), in distance(__x.begin(), __first), - // and in distance(__first, __last). - void splice(iterator __pos, slist& __x, iterator __first, iterator __last) - { - if (__first != __last) - __slist_splice_after(__slist_previous(&_M_head, __pos._M_node), - __slist_previous(&__x._M_head, __first._M_node), - __slist_previous(__first._M_node, __last._M_node)); - } - -public: - void reverse() { - if (_M_head._M_next) - _M_head._M_next = __slist_reverse(_M_head._M_next); - } - - void remove(const _Tp& __val); - void unique(); - void merge(slist& __x); - void sort(); - -#ifdef __STL_MEMBER_TEMPLATES - template - void remove_if(_Predicate __pred); - - template - void unique(_BinaryPredicate __pred); - - template - void merge(slist&, _StrictWeakOrdering); - - template - void sort(_StrictWeakOrdering __comp); -#endif /* __STL_MEMBER_TEMPLATES */ -}; - -template -slist<_Tp,_Alloc>& slist<_Tp,_Alloc>::operator=(const slist<_Tp,_Alloc>& __x) -{ - if (&__x != this) { - _Node_base* __p1 = &_M_head; - _Node* __n1 = (_Node*) _M_head._M_next; - const _Node* __n2 = (const _Node*) __x._M_head._M_next; - while (__n1 && __n2) { - __n1->_M_data = __n2->_M_data; - __p1 = __n1; - __n1 = (_Node*) __n1->_M_next; - __n2 = (const _Node*) __n2->_M_next; - } - if (__n2 == 0) - _M_erase_after(__p1, 0); - else - _M_insert_after_range(__p1, const_iterator((_Node*)__n2), - const_iterator(0)); - } - return *this; -} - -template -void slist<_Tp, _Alloc>::assign(size_type __n, const _Tp& __val) { - _Node_base* __prev = &_M_head; - _Node* __node = (_Node*) _M_head._M_next; - for ( ; __node != 0 && __n > 0 ; --__n) { - __node->_M_data = __val; - __prev = __node; - __node = (_Node*) __node->_M_next; - } - if (__n > 0) - _M_insert_after_fill(__prev, __n, __val); - else - _M_erase_after(__prev, 0); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void -slist<_Tp, _Alloc>::_M_assign_dispatch(_InputIter __first, _InputIter __last, - __false_type) -{ - _Node_base* __prev = &_M_head; - _Node* __node = (_Node*) _M_head._M_next; - while (__node != 0 && __first != __last) { - __node->_M_data = *__first; - __prev = __node; - __node = (_Node*) __node->_M_next; - ++__first; - } - if (__first != __last) - _M_insert_after_range(__prev, __first, __last); - else - _M_erase_after(__prev, 0); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -inline bool -operator==(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) -{ - typedef typename slist<_Tp,_Alloc>::_Node _Node; - _Node* __n1 = (_Node*) _SL1._M_head._M_next; - _Node* __n2 = (_Node*) _SL2._M_head._M_next; - while (__n1 && __n2 && __n1->_M_data == __n2->_M_data) { - __n1 = (_Node*) __n1->_M_next; - __n2 = (_Node*) __n2->_M_next; - } - return __n1 == 0 && __n2 == 0; -} - -template -inline bool operator<(const slist<_Tp,_Alloc>& _SL1, - const slist<_Tp,_Alloc>& _SL2) -{ - return lexicographical_compare(_SL1.begin(), _SL1.end(), - _SL2.begin(), _SL2.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(slist<_Tp,_Alloc>& __x, slist<_Tp,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template -void slist<_Tp,_Alloc>::resize(size_type __len, const _Tp& __x) -{ - _Node_base* __cur = &_M_head; - while (__cur->_M_next != 0 && __len > 0) { - --__len; - __cur = __cur->_M_next; - } - if (__cur->_M_next) - _M_erase_after(__cur, 0); - else - _M_insert_after_fill(__cur, __len, __x); -} - -template -void slist<_Tp,_Alloc>::remove(const _Tp& __val) -{ - _Node_base* __cur = &_M_head; - while (__cur && __cur->_M_next) { - if (((_Node*) __cur->_M_next)->_M_data == __val) - _M_erase_after(__cur); - else - __cur = __cur->_M_next; - } -} - -template -void slist<_Tp,_Alloc>::unique() -{ - _Node_base* __cur = _M_head._M_next; - if (__cur) { - while (__cur->_M_next) { - if (((_Node*)__cur)->_M_data == - ((_Node*)(__cur->_M_next))->_M_data) - _M_erase_after(__cur); - else - __cur = __cur->_M_next; - } - } -} - -template -void slist<_Tp,_Alloc>::merge(slist<_Tp,_Alloc>& __x) -{ - _Node_base* __n1 = &_M_head; - while (__n1->_M_next && __x._M_head._M_next) { - if (((_Node*) __x._M_head._M_next)->_M_data < - ((_Node*) __n1->_M_next)->_M_data) - __slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next); - __n1 = __n1->_M_next; - } - if (__x._M_head._M_next) { - __n1->_M_next = __x._M_head._M_next; - __x._M_head._M_next = 0; - } -} - -template -void slist<_Tp,_Alloc>::sort() -{ - if (_M_head._M_next && _M_head._M_next->_M_next) { - slist __carry; - slist __counter[64]; - int __fill = 0; - while (!empty()) { - __slist_splice_after(&__carry._M_head, &_M_head, _M_head._M_next); - int __i = 0; - while (__i < __fill && !__counter[__i].empty()) { - __counter[__i].merge(__carry); - __carry.swap(__counter[__i]); - ++__i; - } - __carry.swap(__counter[__i]); - if (__i == __fill) - ++__fill; - } - - for (int __i = 1; __i < __fill; ++__i) - __counter[__i].merge(__counter[__i-1]); - this->swap(__counter[__fill-1]); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void slist<_Tp,_Alloc>::remove_if(_Predicate __pred) -{ - _Node_base* __cur = &_M_head; - while (__cur->_M_next) { - if (__pred(((_Node*) __cur->_M_next)->_M_data)) - _M_erase_after(__cur); - else - __cur = __cur->_M_next; - } -} - -template template -void slist<_Tp,_Alloc>::unique(_BinaryPredicate __pred) -{ - _Node* __cur = (_Node*) _M_head._M_next; - if (__cur) { - while (__cur->_M_next) { - if (__pred(((_Node*)__cur)->_M_data, - ((_Node*)(__cur->_M_next))->_M_data)) - _M_erase_after(__cur); - else - __cur = (_Node*) __cur->_M_next; - } - } -} - -template template -void slist<_Tp,_Alloc>::merge(slist<_Tp,_Alloc>& __x, - _StrictWeakOrdering __comp) -{ - _Node_base* __n1 = &_M_head; - while (__n1->_M_next && __x._M_head._M_next) { - if (__comp(((_Node*) __x._M_head._M_next)->_M_data, - ((_Node*) __n1->_M_next)->_M_data)) - __slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next); - __n1 = __n1->_M_next; - } - if (__x._M_head._M_next) { - __n1->_M_next = __x._M_head._M_next; - __x._M_head._M_next = 0; - } -} - -template template -void slist<_Tp,_Alloc>::sort(_StrictWeakOrdering __comp) -{ - if (_M_head._M_next && _M_head._M_next->_M_next) { - slist __carry; - slist __counter[64]; - int __fill = 0; - while (!empty()) { - __slist_splice_after(&__carry._M_head, &_M_head, _M_head._M_next); - int __i = 0; - while (__i < __fill && !__counter[__i].empty()) { - __counter[__i].merge(__carry, __comp); - __carry.swap(__counter[__i]); - ++__i; - } - __carry.swap(__counter[__i]); - if (__i == __fill) - ++__fill; - } - - for (int __i = 1; __i < __fill; ++__i) - __counter[__i].merge(__counter[__i-1], __comp); - this->swap(__counter[__fill-1]); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_SLIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_stack.h b/libstdc++/stl/stl_stack.h deleted file mode 100644 index 2a04b21e507..00000000000 --- a/libstdc++/stl/stl_stack.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_STACK_H -#define __SGI_STL_INTERNAL_STACK_H - -__STL_BEGIN_NAMESPACE - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template > -#else -template -#endif -class stack { - friend bool operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&); - friend bool operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&); -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 _M_c; -public: - stack() : _M_c() {} - explicit stack(const _Sequence& __s) : _M_c(__s) {} - - bool empty() const { return _M_c.empty(); } - size_type size() const { return _M_c.size(); } - reference top() { return _M_c.back(); } - const_reference top() const { return _M_c.back(); } - void push(const value_type& __x) { _M_c.push_back(__x); } - void pop() { _M_c.pop_back(); } -}; - -template -bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return __x._M_c == __y._M_c; -} - -template -bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return __x._M_c < __y._M_c; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return !(__x == __y); -} - -template -bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return __y < __x; -} - -template -bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return !(__y < __x); -} - -template -bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_STACK_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_tempbuf.h b/libstdc++/stl/stl_tempbuf.h deleted file mode 100644 index e1b2eadafcb..00000000000 --- a/libstdc++/stl/stl_tempbuf.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_TEMPBUF_H -#define __SGI_STL_INTERNAL_TEMPBUF_H - - -__STL_BEGIN_NAMESPACE - -template -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*) malloc((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); -} - -#ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS - -template -inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) { - return __get_temporary_buffer(__len, (_Tp*) 0); -} - -#endif /* __STL_EXPLICIT_FUNCTION_TMPL_ARGS */ - -// This overload is not required by the standard; it is an extension. -// It is supported for backward compatibility with the HP STL, and -// because not all compilers support the language feature (explicit -// function template arguments) that is required for the standard -// version of get_temporary_buffer. -template -inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len, _Tp*) { - return __get_temporary_buffer(__len, (_Tp*) 0); -} - -template -void return_temporary_buffer(_Tp* __p) { - free(__p); -} - -template -class _Temporary_buffer { -private: - ptrdiff_t _M_original_len; - ptrdiff_t _M_len; - _Tp* _M_buffer; - - void _M_allocate_buffer() { - _M_original_len = _M_len; - _M_buffer = 0; - - if (_M_len > (ptrdiff_t)(INT_MAX / sizeof(_Tp))) - _M_len = INT_MAX / sizeof(_Tp); - - while (_M_len > 0) { - _M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp)); - if (_M_buffer) - break; - _M_len /= 2; - } - } - - void _M_initialize_buffer(const _Tp&, __true_type) {} - void _M_initialize_buffer(const _Tp& val, __false_type) { - uninitialized_fill_n(_M_buffer, _M_len, val); - } - -public: - ptrdiff_t size() const { return _M_len; } - ptrdiff_t requested_size() const { return _M_original_len; } - _Tp* begin() { return _M_buffer; } - _Tp* end() { return _M_buffer + _M_len; } - - _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) { - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Trivial; - __STL_TRY { - _M_len = 0; - distance(__first, __last, _M_len); - _M_allocate_buffer(); - if (_M_len > 0) - _M_initialize_buffer(*__first, _Trivial()); - } - __STL_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0); - } - - ~_Temporary_buffer() { - destroy(_M_buffer, _M_buffer + _M_len); - free(_M_buffer); - } - -private: - // Disable copy constructor and assignment operator. - _Temporary_buffer(const _Temporary_buffer&) {} - void operator=(const _Temporary_buffer&) {} -}; - -// Class temporary_buffer is not part of the standard. It is an extension. - -template ::value_type -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - > -struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> -{ - temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) - : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) {} - ~temporary_buffer() {} -}; - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_TEMPBUF_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_tree.h b/libstdc++/stl/stl_tree.h deleted file mode 100644 index c82943f568a..00000000000 --- a/libstdc++/stl/stl_tree.h +++ /dev/null @@ -1,1333 +0,0 @@ -/* - * - * 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. - * - * - * 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. - * - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_TREE_H -#define __SGI_STL_INTERNAL_TREE_H - -/* - -Red-black tree class, designed for use in implementing STL -associative containers (set, multiset, map, and multimap). The -insertion and deletion algorithms are based on those in Cormen, -Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990), -except that - -(1) the header cell is maintained with links not only to the root -but also to the leftmost node of the tree, to enable constant time -begin(), and to the rightmost node of the tree, to enable linear time -performance when used with the generic set algorithms (set_union, -etc.); - -(2) when a node being deleted has two children its successor node is -relinked into its place, rather than copied, so that the only -iterators invalidated are those referring to the deleted node. - -*/ - -#include -#include -#include -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1375 -#endif - -typedef bool _Rb_tree_Color_type; -const _Rb_tree_Color_type _S_rb_tree_red = false; -const _Rb_tree_Color_type _S_rb_tree_black = true; - -struct _Rb_tree_node_base -{ - typedef _Rb_tree_Color_type _Color_type; - typedef _Rb_tree_node_base* _Base_ptr; - - _Color_type _M_color; - _Base_ptr _M_parent; - _Base_ptr _M_left; - _Base_ptr _M_right; - - static _Base_ptr _S_minimum(_Base_ptr __x) - { - while (__x->_M_left != 0) __x = __x->_M_left; - return __x; - } - - static _Base_ptr _S_maximum(_Base_ptr __x) - { - while (__x->_M_right != 0) __x = __x->_M_right; - return __x; - } -}; - -template -struct _Rb_tree_node : public _Rb_tree_node_base -{ - typedef _Rb_tree_node<_Value>* _Link_type; - _Value _M_value_field; -}; - - -struct _Rb_tree_base_iterator -{ - typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; - typedef bidirectional_iterator_tag iterator_category; - typedef ptrdiff_t difference_type; - _Base_ptr _M_node; - - void _M_increment() - { - if (_M_node->_M_right != 0) { - _M_node = _M_node->_M_right; - while (_M_node->_M_left != 0) - _M_node = _M_node->_M_left; - } - else { - _Base_ptr __y = _M_node->_M_parent; - while (_M_node == __y->_M_right) { - _M_node = __y; - __y = __y->_M_parent; - } - if (_M_node->_M_right != __y) - _M_node = __y; - } - } - - void _M_decrement() - { - if (_M_node->_M_color == _S_rb_tree_red && - _M_node->_M_parent->_M_parent == _M_node) - _M_node = _M_node->_M_right; - else if (_M_node->_M_left != 0) { - _Base_ptr __y = _M_node->_M_left; - while (__y->_M_right != 0) - __y = __y->_M_right; - _M_node = __y; - } - else { - _Base_ptr __y = _M_node->_M_parent; - while (_M_node == __y->_M_left) { - _M_node = __y; - __y = __y->_M_parent; - } - _M_node = __y; - } - } -}; - -template -struct _Rb_tree_iterator : public _Rb_tree_base_iterator -{ - typedef _Value value_type; - typedef _Ref reference; - typedef _Ptr pointer; - typedef _Rb_tree_iterator<_Value, _Value&, _Value*> - iterator; - typedef _Rb_tree_iterator<_Value, const _Value&, const _Value*> - const_iterator; - typedef _Rb_tree_iterator<_Value, _Ref, _Ptr> - _Self; - typedef _Rb_tree_node<_Value>* _Link_type; - - _Rb_tree_iterator() {} - _Rb_tree_iterator(_Link_type __x) { _M_node = __x; } - _Rb_tree_iterator(const iterator& __it) { _M_node = __it._M_node; } - - reference operator*() const { return _Link_type(_M_node)->_M_value_field; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() { _M_increment(); return *this; } - _Self operator++(int) { - _Self __tmp = *this; - _M_increment(); - return __tmp; - } - - _Self& operator--() { _M_decrement(); return *this; } - _Self operator--(int) { - _Self __tmp = *this; - _M_decrement(); - return __tmp; - } -}; - -inline bool operator==(const _Rb_tree_base_iterator& __x, - const _Rb_tree_base_iterator& __y) { - return __x._M_node == __y._M_node; -} - -inline bool operator!=(const _Rb_tree_base_iterator& __x, - const _Rb_tree_base_iterator& __y) { - return __x._M_node != __y._M_node; -} - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -inline bidirectional_iterator_tag -iterator_category(const _Rb_tree_base_iterator&) { - return bidirectional_iterator_tag(); -} - -inline _Rb_tree_base_iterator::difference_type* -distance_type(const _Rb_tree_base_iterator&) { - return (_Rb_tree_base_iterator::difference_type*) 0; -} - -template -inline _Value* value_type(const _Rb_tree_iterator<_Value, _Ref, _Ptr>&) { - return (_Value*) 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -inline void -_Rb_tree_rotate_left(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root) -{ - _Rb_tree_node_base* __y = __x->_M_right; - __x->_M_right = __y->_M_left; - if (__y->_M_left !=0) - __y->_M_left->_M_parent = __x; - __y->_M_parent = __x->_M_parent; - - if (__x == __root) - __root = __y; - else if (__x == __x->_M_parent->_M_left) - __x->_M_parent->_M_left = __y; - else - __x->_M_parent->_M_right = __y; - __y->_M_left = __x; - __x->_M_parent = __y; -} - -inline void -_Rb_tree_rotate_right(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root) -{ - _Rb_tree_node_base* __y = __x->_M_left; - __x->_M_left = __y->_M_right; - if (__y->_M_right != 0) - __y->_M_right->_M_parent = __x; - __y->_M_parent = __x->_M_parent; - - if (__x == __root) - __root = __y; - else if (__x == __x->_M_parent->_M_right) - __x->_M_parent->_M_right = __y; - else - __x->_M_parent->_M_left = __y; - __y->_M_right = __x; - __x->_M_parent = __y; -} - -inline void -_Rb_tree_rebalance(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root) -{ - __x->_M_color = _S_rb_tree_red; - while (__x != __root && __x->_M_parent->_M_color == _S_rb_tree_red) { - if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left) { - _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right; - if (__y && __y->_M_color == _S_rb_tree_red) { - __x->_M_parent->_M_color = _S_rb_tree_black; - __y->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - __x = __x->_M_parent->_M_parent; - } - else { - if (__x == __x->_M_parent->_M_right) { - __x = __x->_M_parent; - _Rb_tree_rotate_left(__x, __root); - } - __x->_M_parent->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_right(__x->_M_parent->_M_parent, __root); - } - } - else { - _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left; - if (__y && __y->_M_color == _S_rb_tree_red) { - __x->_M_parent->_M_color = _S_rb_tree_black; - __y->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - __x = __x->_M_parent->_M_parent; - } - else { - if (__x == __x->_M_parent->_M_left) { - __x = __x->_M_parent; - _Rb_tree_rotate_right(__x, __root); - } - __x->_M_parent->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_left(__x->_M_parent->_M_parent, __root); - } - } - } - __root->_M_color = _S_rb_tree_black; -} - -inline _Rb_tree_node_base* -_Rb_tree_rebalance_for_erase(_Rb_tree_node_base* __z, - _Rb_tree_node_base*& __root, - _Rb_tree_node_base*& __leftmost, - _Rb_tree_node_base*& __rightmost) -{ - _Rb_tree_node_base* __y = __z; - _Rb_tree_node_base* __x = 0; - _Rb_tree_node_base* __x_parent = 0; - if (__y->_M_left == 0) // __z has at most one non-null child. y == z. - __x = __y->_M_right; // __x might be null. - else - if (__y->_M_right == 0) // __z has exactly one non-null child. y == z. - __x = __y->_M_left; // __x is not null. - else { // __z has two non-null children. Set __y to - __y = __y->_M_right; // __z's successor. __x might be null. - while (__y->_M_left != 0) - __y = __y->_M_left; - __x = __y->_M_right; - } - if (__y != __z) { // relink y in place of z. y is z's successor - __z->_M_left->_M_parent = __y; - __y->_M_left = __z->_M_left; - if (__y != __z->_M_right) { - __x_parent = __y->_M_parent; - if (__x) __x->_M_parent = __y->_M_parent; - __y->_M_parent->_M_left = __x; // __y must be a child of _M_left - __y->_M_right = __z->_M_right; - __z->_M_right->_M_parent = __y; - } - else - __x_parent = __y; - if (__root == __z) - __root = __y; - else if (__z->_M_parent->_M_left == __z) - __z->_M_parent->_M_left = __y; - else - __z->_M_parent->_M_right = __y; - __y->_M_parent = __z->_M_parent; - __STD::swap(__y->_M_color, __z->_M_color); - __y = __z; - // __y now points to node to be actually deleted - } - else { // __y == __z - __x_parent = __y->_M_parent; - if (__x) __x->_M_parent = __y->_M_parent; - if (__root == __z) - __root = __x; - else - if (__z->_M_parent->_M_left == __z) - __z->_M_parent->_M_left = __x; - else - __z->_M_parent->_M_right = __x; - if (__leftmost == __z) - if (__z->_M_right == 0) // __z->_M_left must be null also - __leftmost = __z->_M_parent; - // makes __leftmost == _M_header if __z == __root - else - __leftmost = _Rb_tree_node_base::_S_minimum(__x); - if (__rightmost == __z) - if (__z->_M_left == 0) // __z->_M_right must be null also - __rightmost = __z->_M_parent; - // makes __rightmost == _M_header if __z == __root - else // __x == __z->_M_left - __rightmost = _Rb_tree_node_base::_S_maximum(__x); - } - if (__y->_M_color != _S_rb_tree_red) { - while (__x != __root && (__x == 0 || __x->_M_color == _S_rb_tree_black)) - if (__x == __x_parent->_M_left) { - _Rb_tree_node_base* __w = __x_parent->_M_right; - if (__w->_M_color == _S_rb_tree_red) { - __w->_M_color = _S_rb_tree_black; - __x_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_left(__x_parent, __root); - __w = __x_parent->_M_right; - } - if ((__w->_M_left == 0 || - __w->_M_left->_M_color == _S_rb_tree_black) && - (__w->_M_right == 0 || - __w->_M_right->_M_color == _S_rb_tree_black)) { - __w->_M_color = _S_rb_tree_red; - __x = __x_parent; - __x_parent = __x_parent->_M_parent; - } else { - if (__w->_M_right == 0 || - __w->_M_right->_M_color == _S_rb_tree_black) { - if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; - __w->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_right(__w, __root); - __w = __x_parent->_M_right; - } - __w->_M_color = __x_parent->_M_color; - __x_parent->_M_color = _S_rb_tree_black; - if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; - _Rb_tree_rotate_left(__x_parent, __root); - break; - } - } else { // same as above, with _M_right <-> _M_left. - _Rb_tree_node_base* __w = __x_parent->_M_left; - if (__w->_M_color == _S_rb_tree_red) { - __w->_M_color = _S_rb_tree_black; - __x_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_right(__x_parent, __root); - __w = __x_parent->_M_left; - } - if ((__w->_M_right == 0 || - __w->_M_right->_M_color == _S_rb_tree_black) && - (__w->_M_left == 0 || - __w->_M_left->_M_color == _S_rb_tree_black)) { - __w->_M_color = _S_rb_tree_red; - __x = __x_parent; - __x_parent = __x_parent->_M_parent; - } else { - if (__w->_M_left == 0 || - __w->_M_left->_M_color == _S_rb_tree_black) { - if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; - __w->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_left(__w, __root); - __w = __x_parent->_M_left; - } - __w->_M_color = __x_parent->_M_color; - __x_parent->_M_color = _S_rb_tree_black; - if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; - _Rb_tree_rotate_right(__x_parent, __root); - break; - } - } - if (__x) __x->_M_color = _S_rb_tree_black; - } - return __y; -} - -// Base class to encapsulate the differences between old SGI-style -// allocators and standard-conforming allocators. In order to avoid -// having an empty base class, we arbitrarily move one of rb_tree's -// data members into the base class. - -#ifdef __STL_USE_STD_ALLOCATORS - -// _Base for general standard-conforming allocators. -template -class _Rb_tree_alloc_base { -public: - typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } - - _Rb_tree_alloc_base(const allocator_type& __a) - : _M_node_allocator(__a), _M_header(0) {} - -protected: - typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::allocator_type - _M_node_allocator; - _Rb_tree_node<_Tp>* _M_header; - - _Rb_tree_node<_Tp>* _M_get_node() - { return _M_node_allocator.allocate(1); } - void _M_put_node(_Rb_tree_node<_Tp>* __p) - { _M_node_allocator.deallocate(__p, 1); } -}; - -// Specialization for instanceless allocators. -template -class _Rb_tree_alloc_base<_Tp, _Alloc, true> { -public: - typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Rb_tree_alloc_base(const allocator_type&) : _M_header(0) {} - -protected: - _Rb_tree_node<_Tp>* _M_header; - - typedef typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::_Alloc_type - _Alloc_type; - - _Rb_tree_node<_Tp>* _M_get_node() - { return _Alloc_type::allocate(1); } - void _M_put_node(_Rb_tree_node<_Tp>* __p) - { _Alloc_type::deallocate(__p, 1); } -}; - -template -struct _Rb_tree_base - : public _Rb_tree_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ - typedef _Rb_tree_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - - _Rb_tree_base(const allocator_type& __a) - : _Base(__a) { _M_header = _M_get_node(); } - ~_Rb_tree_base() { _M_put_node(_M_header); } - -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -struct _Rb_tree_base -{ - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Rb_tree_base(const allocator_type&) - : _M_header(0) { _M_header = _M_get_node(); } - ~_Rb_tree_base() { _M_put_node(_M_header); } - -protected: - _Rb_tree_node<_Tp>* _M_header; - - typedef simple_alloc<_Rb_tree_node<_Tp>, _Alloc> _Alloc_type; - - _Rb_tree_node<_Tp>* _M_get_node() - { return _Alloc_type::allocate(1); } - void _M_put_node(_Rb_tree_node<_Tp>* __p) - { _Alloc_type::deallocate(__p, 1); } -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -class _Rb_tree : protected _Rb_tree_base<_Value, _Alloc> { - typedef _Rb_tree_base<_Value, _Alloc> _Base; -protected: - typedef _Rb_tree_node_base* _Base_ptr; - typedef _Rb_tree_node<_Value> _Rb_tree_node; - typedef _Rb_tree_Color_type _Color_type; -public: - typedef _Key key_type; - typedef _Value value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef _Rb_tree_node* _Link_type; - 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(); } - -protected: -#ifdef __STL_USE_NAMESPACES - using _Base::_M_get_node; - using _Base::_M_put_node; - using _Base::_M_header; -#endif /* __STL_USE_NAMESPACES */ - -protected: - - _Link_type _M_create_node(const value_type& __x) - { - _Link_type __tmp = _M_get_node(); - __STL_TRY { - construct(&__tmp->_M_value_field, __x); - } - __STL_UNWIND(_M_put_node(__tmp)); - return __tmp; - } - - _Link_type _M_clone_node(_Link_type __x) - { - _Link_type __tmp = _M_create_node(__x->_M_value_field); - __tmp->_M_color = __x->_M_color; - __tmp->_M_left = 0; - __tmp->_M_right = 0; - return __tmp; - } - - void destroy_node(_Link_type __p) - { - destroy(&__p->_M_value_field); - _M_put_node(__p); - } - -protected: - size_type _M_node_count; // keeps track of size of tree - _Compare _M_key_compare; - - _Link_type& _M_root() const - { return (_Link_type&) _M_header->_M_parent; } - _Link_type& _M_leftmost() const - { return (_Link_type&) _M_header->_M_left; } - _Link_type& _M_rightmost() const - { return (_Link_type&) _M_header->_M_right; } - - static _Link_type& _S_left(_Link_type __x) - { return (_Link_type&)(__x->_M_left); } - static _Link_type& _S_right(_Link_type __x) - { return (_Link_type&)(__x->_M_right); } - static _Link_type& _S_parent(_Link_type __x) - { return (_Link_type&)(__x->_M_parent); } - static reference _S_value(_Link_type __x) - { return __x->_M_value_field; } - static const _Key& _S_key(_Link_type __x) - { return _KeyOfValue()(_S_value(__x)); } - static _Color_type& _S_color(_Link_type __x) - { return (_Color_type&)(__x->_M_color); } - - static _Link_type& _S_left(_Base_ptr __x) - { return (_Link_type&)(__x->_M_left); } - static _Link_type& _S_right(_Base_ptr __x) - { return (_Link_type&)(__x->_M_right); } - static _Link_type& _S_parent(_Base_ptr __x) - { return (_Link_type&)(__x->_M_parent); } - static reference _S_value(_Base_ptr __x) - { return ((_Link_type)__x)->_M_value_field; } - static const _Key& _S_key(_Base_ptr __x) - { return _KeyOfValue()(_S_value(_Link_type(__x)));} - static _Color_type& _S_color(_Base_ptr __x) - { return (_Color_type&)(_Link_type(__x)->_M_color); } - - static _Link_type _S_minimum(_Link_type __x) - { return (_Link_type) _Rb_tree_node_base::_S_minimum(__x); } - - static _Link_type _S_maximum(_Link_type __x) - { return (_Link_type) _Rb_tree_node_base::_S_maximum(__x); } - -public: - typedef _Rb_tree_iterator iterator; - typedef _Rb_tree_iterator - const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_bidirectional_iterator - reverse_iterator; - typedef reverse_bidirectional_iterator - const_reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -private: - iterator _M_insert(_Base_ptr __x, _Base_ptr __y, const value_type& __v); - _Link_type _M_copy(_Link_type __x, _Link_type __p); - void _M_erase(_Link_type __x); - -public: - // allocation/deallocation - _Rb_tree() - : _Base(allocator_type()), _M_node_count(0), _M_key_compare() - { _M_empty_initialize(); } - - _Rb_tree(const _Compare& __comp) - : _Base(allocator_type()), _M_node_count(0), _M_key_compare(__comp) - { _M_empty_initialize(); } - - _Rb_tree(const _Compare& __comp, const allocator_type& __a) - : _Base(__a), _M_node_count(0), _M_key_compare(__comp) - { _M_empty_initialize(); } - - _Rb_tree(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x) - : _Base(__x.get_allocator()), - _M_node_count(0), _M_key_compare(__x._M_key_compare) - { - if (__x._M_root() == 0) - _M_empty_initialize(); - else { - _S_color(_M_header) = _S_rb_tree_red; - _M_root() = _M_copy(__x._M_root(), _M_header); - _M_leftmost() = _S_minimum(_M_root()); - _M_rightmost() = _S_maximum(_M_root()); - } - _M_node_count = __x._M_node_count; - } - ~_Rb_tree() { clear(); } - _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& - operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x); - -private: - void _M_empty_initialize() { - _S_color(_M_header) = _S_rb_tree_red; // used to distinguish header from - // __root, in iterator.operator++ - _M_root() = 0; - _M_leftmost() = _M_header; - _M_rightmost() = _M_header; - } - -public: - // accessors: - _Compare key_comp() const { return _M_key_compare; } - iterator begin() { return _M_leftmost(); } - const_iterator begin() const { return _M_leftmost(); } - iterator end() { return _M_header; } - const_iterator end() const { return _M_header; } - 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_count == 0; } - size_type size() const { return _M_node_count; } - size_type max_size() const { return size_type(-1); } - - void swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __t) { - __STD::swap(_M_header, __t._M_header); - __STD::swap(_M_node_count, __t._M_node_count); - __STD::swap(_M_key_compare, __t._M_key_compare); - } - -public: - // insert/erase - pair insert_unique(const value_type& __x); - iterator insert_equal(const value_type& __x); - - iterator insert_unique(iterator __position, const value_type& __x); - iterator insert_equal(iterator __position, const value_type& __x); - -#ifdef __STL_MEMBER_TEMPLATES - template - void insert_unique(_InputIterator __first, _InputIterator __last); - template - void insert_equal(_InputIterator __first, _InputIterator __last); -#else /* __STL_MEMBER_TEMPLATES */ - void insert_unique(const_iterator __first, const_iterator __last); - void insert_unique(const value_type* __first, const value_type* __last); - void insert_equal(const_iterator __first, const_iterator __last); - void insert_equal(const value_type* __first, const value_type* __last); -#endif /* __STL_MEMBER_TEMPLATES */ - - void erase(iterator __position); - size_type erase(const key_type& __x); - void erase(iterator __first, iterator __last); - void erase(const key_type* __first, const key_type* __last); - void clear() { - if (_M_node_count != 0) { - _M_erase(_M_root()); - _M_leftmost() = _M_header; - _M_root() = 0; - _M_rightmost() = _M_header; - _M_node_count = 0; - } - } - -public: - // set operations: - iterator find(const key_type& __x); - const_iterator find(const key_type& __x) const; - size_type count(const key_type& __x) const; - iterator lower_bound(const key_type& __x); - const_iterator lower_bound(const key_type& __x) const; - iterator upper_bound(const key_type& __x); - const_iterator upper_bound(const key_type& __x) const; - pair equal_range(const key_type& __x); - pair equal_range(const key_type& __x) const; - -public: - // Debugging. - bool __rb_verify() const; -}; - -template -inline bool -operator==(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) -{ - return __x.size() == __y.size() && - equal(__x.begin(), __x.end(), __y.begin()); -} - -template -inline bool -operator<(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void -swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) -{ - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x) -{ - if (this != &__x) { - // Note that _Key may be a constant type. - clear(); - _M_node_count = 0; - _M_key_compare = __x._M_key_compare; - if (__x._M_root() == 0) { - _M_root() = 0; - _M_leftmost() = _M_header; - _M_rightmost() = _M_header; - } - else { - _M_root() = _M_copy(__x._M_root(), _M_header); - _M_leftmost() = _S_minimum(_M_root()); - _M_rightmost() = _S_maximum(_M_root()); - _M_node_count = __x._M_node_count; - } - } - return *this; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::_M_insert(_Base_ptr __x_, _Base_ptr __y_, const _Value& __v) -{ - _Link_type __x = (_Link_type) __x_; - _Link_type __y = (_Link_type) __y_; - _Link_type __z; - - if (__y == _M_header || __x != 0 || - _M_key_compare(_KeyOfValue()(__v), _S_key(__y))) { - __z = _M_create_node(__v); - _S_left(__y) = __z; // also makes _M_leftmost() = __z - // when __y == _M_header - if (__y == _M_header) { - _M_root() = __z; - _M_rightmost() = __z; - } - else if (__y == _M_leftmost()) - _M_leftmost() = __z; // maintain _M_leftmost() pointing to min node - } - else { - __z = _M_create_node(__v); - _S_right(__y) = __z; - if (__y == _M_rightmost()) - _M_rightmost() = __z; // maintain _M_rightmost() pointing to max node - } - _S_parent(__z) = __y; - _S_left(__z) = 0; - _S_right(__z) = 0; - _Rb_tree_rebalance(__z, _M_header->_M_parent); - ++_M_node_count; - return iterator(__z); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::insert_equal(const _Value& __v) -{ - _Link_type __y = _M_header; - _Link_type __x = _M_root(); - while (__x != 0) { - __y = __x; - __x = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ? - _S_left(__x) : _S_right(__x); - } - return _M_insert(__x, __y, __v); -} - - -template -pair::iterator, - bool> -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::insert_unique(const _Value& __v) -{ - _Link_type __y = _M_header; - _Link_type __x = _M_root(); - bool __comp = true; - while (__x != 0) { - __y = __x; - __comp = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)); - __x = __comp ? _S_left(__x) : _S_right(__x); - } - iterator __j = iterator(__y); - if (__comp) - if (__j == begin()) - return pair(_M_insert(__x, __y, __v), true); - else - --__j; - if (_M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v))) - return pair(_M_insert(__x, __y, __v), true); - return pair(__j, false); -} - - -template -typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator -_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc> - ::insert_unique(iterator __position, const _Val& __v) -{ - if (__position._M_node == _M_header->_M_left) { // begin() - if (size() > 0 && - _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node))) - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - else - return insert_unique(__v).first; - } else if (__position._M_node == _M_header) { // end() - if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__v))) - return _M_insert(0, _M_rightmost(), __v); - else - return insert_unique(__v).first; - } else { - iterator __before = __position; - --__before; - if (_M_key_compare(_S_key(__before._M_node), _KeyOfValue()(__v)) - && _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node))) { - if (_S_right(__before._M_node) == 0) - return _M_insert(0, __before._M_node, __v); - else - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - } else - return insert_unique(__v).first; - } -} - -template -typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc> - ::insert_equal(iterator __position, const _Val& __v) -{ - if (__position._M_node == _M_header->_M_left) { // begin() - if (size() > 0 && - _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node))) - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - else - return insert_equal(__v); - } else if (__position._M_node == _M_header) {// end() - if (!_M_key_compare(_KeyOfValue()(__v), _S_key(_M_rightmost()))) - return _M_insert(0, _M_rightmost(), __v); - else - return insert_equal(__v); - } else { - iterator __before = __position; - --__before; - if (!_M_key_compare(_KeyOfValue()(__v), _S_key(__before._M_node)) - && !_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v))) { - if (_S_right(__before._M_node) == 0) - return _M_insert(0, __before._M_node, __v); - else - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - } else - return insert_equal(__v); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template - template -void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_equal(_II __first, _II __last) -{ - for ( ; __first != __last; ++__first) - insert_equal(*__first); -} - -template - template -void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_unique(_II __first, _II __last) { - for ( ; __first != __last; ++__first) - insert_unique(*__first); -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_equal(const _Val* __first, const _Val* __last) -{ - for ( ; __first != __last; ++__first) - insert_equal(*__first); -} - -template -void -_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_equal(const_iterator __first, const_iterator __last) -{ - for ( ; __first != __last; ++__first) - insert_equal(*__first); -} - -template -void -_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_unique(const _Val* __first, const _Val* __last) -{ - for ( ; __first != __last; ++__first) - insert_unique(*__first); -} - -template -void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_unique(const_iterator __first, const_iterator __last) -{ - for ( ; __first != __last; ++__first) - insert_unique(*__first); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -inline void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::erase(iterator __position) -{ - _Link_type __y = - (_Link_type) _Rb_tree_rebalance_for_erase(__position._M_node, - _M_header->_M_parent, - _M_header->_M_left, - _M_header->_M_right); - destroy_node(__y); - --_M_node_count; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::erase(const _Key& __x) -{ - pair __p = equal_range(__x); - size_type __n = 0; - distance(__p.first, __p.second, __n); - erase(__p.first, __p.second); - return __n; -} - -template -typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type -_Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc> - ::_M_copy(_Link_type __x, _Link_type __p) -{ - // structural copy. __x and __p must be non-null. - _Link_type __top = _M_clone_node(__x); - __top->_M_parent = __p; - - __STL_TRY { - if (__x->_M_right) - __top->_M_right = _M_copy(_S_right(__x), __top); - __p = __top; - __x = _S_left(__x); - - while (__x != 0) { - _Link_type __y = _M_clone_node(__x); - __p->_M_left = __y; - __y->_M_parent = __p; - if (__x->_M_right) - __y->_M_right = _M_copy(_S_right(__x), __y); - __p = __y; - __x = _S_left(__x); - } - } - __STL_UNWIND(_M_erase(__top)); - - return __top; -} - -template -void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::_M_erase(_Link_type __x) -{ - // erase without rebalancing - while (__x != 0) { - _M_erase(_S_right(__x)); - _Link_type __y = _S_left(__x); - destroy_node(__x); - __x = __y; - } -} - -template -void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::erase(iterator __first, iterator __last) -{ - if (__first == begin() && __last == end()) - clear(); - else - while (__first != __last) erase(__first++); -} - -template -void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::erase(const _Key* __first, const _Key* __last) -{ - while (__first != __last) erase(*__first++); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) -{ - _Link_type __y = _M_header; // Last node which is not less than __k. - _Link_type __x = _M_root(); // Current node. - - while (__x != 0) - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - iterator __j = iterator(__y); - return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ? - end() : __j; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) const -{ - _Link_type __y = _M_header; /* Last node which is not less than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) { - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - } - const_iterator __j = const_iterator(__y); - return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ? - end() : __j; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::count(const _Key& __k) const -{ - pair __p = equal_range(__k); - size_type __n = 0; - distance(__p.first, __p.second, __n); - return __n; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::lower_bound(const _Key& __k) -{ - _Link_type __y = _M_header; /* Last node which is not less than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return iterator(__y); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::lower_bound(const _Key& __k) const -{ - _Link_type __y = _M_header; /* Last node which is not less than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return const_iterator(__y); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::upper_bound(const _Key& __k) -{ - _Link_type __y = _M_header; /* Last node which is greater than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (_M_key_compare(__k, _S_key(__x))) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return iterator(__y); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::upper_bound(const _Key& __k) const -{ - _Link_type __y = _M_header; /* Last node which is greater than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (_M_key_compare(__k, _S_key(__x))) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return const_iterator(__y); -} - -template -inline -pair::iterator, - typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator> -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::equal_range(const _Key& __k) -{ - return pair(lower_bound(__k), upper_bound(__k)); -} - -template -inline -pair::const_iterator, - typename _Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>::const_iterator> -_Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc> - ::equal_range(const _Key& __k) const -{ - return pair(lower_bound(__k), - upper_bound(__k)); -} - -inline int -__black_count(_Rb_tree_node_base* __node, _Rb_tree_node_base* __root) -{ - if (__node == 0) - return 0; - else { - int __bc = __node->_M_color == _S_rb_tree_black ? 1 : 0; - if (__node == __root) - return __bc; - else - return __bc + __black_count(__node->_M_parent, __root); - } -} - -template -bool _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const -{ - if (_M_node_count == 0 || begin() == end()) - return _M_node_count == 0 && begin() == end() && - _M_header->_M_left == _M_header && _M_header->_M_right == _M_header; - - int __len = __black_count(_M_leftmost(), _M_root()); - for (const_iterator __it = begin(); __it != end(); ++__it) { - _Link_type __x = (_Link_type) __it._M_node; - _Link_type __L = _S_left(__x); - _Link_type __R = _S_right(__x); - - if (__x->_M_color == _S_rb_tree_red) - if ((__L && __L->_M_color == _S_rb_tree_red) || - (__R && __R->_M_color == _S_rb_tree_red)) - return false; - - if (__L && _M_key_compare(_S_key(__x), _S_key(__L))) - return false; - if (__R && _M_key_compare(_S_key(__R), _S_key(__x))) - return false; - - if (!__L && !__R && __black_count(__x, _M_root()) != __len) - return false; - } - - if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root())) - return false; - if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root())) - return false; - - return true; -} - -// Class rb_tree is not part of the C++ standard. It is provided for -// compatibility with the HP STL. - -template -struct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> -{ - typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base; - typedef typename _Base::allocator_type allocator_type; - - rb_tree(const _Compare& __comp = _Compare(), - const allocator_type& __a = allocator_type()) - : _Base(__comp, __a) {} - - ~rb_tree() {} -}; - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_TREE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_uninitialized.h b/libstdc++/stl/stl_uninitialized.h deleted file mode 100644 index 3146c82a71c..00000000000 --- a/libstdc++/stl/stl_uninitialized.h +++ /dev/null @@ -1,279 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H -#define __SGI_STL_INTERNAL_UNINITIALIZED_H - -__STL_BEGIN_NAMESPACE - -// uninitialized_copy - -// Valid if copy construction is equivalent to assignment, and if the -// destructor is trivial. -template -inline _ForwardIter -__uninitialized_copy_aux(_InputIter __first, _InputIter __last, - _ForwardIter __result, - __true_type) -{ - return copy(__first, __last, __result); -} - -template -_ForwardIter -__uninitialized_copy_aux(_InputIter __first, _InputIter __last, - _ForwardIter __result, - __false_type) -{ - _ForwardIter __cur = __result; - __STL_TRY { - for ( ; __first != __last; ++__first, ++__cur) - construct(&*__cur, *__first); - return __cur; - } - __STL_UNWIND(destroy(__result, __cur)); -} - - -template -inline _ForwardIter -__uninitialized_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result, _Tp*) -{ - typedef typename __type_traits<_Tp>::is_POD_type _Is_POD; - return __uninitialized_copy_aux(__first, __last, __result, _Is_POD()); -} - -template -inline _ForwardIter - uninitialized_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result) -{ - return __uninitialized_copy(__first, __last, __result, - __VALUE_TYPE(__result)); -} - -inline char* uninitialized_copy(const char* __first, const char* __last, - char* __result) { - memmove(__result, __first, __last - __first); - return __result + (__last - __first); -} - -inline wchar_t* -uninitialized_copy(const wchar_t* __first, const wchar_t* __last, - wchar_t* __result) -{ - memmove(__result, __first, sizeof(wchar_t) * (__last - __first)); - return __result + (__last - __first); -} - -// uninitialized_copy_n (not part of the C++ standard) - -template -pair<_InputIter, _ForwardIter> -__uninitialized_copy_n(_InputIter __first, _Size __count, - _ForwardIter __result, - input_iterator_tag) -{ - _ForwardIter __cur = __result; - __STL_TRY { - for ( ; __count > 0 ; --__count, ++__first, ++__cur) - construct(&*__cur, *__first); - return pair<_InputIter, _ForwardIter>(__first, __cur); - } - __STL_UNWIND(destroy(__result, __cur)); -} - -template -inline pair<_RandomAccessIter, _ForwardIter> -__uninitialized_copy_n(_RandomAccessIter __first, _Size __count, - _ForwardIter __result, - random_access_iterator_tag) { - _RandomAccessIter __last = __first + __count; - return pair<_RandomAccessIter, _ForwardIter>( - __last, - uninitialized_copy(__first, __last, __result)); -} - -template -inline pair<_InputIter, _ForwardIter> -__uninitialized_copy_n(_InputIter __first, _Size __count, - _ForwardIter __result) { - return __uninitialized_copy_n(__first, __count, __result, - __ITERATOR_CATEGORY(__first)); -} - -template -inline pair<_InputIter, _ForwardIter> -uninitialized_copy_n(_InputIter __first, _Size __count, - _ForwardIter __result) { - return __uninitialized_copy_n(__first, __count, __result, - __ITERATOR_CATEGORY(__first)); -} - -// Valid if copy construction is equivalent to assignment, and if the -// destructor is trivial. -template -inline void -__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, - const _Tp& __x, __true_type) -{ - fill(__first, __last, __x); -} - -template -void -__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, - const _Tp& __x, __false_type) -{ - _ForwardIter __cur = __first; - __STL_TRY { - for ( ; __cur != __last; ++__cur) - construct(&*__cur, __x); - } - __STL_UNWIND(destroy(__first, __cur)); -} - -template -inline void __uninitialized_fill(_ForwardIter __first, - _ForwardIter __last, const _Tp& __x, _Tp1*) -{ - typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; - __uninitialized_fill_aux(__first, __last, __x, _Is_POD()); - -} - -template -inline void uninitialized_fill(_ForwardIter __first, - _ForwardIter __last, - const _Tp& __x) -{ - __uninitialized_fill(__first, __last, __x, __VALUE_TYPE(__first)); -} - -// Valid if copy construction is equivalent to assignment, and if the -// destructor is trivial. -template -inline _ForwardIter -__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, - const _Tp& __x, __true_type) -{ - return fill_n(__first, __n, __x); -} - -template -_ForwardIter -__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, - const _Tp& __x, __false_type) -{ - _ForwardIter __cur = __first; - __STL_TRY { - for ( ; __n > 0; --__n, ++__cur) - construct(&*__cur, __x); - return __cur; - } - __STL_UNWIND(destroy(__first, __cur)); -} - -template -inline _ForwardIter -__uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*) -{ - typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; - return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); -} - -template -inline _ForwardIter -uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) -{ - return __uninitialized_fill_n(__first, __n, __x, __VALUE_TYPE(__first)); -} - -// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, -// __uninitialized_fill_copy. - -// __uninitialized_copy_copy -// Copies [first1, last1) into [result, result + (last1 - first1)), and -// copies [first2, last2) into -// [result, result + (last1 - first1) + (last2 - first2)). - -template -inline _ForwardIter -__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _ForwardIter __result) -{ - _ForwardIter __mid = uninitialized_copy(__first1, __last1, __result); - __STL_TRY { - return uninitialized_copy(__first2, __last2, __mid); - } - __STL_UNWIND(destroy(__result, __mid)); -} - -// __uninitialized_fill_copy -// Fills [result, mid) with x, and copies [first, last) into -// [mid, mid + (last - first)). -template -inline _ForwardIter -__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, - const _Tp& __x, - _InputIter __first, _InputIter __last) -{ - uninitialized_fill(__result, __mid, __x); - __STL_TRY { - return uninitialized_copy(__first, __last, __mid); - } - __STL_UNWIND(destroy(__result, __mid)); -} - -// __uninitialized_copy_fill -// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and -// fills [first2 + (last1 - first1), last2) with x. -template -inline void -__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1, - _ForwardIter __first2, _ForwardIter __last2, - const _Tp& __x) -{ - _ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2); - __STL_TRY { - uninitialized_fill(__mid2, __last2, __x); - } - __STL_UNWIND(destroy(__first2, __mid2)); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_UNINITIALIZED_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/stl_vector.h b/libstdc++/stl/stl_vector.h deleted file mode 100644 index d1149e9af66..00000000000 --- a/libstdc++/stl/stl_vector.h +++ /dev/null @@ -1,823 +0,0 @@ -/* - * - * 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. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_VECTOR_H -#define __SGI_STL_INTERNAL_VECTOR_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// 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. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base class for ordinary allocators. -template -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 _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 -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); } -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _Vector_base { -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Vector_base(const _Alloc&) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) {} - _Vector_base(size_t __n, const _Alloc&) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) - { - _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); } - -protected: - _Tp* _M_start; - _Tp* _M_finish; - _Tp* _M_end_of_storage; - - typedef simple_alloc<_Tp, _Alloc> _M_data_allocator; - _Tp* _M_allocate(size_t __n) - { return _M_data_allocator::allocate(__n); } - void _M_deallocate(_Tp* __p, size_t __n) - { _M_data_allocator::deallocate(__p, __n); } -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -class vector : protected _Vector_base<_Tp, _Alloc> -{ -private: - typedef _Vector_base<_Tp, _Alloc> _Base; -public: - typedef _Tp value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type* iterator; - typedef const value_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(); } - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -protected: -#ifdef __STL_HAS_NAMESPACES - using _Base::_M_allocate; - using _Base::_M_deallocate; - using _Base::_M_start; - using _Base::_M_finish; - using _Base::_M_end_of_storage; -#endif /* __STL_HAS_NAMESPACES */ - -protected: - void _M_insert_aux(iterator __position, const _Tp& __x); - void _M_insert_aux(iterator __position); - -public: - iterator begin() { return _M_start; } - const_iterator begin() const { return _M_start; } - iterator end() { return _M_finish; } - const_iterator end() const { return _M_finish; } - - 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()); } - - size_type size() const - { return size_type(end() - begin()); } - size_type max_size() const - { return size_type(-1) / sizeof(_Tp); } - size_type capacity() const - { return size_type(_M_end_of_storage - begin()); } - bool empty() const - { return begin() == end(); } - - reference operator[](size_type __n) { return *(begin() + __n); } - const_reference operator[](size_type __n) const { return *(begin() + __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); } - -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - template - 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 - 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 - void _M_initialize_aux(_InputIterator __first, _InputIterator __last, - __false_type) { - _M_range_initialize(__first, __last, __ITERATOR_CATEGORY(__first)); - } - -#else - vector(const _Tp* __first, const _Tp* __last, - const allocator_type& __a = allocator_type()) - : _Base(__last - __first, __a) - { _M_finish = uninitialized_copy(__first, __last, _M_start); } -#endif /* __STL_MEMBER_TEMPLATES */ - - ~vector() { destroy(_M_start, _M_finish); } - - vector<_Tp, _Alloc>& operator=(const vector<_Tp, _Alloc>& __x); - void reserve(size_type __n) { - if (capacity() < __n) { - const size_type __old_size = size(); - iterator __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. - - void assign(size_type __n, const _Tp& __val); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type) - { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); } - - template - void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ - - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - reference back() { return *(end() - 1); } - const_reference back() const { return *(end() - 1); } - - 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); - } - void push_back() { - if (_M_finish != _M_end_of_storage) { - construct(_M_finish); - ++_M_finish; - } - else - _M_insert_aux(end()); - } - 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); - } - - 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(__position, __x); - return begin() + __n; - } - 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(__position); - return begin() + __n; - } -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__pos, __first, __last, _Integral()); - } - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, - __true_type) { - insert(__pos, (size_type) __n, (_Tp) __val); - } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) { - _M_range_insert(__pos, __first, __last, __ITERATOR_CATEGORY(__first)); - } -#else /* __STL_MEMBER_TEMPLATES */ - void insert(iterator __position, - const_iterator __first, const_iterator __last); -#endif /* __STL_MEMBER_TEMPLATES */ - - void insert (iterator __pos, size_type __n, const _Tp& __x); - - void pop_back() { - --_M_finish; - destroy(_M_finish); - } - iterator erase(iterator __position) { - if (__position + 1 != end()) - copy(__position + 1, _M_finish, __position); - --_M_finish; - destroy(_M_finish); - return __position; - } - iterator erase(iterator __first, iterator __last) { - iterator __i = copy(__last, _M_finish, __first); - destroy(__i, _M_finish); - _M_finish = _M_finish - (__last - __first); - return __first; - } - - 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); - } - void resize(size_type __new_size) { resize(__new_size, _Tp()); } - void clear() { erase(begin(), end()); } - -protected: - -#ifdef __STL_MEMBER_TEMPLATES - template - iterator _M_allocate_and_copy(size_type __n, _ForwardIterator __first, - _ForwardIterator __last) -{ - iterator __result = _M_allocate(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __result); - return __result; - } - __STL_UNWIND(_M_deallocate(__result, __n)); - } -#else /* __STL_MEMBER_TEMPLATES */ - iterator _M_allocate_and_copy(size_type __n, const_iterator __first, - const_iterator __last) - { - iterator __result = _M_allocate(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __result); - return __result; - } - __STL_UNWIND(_M_deallocate(__result, __n)); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - -#ifdef __STL_MEMBER_TEMPLATES - template - 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 - void _M_range_initialize(_ForwardIterator __first, - _ForwardIterator __last, forward_iterator_tag) - { - size_type __n = 0; - distance(__first, __last, __n); - _M_start = _M_allocate(__n); - _M_end_of_storage = _M_start + __n; - _M_finish = uninitialized_copy(__first, __last, _M_start); - } - - template - void _M_range_insert(iterator __pos, - _InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_range_insert(iterator __pos, - _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ -}; - -template -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 -inline bool -operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) -{ - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -vector<_Tp,_Alloc>& -vector<_Tp,_Alloc>::operator=(const vector<_Tp, _Alloc>& __x) -{ - if (&__x != this) { - const size_type __xlen = __x.size(); - if (__xlen > capacity()) { - iterator __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, _M_finish); - } - 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 -void vector<_Tp, _Alloc>::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()); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -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 template -void -vector<_Tp, _Alloc>::_M_assign_aux(_ForwardIter __first, _ForwardIter __last, - forward_iterator_tag) { - size_type __len = 0; - distance(__first, __last, __len); - - if (__len > capacity()) { - iterator __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, _M_finish); - _M_finish = __new_finish; - } - else { - _ForwardIter __mid = __first; - advance(__mid, size()); - copy(__first, __mid, _M_start); - _M_finish = uninitialized_copy(__mid, __last, _M_finish); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -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, _M_finish - 2, _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; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - construct(__new_finish, __x); - ++__new_finish; - __new_finish = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - 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 -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, _M_finish - 2, _M_finish - 1); - *__position = _Tp(); - } - 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; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - construct(__new_finish); - ++__new_finish; - __new_finish = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - 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 -void vector<_Tp, _Alloc>::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 = _M_finish - __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; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_fill_n(__new_finish, __n, __x); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish); - _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; - } - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -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 template -void -vector<_Tp, _Alloc>::_M_range_insert(iterator __position, - _ForwardIterator __first, - _ForwardIterator __last, - forward_iterator_tag) -{ - if (__first != __last) { - size_type __n = 0; - distance(__first, __last, __n); - if (size_type(_M_end_of_storage - _M_finish) >= __n) { - const size_type __elems_after = _M_finish - __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; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish); - _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; - } - } -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -vector<_Tp, _Alloc>::insert(iterator __position, - const_iterator __first, - const_iterator __last) -{ - if (__first != __last) { - size_type __n = 0; - distance(__first, __last, __n); - if (size_type(_M_end_of_storage - _M_finish) >= __n) { - const size_type __elems_after = _M_finish - __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 { - uninitialized_copy(__first + __elems_after, __last, _M_finish); - _M_finish += __n - __elems_after; - uninitialized_copy(__position, __old_finish, _M_finish); - _M_finish += __elems_after; - copy(__first, __first + __elems_after, __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; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish); - _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 /* __STL_MEMBER_TEMPLATES */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_VECTOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/tempbuf.h b/libstdc++/stl/tempbuf.h deleted file mode 100644 index aa4f289c582..00000000000 --- a/libstdc++/stl/tempbuf.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_TEMPBUF_H -#define __SGI_STL_TEMPBUF_H - -#ifndef __SGI_STL_PAIR_H -#include -#endif -#include /* XXX should use */ -#include /* XXX should use */ -#include /* XXX should use */ -#ifndef __TYPE_TRAITS_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_TEMPBUF_H -#include -#endif - -#ifdef __STL_USE_NAMESPACES - -using __STD::get_temporary_buffer; -using __STD::return_temporary_buffer; -using __STD::temporary_buffer; - -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_TEMPBUF_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/tree.h b/libstdc++/stl/tree.h deleted file mode 100644 index 77c57cbbba1..00000000000 --- a/libstdc++/stl/tree.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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. - * - * - * 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. - * - * - */ - -#ifndef __SGI_STL_TREE_H -#define __SGI_STL_TREE_H - -#ifndef __SGI_STL_INTERNAL_TREE_H -#include -#endif -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::rb_tree; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_TREE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/type_traits.h b/libstdc++/stl/type_traits.h deleted file mode 100644 index b6a7dfc6de9..00000000000 --- a/libstdc++/stl/type_traits.h +++ /dev/null @@ -1,373 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __TYPE_TRAITS_H -#define __TYPE_TRAITS_H - -#ifndef __STL_CONFIG_H -#include -#endif - -/* -This header file provides a framework for allowing compile time dispatch -based on type attributes. This is useful when writing template code. -For example, when making a copy of an array of an unknown type, it helps -to know if the type has a trivial copy constructor or not, to help decide -if a memcpy can be used. - -The class template __type_traits provides a series of typedefs each of -which is either __true_type or __false_type. The argument to -__type_traits can be any type. The typedefs within this template will -attain their correct values by one of these means: - 1. The general instantiation contain conservative values which work - for all types. - 2. Specializations may be declared to make distinctions between types. - 3. Some compilers (such as the Silicon Graphics N32 and N64 compilers) - will automatically provide the appropriate specializations for all - types. - -EXAMPLE: - -//Copy an array of elements which have non-trivial copy constructors -template void copy(T* source, T* destination, int n, __false_type); -//Copy an array of elements which have trivial copy constructors. Use memcpy. -template void copy(T* source, T* destination, int n, __true_type); - -//Copy an array of any type by using the most efficient copy mechanism -template inline void copy(T* source,T* destination,int n) { - copy(source, destination, n, - typename __type_traits::has_trivial_copy_constructor()); -} -*/ - - -struct __true_type { -}; - -struct __false_type { -}; - -template -struct __type_traits { - typedef __true_type this_dummy_member_must_be_first; - /* Do not remove this member. It informs a compiler which - automatically specializes __type_traits that this - __type_traits template is special. It just makes sure that - things work if an implementation is using a template - called __type_traits for something unrelated. */ - - /* The following restrictions should be observed for the sake of - compilers which automatically produce type specific specializations - of this class: - - You may reorder the members below if you wish - - You may remove any of the members below if you wish - - You must not rename members without making the corresponding - name change in the compiler - - Members you add will be treated like regular members unless - you add the appropriate support in the compiler. */ - - - typedef __false_type has_trivial_default_constructor; - typedef __false_type has_trivial_copy_constructor; - typedef __false_type has_trivial_assignment_operator; - typedef __false_type has_trivial_destructor; - typedef __false_type is_POD_type; -}; - - - -// Provide some specializations. This is harmless for compilers that -// have built-in __types_traits support, and essential for compilers -// that don't. - -#ifndef __STL_NO_BOOL - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_NO_BOOL */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#ifdef __STL_HAS_WCHAR_T - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_HAS_WCHAR_T */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#ifdef __STL_LONG_LONG - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_LONG_LONG */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -struct __type_traits<_Tp*> { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - -// The following could be written in terms of numeric_limits. -// We're doing it separately to reduce the number of dependencies. - -template struct _Is_integer { - typedef __false_type _Integral; -}; - -#ifndef __STL_NO_BOOL - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#endif /* __STL_NO_BOOL */ - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#ifdef __STL_HAS_WCHAR_T - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#endif /* __STL_HAS_WCHAR_T */ - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#ifdef __STL_LONG_LONG - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#endif /* __STL_LONG_LONG */ - -#endif /* __TYPE_TRAITS_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/utility b/libstdc++/stl/utility deleted file mode 100644 index df8c224388d..00000000000 --- a/libstdc++/stl/utility +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * 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. - */ - -#ifndef __SGI_STL_UTILITY -#define __SGI_STL_UTILITY - -#include -#include -#include - -#endif /* __SGI_STL_UTILITY */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/vector b/libstdc++/stl/vector deleted file mode 100644 index 4bcdebcc186..00000000000 --- a/libstdc++/stl/vector +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_VECTOR -#define __SGI_STL_VECTOR - -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_VECTOR */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stl/vector.h b/libstdc++/stl/vector.h deleted file mode 100644 index 231a227b7e3..00000000000 --- a/libstdc++/stl/vector.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_VECTOR_H -#define __SGI_STL_VECTOR_H - -#include -#include -#include - -#ifdef __STL_USE_NAMESPACES -using __STD::vector; -#endif /* __STL_USE_NAMESPACES */ - -#endif /* __SGI_STL_VECTOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/libstdc++/stlinst.cc b/libstdc++/stlinst.cc deleted file mode 100644 index 2a221fbaee9..00000000000 --- a/libstdc++/stlinst.cc +++ /dev/null @@ -1,10 +0,0 @@ -// Instantiation file for the -*- C++ -*- Standard Library allocator templates -// This file is part of the GNU ANSI C++ Library. - -#include - -#ifndef __USE_MALLOC -template class __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0>; -#endif - -template class __malloc_alloc_template<0>; diff --git a/libstdc++/string b/libstdc++/string deleted file mode 100644 index fa6f1abaa70..00000000000 --- a/libstdc++/string +++ /dev/null @@ -1,13 +0,0 @@ -// Main header for the -*- C++ -*- string classes. - -#ifndef __STRING__ -#define __STRING__ - -#include - -extern "C++" { -typedef basic_string string; -// typedef basic_string wstring; -} // extern "C++" - -#endif diff --git a/libstdc++/strstream b/libstdc++/strstream deleted file mode 100644 index ee360e0b7e4..00000000000 --- a/libstdc++/strstream +++ /dev/null @@ -1,7 +0,0 @@ -// -*- C++ -*- forwarding header. -// This file is part of the GNU ANSI C++ Library. - -#ifndef __STRSTREAM__ -#define __STRSTREAM__ -#include -#endif diff --git a/libstdc++/tests/ChangeLog b/libstdc++/tests/ChangeLog deleted file mode 100644 index 87ce0fc6c19..00000000000 --- a/libstdc++/tests/ChangeLog +++ /dev/null @@ -1,112 +0,0 @@ -1998-07-17 Jason Merrill - - * tmap.cc: Use less. - * tlist.cc (main): Use remove_if. - -1998-07-13 Manfred Hollstein - - * Makefile.in (VERSION): Bump to 2.9.0. - -1998-07-12 Bob Sidebotham - - * tstring.cc (findtest): New fn. - -1998-06-01 Jason Merrill - - * tlist.cc, tvector.cc, tmap.cc: Remove explicit instantiations. - -Fri Oct 10 00:40:31 1997 Jason Merrill - - * tstring.cc (identitytest): s/remove/erase/. - -Thu Sep 25 19:48:22 1997 Jason Merrill - - * tstring.cc: Add some tests for the member templates. - -Wed Jun 11 11:00:10 1997 Jason Merrill - - * tmap.cc: Explicitly instantiate allocator classes. - * tvector.cc, tlist.cc: Likewise. - -Fri May 16 18:38:05 1997 Bob Manson - - * tcomplex.cc (main): If we're using short doubles, compensate for - roundoff in result of pow(a,b). - -Thu May 1 17:37:53 1997 Jason Merrill - - * configure.in (CHECK): Add $(CXXFLAGS). - * Makefile.in (tcomplex): Add $(CXXFLAGS). - -Fri Apr 25 16:07:46 1997 Bob Manson - - * configure.in: Change "check" to "check-old". Add do-nothing - check target. - -Sun Nov 3 12:44:48 1996 Jason Merrill - - * tstring.cc: Treat string literals as const. - -Tue Sep 24 18:00:20 1996 Jason Merrill - - * tstring.cc, tcomplex.cc: Remove gratuitous uses of std/. - -Mon Jun 17 14:05:50 1996 Per Bothner - - * tlist.cc (test_splice): New test. - -Fri Mar 22 16:08:36 1996 Jason Merrill - - * Makefile.in (VERSION): 2.8.0. - - * tlist.cc, tmap.cc, tvector.cc: Remove explicit instantiation - directive. - -Sat Nov 18 19:52:26 1995 Mike Stump - - * Makefile.in: Update version to 2.7.1. - -Tue May 9 19:36:54 1995 Jason Merrill - - * tstring.cc (decltest): Adjust single-character test. - -Fri May 5 14:35:19 1995 Jason Merrill - - * tcomplex.*: Update to reflect that operator<< now - accepts more forms of input. - -Thu Apr 27 15:34:58 1995 Brendan Kehoe (brendan@lisa.cygnus.com) - - * configure.in: Update to stay in sync with config.shared. - -Thu Feb 16 00:08:28 1995 Jason Merrill - - * Makefile.in (VERSION, SHLIB): Define. - -Tue Jan 24 02:36:24 1995 Jason Merrill - - * Makefile.in (CXXFLAGS): Don't set. - -Mon Jan 23 04:12:10 1995 Jason Merrill - - * tlist.cc (plus): Remove. - -Thu Jan 19 19:41:07 1995 Jason Merrill - - * Makefile.in: Don't set LD_LIBRARY_PATH. Users will have to set - it themselves. - -Mon Jan 16 13:57:34 1995 Jason Merrill - - * Makefile.in: Update to reflect header movement. - -Wed Dec 14 19:55:45 1994 Per Bothner - - * configure.in: Fix quoting problem. Reported nu H.J.Lu. - -Tue Nov 29 16:46:56 1994 Per Bothner - - * Makefile.in, configure.in: Re-write to avoid duplication. - * {tvector,tmap,tlist}.{cc,exp}, configure.in: New tests for STL. - - diff --git a/libstdc++/tests/Makefile.in b/libstdc++/tests/Makefile.in deleted file mode 100644 index 057482f185e..00000000000 --- a/libstdc++/tests/Makefile.in +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 1994 Free Software Foundation - -# This file is part of the GNU ANSI 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. - -VERSION = 2.9.0 -SHLIB = libstdc++.so.$(VERSION) - -DEPLIBS = ../libstdc++.a -LDLIBS = -L.. -lstdc++ -MDEPLIBS = $(DEPLIBS) -MLDLIBS = $(LDLIBS) -lm - -#### package, host, target, and site dependent Makefile fragments come in here. -## - -tcomplex.o: ${srcdir}/../std/complext.h ${srcdir}/../std/dcomplex.h -tcomplex: tcomplex.o $(MDEPLIBS) - $(CXX) $(CXXFLAGS) -o tcomplex tcomplex.o $(MLDLIBS) - -tstring.o: ${srcdir}/../std/bastring.h - -# NOTE: Rules for following tests are generated by $(srcdir)/configure.in !!! - diff --git a/libstdc++/tests/configure.in b/libstdc++/tests/configure.in deleted file mode 100644 index 06c56192beb..00000000000 --- a/libstdc++/tests/configure.in +++ /dev/null @@ -1,65 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../../configure. - -configdirs= -srctrigger=tcomplex.cc -srcname="tests for ANSI C++ library" -package_makefile_frag=Make.pack -package_makefile_rules_frag=Make.pack.r - -# per-host: - -# per-target: - -target_makefile_frag=../target-mkfrag - -TO_TOPDIR=../../ -ALL=' ' -XCXXINCLUDES="-I${srcdir}/.. -I${srcdir}/../stl -I${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio" -SIMPLE_TESTS='tstring tlist tmap tvector' -TESTS="tcomplex ${SIMPLE_TESTS}" -MOSTLYCLEAN="*.o core ${TESTS} *.out" -(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} 2>${package_makefile_rules_frag} - -# post-target: - -CHECK="" - -for TEST in ${SIMPLE_TESTS} ; do - echo "${TEST}: ${TEST}.o" '$(DEPLIBS) - $(CXX) $(CXXFLAGS) -o' "${TEST} ${TEST}.o" '$(LDLIBS) -' >> Makefile -done - -for TEST in ${TESTS} ; do - echo ".PHONY: check-${TEST}" >>Makefile - if [ -f ${srcdir}/${TEST}.inp ] ; then - echo "check-${TEST}: ${TEST}" '$(srcdir)'"/${TEST}.inp - ./${TEST} < "'$(srcdir)'"/${TEST}.inp > ${TEST}.out 2>&1" >>Makefile - else - echo "check-${TEST}: ${TEST} - ./${TEST} > ${TEST}.out 2>&1" >>Makefile - fi - echo ' diff -c $(srcdir)/'"${TEST}.exp ${TEST}.out" >>Makefile - CHECK="${CHECK} check-${TEST}" -done - -if [ "${srcdir}" = "." ] ; then - if [ "${with_target_subdir}" != "." ] ; then - topsrcdir=${with_multisrctop}../../.. - else - topsrcdir=${with_multisrctop}../.. - fi -else - topsrcdir=${srcdir}/../.. -fi - -if [ -d ${topsrcdir}/gcc ] ; then - echo " -check: -check-old: ${CHECK}" >>Makefile -else - echo " -check: ${CHECK}" >>Makefile -fi diff --git a/libstdc++/tests/tcomplex.cc b/libstdc++/tests/tcomplex.cc deleted file mode 100644 index 5311f0d8b7a..00000000000 --- a/libstdc++/tests/tcomplex.cc +++ /dev/null @@ -1,151 +0,0 @@ -// Tests for the -*- C++ -*- complex number classes. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI C++ Library. This library is free -// software; you can redistribute it and/or modify it under the terms of -// the GNU General Public License as published by the Free Software -// Foundation; either version 2, or (at your option) any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include -#include -#include - -// to test near-equality - -const double eps = 0.000001; - -static void close_enough(const double_complex& a, const double_complex& b) -{ - assert(fabs(real(a) - real(b)) < eps && - fabs(imag(a) - imag(b)) < eps); -} - - -void test3(double_complex& a, double_complex& b, double_complex& c) -{ - - close_enough(-(-a) , a); - close_enough((a + b) , (b + a)); - close_enough((a + (-b)) , (a - b)); - close_enough((a * b) , (b * a)); - close_enough((a * (-b)) , -(a * b)); - close_enough((a / (-b)) , -(a / b)); - close_enough((a - b) , -(b - a)); - close_enough((a + (b + c)) , ((a + b) + c)); - close_enough((a * (b * c)) , ((a * b) * c)); - close_enough((a * (b + c)) , ((a * b) + (a * c))); - close_enough(((a - b) + b) , a); - close_enough(((a + b) - b) , a); - close_enough(((a * b) / b) , a); - close_enough(((a / b) * b) , a); - - - double_complex x = a; - x *= b; - close_enough(x , (a * b)); - x += c; - close_enough(x , ((a * b) + c)); - x -= a; - close_enough(x , (((a * b) + c) - a)); - x /= b; - close_enough(x , ((((a * b) + c) - a) / b)); - -} - -main() -{ - double_complex one = 1.0; - double_complex i (0.0, 1.0); - double_complex neg_one = -1.0; - - cout << "double_complex one = " << one << "\n"; - cout << "i = " << i << "\n"; - cout << "neg_one = " << neg_one << "\n"; - cout << "sqrt(neg_one) = " << sqrt(neg_one) << "\n"; - - double_complex a (2.0, 3.0); - double_complex b (4.0, 5.0); - - cout << "a = " << a << "\n"; - cout << "b = " << b << "\n"; - - cout << "a + one = " << (a + one) << "\n"; - (close_enough((a+one), double_complex(3.0, 3.0))); - cout << "a - one = " << (a - one) << "\n"; - (close_enough((a-one), double_complex(1.0, 3.0))); - cout << "a * one = " << (a * one) << "\n"; - (close_enough((a*one), a)); - cout << "a / one = " << (a / one) << "\n"; - (close_enough((a/one), a)); - - cout << "a + b = " << (a + b) << "\n"; - (close_enough((a+b), double_complex(6.0, 8.0))); - cout << "a - b = " << (a - b) << "\n"; - (close_enough((a-b), double_complex(-2.0, -2.0))); - cout << "a * b = " << (a * b) << "\n"; - (close_enough((a*b), double_complex(-7.0, 22.0))); - cout << "a / b = " << (a / b) << "\n"; - (close_enough((a/b), double_complex(0.5609760976, 0.0487804878))); - - double_complex c; - - c = a; cout << "c = a; c += b = " << (c += b) << "\n"; - c = a; cout << "c = a; c -= b = " << (c -= b) << "\n"; - c = a; cout << "c = a; c *= b = " << (c *= b) << "\n"; - c = a; cout << "c = a; c /= b = " << (c /= b) << "\n"; - - cout << "-a = " << (-a) << "\n"; - cout << "real(a) = " << real(a) << "\n"; - assert(real(a) == 2.0); - cout << "imag(a) = " << imag(a) << "\n"; - assert(imag(a) == 3.0); - cout << "conj(a) = " << conj(a) << "\n"; - assert(conj(a) == double_complex(2.0, -3.0)); - cout << "norm(a) = " << norm(a) << "\n"; - assert(norm(a) == 13.0); - - cout << "abs(a) = " << abs(a) << "\n"; - cout << "arg(a) = " << arg(a) << "\n"; - cout << "cos(a) = " << cos(a) << "\n"; - cout << "sin(a) = " << sin(a) << "\n"; - cout << "cosh(a) = " << cosh(a) << "\n"; - cout << "sinh(a) = " << sinh(a) << "\n"; - cout << "log(a) = " << log(a) << "\n"; - cout << "exp(a) = " << exp(a) << "\n"; - cout << "sqrt(a) = " << sqrt(a) << "\n"; - cout << "pow(a, 2) = " << pow(a, 2) << "\n"; - { - double_complex p = pow(a, b); - if(sizeof(float)==sizeof(double)) { - long w = (long)(p.imag()*100000); - if (w==-98642) - p=double_complex(-0.753046,-0.986429); - } - cout << "pow(a, b) = " << p << "\n"; - } - - double_complex d (10, 20); - double_complex e = pow(a, 2); - - test3(one, one, one); - test3(a, a, a); - test3(a, b, d); - test3(e, i, b); - test3(d, d, i); - - cout << "enter a complex number in form a or (a) or (a, b): "; - cin >> c; - cout << "number = " << c << "\n"; - - cout << "\nEnd of test\n"; - return 0; -} diff --git a/libstdc++/tests/tcomplex.exp b/libstdc++/tests/tcomplex.exp deleted file mode 100644 index 5bef15cd376..00000000000 --- a/libstdc++/tests/tcomplex.exp +++ /dev/null @@ -1,37 +0,0 @@ -double_complex one = (1,0) -i = (0,1) -neg_one = (-1,0) -sqrt(neg_one) = (0,1) -a = (2,3) -b = (4,5) -a + one = (3,3) -a - one = (1,3) -a * one = (2,3) -a / one = (2,3) -a + b = (6,8) -a - b = (-2,-2) -a * b = (-7,22) -a / b = (0.560976,0.0487805) -c = a; c += b = (6,8) -c = a; c -= b = (-2,-2) -c = a; c *= b = (-7,22) -c = a; c /= b = (0.560976,0.0487805) --a = (-2,-3) -real(a) = 2 -imag(a) = 3 -conj(a) = (2,-3) -norm(a) = 13 -abs(a) = 3.60555 -arg(a) = 0.982794 -cos(a) = (-4.18963,-9.10923) -sin(a) = (9.1545,-4.16891) -cosh(a) = (-3.72455,0.511823) -sinh(a) = (-3.59056,0.530921) -log(a) = (1.28247,0.982794) -exp(a) = (-7.31511,1.04274) -sqrt(a) = (1.67415,0.895977) -pow(a, 2) = (-5,12) -pow(a, b) = (-0.753046,-0.986429) -enter a complex number in form a or (a) or (a, b): number = (1.2,-34) - -End of test diff --git a/libstdc++/tests/tcomplex.inp b/libstdc++/tests/tcomplex.inp deleted file mode 100644 index c4e1d84660f..00000000000 --- a/libstdc++/tests/tcomplex.inp +++ /dev/null @@ -1 +0,0 @@ -(1.2, -34) diff --git a/libstdc++/tests/tlist.cc b/libstdc++/tests/tlist.cc deleted file mode 100644 index a37c999d0b5..00000000000 --- a/libstdc++/tests/tlist.cc +++ /dev/null @@ -1,151 +0,0 @@ -// test/demo of generic lists - -#include - -#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ - else _assert(#ex, __FILE__,__LINE__); } - -#include -#include -#include - -bool int_compare(int a, int b) -{ - return a < b; -} - -int inc(int x) -{ - return x + 1; -} - -void print(list& l) -{ - for (list::iterator it = l.begin(); it != l.end(); it++) - cout << *it << " "; - cout << "\n"; -} - -int is_odd(int x) -{ - return x & 1; -} - -int is_even(int x) -{ - return (x & 1) == 0; -} - -void sequence(list& a, int lo, int hi) -{ - back_insert_iterator > it(a); - while (lo <= hi) - *it++ = lo++; -} - -int old_rand = 9999; - -int get_rand() -{ - old_rand = ((long)old_rand * (long)1243) % (long)971; - return old_rand; -} - -void randseq(list& a, int n) -{ - back_insert_iterator > it(a); - while (--n >= 0) - *it++ = get_rand() % 50; -} - -int array1 [] = { 9, 16, 36 }; -int array2 [] = { 1, 4 }; - -int test_splice () -{ - list l1 (array1, array1 + 3); - list l2 (array2, array2 + 2); - list::iterator i1 = l1.begin (); - l1.splice (i1, l2); - list::iterator i2 = l1.begin (); - while (i2 != l1.end ()) - cout << *i2++ << endl; - return 0; -} - -main() -{ - list a; int i; - list::iterator it, bit; - sequence(a, 1, 20); - cout << "\nlist a = sequence(1, 20);\n"; print(a); - for (it = a.begin (), i = 0; it != a.end (); it++, i++) - assert (*it == i + 1); - list b; - randseq(b, 20); - cout << "\nlist b = randseq(20);\n"; print(b); - list c; - c.insert (c.end(), a.begin(), a.end()); - c.insert (c.end(), b.begin(), b.end()); - cout << "\nlist c = a and b;\n"; print(c); - - list d; - for (it = a.begin(); it != a.end(); it++) - d.insert(d.end (), inc(*it)); - cout << "\nlist d = map(inc, a);\n"; print(d); - - list e; - back_insert_iterator > e_insertor (e); - reverse_copy (a.begin(), a.end (), e_insertor); - cout << "\nlist e = reverse(a);\n"; print(e); - - list f; - for (it = a.begin(); it != a.end(); it++) - if (is_odd (*it)) - f.insert(f.end (), *it); - cout << "\nlist f = select(is_odd, a);\n"; print(f); - list ff; - for (it = f.begin(); it != f.end(); it++) - if (is_even (*it)) - ff.insert(ff.end (), *it); - assert(ff.empty()); - - int red = 0; - for (it = a.begin(); it != a.end(); it++) - red += *it; - cout << "\nint red = a.reduce(plus, 0);\n"; cout << red; - it = a.begin(); ++it; ++it; - int second = *it; - cout << "\nint second = a[2];\n"; cout << second; - list g; - for (it = a.begin(), bit = b.begin(); it != a.end () && bit != b.end (); ) - g.insert (g.end (), *it++ + *bit++); - cout << "\nlist g = combine(plus, a, b);\n"; print(g); - g.remove_if (is_odd); - cout << "\ng.del(is_odd);\n"; print(g); - - ff.erase (ff.begin (), ff.end()); - for (it = g.begin(); it != g.end(); it++) - if (is_odd (*it)) - ff.insert (ff.end (), *it); - assert(ff.empty()); - - b.sort(); - for (it = b.begin(); bit = it++, it != b.end (); ) assert (*it >= *bit); - cout << "\nb.sort(int_compare);\n"; print(b); - - list h; - back_insert_iterator > h_insertor (h); - merge (a.begin (), a.end (), b.begin (), b.end (), h_insertor, int_compare); - cout << "\nlist h = merge(a, b, int_compare);\n"; print(h); - for (it = h.begin(); bit = it++, it != h.end (); ) assert (*it >= *bit); - - cout << "\nh via iterator:\n"; - for (it = h.begin(); it != h.end (); it++) - cout << *it << ", "; - cout << "\n"; - - test_splice (); - - cout << "\ndone\n"; -} diff --git a/libstdc++/tests/tlist.exp b/libstdc++/tests/tlist.exp deleted file mode 100644 index 65f7806826f..00000000000 --- a/libstdc++/tests/tlist.exp +++ /dev/null @@ -1,44 +0,0 @@ - -list a = sequence(1, 20); -1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 - -list b = randseq(20); -28 27 5 17 44 6 9 40 15 26 49 35 15 48 13 27 25 25 9 6 - -list c = a and b; -1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 28 27 5 17 44 6 9 40 15 26 49 35 15 48 13 27 25 25 9 6 - -list d = map(inc, a); -2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 - -list e = reverse(a); -20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 - -list f = select(is_odd, a); -1 3 5 7 9 11 13 15 17 19 - -int red = a.reduce(plus, 0); -210 -int second = a[2]; -3 -list g = combine(plus, a, b); -29 29 8 21 49 12 16 48 24 36 60 47 28 62 28 43 42 43 28 26 - -g.del(is_odd); -8 12 16 48 24 36 60 28 62 28 42 28 26 - -b.sort(int_compare); -5 6 6 9 9 13 15 15 17 25 25 26 27 27 28 35 40 44 48 49 - -list h = merge(a, b, int_compare); -1 2 3 4 5 5 6 6 6 7 8 9 9 9 10 11 12 13 13 14 15 15 15 16 17 17 18 19 20 25 25 26 27 27 28 35 40 44 48 49 - -h via iterator: -1, 2, 3, 4, 5, 5, 6, 6, 6, 7, 8, 9, 9, 9, 10, 11, 12, 13, 13, 14, 15, 15, 15, 16, 17, 17, 18, 19, 20, 25, 25, 26, 27, 27, 28, 35, 40, 44, 48, 49, -1 -4 -9 -16 -36 - -done diff --git a/libstdc++/tests/tmap.cc b/libstdc++/tests/tmap.cc deleted file mode 100644 index 900e66f506b..00000000000 --- a/libstdc++/tests/tmap.cc +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include - -#define int_less less -struct str_less { - bool operator() (char* x, char* y) const { return strcmp(x,y) < 0; } -}; - -#if 0 -int SIZE; - -void add(int x[], int y[], map& a) -{ - for (int i = 0; i < SIZE; ++i) a[x[i]] = y[i]; -} -#endif - -int -main(int argv, char** argc) -{ -#if 0 - if (argv > 1) - { - SIZE = abs(atoi(argc[1])); - SIZE &= ~1; - } - else - SIZE = 100; - nums = new int[SIZE]; - odds = new int[SIZE]; - perm = new int[SIZE]; -#endif - - map my_map; - - map phones; - - my_map[4] = 40; - my_map[2] = 20; - - // The (char*) is needed because g++ doesn't - // convert char[] to char* in this context. - phones[(char*)"tom"] = 2345; - phones[(char*)"dick"] = 5678; - phones[(char*)"harry"] = 7654; - - cout << "2 -> " << my_map[2] << endl; - cout << "4 -> " << my_map[4] << endl; - - map::iterator it = my_map.begin(); - for ( ; it != my_map.end(); it++) - cout << "my_map[" << (*it).first << "] = " << (*it).second << endl; - - map::iterator pit = phones.begin(); - for ( ; pit != phones.end(); pit++) - cout << "phones[" << (*pit).first << "] = " << (*pit).second << endl; -} diff --git a/libstdc++/tests/tmap.exp b/libstdc++/tests/tmap.exp deleted file mode 100644 index b7b5df249fb..00000000000 --- a/libstdc++/tests/tmap.exp +++ /dev/null @@ -1,7 +0,0 @@ -2 -> 20 -4 -> 40 -my_map[2] = 20 -my_map[4] = 40 -phones[dick] = 5678 -phones[harry] = 7654 -phones[tom] = 2345 diff --git a/libstdc++/tests/tstring.cc b/libstdc++/tests/tstring.cc deleted file mode 100644 index 833d3d96460..00000000000 --- a/libstdc++/tests/tstring.cc +++ /dev/null @@ -1,249 +0,0 @@ -// Tests for the -*- C++ -*- string classes. -// Copyright (C) 1994 Free Software Foundation - -// This file is part of the GNU ANSI C++ Library. This library is free -// software; you can redistribute it and/or modify it under the terms of -// the GNU General Public License as published by the Free Software -// Foundation; either version 2, or (at your option) any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include -#include -#include -#include -#include - -string X = "Hello"; -string Y = "world"; -string N = "123"; -string c; -const char* s = ","; - -void decltest() -{ - string x; - cout << "an empty string:" << x << "\n"; - assert(x == ""); - - string y = "Hello"; - cout << "A string initialized to Hello:" << y << "\n"; - assert(y == "Hello"); - - if (y[y.length()-1] == 'o') - y = y + '\n'; - assert(y == "Hello\n"); - y = "Hello"; - - string a = y; - cout << "A string initialized to previous string:" << a << "\n"; - assert(a == "Hello"); - assert(a == y); - - string b (a, 1, 2); - cout << "A string initialized to (previous string, 1, 2):" << b << "\n"; - assert(b == "el"); - - char ch = '@'; - string z (1, ch); - cout << "A string initialized to @:" << z << "\n"; - assert (z == "@"); - - string n ("20"); - cout << "A string initialized to 20:" << n << "\n"; - assert(n == "20"); - - int i = atoi(n.c_str ()); - double f = atof(n.c_str ()); - cout << "n = " << n << " atoi(n) = " << i << " atof(n) = " << f << "\n"; - assert(i == 20); - assert(f == 20); - - int ar[] = { 'H', 'e', 'l', 'l', 'o' }; - string is (ar, ar+sizeof(ar)/sizeof(ar[0])); - cout << "is = " << is << endl; - assert (is == "Hello"); -} - -void cattest() -{ - string x = X; - string y = Y; - string z = x + y; - cout << "z = x + y = " << z << "\n"; - assert(z == "Helloworld"); - - x += y; - cout << "x += y; x = " << x << "\n"; - assert(x == "Helloworld"); - - y = Y; - x = X; - y.insert (0, x); - cout << "y.insert (0, x); y = " << y << "\n"; - assert(y == "Helloworld"); - - y = Y; - x = X; - x = x + y + x; - cout << "x = x + y + x; x = " << x << "\n"; - assert(x == "HelloworldHello"); - - y = Y; - x = X; - x = y + x + x; - cout << "x = y + x + x; x = " << x << "\n"; - assert(x == "worldHelloHello"); - - x = X; - y = Y; - z = x + s + ' ' + y.substr (y.find ('w'), 1) + y.substr (y.find ('w') + 1) + "."; - cout << "z = x + s + + y.substr (y.find (w), 1) + y.substr (y.find (w) + 1) + . = " << z << "\n"; - assert(z == "Hello, world."); -} - -void -findtest() -{ - string x; - string::size_type pos; - pos = x.find_last_not_of('X'); - assert(pos == string::npos); - pos = x.find_last_not_of("XYZ"); - assert(pos == string::npos); - - string y("a"); - pos = y.find_last_not_of('X'); - assert(pos == 0); - pos = y.find_last_not_of('a'); - assert(pos == string::npos); - pos = y.find_last_not_of("XYZ"); - assert(pos == 0); - pos = y.find_last_not_of("a"); - assert(pos == string::npos); - - string z("ab"); - pos = z.find_last_not_of('X'); - assert(pos == 1); - pos = z.find_last_not_of("XYZ"); - assert(pos == 1); - pos = z.find_last_not_of('b'); - assert(pos == 0); - pos = z.find_last_not_of("Xb"); - assert(pos == 0); - pos = z.find_last_not_of("Xa"); - assert(pos == 1); - pos = z.find_last_of("ab"); - assert(pos == 1); - pos = z.find_last_of("Xa"); - assert(pos == 0); - pos = z.find_last_of("Xb"); - assert(pos == 1); - pos = z.find_last_of("XYZ"); - assert(pos == string::npos); - pos = z.find_last_of('a'); - assert(pos == 0); - pos = z.find_last_of('b'); - assert(pos == 1); - pos = z.find_last_of('X'); - assert(pos == string::npos); -} - -void comparetest() -{ - string x = X; - string y = Y; - string n = N; - string z = x + y; - - assert(x != y); - assert(x == "Hello"); - assert(x != z.substr (0, 4)); - assert(x.compare (y) < 0); - assert(x.compare (z.substr (0, 6)) < 0); - - assert(x.find ("lo") == 3); - assert(x.find ("l", 2) == 2); - assert(x.rfind ("l") == 3); -} - -void substrtest() -{ - string x = X; - - char ch = x[0]; - cout << "ch = x[0] = " << ch << "\n"; - assert(ch == 'H'); - - string z = x.substr (2, 3); - cout << "z = x.substr (2, 3) = " << z << "\n"; - assert(z == "llo"); - - x.replace (2, 2, "r"); - cout << "x.replace (2, 2, r); x = " << x << "\n"; - assert(x == "Hero"); - - x = X; - x.replace (0, 1, 'j'); - cout << "x.replace (0, 1, 'j'); x = " << x << "\n"; - assert(x == "jello"); - - int ar[] = { 'H', 'e', 'l', 'l', 'o' }; - x.replace (find (x.begin (), x.end (), 'l'), - find (x.rbegin (), x.rend (), 'l').base (), - ar, ar+sizeof(ar)/sizeof(ar[0])); - cout << "x = " << x << endl; - assert (x == "jeHelloo"); -} - -void iotest() -{ - string z; - cout << "enter a word:"; - cin >> z; - cout << "word =" << z << " "; - cout << "length = " << z.length() << "\n"; -} - -void identitytest(string a, string b) -{ - string x = a; - string y = b; - x += b; - y.insert (0, a); - assert((a + b) == x); - assert((a + b) == y); - assert(x == y); - - assert((a + b + a) == (a + (b + a))); - - x.erase (x.rfind (b)); - assert(x == a); - - y.replace (0, y.rfind (b), b); - assert(y == (b + b)); - y.replace (y.find (b), b.length (), a); - assert(y == (a + b)); -} - -int main() -{ - decltest(); - cattest(); - comparetest(); - findtest(); - substrtest(); - identitytest(X, X); - identitytest(X, Y); - identitytest(X+Y+N+X+Y+N, "A string that will be used in identitytest but is otherwise just another useless string."); - iotest(); - cout << "\nEnd of test\n"; - return 0; -} diff --git a/libstdc++/tests/tstring.exp b/libstdc++/tests/tstring.exp deleted file mode 100644 index 4526279b888..00000000000 --- a/libstdc++/tests/tstring.exp +++ /dev/null @@ -1,22 +0,0 @@ -an empty string: -A string initialized to Hello:Hello -A string initialized to previous string:Hello -A string initialized to (previous string, 1, 2):el -A string initialized to @:@ -A string initialized to 20:20 -n = 20 atoi(n) = 20 atof(n) = 20 -is = Hello -z = x + y = Helloworld -x += y; x = Helloworld -y.insert (0, x); y = Helloworld -x = x + y + x; x = HelloworldHello -x = y + x + x; x = worldHelloHello -z = x + s + + y.substr (y.find (w), 1) + y.substr (y.find (w) + 1) + . = Hello, world. -ch = x[0] = H -z = x.substr (2, 3) = llo -x.replace (2, 2, r); x = Hero -x.replace (0, 1, 'j'); x = jello -x = jeHelloo -enter a word:word =abcdefghijklmnopqrstuvwxyz length = 26 - -End of test diff --git a/libstdc++/tests/tstring.inp b/libstdc++/tests/tstring.inp deleted file mode 100644 index b0883f382e1..00000000000 --- a/libstdc++/tests/tstring.inp +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnopqrstuvwxyz diff --git a/libstdc++/tests/tvector.cc b/libstdc++/tests/tvector.cc deleted file mode 100644 index ef238ef52da..00000000000 --- a/libstdc++/tests/tvector.cc +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -main () -{ - cout << "Fill of C array:\n"; - char x[50]; - fill (x, x+50, '/'); - fill (x+1, x+49, '*'); - copy (x, x+50, ostream_iterator(cout)); - - cout << "\nFill of vector:\n"; - - vector cvec; - cvec.insert (cvec.begin(), 50, '/'); - fill (cvec.begin()+1, cvec.end()-1, '-'); - copy (cvec.begin(), cvec.end(), ostream_iterator(cout)); - cout << endl; -} diff --git a/libstdc++/tests/tvector.exp b/libstdc++/tests/tvector.exp deleted file mode 100644 index 84a9d1bf3a4..00000000000 --- a/libstdc++/tests/tvector.exp +++ /dev/null @@ -1,4 +0,0 @@ -Fill of C array: -/************************************************/ -Fill of vector: -/------------------------------------------------/ diff --git a/libstdc++/testsuite/ChangeLog b/libstdc++/testsuite/ChangeLog deleted file mode 100644 index 7b1a9f0c3c5..00000000000 --- a/libstdc++/testsuite/ChangeLog +++ /dev/null @@ -1,74 +0,0 @@ -Wed Nov 25 01:00:07 1998 Marc Espie - - * Makefile.in (just-check): Ignore errors. - -Sun Jun 28 00:00:10 1998 Carlo Wood - - * lib/libstdc++.exp: Use global variable ld_library_path (not local) - that is a lot more persistent; dejagnu-980528 needs this. - * lib/libstdc++.exp (test_stdc++): Use regular expression " -lstdc.." - to remove -lstdc++ arguments (not " -lstdc.*"). - -Thu Dec 25 00:34:03 1997 Jeffrey A Law (law@cygnus.com) - - * lib/libstdc++.exp (test_libstdc++): Set LD_LIBRARY_PATH - and SHLIB_PATH appropriately. - -Wed Sep 3 09:39:36 1997 Jeffrey A Law (law@cygnus.com) - - * lib/libstdc++.exp: Remove libg++_link_flags. - -Wed Aug 6 18:43:23 1997 Jason Merrill - - * lib/libstdc++.exp: Remove libio_link_flags. - -Thu Jul 17 14:54:58 1997 Brendan Kehoe - - * lib/libstdc++.exp (base_dir): Move from here... - (test_libstdc++): To here. - (LIBSTDCPP): Delete unused global decl. - -Tue Jun 17 01:46:49 1997 Bob Manson - - * lib/libstdc++.exp: Strip off leading LFs from both the pattern - being matched against and the output from the board. Find the - correct multilib libstdc++ to link with. Use g++_link_flags - and libio_link_flags. Link in the status wrapper if needed. - (libstdc++_init): New procedure. - -Tue Jun 3 17:16:39 1997 Bob Manson - - * lib/libstdc++.exp: Don't use global exec_output variable; the - output is returned from remote_load instead. - -Tue Apr 29 17:20:05 1997 Mike Stump - - * lib/libstdc++.exp: Fixup so that $compile_args works better. - * libstdc++.tests/test.exp: Also run with -O. - -Tue Apr 29 16:34:37 1997 Mike Stump - - * testsuite/lib/libstdc++.exp: Fixup so that we always have the - same number of testcases, and so that we have meaningful testcase - names. - -Tue Apr 29 13:05:14 1997 Bob Manson - - * lib/libstdc++.exp: Add support for --tool_opts. - -Mon Apr 28 11:10:25 1997 Bob Manson - - * Makefile.in: Add comment so target Makefile fragments get added. - Removed clean rule, because it is added by configure. - - * configure.in (TESTS): Add. - -Sun Apr 27 15:03:10 1997 Brendan Kehoe - - * Makefile.in (clean): Add empty rule for now. - -Fri Apr 25 18:59:14 1997 Bob Manson - - * lib/libstdc++.exp(test_libstdc++): Return on error. Generate a - FAIL if the compile fails. Remove CRs from the output from the - testcase. diff --git a/libstdc++/testsuite/Makefile.in b/libstdc++/testsuite/Makefile.in deleted file mode 100644 index 7c85678e1fe..00000000000 --- a/libstdc++/testsuite/Makefile.in +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (C) 1997 Free Software Foundation -# -# This file is part of the GNU IO 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 GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. */ - -srcdir = libstdc++.tests - -EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \ - echo $${rootme}/../../expect/expect ; \ - else echo expect ; fi` - -RUNTEST = `if [ -f $${srcdir}/../../dejagnu/runtest ] ; then \ - echo $${srcdir}/../../dejagnu/runtest ; \ - else echo runtest; fi` -RUNTESTFLAGS = - -#### package, host, target, and site dependent Makefile fragments come in here. -## - -.PHONY: all -all: - -.PHONY: check -check: all just-check - -site.exp: ./config.status Makefile - @echo "Making a new config file..." - -@rm -f ./tmp? - @touch site.exp - -@mv site.exp site.bak - @echo "## these variables are automatically generated by make ##" > ./tmp0 - @echo "# Do not edit here. If you wish to override these values" >> ./tmp0 - @echo "# add them to the last section" >> ./tmp0 - @echo "set host_alias $(host_alias)" >> ./tmp0 - @echo "set host_triplet ${host_canonical}" >> ./tmp0 - @echo "set target_alias $(target_alias)" >> ./tmp0 - @echo "set target_triplet ${target_canonical}" >> ./tmp0 - @echo "set build_triplet ${build_canonical}" >> ./tmp0 - @echo "set srcdir ${srcdir}" >> ./tmp0 - @echo "set tool libstdc++" >> ./tmp0 - @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0 - @cat ./tmp0 > site.exp - @cat site.bak | sed \ - -e '1,/^## All variables above are.*##/ d' >> site.exp - -@rm -f ./tmp? - -just-check: site.exp - -rootme=`pwd`; export rootme; \ - srcdir=${srcdir} ; export srcdir ; \ - EXPECT=${EXPECT} ; export EXPECT ; \ - if [ -f $${rootme}/../../expect/expect ] ; then \ - TCL_LIBRARY=$${srcdir}/../../tcl/library ; \ - export TCL_LIBRARY ; fi ; \ - $(RUNTEST) $(RUNTESTFLAGS) diff --git a/libstdc++/testsuite/config/default.exp b/libstdc++/testsuite/config/default.exp deleted file mode 100644 index 90967cccc18..00000000000 --- a/libstdc++/testsuite/config/default.exp +++ /dev/null @@ -1 +0,0 @@ -load_lib "standard.exp" diff --git a/libstdc++/testsuite/configure.in b/libstdc++/testsuite/configure.in deleted file mode 100644 index ad5f232b085..00000000000 --- a/libstdc++/testsuite/configure.in +++ /dev/null @@ -1,24 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../../configure. - -configdirs= -srctrigger=configure.in -srcname="tests for ANSI C++ library, dejagnu style" -package_makefile_frag=Make.pack -package_makefile_rules_frag=Make.pack.r - -# per-host: - -# per-target: - -target_makefile_frag=../target-mkfrag - -TO_TOPDIR=../../ -ALL=' ' -XCXXINCLUDES="-I${srcdir}/.. -I${srcdir}/../stl -I${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio" -TESTS="tcomplex tstring tlist tmap tvector" -MOSTLYCLEAN="*.o core ${TESTS} *.out" -(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} 2>${package_makefile_rules_frag} - -# post-target: diff --git a/libstdc++/testsuite/lib/libstdc++.exp b/libstdc++/testsuite/lib/libstdc++.exp deleted file mode 100644 index 3333ddad6c7..00000000000 --- a/libstdc++/testsuite/lib/libstdc++.exp +++ /dev/null @@ -1,179 +0,0 @@ -# Copyright (C) 1997 Free Software Foundation, Inc. - -# This program 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 of the License, or -# (at your option) any later version. -# -# This program 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 program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -# Please email any bugs, comments, and/or additions to this file to: -# bug-lib-g++@prep.ai.mit.edu - -# This file was written by Bob Manson. (manson@cygnus.com) - -load_lib "libgloss.exp" - -global tmpdir - -if ![info exists tmpdir] { - set tmpdir "/tmp" -} - -# -# Build the status wrapper library as needed. -# -proc libstdc++_init { args } { - global wrapper_file; - global wrap_compile_flags; - set wrapper_file ""; - set wrap_compile_flags ""; - if [target_info exists needs_status_wrapper] { - set result [build_wrapper "testglue.o"]; - if { $result != "" } { - set wrapper_file [lindex $result 0]; - set wrap_compile_flags [lindex $result 1]; - } else { - warning "Status wrapper failed to build." - } - } -} -# -# Run the test specified by srcfile and resultfile. compile_args and -# exec_args are additional arguments to be passed in when compiling and -# running the testcase, respectively. -# - -proc test_libstdc++ { options srcfile compile_args inpfile resultfile exec_args } { - global base_dir - global LIBSTDCPP - global srcdir subdir objdir - global TOOL_OPTIONS - global ld_library_path - - if [info exists LIBSTDCPP] { - set libstdcpp $LIBSTDCPP; - } else { - set gp [get_multilibs]; - if { $gp != "" } { - if [file exists "$gp/libstdc++/libstdc++.a"] { - set libstdcpp "-L$gp/libstdc++ -lstdc++"; - } - } - if ![info exists libstdcpp] { - set libstdcpp [findfile $base_dir/../../libstdc++/libstdc++.a "-L$base_dir/../../libstdc++ -lstdc++" -lstdc++] - } - } - - verbose "using LIBSTDCPP = $libstdcpp" 2 - set args "" - - # Basically we want to build up a colon separated path list from - # the value of $libstdcpp. - - # First strip away any -L arguments. - regsub -all -- "-L" $libstdcpp "" ld_library_path - - # Then remove any -lstdc++ argument. - regsub -all -- " -lstdc.." $ld_library_path "" ld_library_path - - # That's enough to make things work for the normal case. - # If we wanted to handle an arbitrary value of libstdcpp, - # then we'd have to do a lot more work. - - if { $compile_args != "" } { - lappend args "additional_flags=$compile_args" - } - lappend args "incdir=.." - lappend args "incdir=$srcdir/.." - lappend args "incdir=$srcdir/../stl" - lappend args "incdir=." - if [info exists TOOL_OPTIONS] { - lappend args "additional_flags=$TOOL_OPTIONS" - } - - global wrapper_file wrap_compile_flags; - # We have to include libio, for _G_config.h. - lappend args "additional_flags=$wrap_compile_flags"; - lappend args "libs=$wrapper_file"; - lappend args "libs=$libstdcpp"; - lappend args "additional_flags=[libio_include_flags]" - lappend args debug - - regsub "^.*/(\[^/.\]+)\[.\]\[^/]*$" "$srcfile" "\\1" out - set executable "${objdir}/$out" - set errname "[file tail $srcfile]" - if { $compile_args != "" } { - set errname "$errname $compile_args" - } - - if { [target_compile $srcfile "$executable" executable $args] != "" } { - fail "$errname compilation" - setup_xfail "*-*-*" - fail "$errname execution" - setup_xfail "*-*-*" - fail "$errname output" - return; - } - pass "$errname compilation" - - set result [libstdc++_load $executable "$exec_args" "$inpfile"]; - set status [lindex $result 0]; - set output [lindex $result 1]; - $status "$errname execution" - if { $status != "pass" } { - setup_xfail "*-*-*" - fail "$errname output" - return; - } - - verbose "resultfile is $resultfile" - set id [open $resultfile r]; - set expected "" - append expected [read $id]; - regsub -all "\r" "$output" "" output; - regsub "\n*$" $expected "" expected - regsub "\n*$" $output "" output - regsub "^\n*" $expected "" expected - regsub "^\n*" $output "" output - regsub -all "\[ \t\]\[ \t\]*" $expected " " expected - regsub -all "\[ \t\]*\n\n*" $expected "\n" expected - regsub -all "\[ \t\]\[ \t\]*" $output " " output - regsub -all "\[ \t\]*\n\n*" $output "\n" output - verbose "expected is $expected" - verbose "actual is $output" - set passed 0; - if {$options == "regexp_match"} { - if [regexp $expected $output] { - set passed 1; - } - } else { - if { $expected == $output } { - set passed 1; - } - } - if { $passed == 1 } { - pass "$errname output" - } else { - clone_output "expected was $expected" - clone_output "output was $output" - fail "$errname output" - } - close $id; -} - -# -# libstdc++_version -- extract and print the version number of libstdc++p -# -proc default_libstdc++_version {} { -} - -proc default_libstdc++_start { } { -} diff --git a/libstdc++/testsuite/libstdc++.tests/test.exp b/libstdc++/testsuite/libstdc++.tests/test.exp deleted file mode 100644 index 7368cfb282e..00000000000 --- a/libstdc++/testsuite/libstdc++.tests/test.exp +++ /dev/null @@ -1,34 +0,0 @@ -global srcdir subdir - -catch "glob -nocomplain $srcdir/$subdir/../../tests/*.exp" srcfiles -verbose "srcfiles are $srcfiles" - -set prefix "" -foreach x $srcfiles { - regsub "\\.exp$" $x "" prefix - set bname [file tail $prefix] - set args "" - if [file exists $srcdir/$subdir/${bname}.arg] { - set id [open "$srcdir/$subdir/${bname}.arg" r]; - set args [read -nonewline $id]; - close $id; - } - if [file exists $srcdir/$subdir/${bname}.xpo] { - set resfile "$srcdir/$subdir/${bname}.xpo" - set options "regexp_match" - } else { - set resfile "${prefix}.exp" - set options "" - } - - if [file exists ${prefix}.inp] { - set inpfile ${prefix}.inp - } else { - set inpfile "" - } - - verbose "inpfile is $inpfile" - - test_libstdc++ $options "${prefix}.cc" "" $inpfile $resfile $args - test_libstdc++ $options "${prefix}.cc" "-O" $inpfile $resfile $args -} diff --git a/libstdc++/tinfo.cc b/libstdc++/tinfo.cc deleted file mode 100644 index ffad6e72994..00000000000 --- a/libstdc++/tinfo.cc +++ /dev/null @@ -1,1210 +0,0 @@ -// Methods for type_info for -*- C++ -*- Run Time Type Identification. -// Copyright (C) 1994, 1996, 1998, 1999, 2000 Free Software Foundation - -// This file is part of GNU CC. - -// GNU CC 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. - -// GNU CC 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 GNU CC; 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. - -#pragma implementation "typeinfo" - -#include -#include "tinfo.hP" -#include "new" // for placement new - -// This file contains the minimal working set necessary to link with code -// that uses virtual functions and -frtti but does not actually use RTTI -// functionality. - -std::type_info:: -~type_info () -{ } - -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -// original (old) abi - -namespace -{ -// ADDR is a pointer to an object. Convert it to a pointer to a base, -// using OFFSET. -inline void* -convert_to_base (void *addr, bool is_virtual, myint32 offset) -{ - if (!addr) - return NULL; - - if (!is_virtual) - return (char *) addr + offset; - - // Under the old ABI, the offset gives us the address of a pointer - // to the virtual base. - return *((void **) ((char *) addr + offset)); -} - -} - -// We can't rely on common symbols being shared between shared objects. -bool std::type_info:: -operator== (const std::type_info& arg) const -{ - return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) == 0); -} - -extern "C" void -__rtti_class (void *addr, const char *name, - const __class_type_info::base_info *bl, size_t bn) -{ new (addr) __class_type_info (name, bl, bn); } - -extern "C" void -__rtti_si (void *addr, const char *n, const std::type_info *ti) -{ - new (addr) __si_type_info - (n, static_cast (*ti)); -} - -extern "C" void -__rtti_user (void *addr, const char *name) -{ new (addr) __user_type_info (name); } - -// Upcast for catch checking. OBJPTR points to the thrown object and might be -// NULL. Return 0 on failure, non-zero on success. Set *ADJPTR to adjusted -// object pointer. -int __user_type_info:: -upcast (const type_info &target, void *objptr, - void **adjptr) const -{ - upcast_result result; - - if (do_upcast (contained_public, target, objptr, result)) - return 0; - *adjptr = result.target_obj; - return contained_public_p (result.whole2target); -} - -// Down or cross cast for dynamic_cast. OBJPTR points to the most derrived -// object, SUBPTR points to the static base object. Both must not be NULL. -// TARGET specifies the desired target type, SUBTYPE specifies the static -// type. Both must be defined. Returns adjusted object pointer on success, -// NULL on failure. [expr.dynamic.cast]/8 says 'unambiguous public base'. This -// itself is an ambiguous statement. We choose it to mean the base must be -// separately unambiguous and public, rather than unambiguous considering only -// public bases. -void *__user_type_info:: -dyncast (int boff, - const type_info &target, void *objptr, - const type_info &subtype, void *subptr) const -{ - dyncast_result result; - - do_dyncast (boff, contained_public, - target, objptr, subtype, subptr, result); - if (!result.target_obj) - return NULL; - if (contained_public_p (result.target2sub)) - return result.target_obj; - if (contained_public_p (sub_kind (result.whole2sub & result.whole2target))) - // Found a valid cross cast - return result.target_obj; - if (contained_nonvirtual_p (result.whole2sub)) - // Found an invalid cross cast, which cannot also be a down cast - return NULL; - if (result.target2sub == unknown) - result.target2sub = static_cast (target) - .find_public_subobj (boff, subtype, - result.target_obj, subptr); - if (contained_public_p (result.target2sub)) - // Found a valid down cast - return result.target_obj; - // Must be an invalid down cast, or the cross cast wasn't bettered - return NULL; -} - -// Catch cast helper. ACCESS_PATH is the access from the complete thrown -// object to this base. TARGET is the desired type we want to catch. OBJPTR -// points to this base within the throw object, it might be NULL. Fill in -// RESULT with what we find. Return true, should we determine catch must fail. -bool __user_type_info:: -do_upcast (sub_kind access_path, - const type_info &target, void *objptr, - upcast_result &__restrict result) const -{ - if (*this == target) - { - result.target_obj = objptr; - result.base_type = nonvirtual_base_type; - result.whole2target = access_path; - return contained_nonpublic_p (access_path); - } - return false; -} - -// dynamic cast helper. ACCESS_PATH gives the access from the most derived -// object to this base. TARGET indicates the desired type we want. OBJPTR -// points to this base within the object. SUBTYPE indicates the static type -// started from and SUBPTR points to that base within the most derived object. -// Fill in RESULT with what we find. Return true if we have located an -// ambiguous match. -bool __user_type_info:: -do_dyncast (int, sub_kind access_path, - const type_info &target, void *objptr, - const type_info &subtype, void *subptr, - dyncast_result &__restrict result) const -{ - if (objptr == subptr && *this == subtype) - { - // The subobject we started from. Indicate how we are accessible from - // the most derived object. - result.whole2sub = access_path; - return false; - } - if (*this == target) - { - result.target_obj = objptr; - result.whole2target = access_path; - result.target2sub = not_contained; - return false; - } - return false; -} - -// find_public_subobj helper. Return contained_public if we are the desired -// subtype. OBJPTR points to this base type, SUBPTR points to the desired base -// object. -__user_type_info::sub_kind __user_type_info:: -do_find_public_subobj (int, const type_info &, void *objptr, void *subptr) const -{ - if (subptr == objptr) - // Must be our type, as the pointers match. - return contained_public; - return not_contained; -} - -// catch helper for single public inheritance types. See -// __user_type_info::do_upcast for semantics. -bool __si_type_info:: -do_upcast (sub_kind access_path, - const type_info &target, void *objptr, - upcast_result &__restrict result) const -{ - if (*this == target) - { - result.target_obj = objptr; - result.base_type = nonvirtual_base_type; - result.whole2target = access_path; - return contained_nonpublic_p (access_path); - } - return base.do_upcast (access_path, target, objptr, result); -} - -// dynamic cast helper for single public inheritance types. See -// __user_type_info::do_dyncast for semantics. BOFF indicates how SUBTYPE -// types are inherited by TARGET types. -bool __si_type_info:: -do_dyncast (int boff, sub_kind access_path, - const type_info &target, void *objptr, - const type_info &subtype, void *subptr, - dyncast_result &__restrict result) const -{ - if (objptr == subptr && *this == subtype) - { - // The subobject we started from. Indicate how we are accessible from - // the most derived object. - result.whole2sub = access_path; - return false; - } - if (*this == target) - { - result.target_obj = objptr; - result.whole2target = access_path; - if (boff >= 0) - result.target2sub = ((char *)subptr - (char *)objptr) == boff - ? contained_public : not_contained; - else if (boff == -2) - result.target2sub = not_contained; - return false; - } - return base.do_dyncast (boff, access_path, - target, objptr, subtype, subptr, result); -} - -// find_public_subobj helper. See __user_type_info::do_find_public_subobj or -// semantics. BOFF indicates how SUBTYPE types are inherited by the original -// target object. -__user_type_info::sub_kind __si_type_info:: -do_find_public_subobj (int boff, const type_info &subtype, void *objptr, void *subptr) const -{ - if (subptr == objptr && subtype == *this) - return contained_public; - return base.do_find_public_subobj (boff, subtype, objptr, subptr); -} - -// catch helper for multiple or non-public inheritance types. See -// __user_type_info::do_upcast for semantics. -bool __class_type_info:: -do_upcast (sub_kind access_path, - const type_info &target, void *objptr, - upcast_result &__restrict result) const -{ - if (*this == target) - { - result.target_obj = objptr; - result.base_type = nonvirtual_base_type; - result.whole2target = access_path; - return contained_nonpublic_p (access_path); - } - - for (size_t i = n_bases; i--;) - { - upcast_result result2; - void *p = objptr; - sub_kind sub_access = access_path; - p = convert_to_base (p, - base_list[i].is_virtual, - base_list[i].offset); - if (base_list[i].is_virtual) - sub_access = sub_kind (sub_access | contained_virtual_mask); - if (base_list[i].access != PUBLIC) - sub_access = sub_kind (sub_access & ~contained_public_mask); - if (base_list[i].base->do_upcast (sub_access, target, p, result2) - && !contained_virtual_p (result2.whole2target)) - return true; // must fail - if (result2.base_type) - { - if (result2.base_type == nonvirtual_base_type - && base_list[i].is_virtual) - result2.base_type = base_list[i].base; - if (!result.base_type) - result = result2; - else if (result.target_obj != result2.target_obj) - { - // Found an ambiguity. - result.target_obj = NULL; - result.whole2target = contained_ambig; - return true; - } - else if (result.target_obj) - { - // Ok, found real object via a virtual path. - result.whole2target - = sub_kind (result.whole2target | result2.whole2target); - } - else - { - // Dealing with a null pointer, need to check vbase - // containing each of the two choices. - if (result2.base_type == nonvirtual_base_type - || result.base_type == nonvirtual_base_type - || !(*result2.base_type == *result.base_type)) - { - // Already ambiguous, not virtual or via different virtuals. - // Cannot match. - result.whole2target = contained_ambig; - return true; - } - result.whole2target - = sub_kind (result.whole2target | result2.whole2target); - } - } - } - return false; -} - -// dynamic cast helper for non-public or multiple inheritance types. See -// __user_type_info::do_dyncast for overall semantics. -// This is a big hairy function. Although the run-time behaviour of -// dynamic_cast is simple to describe, it gives rise to some non-obvious -// behaviour. We also desire to determine as early as possible any definite -// answer we can get. Because it is unknown what the run-time ratio of -// succeeding to failing dynamic casts is, we do not know in which direction -// to bias any optimizations. To that end we make no particular effort towards -// early fail answers or early success answers. Instead we try to minimize -// work by filling in things lazily (when we know we need the information), -// and opportunisticly take early success or failure results. -bool __class_type_info:: -do_dyncast (int boff, sub_kind access_path, - const type_info &target, void *objptr, - const type_info &subtype, void *subptr, - dyncast_result &__restrict result) const -{ - if (objptr == subptr && *this == subtype) - { - // The subobject we started from. Indicate how we are accessible from - // the most derived object. - result.whole2sub = access_path; - return false; - } - if (*this == target) - { - result.target_obj = objptr; - result.whole2target = access_path; - if (boff >= 0) - result.target2sub = ((char *)subptr - (char *)objptr) == boff - ? contained_public : not_contained; - else if (boff == -2) - result.target2sub = not_contained; - return false; - } - bool result_ambig = false; - for (size_t i = n_bases; i--;) - { - dyncast_result result2; - void *p; - sub_kind sub_access = access_path; - p = convert_to_base (objptr, - base_list[i].is_virtual, - base_list[i].offset); - if (base_list[i].is_virtual) - sub_access = sub_kind (sub_access | contained_virtual_mask); - if (base_list[i].access != PUBLIC) - sub_access = sub_kind (sub_access & ~contained_public_mask); - - bool result2_ambig - = base_list[i].base->do_dyncast (boff, sub_access, - target, p, subtype, subptr, result2); - result.whole2sub = sub_kind (result.whole2sub | result2.whole2sub); - if (result2.target2sub == contained_public - || result2.target2sub == contained_ambig) - { - result.target_obj = result2.target_obj; - result.whole2target = result2.whole2target; - result.target2sub = result2.target2sub; - // Found a downcast which can't be bettered or an ambiguous downcast - // which can't be disambiguated - return result2_ambig; - } - - if (!result_ambig && !result.target_obj) - { - // Not found anything yet. - result.target_obj = result2.target_obj; - result.whole2target = result2.whole2target; - result_ambig = result2_ambig; - } - else if (result.target_obj && result.target_obj == result2.target_obj) - { - // Found at same address, must be via virtual. Pick the most - // accessible path. - result.whole2target = - sub_kind (result.whole2target | result2.whole2target); - } - else if ((result.target_obj && result2.target_obj) - || (result_ambig && result2.target_obj) - || (result2_ambig && result.target_obj)) - { - // Found two different TARGET bases, or a valid one and a set of - // ambiguous ones, must disambiguate. See whether SUBOBJ is - // contained publicly within one of the non-ambiguous choices. - // If it is in only one, then that's the choice. If it is in - // both, then we're ambiguous and fail. If it is in neither, - // we're ambiguous, but don't yet fail as we might later find a - // third base which does contain SUBPTR. - - sub_kind new_sub_kind = result2.target2sub; - sub_kind old_sub_kind = result.target2sub; - - if (contained_nonvirtual_p (result.whole2sub)) - { - // We already found SUBOBJ as a non-virtual base of most - // derived. Therefore if it is in either choice, it can only be - // in one of them, and we will already know. - if (old_sub_kind == unknown) - old_sub_kind = not_contained; - if (new_sub_kind == unknown) - new_sub_kind = not_contained; - } - else - { - const __user_type_info &t = - static_cast (target); - - if (old_sub_kind >= not_contained) - ;// already calculated - else if (contained_nonvirtual_p (new_sub_kind)) - // Already found non-virtually inside the other choice, - // cannot be in this. - old_sub_kind = not_contained; - else - old_sub_kind = t.find_public_subobj (boff, subtype, - result.target_obj, subptr); - - if (new_sub_kind >= not_contained) - ;// already calculated - else if (contained_nonvirtual_p (old_sub_kind)) - // Already found non-virtually inside the other choice, - // cannot be in this. - new_sub_kind = not_contained; - else - new_sub_kind = t.find_public_subobj (boff, subtype, - result2.target_obj, subptr); - } - - // Neither sub_kind can be contained_ambig -- we bail out early - // when we find those. - if (contained_p (sub_kind (new_sub_kind ^ old_sub_kind))) - { - // Only on one choice, not ambiguous. - if (contained_p (new_sub_kind)) - { - // Only in new. - result.target_obj = result2.target_obj; - result.whole2target = result2.whole2target; - result_ambig = false; - old_sub_kind = new_sub_kind; - } - result.target2sub = old_sub_kind; - if (result.target2sub == contained_public) - return false; // Can't be an ambiguating downcast for later discovery. - } - else if (contained_p (sub_kind (new_sub_kind & old_sub_kind))) - { - // In both. - result.target_obj = NULL; - result.target2sub = contained_ambig; - return true; // Fail. - } - else - { - // In neither publicly, ambiguous for the moment, but keep - // looking. It is possible that it was private in one or - // both and therefore we should fail, but that's just tough. - result.target_obj = NULL; - result.target2sub = not_contained; - result_ambig = true; - } - } - - if (result.whole2sub == contained_private) - // We found SUBOBJ as a private non-virtual base, therefore all - // cross casts will fail. We have already found a down cast, if - // there is one. - return result_ambig; - } - - return result_ambig; -} - -// find_public_subobj helper for non-public or multiple inheritance types. See -// __user_type_info::do_find_public_subobj for semantics. We make use of BOFF -// to prune the base class walk. -__user_type_info::sub_kind __class_type_info:: -do_find_public_subobj (int boff, const type_info &subtype, void *objptr, void *subptr) const -{ - if (objptr == subptr && subtype == *this) - return contained_public; - - for (size_t i = n_bases; i--;) - { - if (base_list[i].access != PUBLIC) - continue; // Not public, can't be here. - void *p; - - if (base_list[i].is_virtual && boff == -3) - // Not a virtual base, so can't be here. - continue; - - p = convert_to_base (objptr, - base_list[i].is_virtual, - base_list[i].offset); - - sub_kind base_kind = base_list[i].base->do_find_public_subobj - (boff, subtype, p, subptr); - if (contained_p (base_kind)) - { - if (base_list[i].is_virtual) - base_kind = sub_kind (base_kind | contained_virtual_mask); - return base_kind; - } - } - - return not_contained; -} -#else -// new abi - -namespace std { - -// return true if this is a type_info for a pointer type -bool type_info:: -__is_pointer_p () const -{ - return false; -} - -// return true if this is a type_info for a function type -bool type_info:: -__is_function_p () const -{ - return false; -} - -// try and catch a thrown object. -bool type_info:: -__do_catch (const type_info *thr_type, void **, unsigned) const -{ - return *this == *thr_type; -} - -// upcast from this type to the target. __class_type_info will override -bool type_info:: -__do_upcast (const abi::__class_type_info *, void **) const -{ - return false; -} - -}; - -namespace { - -using namespace std; -using namespace abi; - -// initial part of a vtable, this structure is used with offsetof, so we don't -// have to keep alignments consistent manually. -struct vtable_prefix { - ptrdiff_t whole_object; // offset to most derived object - const __class_type_info *whole_type; // pointer to most derived type_info - const void *origin; // what a class's vptr points to -}; - -template -inline const T * -adjust_pointer (const void *base, ptrdiff_t offset) -{ - return reinterpret_cast - (reinterpret_cast (base) + offset); -} - -// ADDR is a pointer to an object. Convert it to a pointer to a base, -// using OFFSET. IS_VIRTUAL is true, if we are getting a virtual base. -inline void const * -convert_to_base (void const *addr, bool is_virtual, ptrdiff_t offset) -{ - if (is_virtual) - { - const void *vtable = *static_cast (addr); - - offset = *adjust_pointer (vtable, offset); - } - - return adjust_pointer (addr, offset); -} - -// some predicate functions for __class_type_info::__sub_kind -inline bool contained_p (__class_type_info::__sub_kind access_path) -{ - return access_path >= __class_type_info::__contained_mask; -} -inline bool public_p (__class_type_info::__sub_kind access_path) -{ - return access_path & __class_type_info::__contained_public_mask; -} -inline bool virtual_p (__class_type_info::__sub_kind access_path) -{ - return (access_path & __class_type_info::__contained_virtual_mask); -} -inline bool contained_public_p (__class_type_info::__sub_kind access_path) -{ - return ((access_path & __class_type_info::__contained_public) - == __class_type_info::__contained_public); -} -inline bool contained_nonpublic_p (__class_type_info::__sub_kind access_path) -{ - return ((access_path & __class_type_info::__contained_public) - == __class_type_info::__contained_mask); -} -inline bool contained_nonvirtual_p (__class_type_info::__sub_kind access_path) -{ - return ((access_path & (__class_type_info::__contained_mask - | __class_type_info::__contained_virtual_mask)) - == __class_type_info::__contained_mask); -} - -static const __class_type_info *const nonvirtual_base_type = - static_cast (0) + 1; - -}; // namespace - -namespace __cxxabiv1 -{ - -__class_type_info:: -~__class_type_info () -{} - -__si_class_type_info:: -~__si_class_type_info () -{} - -__vmi_class_type_info:: -~__vmi_class_type_info () -{} - -// __upcast_result is used to hold information during traversal of a class -// heirarchy when catch matching. -struct __class_type_info::__upcast_result -{ - const void *dst_ptr; // pointer to caught object - __sub_kind part2dst; // path from current base to target - int src_details; // hints about the source type heirarchy - const __class_type_info *base_type; // where we found the target, - // if in vbase the __class_type_info of vbase - // if a non-virtual base then 1 - // else NULL - public: - __upcast_result (int d) - :dst_ptr (NULL), part2dst (__unknown), src_details (d), base_type (NULL) - {} -}; - -// __dyncast_result is used to hold information during traversal of a class -// heirarchy when dynamic casting. -struct __class_type_info::__dyncast_result -{ - const void *dst_ptr; // pointer to target object or NULL - __sub_kind whole2dst; // path from most derived object to target - __sub_kind whole2src; // path from most derived object to sub object - __sub_kind dst2src; // path from target to sub object - int whole_details; // details of the whole class heirarchy - - public: - __dyncast_result (int details_ = __vmi_class_type_info::__flags_unknown_mask) - :dst_ptr (NULL), whole2dst (__unknown), - whole2src (__unknown), dst2src (__unknown), - whole_details (details_) - {} -}; - -bool __class_type_info:: -__do_catch (const type_info *thr_type, - void **thr_obj, - unsigned outer) const -{ - if (*this == *thr_type) - return true; - if (outer >= 4) - // Neither `A' nor `A *'. - return false; - return thr_type->__do_upcast (this, thr_obj); -} - -bool __class_type_info:: -__do_upcast (const __class_type_info *dst_type, - void **obj_ptr) const -{ - __upcast_result result (__vmi_class_type_info::__flags_unknown_mask); - - __do_upcast (dst_type, *obj_ptr, result); - if (!contained_public_p (result.part2dst)) - return false; - *obj_ptr = const_cast (result.dst_ptr); - return true; -} - -inline __class_type_info::__sub_kind __class_type_info:: -__find_public_src (ptrdiff_t src2dst, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const -{ - if (src2dst >= 0) - return adjust_pointer (obj_ptr, src2dst) == src_ptr - ? __contained_public : __not_contained; - if (src2dst == -2) - return __not_contained; - return __do_find_public_src (src2dst, obj_ptr, src_type, src_ptr); -} - -__class_type_info::__sub_kind __class_type_info:: -__do_find_public_src (ptrdiff_t, - const void *obj_ptr, - const __class_type_info *, - const void *src_ptr) const -{ - if (src_ptr == obj_ptr) - // Must be our type, as the pointers match. - return __contained_public; - return __not_contained; -} - -__class_type_info::__sub_kind __si_class_type_info:: -__do_find_public_src (ptrdiff_t src2dst, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const -{ - if (src_ptr == obj_ptr && *this == *src_type) - return __contained_public; - return __base_type->__do_find_public_src (src2dst, obj_ptr, src_type, src_ptr); -} - -__class_type_info::__sub_kind __vmi_class_type_info:: -__do_find_public_src (ptrdiff_t src2dst, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const -{ - if (obj_ptr == src_ptr && *this == *src_type) - return __contained_public; - - for (size_t i = __base_count; i--;) - { - if (!__base_info[i].__is_public_p ()) - continue; // Not public, can't be here. - - const void *base = obj_ptr; - ptrdiff_t offset = __base_info[i].__offset (); - bool is_virtual = __base_info[i].__is_virtual_p (); - - if (is_virtual) - { - if (src2dst == -3) - continue; // Not a virtual base, so can't be here. - } - base = convert_to_base (base, is_virtual, offset); - - __sub_kind base_kind = __base_info[i].__base->__do_find_public_src - (src2dst, base, src_type, src_ptr); - if (contained_p (base_kind)) - { - if (is_virtual) - base_kind = __sub_kind (base_kind | __contained_virtual_mask); - return base_kind; - } - } - - return __not_contained; -} - -bool __class_type_info:: -__do_dyncast (ptrdiff_t, - __sub_kind access_path, - const __class_type_info *dst_type, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr, - __dyncast_result &__restrict result) const -{ - if (obj_ptr == src_ptr && *this == *src_type) - { - // The src object we started from. Indicate how we are accessible from - // the most derived object. - result.whole2src = access_path; - return false; - } - if (*this == *dst_type) - { - result.dst_ptr = obj_ptr; - result.whole2dst = access_path; - result.dst2src = __not_contained; - return false; - } - return false; -} - -bool __si_class_type_info:: -__do_dyncast (ptrdiff_t src2dst, - __sub_kind access_path, - const __class_type_info *dst_type, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr, - __dyncast_result &__restrict result) const -{ - if (*this == *dst_type) - { - result.dst_ptr = obj_ptr; - result.whole2dst = access_path; - if (src2dst >= 0) - result.dst2src = adjust_pointer (obj_ptr, src2dst) == src_ptr - ? __contained_public : __not_contained; - else if (src2dst == -2) - result.dst2src = __not_contained; - return false; - } - if (obj_ptr == src_ptr && *this == *src_type) - { - // The src object we started from. Indicate how we are accessible from - // the most derived object. - result.whole2src = access_path; - return false; - } - return __base_type->__do_dyncast (src2dst, access_path, dst_type, obj_ptr, - src_type, src_ptr, result); -} - -// This is a big hairy function. Although the run-time behaviour of -// dynamic_cast is simple to describe, it gives rise to some non-obvious -// behaviour. We also desire to determine as early as possible any definite -// answer we can get. Because it is unknown what the run-time ratio of -// succeeding to failing dynamic casts is, we do not know in which direction -// to bias any optimizations. To that end we make no particular effort towards -// early fail answers or early success answers. Instead we try to minimize -// work by filling in things lazily (when we know we need the information), -// and opportunisticly take early success or failure results. -bool __vmi_class_type_info:: -__do_dyncast (ptrdiff_t src2dst, - __sub_kind access_path, - const __class_type_info *dst_type, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr, - __dyncast_result &__restrict result) const -{ - if (result.whole_details & __flags_unknown_mask) - result.whole_details = __flags; - - if (obj_ptr == src_ptr && *this == *src_type) - { - // The src object we started from. Indicate how we are accessible from - // the most derived object. - result.whole2src = access_path; - return false; - } - if (*this == *dst_type) - { - result.dst_ptr = obj_ptr; - result.whole2dst = access_path; - if (src2dst >= 0) - result.dst2src = adjust_pointer (obj_ptr, src2dst) == src_ptr - ? __contained_public : __not_contained; - else if (src2dst == -2) - result.dst2src = __not_contained; - return false; - } - - bool result_ambig = false; - for (size_t i = __base_count; i--;) - { - __dyncast_result result2 (result.whole_details); - void const *base = obj_ptr; - __sub_kind base_access = access_path; - ptrdiff_t offset = __base_info[i].__offset (); - bool is_virtual = __base_info[i].__is_virtual_p (); - - if (is_virtual) - base_access = __sub_kind (base_access | __contained_virtual_mask); - base = convert_to_base (base, is_virtual, offset); - - if (!__base_info[i].__is_public_p ()) - { - if (src2dst == -2 && - !(result.whole_details - & (__non_diamond_repeat_mask | __diamond_shaped_mask))) - // The hierarchy has no duplicate bases (which might ambiguate - // things) and where we started is not a public base of what we - // want (so it cannot be a downcast). There is nothing of interest - // hiding in a non-public base. - continue; - base_access = __sub_kind (base_access & ~__contained_public_mask); - } - - bool result2_ambig - = __base_info[i].__base->__do_dyncast (src2dst, base_access, - dst_type, base, - src_type, src_ptr, result2); - result.whole2src = __sub_kind (result.whole2src | result2.whole2src); - if (result2.dst2src == __contained_public - || result2.dst2src == __contained_ambig) - { - result.dst_ptr = result2.dst_ptr; - result.whole2dst = result2.whole2dst; - result.dst2src = result2.dst2src; - // Found a downcast which can't be bettered or an ambiguous downcast - // which can't be disambiguated - return result2_ambig; - } - - if (!result_ambig && !result.dst_ptr) - { - // Not found anything yet. - result.dst_ptr = result2.dst_ptr; - result.whole2dst = result2.whole2dst; - result_ambig = result2_ambig; - if (result.dst_ptr && result.whole2src != __unknown - && !(__flags & __non_diamond_repeat_mask)) - // Found dst and src and we don't have repeated bases. - return result_ambig; - } - else if (result.dst_ptr && result.dst_ptr == result2.dst_ptr) - { - // Found at same address, must be via virtual. Pick the most - // accessible path. - result.whole2dst = - __sub_kind (result.whole2dst | result2.whole2dst); - } - else if ((result.dst_ptr != 0 | result_ambig) - && (result2.dst_ptr != 0 | result2_ambig)) - { - // Found two different DST_TYPE bases, or a valid one and a set of - // ambiguous ones, must disambiguate. See whether SRC_PTR is - // contained publicly within one of the non-ambiguous choices. If it - // is in only one, then that's the choice. If it is in both, then - // we're ambiguous and fail. If it is in neither, we're ambiguous, - // but don't yet fail as we might later find a third base which does - // contain SRC_PTR. - - __sub_kind new_sub_kind = result2.dst2src; - __sub_kind old_sub_kind = result.dst2src; - - if (contained_p (result.whole2src) - && (!virtual_p (result.whole2src) - || !(result.whole_details & __diamond_shaped_mask))) - { - // We already found SRC_PTR as a base of most derived, and - // either it was non-virtual, or the whole heirarchy is - // not-diamond shaped. Therefore if it is in either choice, it - // can only be in one of them, and we will already know. - if (old_sub_kind == __unknown) - old_sub_kind = __not_contained; - if (new_sub_kind == __unknown) - new_sub_kind = __not_contained; - } - else - { - if (old_sub_kind >= __not_contained) - ;// already calculated - else if (contained_p (new_sub_kind) - && (!virtual_p (new_sub_kind) - || !(__flags & __diamond_shaped_mask))) - // Already found inside the other choice, and it was - // non-virtual or we are not diamond shaped. - old_sub_kind = __not_contained; - else - old_sub_kind = dst_type->__find_public_src - (src2dst, result.dst_ptr, src_type, src_ptr); - - if (new_sub_kind >= __not_contained) - ;// already calculated - else if (contained_p (old_sub_kind) - && (!virtual_p (old_sub_kind) - || !(__flags & __diamond_shaped_mask))) - // Already found inside the other choice, and it was - // non-virtual or we are not diamond shaped. - new_sub_kind = __not_contained; - else - new_sub_kind = dst_type->__find_public_src - (src2dst, result2.dst_ptr, src_type, src_ptr); - } - - // Neither sub_kind can be contained_ambig -- we bail out early - // when we find those. - if (contained_p (__sub_kind (new_sub_kind ^ old_sub_kind))) - { - // Only on one choice, not ambiguous. - if (contained_p (new_sub_kind)) - { - // Only in new. - result.dst_ptr = result2.dst_ptr; - result.whole2dst = result2.whole2dst; - result_ambig = false; - old_sub_kind = new_sub_kind; - } - result.dst2src = old_sub_kind; - if (public_p (result.dst2src)) - return false; // Can't be an ambiguating downcast for later discovery. - if (!virtual_p (result.dst2src)) - return false; // Found non-virtually can't be bettered - } - else if (contained_p (__sub_kind (new_sub_kind & old_sub_kind))) - { - // In both. - result.dst_ptr = NULL; - result.dst2src = __contained_ambig; - return true; // Fail. - } - else - { - // In neither publicly, ambiguous for the moment, but keep - // looking. It is possible that it was private in one or - // both and therefore we should fail, but that's just tough. - result.dst_ptr = NULL; - result.dst2src = __not_contained; - result_ambig = true; - } - } - - if (result.whole2src == __contained_private) - // We found SRC_PTR as a private non-virtual base, therefore all - // cross casts will fail. We have already found a down cast, if - // there is one. - return result_ambig; - } - - return result_ambig; -} - -bool __class_type_info:: -__do_upcast (const __class_type_info *dst, const void *obj, - __upcast_result &__restrict result) const -{ - if (*this == *dst) - { - result.dst_ptr = obj; - result.base_type = nonvirtual_base_type; - result.part2dst = __contained_public; - return true; - } - return false; -} - -bool __si_class_type_info:: -__do_upcast (const __class_type_info *dst, const void *obj_ptr, - __upcast_result &__restrict result) const -{ - if (__class_type_info::__do_upcast (dst, obj_ptr, result)) - return true; - - return __base_type->__do_upcast (dst, obj_ptr, result); -} - -bool __vmi_class_type_info:: -__do_upcast (const __class_type_info *dst, const void *obj_ptr, - __upcast_result &__restrict result) const -{ - if (__class_type_info::__do_upcast (dst, obj_ptr, result)) - return true; - - int src_details = result.src_details; - if (src_details & __flags_unknown_mask) - src_details = __flags; - - for (size_t i = __base_count; i--;) - { - __upcast_result result2 (src_details); - const void *base = obj_ptr; - ptrdiff_t offset = __base_info[i].__offset (); - bool is_virtual = __base_info[i].__is_virtual_p (); - bool is_public = __base_info[i].__is_public_p (); - - if (!is_public && !(src_details & __non_diamond_repeat_mask)) - // original cannot have an ambiguous base, so skip private bases - continue; - - if (base) - base = convert_to_base (base, is_virtual, offset); - - if (__base_info[i].__base->__do_upcast (dst, base, result2)) - { - if (result2.base_type == nonvirtual_base_type && is_virtual) - result2.base_type = __base_info[i].__base; - if (contained_p (result2.part2dst) && !is_public) - result2.part2dst = __sub_kind (result2.part2dst & ~__contained_public_mask); - - if (!result.base_type) - { - result = result2; - if (!contained_p (result.part2dst)) - return true; // found ambiguously - - if (result.part2dst & __contained_public_mask) - { - if (!(__flags & __non_diamond_repeat_mask)) - return true; // cannot have an ambiguous other base - } - else - { - if (!virtual_p (result.part2dst)) - return true; // cannot have another path - if (!(__flags & __diamond_shaped_mask)) - return true; // cannot have a more accessible path - } - } - else if (result.dst_ptr != result2.dst_ptr) - { - // Found an ambiguity. - result.dst_ptr = NULL; - result.part2dst = __contained_ambig; - return true; - } - else if (result.dst_ptr) - { - // Ok, found real object via a virtual path. - result.part2dst - = __sub_kind (result.part2dst | result2.part2dst); - } - else - { - // Dealing with a null pointer, need to check vbase - // containing each of the two choices. - if (result2.base_type == nonvirtual_base_type - || result.base_type == nonvirtual_base_type - || !(*result2.base_type == *result.base_type)) - { - // Already ambiguous, not virtual or via different virtuals. - // Cannot match. - result.part2dst = __contained_ambig; - return true; - } - result.part2dst - = __sub_kind (result.part2dst | result2.part2dst); - } - } - } - return result.part2dst != __unknown; -} - -// this is the external interface to the dynamic cast machinery -extern "C" void * -__dynamic_cast (const void *src_ptr, // object started from - const __class_type_info *src_type, // type of the starting object - const __class_type_info *dst_type, // desired target type - ptrdiff_t src2dst) // how src and dst are related -{ - const void *vtable = *static_cast (src_ptr); - const vtable_prefix *prefix = - adjust_pointer (vtable, - -offsetof (vtable_prefix, origin)); - const void *whole_ptr = - adjust_pointer (src_ptr, prefix->whole_object); - const __class_type_info *whole_type = prefix->whole_type; - __class_type_info::__dyncast_result result; - - whole_type->__do_dyncast (src2dst, __class_type_info::__contained_public, - dst_type, whole_ptr, src_type, src_ptr, result); - if (!result.dst_ptr) - return NULL; - if (contained_public_p (result.dst2src)) - // Src is known to be a public base of dst. - return const_cast (result.dst_ptr); - if (contained_public_p (__class_type_info::__sub_kind (result.whole2src & result.whole2dst))) - // Both src and dst are known to be public bases of whole. Found a valid - // cross cast. - return const_cast (result.dst_ptr); - if (contained_nonvirtual_p (result.whole2src)) - // Src is known to be a non-public nonvirtual base of whole, and not a - // base of dst. Found an invalid cross cast, which cannot also be a down - // cast - return NULL; - if (result.dst2src == __class_type_info::__unknown) - result.dst2src = dst_type->__find_public_src (src2dst, result.dst_ptr, - src_type, src_ptr); - if (contained_public_p (result.dst2src)) - // Found a valid down cast - return const_cast (result.dst_ptr); - // Must be an invalid down cast, or the cross cast wasn't bettered - return NULL; -} - -}; // namespace __cxxabiv1 -#endif diff --git a/libstdc++/tinfo.hP b/libstdc++/tinfo.hP deleted file mode 100644 index 6be77bae268..00000000000 --- a/libstdc++/tinfo.hP +++ /dev/null @@ -1,223 +0,0 @@ -// RTTI support internals for -*- C++ -*- -// Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000 Free Software Foundation - -#include "typeinfo" - -// Class declarations shared between the typeinfo implementation files. - -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -// original (old) abi - -// type_info for a class with no base classes (or an enum). - -struct __user_type_info : public std::type_info { - __user_type_info (const char *n) : type_info (n) {} - - // If our type can be upcast to a public and unambiguous base, then return - // non-zero and set RES to point to the base object. OBJ points to the throw - // object and can be NULL, if there is no object to adjust. - int upcast (const type_info &target, void *obj, void **res) const; - - // If our type can be dynamicly cast to the target type, then return - // pointer to the target object. OBJ is the pointer to the most derived - // type and cannot be NULL. SUBTYPE and SUBOBJ indicate the static type - // base object from whence we came, it cannot be NULL. SUBTYPE cannot be - // the same as TARGET. TARGET cannot be a base of SUBTYPE. - // BOFF indicates how SUBTYPE is related to TARGET. - // BOFF >= 0, there is only one public non-virtual SUBTYPE base at offset - // BOFF, and there are no public virtual SUBTYPE bases. - // Therefore check if SUBOBJ is at offset BOFF when we find a target - // BOFF == -1, SUBTYPE occurs as multiple public virtual or non-virtual bases. - // Lazily search all the bases of TARGET. - // BOFF == -2, SUBTYPE is not a public base. - // BOFF == -3, SUBTYPE occurs as multiple public non-virtual bases. - // Lazily search the non-virtual bases of TARGET. - // For backwards compatibility set BOFF to -1, that is the safe "unknown" - // value. We do not care about SUBTYPES as private bases of TARGET, as they - // can never succeed as downcasts, only as crosscasts -- and then only if - // they are virtual. This is more complicated that it might seem. - void *dyncast (int boff, - const type_info &target, void *obj, - const type_info &subtype, void *subobj) const; - - // non_virtual_base_type is used to indicate that a base class is via a - // non-virtual access path. - static const type_info *const nonvirtual_base_type - = static_cast (0) + 1; - - // sub_kind tells us about how a base object is contained within a derived - // object. We often do this lazily, hence the UNKNOWN value. At other times - // we may use NOT_CONTAINED to mean not publicly contained. - enum sub_kind - { - unknown = 0, // we have no idea - not_contained, // not contained within us (in some - // circumstances this might mean not contained - // publicly) - contained_ambig, // contained ambiguously - contained_mask = 4, // contained within us - contained_virtual_mask = 1, // via a virtual path - contained_public_mask = 2, // via a public path - contained_private = contained_mask, - contained_public = contained_mask | contained_public_mask - }; - // some predicate functions for sub_kind - static inline bool contained_p (sub_kind access_path) - { - return access_path >= contained_mask; - } - static inline bool contained_public_p (sub_kind access_path) - { - return access_path >= contained_public; - } - static inline bool contained_nonpublic_p (sub_kind access_path) - { - return (access_path & contained_public) == contained_mask; - } - static inline bool contained_nonvirtual_p (sub_kind access_path) - { - return (access_path & (contained_mask | contained_virtual_mask)) - == contained_mask; - } - static inline bool contained_virtual_p (sub_kind access_path) - { - return (access_path & (contained_mask | contained_virtual_mask)) - == (contained_mask | contained_virtual_mask); - } - - struct upcast_result - { - void *target_obj; // pointer to target object or NULL (init NULL) - sub_kind whole2target; // path from most derived object to target - const type_info *base_type; // where we found the target, (init NULL) - // if in vbase the __user_type_info of vbase) - // if a non-virtual base then 1 - // else NULL - public: - upcast_result () - :target_obj (NULL), whole2target (unknown), base_type (NULL) - {} - }; - struct dyncast_result - { - void *target_obj; // pointer to target object or NULL (init NULL) - sub_kind whole2target; // path from most derived object to target - sub_kind whole2sub; // path from most derived object to sub object - sub_kind target2sub; // path from target to sub object - - public: - dyncast_result () - :target_obj (NULL), whole2target (unknown), - whole2sub (unknown), target2sub (unknown) - {} - }; - - public: - // Helper for upcast. See if TARGET is us, or one of our bases. ACCESS_PATH - // gives the access from the start object. Return TRUE if we know the catch - // fails. - virtual bool do_upcast (sub_kind access_path, - const type_info &target, void *obj, - upcast_result &__restrict result) const; - // Helper for dyncast. BOFF indicates how the SUBTYPE is related to TARGET. - // ACCESS_PATH indicates the access from the most derived object. It is - // used to prune the DAG walk. All information about what we find is put - // into RESULT. Return true, if the match we have found is ambiguous. - virtual bool do_dyncast (int boff, sub_kind access_path, - const type_info &target, void *obj, - const type_info &subtype, void *subptr, - dyncast_result &__restrict result) const; - public: - // Indicate whether SUBPTR of type SUBTYPE is contained publicly within - // OBJPTR. OBJPTR points to this base object. BOFF indicates how SUBTYPE - // objects might be contained within this type. If SUBPTR is one of our - // SUBTYPE bases, indicate virtuality. Returns not_contained for non - // containment or private containment. - sub_kind find_public_subobj (int boff, const type_info &subtype, - void *objptr, void *subptr) const - { - if (boff >= 0) - return ((char *)subptr - (char *)objptr) == boff - ? contained_public : not_contained; - if (boff == -2) - return not_contained; - return do_find_public_subobj (boff, subtype, objptr, subptr); - } - - public: - // Helper for find_subobj. BOFF indicates how SUBTYPE bases are inherited by - // the type started from -- which is not necessarily the current type. - // OBJPTR points to the current base. - virtual sub_kind do_find_public_subobj (int boff, const type_info &subtype, - void *objptr, void *subptr) const; -}; - -// type_info for a class with one public, nonvirtual base class. - -class __si_type_info : public __user_type_info { - const __user_type_info &base; - -public: - __si_type_info (const char *n, const __user_type_info &b) - : __user_type_info (n), base (b) { } - - private: - virtual bool do_upcast (sub_kind access_path, - const type_info &target, void *obj, - upcast_result &__restrict result) const; - virtual bool do_dyncast (int boff, sub_kind access_path, - const type_info &target, void *obj, - const type_info &subtype, void *subptr, - dyncast_result &__restrict result) const; - virtual sub_kind do_find_public_subobj (int boff, const type_info &subtype, - void *objptr, void *subptr) const; -}; - -// type_info for a general class. - -#include - -#if INT_MAX == 2147483647 -typedef int myint32; -#elif SHRT_MAX == 2147483647 -typedef short myint32; -#elif SCHAR_MAX == 2147483647 -typedef signed char myint32; -#elif LONG_MAX == 2147483647 -typedef long myint32; -#else -# error "No 32-bit data type?" -#endif - -struct __class_type_info : public __user_type_info { - enum access { PUBLIC = 1, PROTECTED = 2, PRIVATE = 3 }; - - struct base_info { - const __user_type_info *base; - myint32 offset: 29; - bool is_virtual: 1; - enum access access: 2; - }; - - const base_info *base_list; - size_t n_bases; - - __class_type_info (const char *name, const base_info *bl, size_t bn) - : __user_type_info (name), base_list (bl), n_bases (bn) {} - - public: - virtual bool do_upcast (sub_kind access_path, - const type_info &target, void *obj, - upcast_result &__restrict result) const; - virtual bool do_dyncast (int boff, sub_kind access_path, - const type_info &target, void *obj, - const type_info &subtype, void *subptr, - dyncast_result &__restrict result) const; - virtual sub_kind do_find_public_subobj (int boff, const type_info &subtype, - void *objptr, void *subptr) const; -}; -#else -// new abi -#include - -#endif diff --git a/libstdc++/tinfo2.cc b/libstdc++/tinfo2.cc deleted file mode 100644 index 6e1c916f177..00000000000 --- a/libstdc++/tinfo2.cc +++ /dev/null @@ -1,452 +0,0 @@ -// Methods for type_info for -*- C++ -*- Run Time Type Identification. -// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000 Free Software Foundation - -// This file is part of GNU CC. - -// GNU CC 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. - -// GNU CC 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 GNU CC; 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. - -#include -#include "tinfo.hP" -#include "new" // for placement new - -// We can't rely on having stdlib.h if we're freestanding. -extern "C" void abort (); - -using std::type_info; - -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -bool -type_info::before (const type_info &arg) const -{ - return __builtin_strcmp (name (), arg.name ()) < 0; -} - -// type info for pointer type. - -struct __pointer_type_info : public type_info { - const type_info& type; - - __pointer_type_info (const char *n, const type_info& ti) - : type_info (n), type (ti) {} -}; - -// type info for attributes - -struct __attr_type_info : public type_info { - enum cv { NONE = 0, CONST = 1, VOLATILE = 2, CONSTVOL = 1 | 2 }; - - const type_info& type; - cv attr; - - __attr_type_info (const char *n, cv a, const type_info& t) - : type_info (n), type (t), attr (a) {} -}; - -// type_info for builtin type - -struct __builtin_type_info : public type_info { - __builtin_type_info (const char *n): type_info (n) {} -}; - -// type info for function. - -struct __func_type_info : public type_info { - __func_type_info (const char *n) : type_info (n) {} -}; - -// type info for pointer to member function. - -struct __ptmf_type_info : public type_info { - __ptmf_type_info (const char *n) : type_info (n) {} -}; - -// type info for pointer to data member. - -struct __ptmd_type_info : public type_info { - __ptmd_type_info (const char *n): type_info (n) {} -}; - -// type info for array. - -struct __array_type_info : public type_info { - __array_type_info (const char *n): type_info (n) {} -}; - -#else - -#include -#endif - -#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 -namespace __cxxabiv1 { - -using namespace std; - -// This has special meaning to the compiler, and will cause it -// to emit the type_info structures for the fundamental types which are -// mandated to exist in the runtime. -__fundamental_type_info:: -~__fundamental_type_info () -{} - -__array_type_info:: -~__array_type_info () -{} - -__function_type_info:: -~__function_type_info () -{} - -__enum_type_info:: -~__enum_type_info () -{} - -__pbase_type_info:: -~__pbase_type_info () -{} - -__pointer_type_info:: -~__pointer_type_info () -{} - -__pointer_to_member_type_info:: -~__pointer_to_member_type_info () -{} - -bool __pointer_type_info:: -__is_pointer_p () const -{ - return true; -} - -bool __function_type_info:: -__is_function_p () const -{ - return true; -} - -bool __pbase_type_info:: -__do_catch (const type_info *thr_type, - void **thr_obj, - unsigned outer) const -{ - if (*this == *thr_type) - return true; // same type - if (typeid (*this) != typeid (*thr_type)) - return false; // not both same kind of pointers - - if (!(outer & 1)) - // We're not the same and our outer pointers are not all const qualified - // Therefore there must at least be a qualification conversion involved - // But for that to be valid, our outer pointers must be const qualified. - return false; - - const __pbase_type_info *thrown_type = - static_cast (thr_type); - - if (thrown_type->__qualifier_flags & ~__qualifier_flags) - // We're less qualified. - return false; - - if (!(__qualifier_flags & __const_mask)) - outer &= ~1; - - return __pointer_catch (thrown_type, thr_obj, outer); -} - -inline bool __pbase_type_info:: -__pointer_catch (const __pbase_type_info *thrown_type, - void **thr_obj, - unsigned outer) const -{ - return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2); -} - -bool __pointer_type_info:: -__pointer_catch (const __pbase_type_info *thrown_type, - void **thr_obj, - unsigned outer) const -{ - if (outer < 2 && *__pointee == typeid (void)) - { - // conversion to void - return !thrown_type->__pointee->__is_function_p (); - } - - return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer); -} - -bool __pointer_to_member_type_info:: -__pointer_catch (const __pbase_type_info *thr_type, - void **thr_obj, - unsigned outer) const -{ - // This static cast is always valid, as our caller will have determined that - // thr_type is really a __pointer_to_member_type_info. - const __pointer_to_member_type_info *thrown_type = - static_cast (thr_type); - - if (*__context_class != *thrown_type->__context_class) - return false; // not pointers to member of same class - - return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer); -} - -} // namespace std -#endif - -// Entry points for the compiler. - -/* Low level match routine used by compiler to match types of catch - variables and thrown objects. */ - -extern "C" int -__throw_type_match_rtti_2 (const void *catch_type_r, const void *throw_type_r, - void *objptr, void **valp) -{ - const type_info &catch_type = *(const type_info *)catch_type_r; - const type_info &throw_type = *(const type_info *)throw_type_r; - - *valp = objptr; - -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -// old abi - if (catch_type == throw_type) - return 1; - - if (const __user_type_info *p - = dynamic_cast (&throw_type)) - { - return p->upcast (catch_type, objptr, valp); - } - else if (const __pointer_type_info *fr = - dynamic_cast (&throw_type)) - { - const __pointer_type_info *to = - dynamic_cast (&catch_type); - - if (! to) - return 0; - - const type_info *subfr = &fr->type, *subto = &to->type; - __attr_type_info::cv cvfrom, cvto; - - if (const __attr_type_info *at - = dynamic_cast (subfr)) - { - cvfrom = at->attr; - subfr = &at->type; - } - else - cvfrom = __attr_type_info::NONE; - - if (const __attr_type_info *at - = dynamic_cast (subto)) - { - cvto = at->attr; - subto = &at->type; - } - else - cvto = __attr_type_info::NONE; - - if (((cvfrom & __attr_type_info::CONST) - > (cvto & __attr_type_info::CONST)) - || ((cvfrom & __attr_type_info::VOLATILE) - > (cvto & __attr_type_info::VOLATILE))) - return 0; - - if (*subto == *subfr) - return 1; - else if (*subto == typeid (void) - && dynamic_cast (subfr) == 0) - return 1; - else if (const __user_type_info *p - = dynamic_cast (subfr)) - return p->upcast (*subto, objptr, valp); - else if (const __pointer_type_info *pfr - = dynamic_cast (subfr)) - { - // Multi-level pointer conversion. - - const __pointer_type_info *pto - = dynamic_cast (subto); - - if (! pto) - return 0; - - bool constp = (cvto & __attr_type_info::CONST); - for (subto = &pto->type, subfr = &pfr->type; ; - subto = &pto->type, subfr = &pfr->type) - { - if (const __attr_type_info *at - = dynamic_cast (subfr)) - { - cvfrom = at->attr; - subfr = &at->type; - } - else - cvfrom = __attr_type_info::NONE; - - if (const __attr_type_info *at - = dynamic_cast (subto)) - { - cvto = at->attr; - subto = &at->type; - } - else - cvto = __attr_type_info::NONE; - - if (((cvfrom & __attr_type_info::CONST) - > (cvto & __attr_type_info::CONST)) - || ((cvfrom & __attr_type_info::VOLATILE) - > (cvto & __attr_type_info::VOLATILE))) - return 0; - - if (! constp - && (((cvfrom & __attr_type_info::CONST) - < (cvto & __attr_type_info::CONST)) - || ((cvfrom & __attr_type_info::VOLATILE) - < (cvto & __attr_type_info::VOLATILE)))) - return 0; - - if (*subto == *subfr) - return 1; - - pto = dynamic_cast (subto); - pfr = dynamic_cast (subfr); - if (! pto || ! pfr) - return 0; - - if (! (cvto & __attr_type_info::CONST)) - constp = false; - } - } - } -#else -// new abi - - return catch_type.__do_catch (&throw_type, valp, 1); -#endif - return 0; -} - -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -/* Backward compatibility wrapper. */ - -extern "C" void* -__throw_type_match_rtti (const void *catch_type_r, const void *throw_type_r, - void *objptr) -{ - void *ret; - if (__throw_type_match_rtti_2 (catch_type_r, throw_type_r, objptr, &ret)) - return ret; - return NULL; -} -#endif - -/* Called from __cp_pop_exception. Is P the type_info node for a pointer - of some kind? */ - -bool -__is_pointer (void *p) -{ - const type_info *t = reinterpret_cast (p); -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -// old abi - const __pointer_type_info *pt = - dynamic_cast (t); - return pt != 0; -#else -// new abi - return t->__is_pointer_p (); -#endif -} - -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 -// old abi - -extern "C" void -__rtti_ptr (void *addr, const char *n, const type_info *ti) -{ new (addr) __pointer_type_info (n, *ti); } - -extern "C" void -__rtti_attr (void *addr, const char *n, int attrval, const type_info *ti) -{ - new (addr) __attr_type_info - (n, static_cast <__attr_type_info::cv> (attrval), *ti); -} - -extern "C" void -__rtti_func (void *addr, const char *name) -{ new (addr) __func_type_info (name); } - -extern "C" void -__rtti_ptmf (void *addr, const char *name) -{ new (addr) __ptmf_type_info (name); } - -extern "C" void -__rtti_ptmd (void *addr, const char *name) -{ new (addr) __ptmd_type_info (name); } - -extern "C" void -__rtti_array (void *addr, const char *name) -{ new (addr) __array_type_info (name); } - -extern "C" void * -__dynamic_cast (const type_info& (*from)(void), const type_info& (*to)(void), - int require_public, void *address, const type_info & (*sub)(void), void *subptr) -{ - if (!require_public) abort(); - return static_cast <__user_type_info const &> (from ()).dyncast - (/*boff=*/-1, to (), address, sub (), subptr); -} - -extern "C" void * -__dynamic_cast_2 (const type_info& (*from)(void), const type_info& (*to)(void), - int boff, - void *address, const type_info & (*sub)(void), void *subptr) -{ - return static_cast <__user_type_info const &> (from ()).dyncast - (boff, to (), address, sub (), subptr); -} - -// type_info nodes and functions for the builtin types. The mangling here -// must match the mangling in gcc/cp/rtti.c. - -#define BUILTIN(mangled) \ -unsigned char __ti##mangled [sizeof (__builtin_type_info)] \ - __attribute__ ((aligned (__alignof__ (void *)))); \ -extern "C" const type_info &__tf##mangled (void) { \ - if ((*(void **) __ti##mangled) == 0) \ - new (__ti##mangled) __builtin_type_info (#mangled); \ - return *(type_info *)__ti##mangled; \ -} - -BUILTIN (v); BUILTIN (x); BUILTIN (l); BUILTIN (i); BUILTIN (s); BUILTIN (b); -BUILTIN (c); BUILTIN (w); BUILTIN (r); BUILTIN (d); BUILTIN (f); -BUILTIN (Ui); BUILTIN (Ul); BUILTIN (Ux); BUILTIN (Us); BUILTIN (Uc); -BUILTIN (Sc); - -#endif diff --git a/libstdc++/typeinfo b/libstdc++/typeinfo deleted file mode 100644 index 91f0de2c720..00000000000 --- a/libstdc++/typeinfo +++ /dev/null @@ -1,134 +0,0 @@ -// RTTI support for -*- C++ -*- -// Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000 Free Software Foundation - -// This file is part of GNU CC. -// -// GNU CC 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. -// -// GNU CC 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 GNU CC; 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. - -// __GXX_ABI_VERSION distinguishes the ABI that is being used. Values <100 -// indicate the `old' abi, which grew as C++ was defined. Values >=100 -// indicate the `new' abi, which is a cross vendor C++ abi, documented at -// `http://reality.sgi.com/dehnert_engr/cxx/'. - -#ifndef __TYPEINFO__ -#define __TYPEINFO__ - -#pragma interface "typeinfo" - -#include - -extern "C++" { - -#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 -namespace __cxxabiv1 -{ - class __class_type_info; -} // namespace __cxxabiv1 -#endif - -namespace std { - -class type_info { -public: - // Destructor. Being the first non-inline virtual function, this controls in - // which translation unit the vtable is emitted. The compiler makes use of - // that information to know where to emit the runtime-mandated type_info - // structures in the new-abi. - virtual ~type_info (); - -private: - // Assigning type_info is not supported. made private. - type_info& operator= (const type_info&); - type_info (const type_info&); - -protected: - const char *__name; - -protected: - explicit type_info (const char *__n): __name (__n) { } - -public: - // the public interface -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 - // In old abi, there can be multiple instances of a type_info object for one - // type. Uniqueness must use the _name value, not object address. - bool before (const type_info& arg) const; - const char* name () const - { return __name; } - bool operator== (const type_info& __arg) const; - bool operator!= (const type_info& __arg) const - { return !operator== (__arg); } - -#else - // In new abi we can rely on type_info's NTBS being unique, - // and therefore address comparisons are sufficient. - bool before (const type_info& __arg) const - { return __name < __arg.__name; } - const char* name () const - { return __name; } - bool operator== (const type_info& __arg) const - { return __name == __arg.__name; } - bool operator!= (const type_info& __arg) const - { return !operator== (__arg); } -#endif - - // the internal interface -#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 -public: - // return true if this is a pointer type of some kind - virtual bool __is_pointer_p () const; - // return true if this is a function type - virtual bool __is_function_p () const; - - // Try and catch a thrown type. Store an adjusted pointer to the caught type - // in THR_OBJ. If THR_TYPE is not a pointer type, then THR_OBJ points to the - // thrown object. If THR_TYPE is a pointer type, then THR_OBJ is the pointer - // itself. OUTER indicates the number of outer pointers, and whether they - // were const qualified. - virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj, - unsigned __outer) const; - - // internally used during catch matching - virtual bool __do_upcast (const __cxxabiv1::__class_type_info *__target, - void **__obj_ptr) const; -#endif -}; - -class bad_cast : public exception { -public: - bad_cast() { } - virtual ~bad_cast() { } -}; - -class bad_typeid : public exception { - public: - bad_typeid () { } - virtual ~bad_typeid () { } -}; - -} // namespace std - -} // extern "C++" -#endif diff --git a/libstdc++/valarray b/libstdc++/valarray deleted file mode 100644 index a938b6a6863..00000000000 --- a/libstdc++/valarray +++ /dev/null @@ -1,8 +0,0 @@ -// Main header for -*- C++ -*- valarray classes. - -#ifndef __VALARRAY__ -#define __VALARRAY__ - -#include - -#endif diff --git a/libstdc++/valarray.cc b/libstdc++/valarray.cc deleted file mode 100644 index 5de4e929982..00000000000 --- a/libstdc++/valarray.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include - -template void - __valarray_fill(size_t* __restrict__, size_t, const size_t&); - -template void - __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__); - -template valarray::valarray(size_t); -template valarray::~valarray(); -template valarray::valarray(const valarray&); -template size_t valarray::size() const; -template size_t& valarray::operator[](size_t); - - -inline size_t -__valarray_product(const valarray& __a) -{ - // XXX: This ugly cast is necessary because - // valarray::operator[]() const returns a VALUE! - // Try to get the committee to correct that gross error. - typedef const size_t* __restrict__ _Tp; - const size_t __n = __a.size(); - valarray& __t = const_cast&>(__a); - return __valarray_product(&__t[0], &__t[0] + __n); -} - - -void __gslice_to_index(size_t __o, const valarray& __l, - const valarray& __s, - valarray& __i) -{ - const size_t __n = __l.size(); - size_t* const __t = static_cast(alloca(__n*sizeof(size_t))); - __valarray_fill(__t, __n, size_t(0)); - const size_t __z = __i.size(); - __valarray_fill(&__i[0], __z, __o); - for (size_t __j=0; __j<__z; ++__j) { - for (size_t __k=0; __k<__n; ++__k) - __i[__j] += __s[__k]*__t[__k]; - ++__t[__n-1]; - for (size_t __k=__n-1; __k; --__k) { - if (__t[__k] >= __l[__k]) { - __t[__k] = 0; - ++__t[__k-1]; - } - } - } -} - -_Indexer::_Indexer(size_t __o, const valarray& __l, - const valarray& __s) - : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s), - _M_index(__l.size() ? __valarray_product(__l) : 0) -{ __gslice_to_index(__o, __l, __s, _M_index); } - - - diff --git a/libstdc++/vec.cc b/libstdc++/vec.cc deleted file mode 100644 index 966feb486de..00000000000 --- a/libstdc++/vec.cc +++ /dev/null @@ -1,279 +0,0 @@ -// new abi support -*- C++ -*- -// Copyright (C) 2000 -// Free Software Foundation, Inc. -// Written by Nathan Sidwell, Codesourcery LLC, -// -// GNU CC 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. - -// GNU CC 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 GNU CC; 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. - -#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 -#include -#include -#include - -// Exception handling hook, to mark current exception as not caught -- -// generally because we're about to rethrow it after some cleanup. -extern "C" void __uncatch_exception (void); - -namespace __cxxabiv1 -{ - -/* allocate and construct array */ -extern "C" void * -__cxa_vec_new (size_t element_count, - size_t element_size, - size_t padding_size, - void (*constructor) (void *), - void (*destructor) (void *)) -{ - return __cxa_vec_new2 (element_count, element_size, padding_size, - constructor, destructor, - &operator new[], &operator delete []); -} - -extern "C" void * -__cxa_vec_new2 (size_t element_count, - size_t element_size, - size_t padding_size, - void (*constructor) (void *), - void (*destructor) (void *), - void *(*alloc) (size_t), - void (*dealloc) (void *)) -{ - size_t size = element_count * element_size + padding_size; - char *base = static_cast (alloc (size)); - - if (padding_size) - { - base += padding_size; - reinterpret_cast (base)[-1] = element_count; - } - try - { - __cxa_vec_ctor (base, element_count, element_size, - constructor, destructor); - } - catch (...) - { - __uncatch_exception (); - dealloc (base - padding_size); - throw; - } - return base; -} - -extern "C" void * -__cxa_vec_new3 (size_t element_count, - size_t element_size, - size_t padding_size, - void (*constructor) (void *), - void (*destructor) (void *), - void *(*alloc) (size_t), - void (*dealloc) (void *, size_t)) -{ - size_t size = element_count * element_size + padding_size; - char *base = static_cast (alloc (size)); - - if (padding_size) - { - base += padding_size; - reinterpret_cast (base)[-1] = element_count; - } - try - { - __cxa_vec_ctor (base, element_count, element_size, - constructor, destructor); - } - catch (...) - { - __uncatch_exception (); - dealloc (base - padding_size, size); - throw; - } - return base; -} - -/* construct array */ -extern "C" void -__cxa_vec_ctor (void *array_address, - size_t element_count, - size_t element_size, - void (*constructor) (void *), - void (*destructor) (void *)) -{ - size_t ix = 0; - char *ptr = static_cast (array_address); - - try - { - if (constructor) - for (; ix != element_count; ix++, ptr += element_size) - constructor (ptr); - } - catch (...) - { - __uncatch_exception (); - __cxa_vec_dtor (array_address, ix, element_size, destructor); - throw; - } -} - -/* construct an array by copying */ - -extern "C" void -__cxa_vec_cctor (void *dest_array, - void *src_array, - size_t element_count, - size_t element_size, - void (*constructor) (void *, void *), - void (*destructor) (void *)) -{ - size_t ix = 0; - char *dest_ptr = static_cast (dest_array); - char *src_ptr = static_cast (src_array); - - try - { - if (constructor) - for (; ix != element_count; - ix++, src_ptr += element_size, dest_ptr += element_size) - constructor (dest_ptr, src_ptr); - } - catch (...) - { - __uncatch_exception (); - __cxa_vec_dtor (dest_array, ix, element_size, destructor); - throw; - } -} - -/* destruct array */ -extern "C" void -__cxa_vec_dtor (void *array_address, - size_t element_count, - size_t element_size, - void (*destructor) (void *)) -{ - if (destructor) - { - char *ptr = static_cast (array_address); - size_t ix = element_count; - bool unwinding = std::uncaught_exception (); - - ptr += element_count * element_size; - - try - { - while (ix--) - { - ptr -= element_size; - destructor (ptr); - } - } - catch (...) - { - if (unwinding) - // [except.ctor]/3 If a destructor called during stack unwinding - // exits with an exception, terminate is called. - std::terminate (); - __uncatch_exception (); - __cxa_vec_dtor (array_address, ix, element_size, destructor); - throw; - } - } -} - -/* destruct and release array */ -extern "C" void -__cxa_vec_delete (void *array_address, - size_t element_size, - size_t padding_size, - void (*destructor) (void *)) -{ - __cxa_vec_delete2 (array_address, element_size, padding_size, - destructor, - &operator delete []); -} - -extern "C" void -__cxa_vec_delete2 (void *array_address, - size_t element_size, - size_t padding_size, - void (*destructor) (void *), - void (*dealloc) (void *)) -{ - char *base = static_cast (array_address); - - if (padding_size) - { - size_t element_count = reinterpret_cast (base)[-1]; - base -= padding_size; - try - { - __cxa_vec_dtor (array_address, element_count, element_size, - destructor); - } - catch (...) - { - __uncatch_exception (); - dealloc (base); - throw; - } - } - dealloc (base); -} - -extern "C" void -__cxa_vec_delete3 (void *array_address, - size_t element_size, - size_t padding_size, - void (*destructor) (void *), - void (*dealloc) (void *, size_t)) -{ - char *base = static_cast (array_address); - size_t size = 0; - - if (padding_size) - { - size_t element_count = reinterpret_cast (base)[-1]; - base -= padding_size; - size = element_count * element_size + padding_size; - try - { - __cxa_vec_dtor (array_address, element_count, element_size, - destructor); - } - catch (...) - { - __uncatch_exception (); - dealloc (base, size); - throw; - } - } - dealloc (base, size); -} - -} // namespace __cxxabiv1 - -#endif // defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100