This commit was generated by cvs2svn to compensate for changes in r51920,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
David E. O'Brien 1999-10-04 08:12:38 +00:00
commit 1b66e37f0a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=51921
159 changed files with 26972 additions and 0 deletions

1106
contrib/libstdc++/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,322 @@
# Copyright (C) 1994, 1995 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
OBJS = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.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
ARLIB = libstdc++.a
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 =
STAMP = bigstmp
LIBS = $(ARLIB)
#### 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)
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"$(enable_shared)" = xyes ]; then \
sed 's,\([A-Za-z_]*\.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)
$(SHLIB): piclist
$(CC) $(LIBCXXFLAGS) $(SHFLAGS) -shared -o $(SHLIB) `cat piclist` $(SHDEPS)
$(SHARLIB): $(SHLIB)
-rm -f t$(SHARLIB)
$(AR) $(AR_FLAGS) t$(SHARLIB) $(SHLIB)
mv t$(SHARLIB) $(SHARLIB)
$(RANLIB) $(SHARLIB)
$(SHLINK):
ln -f -s $(SHLIB) $(SHLINK)
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.
cstringi.o: cstringi.cc
cstdlibi.o: cstdlibi.cc
cmathi.o: cmathi.cc
stdexcepti.o: stdexcepti.cc
stlinst.o: stlinst.cc
# 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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"$(enable_shared)" = xyes ]; 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/*.*; 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$(libsubdir) = x ] || [ x$(enable_version_specific_runtime_libs) != xyes ]; then \
INSTALLDIR=$(libdir); \
else \
INSTALLDIR=$(libsubdir); \
fi; \
rm -f $${INSTALLDIR}$(MULTISUBDIR)/$(SHLINK) ; \
for FILE in $(LIBS) ; do \
rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
if [ $$FILE = $(SHLINK) ] ; then \
ln -f -s $(SHLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
elif [ $$FILE = mshlink ]; then \
for FILE in $(MSHLINK) ; do \
rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
ln -f -s $(SHLIB) $${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:
# Remove these for public releases.
MYCXXFLAGS = -g -O2 -Wpointer-arith -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -Winline -Wwrite-strings
MYCFLAGS = -g -O2 -Wpointer-arith -Wnested-externs
.PHONY: stuff
stuff:
$(MAKE) stuff1
$(MAKE) stuff2
stuff1:
$(MAKE) clean
$(MAKE) -C ../libio c++clean
touch ../../gcc/libgcc2.ready
stuff2:
-$(MAKE) -C ../../gcc/ libgcc.a
-$(MAKE) check CXXFLAGS="$(MYCXXFLAGS)" CFLAGS="$(MYCFLAGS)"
-$(MAKE) -C ../libio check
-$(MAKE) -C ../../gcc check-g++

9
contrib/libstdc++/NEWS Normal file
View File

@ -0,0 +1,9 @@
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++.

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CASSERT__
#define __CASSERT__
#include <assert.h>
#endif

7
contrib/libstdc++/cctype Normal file
View File

@ -0,0 +1,7 @@
// The -*- C++ -*- character type header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CCTYPE__
#define __CCTYPE__
#include <ctype.h>
#endif

7
contrib/libstdc++/cerrno Normal file
View File

@ -0,0 +1,7 @@
// The -*- C++ -*- error number header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CERRNO__
#define __CERRNO__
#include <errno.h>
#endif

7
contrib/libstdc++/cfloat Normal file
View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CFLOAT__
#define __CFLOAT__
#include <float.h>
#endif

155
contrib/libstdc++/cinst.cc Normal file
View File

@ -0,0 +1,155 @@
// 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 <std/complext.cc>
typedef complex<f> c;
typedef const c& ccr;
#ifdef MAIN
template class complex<f>;
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<f>&);
#endif
#ifdef INSERT
template ostream& operator<< (ostream&, const complex<f>&);
#endif

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CISO646__
#define __CISO646__
#include <iso646.h>
#endif

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CLIMITS__
#define __CLIMITS__
#include <limits.h>
#endif

View File

@ -0,0 +1,7 @@
// The -*- C++ -*- locale support header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CLOCALE__
#define __CLOCALE__
#include <locale.h>
#endif

76
contrib/libstdc++/cmath Normal file
View File

@ -0,0 +1,76 @@
// The -*- C++ -*- math functions header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CMATH__
#define __CMATH__
#include <_G_config.h>
#include <math.h>
#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

View File

@ -0,0 +1,7 @@
// 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 <cmath>

18
contrib/libstdc++/complex Normal file
View File

@ -0,0 +1,18 @@
// Main header for the -*- C++ -*- complex number classes.
// This file is part of the GNU ANSI C++ Library.
#ifndef __COMPLEX__
#define __COMPLEX__
#include <std/complext.h>
extern "C++" {
#define __STD_COMPLEX
// ANSI complex types
typedef complex<float> float_complex;
typedef complex<double> double_complex;
typedef complex<long double> long_double_complex;
}
#endif

View File

@ -0,0 +1,6 @@
// -*- C++ -*- backward compatiblity header.
// Copyright (C) 1994 Free Software Foundation
#ifndef __COMPLEX_H__
#include <complex>
#endif

View File

@ -0,0 +1,8 @@
# AIX has wierd shared/non-shared libraries.
ARLIB = libstdc++-ar.a
SHLINK = libstdc++.a
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
DEPLIBS = ../$(SHLIB)
SHDEPS = -lm
SHFLAGS = -Wl,-unix

View File

@ -0,0 +1,6 @@
# We don't need -fpic on the alpha, so let's install both the shared and
# non-shared versions.
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
DEPLIBS = ../$(SHLIB)
SHDEPS = -lm

View File

@ -0,0 +1,2 @@
# 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`

View File

@ -0,0 +1,8 @@
# Elf without shared libm -- we have to link with the archive library, even
# for programs that don't use complex.
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
SHFLAGS = -h $(SHLIB)
DEPLIBS = ../$(SHLIB)
LDLIBS = -L.. -lstdc++ -lm
MLDLIBS = -L.. -lstdc++ -lm

View File

@ -0,0 +1,6 @@
# Elf with shared libm, so we can link it into the shared libstdc++.
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
SHFLAGS = -h $(SHLIB)
SHDEPS = -lm
DEPLIBS = ../$(SHLIB)

View File

@ -0,0 +1,6 @@
# HPUX uses the .sl suffix for shared libraries.
SHLIB = libstdc++.sl
LIBS = $(ARLIB) $(SHLIB)
DEPLIBS = ../$(SHLIB)
SHFLAGS = $(PICFLAG)

View File

@ -0,0 +1,6 @@
# We don't need -fpic on IRIX, so let's install both the shared and
# non-shared versions.
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
DEPLIBS = ../$(SHLIB)
SHDEPS = -lm

View File

@ -0,0 +1,6 @@
# Elf with shared libm, so we can link it into the shared libstdc++.
LIBS = $(ARLIB) $(SHLIB) $(SHLINK) mshlink
SHFLAGS = -Wl,-soname,$(MSHLINK)
SHDEPS = -lm
DEPLIBS = ../$(SHLIB)

View File

@ -0,0 +1,2 @@
# tell we want the mt-safe version
MT_CFLAGS = -D_IO_MTSAFE_IO

View File

@ -0,0 +1,7 @@
# Base shared lib for OpenBSD i386
LIBS = $(ARLIB) $(SHLIB) $(SHLINK) mshlink
SHFLAGS = -nostdlib -Wl,-Bshareable,-Bforcearchive
SHDEPS = -lm
DEPLIBS = ../$(SHLIB)

View File

@ -0,0 +1,3 @@
# tell we want the mt-safe version
MT_CFLAGS = -D_IO_MTSAFE_IO -D_PTHREADS

View File

@ -0,0 +1,6 @@
# Solaris2 with shared libm, so we can link it into the shared libstdc++.
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
SHFLAGS = -h $(SHLIB)
SHDEPS = -lm
DEPLIBS = ../$(SHLIB)

View File

@ -0,0 +1,9 @@
# 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) $(SHLIB)
SHFLAGS = $(PICFLAG)
DEPLIBS = ../$(SHLIB)
LDLIBS = -L.. -lstdc++ -lm
MLDLIBS = -L.. -lstdc++ -lm

View File

@ -0,0 +1,119 @@
# 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 [ "${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
hppa*-*-*) frags=../../config/mh-papic ;;
i[3456]86-*-*) frags=../../config/mh-x86pic ;;
alpha*-*-linux*) frags=../../config/mh-elfalphapic ;;
# There doesn't seem to be a simpler way to say all-ppc except AIX
*-*-aix*) ;;
powerpc*-* | ppc*-*) frags=../../config/mh-ppcpic ;;
*-*-*) frags=../../config/mh-${target_cpu}pic ;;
esac
case "${target}" in
*-dec-osf*) frags="${frags} dec-osf.ml";;
*-*-hpux*) frags="${frags} hpux.ml" ;;
*-*-irix[56]*) frags="${frags} irix5.ml" ;;
*-*-linux*aout*) ;;
*-*-linux*) frags="${frags} linux.ml" ;;
*-*-openbsd*) frags="${frags} openbsd.ml" ;;
*-*-sysv4*) frags="${frags} elf.ml" ;;
*-*-solaris*) frags="${frags} sol2shm.ml" ;;
*-*-sunos4*) frags="${frags} sunos4.ml" ;;
*-*-aix*) frags="${frags} aix.ml" ;;
esac
fi
# Make sure the right flags are defined for multi-threading.
case "${target}" in
alpha*-*-linux-gnulibc1) frags="${frags} linux.mt" ;;
powerpc*-*-linux-gnulibc1) frags="${frags} linux.mt" ;;
*-*-linux-gnu) frags="${frags} linux.mt" ;;
*-*-openbsd*)
case "x${enable_threads}" in
xyes|xposix) frags="${frags} openbsd.mt" ;;
esac;;
m68k-motorola-sysv) frags="${frags} delta.mt" ;;
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"
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}
# post-target:
# If cross-compiling, we install in $(tooldir).
if [ -n "${with_cross_host}" ] ; then
rm -f Makefile.tem
sed \
-e 's|\(INSTALLDIR[ ]*=[ ]*\)[^ ;]*|\1$(tooldir)/lib|' \
Makefile >Makefile.tem
mv -f Makefile.tem Makefile
fi
. ${topsrcdir}/config-ml.in

View File

@ -0,0 +1,8 @@
// The -*- C++ -*- setjmp/longjmp header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CSETJMP__
#define __CSETJMP__
#include <setjmp.h>
#endif

View File

@ -0,0 +1,7 @@
// The -*- C++ -*- signal handling header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CSIGNAL__
#define __CSIGNAL__
#include <signal.h>
#endif

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CSTDARG__
#define __CSTDARG__
#include <stdarg.h>
#endif

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CSTDDEF__
#define __CSTDDEF__
#include <stddef.h>
#endif

7
contrib/libstdc++/cstdio Normal file
View File

@ -0,0 +1,7 @@
// The -*- C++ -*- standard I/O header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CSTDIO__
#define __CSTDIO__
#include <stdio.h>
#endif

23
contrib/libstdc++/cstdlib Normal file
View File

@ -0,0 +1,23 @@
// The -*- C++ -*- standard library header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CSTDLIB__
#define __CSTDLIB__
#include <stdlib.h>
#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

View File

@ -0,0 +1,7 @@
// 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 <cstdlib>

96
contrib/libstdc++/cstring Normal file
View File

@ -0,0 +1,96 @@
// The -*- C++ -*- null-terminated string header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CSTRING__
#define __CSTRING__
#include <string.h>
#if 0 // Let's not bother with this just yet.
#include <cstddef>
#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<char *> (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<char *> (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<char *> (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<char *> (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<void *> (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__)

View File

@ -0,0 +1,7 @@
// 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 <cstring>

7
contrib/libstdc++/ctime Normal file
View File

@ -0,0 +1,7 @@
// The -*- C++ -*- time header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CTIME__
#define __CTIME__
#include <time.h>
#endif

7
contrib/libstdc++/cwchar Normal file
View File

@ -0,0 +1,7 @@
// The -*- C++ -*- wide character header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CWCHAR__
#define __CWCHAR__
#include <wchar.h>
#endif

View File

@ -0,0 +1,7 @@
// The -*- C++ -*- wide character type header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __CWCTYPE__
#define __CWCTYPE__
#include <wctype.h>
#endif

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __FSTREAM__
#define __FSTREAM__
#include <fstream.h>
#endif

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __IOMANIP__
#define __IOMANIP__
#include <iomanip.h>
#endif

15
contrib/libstdc++/iosfwd Normal file
View File

@ -0,0 +1,15 @@
// -*- 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

View File

@ -0,0 +1,7 @@
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.
#ifndef __IOSTREAM__
#define __IOSTREAM__
#include <iostream.h>
#endif

132
contrib/libstdc++/sinst.cc Normal file
View File

@ -0,0 +1,132 @@
// 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 <string>
#ifdef C
typedef char c;
#endif
#ifdef W
typedef wchar_t c;
#endif
#ifdef TRAITS
template class string_char_traits <c>;
#endif
typedef basic_string <c> s;
#ifdef MAIN
template class basic_string <c>;
#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

View File

@ -0,0 +1,524 @@
// Member templates 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.
extern "C++" {
template <class charT, class traits, class Allocator>
inline void * basic_string <charT, traits, Allocator>::Rep::
operator new (size_t s, size_t extra)
{
return Allocator::allocate(s + extra * sizeof (charT));
}
template <class charT, class traits, class Allocator>
inline void basic_string <charT, traits, Allocator>::Rep::
operator delete (void * ptr)
{
Allocator::deallocate(ptr, sizeof(Rep) +
reinterpret_cast<Rep *>(ptr)->res *
sizeof (charT));
}
template <class charT, class traits, class Allocator>
inline size_t basic_string <charT, traits, Allocator>::Rep::
frob_size (size_t s)
{
size_t i = 16;
while (i < s) i *= 2;
return i;
}
template <class charT, class traits, class Allocator>
inline basic_string <charT, traits, Allocator>::Rep *
basic_string <charT, traits, Allocator>::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 <class charT, class traits, class Allocator>
charT * basic_string <charT, traits, Allocator>::Rep::
clone ()
{
Rep *p = Rep::create (len);
p->copy (0, data (), len);
p->len = len;
return p->data ();
}
template <class charT, class traits, class Allocator>
inline bool basic_string <charT, traits, Allocator>::Rep::
excess_slop (size_t s, size_t r)
{
return 2 * (s <= 16 ? 16 : s) < r;
}
template <class charT, class traits, class Allocator>
inline bool basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
void basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>&
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
inline void basic_string <charT, traits, Allocator>::Rep::
copy (size_t pos, const charT *s, size_t n)
{
if (n)
traits::copy (data () + pos, s, n);
}
template <class charT, class traits, class Allocator>
inline void basic_string <charT, traits, Allocator>::Rep::
move (size_t pos, const charT *s, size_t n)
{
if (n)
traits::move (data () + pos, s, n);
}
template <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>&
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
inline void basic_string <charT, traits, Allocator>::Rep::
set (size_t pos, const charT c, size_t n)
{
traits::set (data () + pos, c, n);
}
template <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
void basic_string <charT, traits, Allocator>::
resize (size_type n, charT c)
{
LENGTHERROR (n > max_size ());
if (n > length ())
append (n - length (), c);
else
erase (n);
}
template <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
inline basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
_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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
find (charT c, size_type pos) const
{
return _find (data (), c, pos, length ());
}
template <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
int basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
int basic_string <charT, traits, Allocator>::
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;
return (length () - pos) - n;
}
#include <iostream.h>
template <class charT, class traits, class Allocator>
istream &
operator>> (istream &is, basic_string <charT, traits, Allocator> &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 += ch;
if (--w == 1)
break;
}
}
is.isfx ();
if (s.length () == 0)
is.setstate (ios::failbit);
return is;
}
template <class charT, class traits, class Allocator>
ostream &
operator<< (ostream &o, const basic_string <charT, traits, Allocator>& s)
{
return o.write (s.data (), s.length ());
}
template <class charT, class traits, class Allocator>
istream&
getline (istream &is, basic_string <charT, traits, Allocator>& 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 += 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 <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>::Rep
basic_string<charT, traits, Allocator>::nilRep = { 0, 0, 1, false };
template <class charT, class traits, class Allocator>
const basic_string <charT, traits, Allocator>::size_type
basic_string <charT, traits, Allocator>::npos;
} // extern "C++"

View File

@ -0,0 +1,620 @@
// Main templates for the -*- C++ -*- string classes.
// Copyright (C) 1994, 1995 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 <cstddef>
#include <std/straits.h>
// NOTE : This does NOT conform to the draft standard and is likely to change
#include <alloc.h>
extern "C++" {
class istream; class ostream;
#include <iterator>
#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 <cassert>
#define OUTOFRANGE(cond) assert (!(cond))
#define LENGTHERROR(cond) assert (!(cond))
#endif
template <class charT, class traits = string_char_traits<charT>,
class Allocator = alloc >
class basic_string
{
private:
struct Rep {
size_t len, res, ref;
bool selfish;
charT* data () { return reinterpret_cast<charT *>(this + 1); }
charT& operator[] (size_t s) { return data () [s]; }
charT* grab () { if (selfish) return clone (); ++ref; return data (); }
void release () { if (--ref == 0) delete this; }
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<iterator> reverse_iterator;
typedef ::reverse_iterator<const_iterator> const_reverse_iterator;
static const size_type npos = static_cast<size_type>(-1);
private:
Rep *rep () const { return reinterpret_cast<Rep *>(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<class InputIterator>
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<class InputIterator>
basic_string& append(InputIterator first, InputIterator last)
#else
basic_string& append(const_iterator first, const_iterator last)
#endif
{ return replace (iend (), iend (), first, last); }
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<class InputIterator>
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<class InputIterator>
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<class InputIterator>
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) { }
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 <class charT, class traits, class Allocator> template <class InputIterator>
basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::
replace (iterator i1, iterator i2, InputIterator j1, InputIterator j2)
#else
template <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::
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 <class charT, class traits, class Allocator>
inline basic_string <charT, traits, Allocator>
operator+ (const basic_string <charT, traits, Allocator>& lhs,
const basic_string <charT, traits, Allocator>& rhs)
{
basic_string <charT, traits, Allocator> str (lhs);
str.append (rhs);
return str;
}
template <class charT, class traits, class Allocator>
inline basic_string <charT, traits, Allocator>
operator+ (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)
{
basic_string <charT, traits, Allocator> str (lhs);
str.append (rhs);
return str;
}
template <class charT, class traits, class Allocator>
inline basic_string <charT, traits, Allocator>
operator+ (charT lhs, const basic_string <charT, traits, Allocator>& rhs)
{
basic_string <charT, traits, Allocator> str (1, lhs);
str.append (rhs);
return str;
}
template <class charT, class traits, class Allocator>
inline basic_string <charT, traits, Allocator>
operator+ (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)
{
basic_string <charT, traits, Allocator> str (lhs);
str.append (rhs);
return str;
}
template <class charT, class traits, class Allocator>
inline basic_string <charT, traits, Allocator>
operator+ (const basic_string <charT, traits, Allocator>& lhs, charT rhs)
{
basic_string <charT, traits, Allocator> str (lhs);
str.append (1, rhs);
return str;
}
template <class charT, class traits, class Allocator>
inline bool
operator== (const basic_string <charT, traits, Allocator>& lhs,
const basic_string <charT, traits, Allocator>& rhs)
{
return (lhs.compare (rhs) == 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator== (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)
{
return (rhs.compare (lhs) == 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator== (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)
{
return (lhs.compare (rhs) == 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator!= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)
{
return (rhs.compare (lhs) != 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator!= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)
{
return (lhs.compare (rhs) != 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator< (const basic_string <charT, traits, Allocator>& lhs,
const basic_string <charT, traits, Allocator>& rhs)
{
return (lhs.compare (rhs) < 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator< (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)
{
return (rhs.compare (lhs) > 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator< (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)
{
return (lhs.compare (rhs) < 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator> (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)
{
return (rhs.compare (lhs) < 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator> (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)
{
return (lhs.compare (rhs) > 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator<= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)
{
return (rhs.compare (lhs) >= 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator<= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)
{
return (lhs.compare (rhs) <= 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator>= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)
{
return (rhs.compare (lhs) <= 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator>= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)
{
return (lhs.compare (rhs) >= 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator!= (const basic_string <charT, traits, Allocator>& lhs,
const basic_string <charT, traits, Allocator>& rhs)
{
return (lhs.compare (rhs) != 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator> (const basic_string <charT, traits, Allocator>& lhs,
const basic_string <charT, traits, Allocator>& rhs)
{
return (lhs.compare (rhs) > 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator<= (const basic_string <charT, traits, Allocator>& lhs,
const basic_string <charT, traits, Allocator>& rhs)
{
return (lhs.compare (rhs) <= 0);
}
template <class charT, class traits, class Allocator>
inline bool
operator>= (const basic_string <charT, traits, Allocator>& lhs,
const basic_string <charT, traits, Allocator>& rhs)
{
return (lhs.compare (rhs) >= 0);
}
class istream; class ostream;
template <class charT, class traits, class Allocator> istream&
operator>> (istream&, basic_string <charT, traits, Allocator>&);
template <class charT, class traits, class Allocator> ostream&
operator<< (ostream&, const basic_string <charT, traits, Allocator>&);
template <class charT, class traits, class Allocator> istream&
getline (istream&, basic_string <charT, traits, Allocator>&, charT delim = '\n');
} // extern "C++"
#include <std/bastring.cc>
#endif

View File

@ -0,0 +1,273 @@
// 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 <complex>
extern "C++" {
template <class FLOAT> complex<FLOAT>
cos (const complex<FLOAT>& x)
{
return complex<FLOAT> (cos (real (x)) * cosh (imag (x)),
- sin (real (x)) * sinh (imag (x)));
}
template <class FLOAT> complex<FLOAT>
cosh (const complex<FLOAT>& x)
{
return complex<FLOAT> (cosh (real (x)) * cos (imag (x)),
sinh (real (x)) * sin (imag (x)));
}
template <class FLOAT> complex<FLOAT>
exp (const complex<FLOAT>& x)
{
return polar (FLOAT (exp (real (x))), imag (x));
}
template <class FLOAT> complex<FLOAT>
log (const complex<FLOAT>& x)
{
return complex<FLOAT> (log (abs (x)), arg (x));
}
template <class FLOAT> complex<FLOAT>
pow (const complex<FLOAT>& x, const complex<FLOAT>& 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 <class FLOAT> complex<FLOAT>
pow (const complex<FLOAT>& x, FLOAT y)
{
return exp (FLOAT (y) * log (x));
}
template <class FLOAT> complex<FLOAT>
pow (FLOAT x, const complex<FLOAT>& y)
{
return exp (y * FLOAT (log (x)));
}
template <class FLOAT> complex<FLOAT>
sin (const complex<FLOAT>& x)
{
return complex<FLOAT> (sin (real (x)) * cosh (imag (x)),
cos (real (x)) * sinh (imag (x)));
}
template <class FLOAT> complex<FLOAT>
sinh (const complex<FLOAT>& x)
{
return complex<FLOAT> (sinh (real (x)) * cos (imag (x)),
cosh (real (x)) * sin (imag (x)));
}
#include <iostream.h>
template <class FLOAT> istream&
operator >> (istream& is, complex<FLOAT>& 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<FLOAT> (re, im);
return is;
}
template <class FLOAT> ostream&
operator << (ostream& os, const complex<FLOAT>& 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 <class FLOAT> complex<FLOAT>&
__doadv (complex<FLOAT>* ths, const complex<FLOAT>& 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 <class FLOAT> complex<FLOAT>
operator / (const complex<FLOAT>& x, const complex<FLOAT>& 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<FLOAT> (nr, ni);
}
template <class FLOAT> complex<FLOAT>
operator / (FLOAT x, const complex<FLOAT>& 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<FLOAT> (nr, ni);
}
template <class FLOAT> complex<FLOAT>
pow (const complex<FLOAT>& xin, int y)
{
if (y == 0)
return complex<FLOAT> (1.0);
complex<FLOAT> r (1.0);
complex<FLOAT> x (xin);
if (y < 0)
{
y = -y;
x = 1/x;
}
for (;;)
{
if (y & 1)
r *= x;
if (y >>= 1)
x *= x;
else
return r;
}
}
template <class FLOAT> complex<FLOAT>
sqrt (const complex<FLOAT>& 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<FLOAT> (nr, ni);
}
} // extern "C++"

View File

@ -0,0 +1,400 @@
// 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 <cmath>
#if ! defined (__GNUG__) && ! defined (__attribute__)
#define __attribute__(foo) /* Ignore. */
#endif
class istream;
class ostream;
extern "C++" {
template <class _FLT> class complex;
template <class _FLT> complex<_FLT>&
__doapl (complex<_FLT>* ths, const complex<_FLT>& r);
template <class _FLT> complex<_FLT>&
__doami (complex<_FLT>* ths, const complex<_FLT>& r);
template <class _FLT> complex<_FLT>&
__doaml (complex<_FLT>* ths, const complex<_FLT>& r);
template <class _FLT> complex<_FLT>&
__doadv (complex<_FLT>* ths, const complex<_FLT>& r);
template <class _FLT>
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<float>;
class complex<double>;
class complex<long double>;
template <class _FLT>
inline complex<_FLT>&
__doapl (complex<_FLT>* ths, const complex<_FLT>& r)
{
ths->re += r.re;
ths->im += r.im;
return *ths;
}
template <class _FLT>
inline complex<_FLT>&
complex<_FLT>::operator += (const complex<_FLT>& r)
{
return __doapl (this, r);
}
template <class _FLT>
inline complex<_FLT>&
__doami (complex<_FLT>* ths, const complex<_FLT>& r)
{
ths->re -= r.re;
ths->im -= r.im;
return *ths;
}
template <class _FLT>
inline complex<_FLT>&
complex<_FLT>::operator -= (const complex<_FLT>& r)
{
return __doami (this, r);
}
template <class _FLT>
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 <class _FLT>
inline complex<_FLT>&
complex<_FLT>::operator *= (const complex<_FLT>& r)
{
return __doaml (this, r);
}
template <class _FLT>
inline complex<_FLT>&
complex<_FLT>::operator /= (const complex<_FLT>& r)
{
return __doadv (this, r);
}
template <class _FLT> inline _FLT
imag (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline _FLT
imag (const complex<_FLT>& x)
{
return x.imag ();
}
template <class _FLT> inline _FLT
real (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline _FLT
real (const complex<_FLT>& x)
{
return x.real ();
}
template <class _FLT> inline complex<_FLT>
operator + (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator + (const complex<_FLT>& x, const complex<_FLT>& y)
{
return complex<_FLT> (real (x) + real (y), imag (x) + imag (y));
}
template <class _FLT> inline complex<_FLT>
operator + (const complex<_FLT>& x, _FLT y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator + (const complex<_FLT>& x, _FLT y)
{
return complex<_FLT> (real (x) + y, imag (x));
}
template <class _FLT> inline complex<_FLT>
operator + (_FLT x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator + (_FLT x, const complex<_FLT>& y)
{
return complex<_FLT> (x + real (y), imag (y));
}
template <class _FLT> inline complex<_FLT>
operator - (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator - (const complex<_FLT>& x, const complex<_FLT>& y)
{
return complex<_FLT> (real (x) - real (y), imag (x) - imag (y));
}
template <class _FLT> inline complex<_FLT>
operator - (const complex<_FLT>& x, _FLT y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator - (const complex<_FLT>& x, _FLT y)
{
return complex<_FLT> (real (x) - y, imag (x));
}
template <class _FLT> inline complex<_FLT>
operator - (_FLT x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator - (_FLT x, const complex<_FLT>& y)
{
return complex<_FLT> (x - real (y), - imag (y));
}
template <class _FLT> inline complex<_FLT>
operator * (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> 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 <class _FLT> inline complex<_FLT>
operator * (const complex<_FLT>& x, _FLT y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator * (const complex<_FLT>& x, _FLT y)
{
return complex<_FLT> (real (x) * y, imag (x) * y);
}
template <class _FLT> inline complex<_FLT>
operator * (_FLT x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator * (_FLT x, const complex<_FLT>& y)
{
return complex<_FLT> (x * real (y), x * imag (y));
}
template <class _FLT> complex<_FLT>
operator / (const complex<_FLT>& x, _FLT y) __attribute__ ((const));
template <class _FLT> complex<_FLT>
operator / (const complex<_FLT>& x, _FLT y)
{
return complex<_FLT> (real (x) / y, imag (x) / y);
}
template <class _FLT> inline complex<_FLT>
operator + (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator + (const complex<_FLT>& x)
{
return x;
}
template <class _FLT> inline complex<_FLT>
operator - (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
operator - (const complex<_FLT>& x)
{
return complex<_FLT> (-real (x), -imag (x));
}
template <class _FLT> inline bool
operator == (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline bool
operator == (const complex<_FLT>& x, const complex<_FLT>& y)
{
return real (x) == real (y) && imag (x) == imag (y);
}
template <class _FLT> inline bool
operator == (const complex<_FLT>& x, _FLT y) __attribute__ ((const));
template <class _FLT> inline bool
operator == (const complex<_FLT>& x, _FLT y)
{
return real (x) == y && imag (x) == 0;
}
template <class _FLT> inline bool
operator == (_FLT x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline bool
operator == (_FLT x, const complex<_FLT>& y)
{
return x == real (y) && imag (y) == 0;
}
template <class _FLT> inline bool
operator != (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> inline bool
operator != (const complex<_FLT>& x, const complex<_FLT>& y)
{
return real (x) != real (y) || imag (x) != imag (y);
}
template <class _FLT> inline bool
operator != (const complex<_FLT>& x, _FLT y) __attribute__ ((const));
template <class _FLT> inline bool
operator != (const complex<_FLT>& x, _FLT y)
{
return real (x) != y || imag (x) != 0;
}
template <class _FLT> inline bool
operator != (_FLT x, const complex<_FLT>& y) __attribute__ ((const));
template <class _FLT> 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 <class _FLT> inline _FLT
abs (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline _FLT
abs (const complex<_FLT>& x)
{
return hypot (real (x), imag (x));
}
template <class _FLT> inline _FLT
arg (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline _FLT
arg (const complex<_FLT>& x)
{
return atan2 (imag (x), real (x));
}
template <class _FLT> inline complex<_FLT>
polar (_FLT r, _FLT t) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
polar (_FLT r, _FLT t)
{
return complex<_FLT> (r * cos (t), r * sin (t));
}
template <class _FLT> inline complex<_FLT>
conj (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline complex<_FLT>
conj (const complex<_FLT>& x)
{
return complex<_FLT> (real (x), -imag (x));
}
template <class _FLT> inline _FLT
norm (const complex<_FLT>& x) __attribute__ ((const));
template <class _FLT> inline _FLT
norm (const complex<_FLT>& x)
{
return real (x) * real (x) + imag (x) * imag (x);
}
// Declarations of templates in complext.ccI
template <class _FLT> complex<_FLT>
operator / (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
operator / (_FLT, const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
cos (const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
cosh (const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
exp (const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
log (const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
pow (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
pow (const complex<_FLT>&, _FLT) __attribute__ ((const));
template <class _FLT> complex<_FLT>
pow (const complex<_FLT>&, int) __attribute__ ((const));
template <class _FLT> complex<_FLT>
pow (_FLT, const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
sin (const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
sinh (const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> complex<_FLT>
sqrt (const complex<_FLT>&) __attribute__ ((const));
template <class _FLT> istream& operator >> (istream&, complex<_FLT>&);
template <class _FLT> ostream& operator << (ostream&, const complex<_FLT>&);
} // extern "C++"
// Specializations and such
#include <std/fcomplex.h>
#include <std/dcomplex.h>
#include <std/ldcomplex.h>
#endif

View File

@ -0,0 +1,91 @@
// 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<double>
{
public:
complex (double r = 0, double i = 0): re (r), im (i) { }
complex (const complex<float>& r): re (r.real ()), im (r.imag ()) { }
explicit complex (const complex<long double>& 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<float>::complex (const complex<double>& r)
: re (r.real ()), im (r.imag ())
{ }
} // extern "C++"
#endif

View File

@ -0,0 +1,87 @@
// 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<float>
{
public:
complex (float r = 0, float i = 0): re (r), im (i) { }
explicit complex (const complex<double>& r);
explicit complex (const complex<long double>& 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

View File

@ -0,0 +1,95 @@
// 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<long double>
{
public:
complex (long double r = 0, long double i = 0): re (r), im (i) { }
complex (const complex<float>& r): re (r.real ()), im (r.imag ()) { }
complex (const complex<double>& 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<float>::complex (const complex<long double>& r)
: re (r.real ()), im (r.imag ())
{ }
inline complex<double>::complex (const complex<long double>& r)
: re (r.real ()), im (r.imag ())
{ }
} // extern "C++"
#endif

View File

@ -0,0 +1,161 @@
// Character traits template 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.
#ifndef __STRING_CHAR_TRAITS__
#define __STRING_CHAR_TRAITS__
#ifdef __GNUG__
// For string_char_traits <char>
#pragma interface "std/straits.h"
#endif
#include <cstddef>
extern "C++" {
template <class charT>
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 <cctype>
#include <cstring>
struct string_char_traits <char> {
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 <cwctype>
struct string_char_traits <wchar_t> {
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

101
contrib/libstdc++/stdexcept Normal file
View File

@ -0,0 +1,101 @@
// 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 <exception>
#include <string>
extern "C++" {
#ifdef __HONOR_STD
namespace std {
#endif
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) { }
};
#ifdef __HONOR_STD
} // namespace std
#endif
} // extern "C++"
#endif

View File

@ -0,0 +1,21 @@
// Implementation file for Exception Support for -*- C++ -*-
// This file is part of the GNU ANSI C++ Library.
#ifdef __GNUG__
#pragma implementation "stdexcept"
#endif
#include <stdexcept>
// Entry points for string.
void
__out_of_range (const char *s)
{
throw out_of_range (s);
}
void __length_error (const char *s)
{
throw length_error (s);
}

15
contrib/libstdc++/stl.h Normal file
View File

@ -0,0 +1,15 @@
// -*- C++ -*- compatibility header.
// This file is part of the GNU ANSI C++ Library.
#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <utility>
#include <vector>

View File

@ -0,0 +1,273 @@
Sun Mar 14 02:38:07 PST 1999 Jeff Law (law@cygnus.com)
* egcs-1.1.2 Released.
Fri Jul 10 15:20:09 1998 Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
* 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 <drepper@cygnus.com>
* 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 <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* stl_algo.h (__lg): Fix for n == 0.
Sat Nov 8 00:45:17 1997 Jason Merrill <jason@yorick.cygnus.com>
* stl_hash_set.h (swap): Fix typo.
Fri Nov 7 10:27:40 1997 Jason Merrill <jason@yorick.cygnus.com>
* stl_hashtable.h: Fix typo.
Thu Nov 6 11:19:09 1997 Jason Merrill <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* tree.h, vector.h: Fix accidental divergence from SGI release.
Tue Sep 9 19:47:28 1997 Jason Merrill <jason@yorick.cygnus.com>
* 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 <mmitchell@usa.net>
* stl_config.h (__STL_MEMBER_TEMPLATES): Enable.
Tue Aug 5 17:06:01 1997 Jason Merrill <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* 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 <drepper@cygnus.com>
* tree.h (rb_tree): Reverse order of member initializations
to prevent warnings.
Sun Jun 15 18:17:21 1997 Jason Merrill <jason@yorick.cygnus.com>
* *.h: Update to 6/13 SGI release.
Fri May 23 10:56:18 1997 Jason Merrill <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* *.h: Update to 3/24 SGI release.
Wed Feb 19 18:19:18 1997 Jason Merrill <jason@yorick.cygnus.com>
* *.h: Update to 2/18 SGI release.
* bool.h: Lose.
Mon Feb 10 16:33:23 1997 Jason Merrill <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* *.h: Update to 1/8 SGI release.
Mon Sep 30 17:56:43 1996 Jason Merrill <jason@yorick.cygnus.com>
* alloc.h (__unlock): Never use __lock_release.
Fri Sep 27 19:03:06 1996 Jason Merrill <jason@yorick.cygnus.com>
* alloc.h (__default_alloc_template): lock is a friend.
Thu Sep 19 20:10:37 1996 Jason Merrill <jason@yorick.cygnus.com>
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 <jason@yorick.cygnus.com>
* deque.h, list.h, tree.h: Remove kludge obsoleted by new
overloading code.
Sat Aug 10 14:59:50 1996 Jason Merrill <jason@yorick.cygnus.com>
* tempbuf.cc (__stl_temp_buffer): Align like a pointer.
Wed Jun 26 13:00:44 1996 Jason Merrill <jason@yorick.cygnus.com>
* iterator.h: Add default template parameters.
Wed Apr 24 10:45:22 1996 Doug Evans <dje@blues.cygnus.com>
* Makefile.in (tempbuf.o,random.o): Add rules for SunOS VPATH.
Fri Apr 5 17:52:31 1996 Per Bothner <bothner@kalessin.cygnus.com>
* configure.in (EXTRA_MOSTLYCLEAN): New, to remove stl.list.
Fri Mar 22 14:58:30 1996 Jason Merrill <jason@yorick.cygnus.com>
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 <jason@yorick.cygnus.com>
* deque.h (distance_type): Add overload for g++.
From Joe Buck.
Thu Feb 22 14:07:12 1996 Jason Merrill <jason@yorick.cygnus.com>
* 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 <bool.h> 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 <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* 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 <jason@yorick.cygnus.com>
* 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 <bool.h>
with #ifndef __GNUG__.
Thu Nov 2 17:05:44 1995 Jason Merrill <jason@yorick.cygnus.com>
* deque.h (deque<T>::insert): Fix merge typo.
* vector.h (value_type): Lose.
Thu Nov 2 14:33:47 1995 Per Bothner <bothner@kalessin.cygnus.com>
* 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 <bothner@kalessin.cygnus.com>
* list.h: Avoid duplicate construction and destruction of list_nodes.
Patch from Klamer Schutte <klamer@ph.tn.tudelft.nl>.
Fri Aug 11 16:45:18 1995 Per Bothner <bothner@kalessin.cygnus.com>
* algo.h, algobase.h, deque.h: Merged in Jul 12 1995 release from HP.
Mon Jun 5 18:38:56 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* Makefile.in (stl.list): Depend on stamp-picdir.
Wed May 17 02:30:47 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* 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 <mrs@cygnus.com>
* random.cc (seed): Move `for' decl out of `for' statement.
Wed Apr 26 13:09:16 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* configure.in (XCXXINCLUDES): Rename.
Wed Mar 29 19:24:56 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* 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 <mrs@cygnus.com>
* 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 <mrs@cygnus.com>
* iterator.h: Add default template parameters where possible.
Fri Dec 30 16:29:39 1994 Mike Stump <mrs@cygnus.com>
* algo.h: Change rand to __rand to fix make check on linux systems.
Tue Nov 29 15:30:30 1994 Per Bothner <bothner@kalessin.cygnus.com>
* Initial check-in, based on HP's October 21, 1994.

View File

@ -0,0 +1,16 @@
This directory contains an SGI release of the C++ Standard Template
Library, slightly modified to work with g++ (version 2.8.0 or newer).
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.
CYGNUS MAKES NO COMMITTMENT (yet) TO SUPPORT BACKWARD COMPATIBILITY FOR STL.
For examples if 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.
--Jason Merrill
Cygnus Support jason@cygnus.com

View File

@ -0,0 +1,114 @@
/*
*
* 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 <algobase.h>
#include <tempbuf.h>
#include <stl_algo.h>
#include <stl_numeric.h>
#ifdef __STL_USE_NAMESPACES
// Names from <stl_algo.h>
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 <stl_numeric.h>
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:

View File

@ -0,0 +1,71 @@
/*
*
* 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 <pair.h>
#endif
#ifndef __SGI_STL_ITERATOR_H
#include <iterator.h>
#endif
#ifndef __SGI_STL_INTERNAL_ALGOBASE_H
#include <stl_algobase.h>
#endif
#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H
#include <stl_uninitialized.h>
#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:

View File

@ -0,0 +1,39 @@
/*
*
* 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 <stl_algobase.h>
#include <stl_construct.h>
#include <stl_tempbuf.h>
#include <stl_algo.h>
#endif /* __SGI_STL_ALGORITHM */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,44 @@
/*
* 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 <stl_config.h>
#endif
#ifndef __SGI_STL_INTERNAL_ALLOC_H
#include <stl_alloc.h>
#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 */
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_ALLOC_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,51 @@
/*
*
* 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 <vector.h>
#else
#include <algobase.h>
#include <alloc.h>
#endif
#include <stl_bvector.h>
#ifdef __STL_USE_NAMESPACES
using __STD::bit_vector;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_BVECTOR_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,86 @@
/*
*
* 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.
//
// DO NOT USE THIS FILE unless you have an old container implementation
// that requires an allocator with the HP-style interface. SGI STL
// uses a different allocator interface. SGI-style allocators are not
// parametrized with respect to the object type; they traffic in void *
// pointers. This file is not included by any other SGI STL header.
#ifndef DEFALLOC_H
#define DEFALLOC_H
#include <new.h>
#include <stddef.h>
#include <stdlib.h>
#include <limits.h>
#include <iostream.h>
#include <algobase.h>
template <class T>
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 <class T>
inline void deallocate(T* buffer) {
::operator delete(buffer);
}
template <class T>
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<void> {
public:
typedef void* pointer;
};
#endif

View File

@ -0,0 +1,40 @@
/*
*
* 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 <stl_algobase.h>
#include <stl_alloc.h>
#include <stl_construct.h>
#include <stl_uninitialized.h>
#include <stl_deque.h>
#endif /* __SGI_STL_DEQUE */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,42 @@
/*
*
* 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 <algobase.h>
#include <alloc.h>
#include <stl_deque.h>
#ifdef __STL_USE_NAMESPACES
using __STD::deque;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_DEQUE_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,118 @@
/*
*
* 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 <stl_config.h>
#endif
#ifndef __SGI_STL_INTERNAL_RELOPS
#include <stl_relops.h>
#endif
#include <stddef.h>
#ifndef __SGI_STL_INTERNAL_FUNCTION_H
#include <stl_function.h>
#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:

View File

@ -0,0 +1,26 @@
/*
* 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 <stl_config.h>
#include <stddef.h>
#include <stl_function.h>
#endif /* __SGI_STL_FUNCTIONAL */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,40 @@
/*
* 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 <stl_hashtable.h>
#endif
#include <stl_hash_map.h>
#endif /* __SGI_STL_HASH_MAP */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,48 @@
/*
* 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 <stl_hashtable.h>
#endif
#include <stl_hash_map.h>
#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:

View File

@ -0,0 +1,40 @@
/*
* 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 <stl_hashtable.h>
#endif
#include <stl_hash_set.h>
#endif /* __SGI_STL_HASH_SET */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,43 @@
/*
* 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 <stl_hashtable.h>
#endif
#include <stl_hash_set.h>
#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 */

View File

@ -0,0 +1,48 @@
/*
* 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 <stl_hashtable.h>
#include <algo.h>
#include <alloc.h>
#include <vector.h>
#ifdef __STL_USE_NAMESPACES
using __STD::hash;
using __STD::hashtable;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_HASHTABLE_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,46 @@
/*
*
* 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 <stl_config.h>
#include <stl_heap.h>
#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:

View File

@ -0,0 +1,40 @@
/*
*
* 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 <stl_config.h>
#include <stl_relops.h>
#include <stddef.h>
#include <iostream.h>
#include <stl_iterator.h>
#endif /* __SGI_STL_ITERATOR */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,104 @@
/*
*
* 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 <function.h>
#endif
#include <stddef.h>
#include <iostream.h>
#ifndef __SGI_STL_INTERNAL_ITERATOR_H
#include <stl_iterator.h>
#endif
#ifndef __TYPE_TRAITS_H
#include <type_traits.h>
#endif
#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H
#include <stl_construct.h>
#endif
#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H
#include <stl_raw_storage_iter.h>
#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:

View File

@ -0,0 +1,40 @@
/*
*
* 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 <stl_algobase.h>
#include <stl_alloc.h>
#include <stl_construct.h>
#include <stl_uninitialized.h>
#include <stl_list.h>
#endif /* __SGI_STL_LIST */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,42 @@
/*
*
* 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 <algobase.h>
#include <alloc.h>
#include <stl_list.h>
#ifdef __STL_USE_NAMESPACES
using __STD::list;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_LIST_H */
// Local Variables:
// mode:C++
// End:

40
contrib/libstdc++/stl/map Normal file
View File

@ -0,0 +1,40 @@
/*
*
* 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 <stl_tree.h>
#endif
#include <stl_map.h>
#include <stl_multimap.h>
#endif /* __SGI_STL_MAP */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,41 @@
/*
*
* 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 <tree.h>
#include <stl_map.h>
#ifdef __STL_USE_NAMESPACES
using __STD::map;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_MAP_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,89 @@
/*
* 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 <stl_algobase.h>
#include <stl_alloc.h>
#include <stl_construct.h>
#include <stl_tempbuf.h>
#include <stl_uninitialized.h>
#include <stl_raw_storage_iter.h>
// Note: auto_ptr is commented out in this release because the details
// of the interface are still being discussed by the C++ standardization
// committee. It will be included once the iterface is finalized.
#if 0
#if defined(_MUTABLE_IS_KEYWORD) && defined(_EXPLICIT_IS_KEYWORD) && \
defined(__STL_MEMBER_TEMPLATES)
__STL_BEGIN_NAMESPACE
template <class X> class auto_ptr {
private:
X* ptr;
mutable bool owns;
public:
typedef X element_type;
explicit auto_ptr(X* p = 0) __STL_NOTHROW : ptr(p), owns(p) {}
auto_ptr(const auto_ptr& a) __STL_NOTHROW : ptr(a.ptr), owns(a.owns) {
a.owns = 0;
}
template <class T> auto_ptr(const auto_ptr<T>& a) __STL_NOTHROW
: ptr(a.ptr), owns(a.owns) {
a.owns = 0;
}
auto_ptr& operator=(const auto_ptr& a) __STL_NOTHROW {
if (&a != this) {
if (owns)
delete ptr;
owns = a.owns;
ptr = a.ptr;
a.owns = 0;
}
}
template <class T> auto_ptr& operator=(const auto_ptr<T>& a) __STL_NOTHROW {
if (&a != this) {
if (owns)
delete ptr;
owns = a.owns;
ptr = a.ptr;
a.owns = 0;
}
}
~auto_ptr() {
if (owns)
delete ptr;
}
X& operator*() const __STL_NOTHROW { return *ptr; }
X* operator->() const __STL_NOTHROW { return ptr; }
X* get() const __STL_NOTHROW { return ptr; }
X* release const __STL_NOTHROW { owns = false; return ptr }
};
__STL_END_NAMESPACE
#endif /* mutable && explicit && member templates */
#endif /* 0 */
#endif /* __SGI_STL_MEMORY */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,41 @@
/*
*
* 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 <tree.h>
#include <stl_multimap.h>
#ifdef __STL_USE_NAMESPACES
using __STD::multimap;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_MULTIMAP_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,41 @@
/*
*
* 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 <tree.h>
#include <stl_multiset.h>
#ifdef __STL_USE_NAMESPACES
using __STD::multiset;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_MULTISET_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,42 @@
/*
*
* 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 <stl_config.h>
#include <stl_relops.h>
#include <stddef.h>
#include <iostream.h>
#include <stl_iterator.h>
#include <stl_function.h>
#include <stl_numeric.h>
#endif /* __SGI_STL_NUMERIC */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,51 @@
/*
*
* 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 <stl_config.h>
#endif
#ifndef __SGI_STL_INTERNAL_RELOPS
#include <stl_relops.h>
#endif
#ifndef __SGI_STL_INTERNAL_PAIR_H
#include <stl_pair.h>
#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:

View File

@ -0,0 +1,347 @@
/*
* 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 n 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 <stl_config.h>
#include <stl_alloc.h>
#ifndef __RESTRICT
# define __RESTRICT
#endif
__STL_BEGIN_NAMESPACE
// Note that this class has nonstatic members. We instantiate it once
// per thread.
template <bool dummy>
class __pthread_alloc_template {
private:
enum {ALIGN = 8};
enum {MAX_BYTES = 128}; // power of 2
enum {NFREELISTS = MAX_BYTES/ALIGN};
union obj {
union obj * free_list_link;
char client_data[ALIGN]; /* The client sees this. */
};
// Per instance state
obj* volatile free_list[NFREELISTS];
__pthread_alloc_template<dummy>* next; // Free list link
static size_t ROUND_UP(size_t bytes) {
return (((bytes) + ALIGN-1) & ~(ALIGN - 1));
}
static size_t 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.
void *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 *chunk_alloc(size_t size, int &nobjs);
// Chunk allocation state. And other shared state.
// Protected by chunk_allocator_lock.
static pthread_mutex_t chunk_allocator_lock;
static char *start_free;
static char *end_free;
static size_t heap_size;
static __pthread_alloc_template<dummy>* free_allocators;
static pthread_key_t key;
static bool key_initialized;
// Pthread key under which allocator is stored.
// Allocator instances that are currently unclaimed by any thread.
static void destructor(void *instance);
// Function to be called on thread exit to reclaim allocator
// instance.
static __pthread_alloc_template<dummy> *new_allocator();
// Return a recycled or new allocator instance.
static __pthread_alloc_template<dummy> *get_allocator_instance();
// ensure that the current thread has an associated
// allocator instance.
class lock {
public:
lock () { pthread_mutex_lock(&chunk_allocator_lock); }
~lock () { pthread_mutex_unlock(&chunk_allocator_lock); }
};
friend class lock;
public:
__pthread_alloc_template() : next(0)
{
memset((void *)free_list, 0, NFREELISTS * sizeof(obj *));
}
/* n must be > 0 */
static void * allocate(size_t n)
{
obj * volatile * my_free_list;
obj * __RESTRICT result;
__pthread_alloc_template<dummy>* a;
if (n > MAX_BYTES) {
return(malloc(n));
}
if (!key_initialized ||
!(a = (__pthread_alloc_template<dummy>*)
pthread_getspecific(key))) {
a = get_allocator_instance();
}
my_free_list = a -> free_list + FREELIST_INDEX(n);
result = *my_free_list;
if (result == 0) {
void *r = a -> refill(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_template<dummy>* a;
if (n > MAX_BYTES) {
free(p);
return;
}
if (!key_initialized ||
!(a = (__pthread_alloc_template<dummy>*)
pthread_getspecific(key))) {
a = get_allocator_instance();
}
my_free_list = a->free_list + 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<false> pthread_alloc;
template <bool dummy>
void __pthread_alloc_template<dummy>::destructor(void * instance)
{
__pthread_alloc_template<dummy>* a =
(__pthread_alloc_template<dummy>*)instance;
a -> next = free_allocators;
free_allocators = a;
}
template <bool dummy>
__pthread_alloc_template<dummy>*
__pthread_alloc_template<dummy>::new_allocator()
{
if (0 != free_allocators) {
__pthread_alloc_template<dummy>* result = free_allocators;
free_allocators = free_allocators -> next;
return result;
} else {
return new __pthread_alloc_template<dummy>;
}
}
template <bool dummy>
__pthread_alloc_template<dummy>*
__pthread_alloc_template<dummy>::get_allocator_instance()
{
__pthread_alloc_template<dummy>* result;
if (!key_initialized) {
/*REFERENCED*/
lock lock_instance;
if (!key_initialized) {
if (pthread_key_create(&key, destructor)) {
abort(); // failed
}
key_initialized = true;
}
}
result = new_allocator();
if (pthread_setspecific(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 <bool dummy>
char *__pthread_alloc_template<dummy>
::chunk_alloc(size_t size, int &nobjs)
{
{
char * result;
size_t total_bytes;
size_t bytes_left;
/*REFERENCED*/
lock lock_instance; // Acquire lock for this routine
total_bytes = size * nobjs;
bytes_left = end_free - start_free;
if (bytes_left >= total_bytes) {
result = start_free;
start_free += total_bytes;
return(result);
} else if (bytes_left >= size) {
nobjs = bytes_left/size;
total_bytes = size * nobjs;
result = start_free;
start_free += total_bytes;
return(result);
} else {
size_t bytes_to_get = 2 * total_bytes + ROUND_UP(heap_size >> 4);
// Try to make use of the left-over piece.
if (bytes_left > 0) {
__pthread_alloc_template<dummy>* a =
(__pthread_alloc_template<dummy>*)pthread_getspecific(key);
obj * volatile * my_free_list =
a->free_list + FREELIST_INDEX(bytes_left);
((obj *)start_free) -> free_list_link = *my_free_list;
*my_free_list = (obj *)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);
start_free = (char *)memalign(cache_line_size, bytes_to_get);
if (0 == start_free) {
start_free = (char *)malloc_alloc::allocate(bytes_to_get);
}
}
# else /* !SGI_SOURCE */
start_free = (char *)malloc_alloc::allocate(bytes_to_get);
# endif
heap_size += bytes_to_get;
end_free = start_free + bytes_to_get;
}
}
// lock is released here
return(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 <bool dummy>
void *__pthread_alloc_template<dummy>
::refill(size_t n)
{
int nobjs = 128;
char * chunk = 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 + 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 <bool dummy>
void *__pthread_alloc_template<dummy>
::reallocate(void *p, size_t old_sz, size_t new_sz)
{
void * result;
size_t copy_sz;
if (old_sz > MAX_BYTES && new_sz > MAX_BYTES) {
return(realloc(p, new_sz));
}
if (ROUND_UP(old_sz) == 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 <bool dummy>
__pthread_alloc_template<dummy> *
__pthread_alloc_template<dummy>::free_allocators = 0;
template <bool dummy>
pthread_key_t __pthread_alloc_template<dummy>::key;
template <bool dummy>
bool __pthread_alloc_template<dummy>::key_initialized = false;
template <bool dummy>
pthread_mutex_t __pthread_alloc_template<dummy>::chunk_allocator_lock
= PTHREAD_MUTEX_INITIALIZER;
template <bool dummy>
char *__pthread_alloc_template<dummy>
::start_free = 0;
template <bool dummy>
char *__pthread_alloc_template<dummy>
::end_free = 0;
template <bool dummy>
size_t __pthread_alloc_template<dummy>
::heap_size = 0;
__STL_END_NAMESPACE
#endif /* __SGI_STL_PTHREAD_ALLOC */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,31 @@
/*
* 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 <pthread_alloc>
#ifdef __STL_USE_NAMESPACES
using __STD::__pthread_alloc_template;
using __STL::pthread_alloc;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_PTHREAD_ALLOC_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,45 @@
/*
*
* 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 <stl_algobase.h>
#include <stl_alloc.h>
#include <stl_construct.h>
#include <stl_uninitialized.h>
#include <stl_vector.h>
#include <stl_bvector.h>
#include <stl_heap.h>
#include <stl_deque.h>
#include <stl_function.h>
#include <stl_queue.h>
#endif /* __SGI_STL_QUEUE */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,32 @@
/*
* 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 <stl_algobase.h>
#include <tempbuf.h>
#include <stl_algo.h>
#include <stl_function.h>
#include <stl_numeric.h>
#include <stl_alloc.h>
#include <stl_construct.h>
#include <stl_uninitialized.h>
#include <stl_hash_fun.h>
#include <stl_rope.h>
#endif /* __SGI_STL_ROPE */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,34 @@
/*
* 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 <hashtable.h>
#include <stl_rope.h>
#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:

File diff suppressed because it is too large Load Diff

40
contrib/libstdc++/stl/set Normal file
View File

@ -0,0 +1,40 @@
/*
*
* 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 <stl_tree.h>
#endif
#include <stl_set.h>
#include <stl_multiset.h>
#endif /* __SGI_STL_SET */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,41 @@
/*
*
* 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 <tree.h>
#include <stl_set.h>
#ifdef __STL_USE_NAMESPACES
using __STD::set;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_SET_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,28 @@
/*
* 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 <stl_algobase.h>
#include <stl_alloc.h>
#include <stl_construct.h>
#include <stl_uninitialized.h>
#include <stl_slist.h>
#endif /* __SGI_STL_SLIST */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,30 @@
/*
* 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 <algobase.h>
#include <alloc.h>
#include <stl_slist.h>
#ifdef __STL_USE_NAMESPACES
using __STD::slist;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_SLIST_H */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,41 @@
/*
*
* 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 <stl_algobase.h>
#include <stl_alloc.h>
#include <stl_construct.h>
#include <stl_uninitialized.h>
#include <stl_deque.h>
#include <stl_stack.h>
#endif /* __SGI_STL_STACK */
// Local Variables:
// mode:C++
// End:

View File

@ -0,0 +1,46 @@
/*
*
* 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 <vector.h>
#include <deque.h>
#include <heap.h>
#include <stl_stack.h>
#include <stl_queue.h>
#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:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,442 @@
/*
*
* 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_ALGOBASE_H
#define __SGI_STL_INTERNAL_ALGOBASE_H
#ifndef __STL_CONFIG_H
#include <stl_config.h>
#endif
#ifndef __SGI_STL_INTERNAL_RELOPS
#include <stl_relops.h>
#endif
#ifndef __SGI_STL_INTERNAL_PAIR_H
#include <stl_pair.h>
#endif
#ifndef __TYPE_TRAITS_H_
#include <type_traits.h>
#endif
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <stddef.h>
#include <new.h>
#include <iostream.h>
#ifndef __SGI_STL_INTERNAL_ITERATOR_H
#include <stl_iterator.h>
#endif
__STL_BEGIN_NAMESPACE
template <class ForwardIterator1, class ForwardIterator2, class T>
inline void __iter_swap(ForwardIterator1 a, ForwardIterator2 b, T*) {
T tmp = *a;
*a = *b;
*b = tmp;
}
template <class ForwardIterator1, class ForwardIterator2>
inline void iter_swap(ForwardIterator1 a, ForwardIterator2 b) {
__iter_swap(a, b, value_type(a));
}
template <class T>
inline void swap(T& a, T& b) {
T tmp = a;
a = b;
b = tmp;
}
#ifndef __BORLANDC__
#undef min
#undef max
template <class T>
inline const T& min(const T& a, const T& b) {
return b < a ? b : a;
}
template <class T>
inline const T& max(const T& a, const T& b) {
return a < b ? b : a;
}
#endif /* __BORLANDC__ */
template <class T, class Compare>
inline const T& min(const T& a, const T& b, Compare comp) {
return comp(b, a) ? b : a;
}
template <class T, class Compare>
inline const T& max(const T& a, const T& b, Compare comp) {
return comp(a, b) ? b : a;
}
template <class InputIterator, class OutputIterator>
inline OutputIterator __copy(InputIterator first, InputIterator last,
OutputIterator result, input_iterator_tag)
{
for ( ; first != last; ++result, ++first)
*result = *first;
return result;
}
template <class RandomAccessIterator, class OutputIterator, class Distance>
inline OutputIterator
__copy_d(RandomAccessIterator first, RandomAccessIterator last,
OutputIterator result, Distance*)
{
for (Distance n = last - first; n > 0; --n, ++result, ++first)
*result = *first;
return result;
}
template <class RandomAccessIterator, class OutputIterator>
inline OutputIterator
__copy(RandomAccessIterator first, RandomAccessIterator last,
OutputIterator result, random_access_iterator_tag)
{
return __copy_d(first, last, result, distance_type(first));
}
template <class InputIterator, class OutputIterator>
struct __copy_dispatch
{
OutputIterator operator()(InputIterator first, InputIterator last,
OutputIterator result) {
return __copy(first, last, result, iterator_category(first));
}
};
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
template <class T>
inline T* __copy_t(const T* first, const T* last, T* result, __true_type) {
memmove(result, first, sizeof(T) * (last - first));
return result + (last - first);
}
template <class T>
inline T* __copy_t(const T* first, const T* last, T* result, __false_type) {
return __copy_d(first, last, result, (ptrdiff_t*) 0);
}
template <class T>
struct __copy_dispatch<T*, T*>
{
T* operator()(T* first, T* last, T* result) {
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
return __copy_t(first, last, result, t());
}
};
template <class T>
struct __copy_dispatch<const T*, T*>
{
T* operator()(const T* first, const T* last, T* result) {
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
return __copy_t(first, last, result, t());
}
};
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
template <class InputIterator, class OutputIterator>
inline OutputIterator copy(InputIterator first, InputIterator last,
OutputIterator result)
{
return __copy_dispatch<InputIterator,OutputIterator>()(first, last, result);
}
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);
}
template <class BidirectionalIterator1, class BidirectionalIterator2>
inline BidirectionalIterator2 __copy_backward(BidirectionalIterator1 first,
BidirectionalIterator1 last,
BidirectionalIterator2 result) {
while (first != last) *--result = *--last;
return result;
}
template <class BidirectionalIterator1, class BidirectionalIterator2>
struct __copy_backward_dispatch
{
BidirectionalIterator2 operator()(BidirectionalIterator1 first,
BidirectionalIterator1 last,
BidirectionalIterator2 result) {
return __copy_backward(first, last, result);
}
};
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
template <class T>
inline T* __copy_backward_t(const T* first, const T* last, T* result,
__true_type) {
const ptrdiff_t N = last - first;
memmove(result - N, first, sizeof(T) * N);
return result - N;
}
template <class T>
inline T* __copy_backward_t(const T* first, const T* last, T* result,
__false_type) {
return __copy_backward(first, last, result);
}
template <class T>
struct __copy_backward_dispatch<T*, T*>
{
T* operator()(T* first, T* last, T* result) {
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
return __copy_backward_t(first, last, result, t());
}
};
template <class T>
struct __copy_backward_dispatch<const T*, T*>
{
T* operator()(const T* first, const T* last, T* result) {
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
return __copy_backward_t(first, last, result, t());
}
};
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
template <class BidirectionalIterator1, class BidirectionalIterator2>
inline BidirectionalIterator2 copy_backward(BidirectionalIterator1 first,
BidirectionalIterator1 last,
BidirectionalIterator2 result) {
return __copy_backward_dispatch<BidirectionalIterator1,
BidirectionalIterator2>()(first, last,
result);
}
template <class InputIterator, class Size, class OutputIterator>
pair<InputIterator, OutputIterator> __copy_n(InputIterator first, Size count,
OutputIterator result,
input_iterator_tag) {
for ( ; count > 0; --count, ++first, ++result)
*result = *first;
return pair<InputIterator, OutputIterator>(first, result);
}
template <class RandomAccessIterator, class Size, class OutputIterator>
inline pair<RandomAccessIterator, OutputIterator>
__copy_n(RandomAccessIterator first, Size count,
OutputIterator result,
random_access_iterator_tag) {
RandomAccessIterator last = first + count;
return pair<RandomAccessIterator, OutputIterator>(last,
copy(first, last, result));
}
template <class InputIterator, class Size, class OutputIterator>
inline pair<InputIterator, OutputIterator>
copy_n(InputIterator first, Size count,
OutputIterator result) {
return __copy_n(first, count, result, iterator_category(first));
}
template <class ForwardIterator, class T>
void fill(ForwardIterator first, ForwardIterator last, const T& value) {
for ( ; first != last; ++first)
*first = value;
}
template <class OutputIterator, class Size, class T>
OutputIterator fill_n(OutputIterator first, Size n, const T& value) {
for ( ; n > 0; --n, ++first)
*first = value;
return first;
}
template <class InputIterator1, class InputIterator2>
pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2) {
while (first1 != last1 && *first1 == *first2) {
++first1;
++first2;
}
return pair<InputIterator1, InputIterator2>(first1, first2);
}
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
BinaryPredicate binary_pred) {
while (first1 != last1 && binary_pred(*first1, *first2)) {
++first1;
++first2;
}
return pair<InputIterator1, InputIterator2>(first1, first2);
}
template <class InputIterator1, class InputIterator2>
inline bool equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2) {
for ( ; first1 != last1; ++first1, ++first2)
if (*first1 != *first2)
return false;
return true;
}
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
inline bool equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, BinaryPredicate binary_pred) {
for ( ; first1 != last1; ++first1, ++first2)
if (!binary_pred(*first1, *first2))
return false;
return true;
}
template <class InputIterator1, class InputIterator2>
bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2) {
for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) {
if (*first1 < *first2)
return true;
if (*first2 < *first1)
return false;
}
return first1 == last1 && first2 != last2;
}
template <class InputIterator1, class InputIterator2, class Compare>
bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 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
return lexicographical_compare((const unsigned char*) first1,
(const unsigned char*) last1,
(const unsigned char*) first2,
(const unsigned char*) last2);
#endif
}
template <class InputIterator1, class InputIterator2>
int lexicographical_compare_3way(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 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
}
__STL_END_NAMESPACE
#endif /* __SGI_STL_INTERNAL_ALGOBASE_H */
// Local Variables:
// mode:C++
// End:

Some files were not shown because too many files have changed in this diff Show More