aboutsummaryrefslogtreecommitdiff
path: root/libstdc++
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++')
-rw-r--r--libstdc++/ChangeLog126
-rw-r--r--libstdc++/Makefile.in16
-rw-r--r--libstdc++/configure.in16
-rw-r--r--libstdc++/sstream343
-rw-r--r--libstdc++/std/bastring.cc10
-rw-r--r--libstdc++/std/bastring.h22
-rw-r--r--libstdc++/std/complext.cc2
-rw-r--r--libstdc++/std/gslice.h111
-rw-r--r--libstdc++/std/gslice_array.h170
-rw-r--r--libstdc++/std/indirect_array.h157
-rw-r--r--libstdc++/std/mask_array.h154
-rw-r--r--libstdc++/std/slice.h76
-rw-r--r--libstdc++/std/slice_array.h156
-rw-r--r--libstdc++/std/std_valarray.h728
-rw-r--r--libstdc++/std/valarray_array.h346
-rw-r--r--libstdc++/std/valarray_array.tcc130
-rw-r--r--libstdc++/std/valarray_meta.h1046
-rw-r--r--libstdc++/stdexcepti.cc4
-rw-r--r--libstdc++/stl/ChangeLog42
-rw-r--r--libstdc++/stl/bitset3
-rw-r--r--libstdc++/stl/pthread_alloc18
-rw-r--r--libstdc++/stl/stl_algo.h4
-rw-r--r--libstdc++/stl/stl_deque.h14
-rw-r--r--libstdc++/stl/stl_function.h8
-rw-r--r--libstdc++/stl/stl_numeric.h14
-rw-r--r--libstdc++/stl/stl_queue.h82
-rw-r--r--libstdc++/stl/stl_rope.h28
-rw-r--r--libstdc++/tests/ChangeLog16
-rw-r--r--libstdc++/testsuite/ChangeLog16
-rw-r--r--libstdc++/valarray8
-rw-r--r--libstdc++/valarray.cc50
31 files changed, 3797 insertions, 119 deletions
diff --git a/libstdc++/ChangeLog b/libstdc++/ChangeLog
index f6fa7dd3838..1d48242b6cd 100644
--- a/libstdc++/ChangeLog
+++ b/libstdc++/ChangeLog
@@ -1,3 +1,129 @@
+2001-01-01 Bernd Schmidt <bernds@redhat.co.uk>
+
+ 1999-12-07 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+ * stl_deque.h (_Deque_base::const_iterator): Change third
+ template argument to pointer type.
+ Reported by Carlo Wood <carlo@node1500a.a2000.nl>
+
+ 1999-11-10 Benjamin Kosnik <bkoz@haight.constant.com>
+ Matthias Klose <doko@cs.tu-berlin.de>
+ * stl_rope.h: Fix initialization order.
+ * stl_deque.h: Use static_casts<size_type>(signed_type).
+
+2000-11-24 Magnus Fromreide <magfr@lysator.liu.se>
+
+ * sstream: Backport libstdc++-V3 sstream to V2.
+
+2000-04-24 Magnus Fromreide <magfr@lysator.liu.se>
+
+ * sstream: New file.
+ * Makefile.in (HEADERS): Add it.
+
+2000-03-12 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+
+ * std/bastring.h (basic_string<>::push_back): Define.
+
+Tue Mar 7 21:37:56 2000 Jeffrey A Law (law@cygnus.com)
+
+ 1999-11-19 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+ * std/valarray_meta.h (_DEFINE_EXPR_UNARY_FUNCTION): Don't forget
+ to define tanh.
+
+ 1999-11-05 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+ * std/valarray_meta.h (_DEFINE_EXPR_UNARY_FUNCTION): When
+ building meta-expressions don't forget to take the contained
+ closures.
+
+ 1999-10-19 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+ * std/valarray_meta.h: (_BinClos::_BinClos): Fix typo.
+
+ 1999-09-17 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+ * std/complext.cc (pow): Don't expect floating point promotion
+ in presence of template argument deduction. There is no such
+ thing.
+
+2000-02-06 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+ * std/valarray_array.h (__valarray_copy): Fix typo.
+
+1999-12-14 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+ * std/bastring.h (basic_string::basic_string): Rename parameters
+ to avoid shadow warnings.
+ * std/bastring.cc (alloc): Likewise.
+
+Sun Oct 24 23:54:10 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.2 Released.
+
+Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.1 Released.
+
+Thu Aug 5 02:00:13 1999 Loren Rittle <ljrittle@acm.org>
+
+ * Makefile.in (MARLINK, MSHLINK): Handle library version
+ number components with more than one numeric digit.
+
+Mon Aug 2 00:40:10 1999 Jeffrey A Law (law@cygnus.com)
+
+ 1999-07-16 Markus Gyger (mgyger@gmu.edu)
+ * stdexcepti.cc (__out_of_range): Use std:: qualifier for names
+ in std.
+ (__length_error): Likewise.
+
+Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+Sat Jul 17 23:49:59 1999 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (INTERFACE): Bump to 3.
+
+Fri Jul 9 01:20:23 1999 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (VERSION): Bump to 2.10.0.
+
+Tue Jun 8 00:21:11 1999 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in (*-*-freebsd2*): Add missing '*' at end of configure
+ string.
+
+1999-06-05 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+
+ * std/std_valarray.h: Don't #include unconditionally <alloca.h>
+
+1999-06-05 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+
+ * std/std_valarray.h: New file.
+ * std/slice.h: New file.
+ * std/slice_array.h: New file.
+ * std/gslice.h: New file.
+ * std/gslice_array.h: New file.
+ * std/mask_array.h: New file.
+ * std/indirect_array.h: New file.
+ * std/valarray_array.h: New file.
+ * std/valarray_array.tcc: New file.
+ * std/valarray_meta.h: New file.
+ * valarray.cc: New file.
+ * valarray: New file
+
+ * Makefile.in (OBJS): add valarray.o
+ (HEADERS): add valarray
+ (valarray.o): define dependency on valarray.cc
+ (install): make it possible to install valarray file.
+
+Wed Jun 2 00:21:54 1999 Robert Lipe <robertlipe@usa.net>
+
+ * std/bastring.h (class basic_string:Rep): Encode xlock opcode
+ as .bytes instead of mnemonics.
+
+1999-05-20 Angela Marie Thomas <angela@cygnus.com>
+
+ * configure.in: Test for ${compiler_name}.exe as well.
+
1999-05-15 Mark Kettenis <kettenis@gnu.org>
* configure.in: Add shared library support for the Hurd
diff --git a/libstdc++/Makefile.in b/libstdc++/Makefile.in
index 9e03d0545a7..f13eddcf294 100644
--- a/libstdc++/Makefile.in
+++ b/libstdc++/Makefile.in
@@ -14,12 +14,12 @@
# 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
-INTERFACE = 2
+VERSION = 2.10.0
+INTERFACE = 3
gxx_include_dir=${includedir}/g++
-OBJS = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.o
+OBJS = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.o valarray.o
SUBLIBS = $(STAMP)-string $(STAMP)-complx
# C++ headers with no extension
@@ -28,15 +28,16 @@ HEADERS= cassert cctype cerrno cfloat ciso646 climits clocale cmath complex \
cwchar cwctype string stdexcept \
algorithm deque functional hash_map hash_set iterator list map \
memory numeric pthread_alloc queue rope set slist stack utility \
- vector fstream iomanip iostream strstream iosfwd bitset
+ vector fstream iomanip iostream strstream iosfwd bitset valarray \
+ sstream
ARLIB = libstdc++.a.$(VERSION)
ARLINK = libstdc++.a
-MARLINK = libstdc++.a.`echo $(VERSION) | sed 's/\([0-9][.][0-9]\).*/\1/'`
+MARLINK = libstdc++.a.`echo $(VERSION) | sed 's/\([0-9]*[.][0-9]*\).*/\1/'`
SHLIB = libstdc++.so.$(VERSION)
SHARLIB = libstdc++-sh.a
SHLINK = libstdc++.so
-MSHLINK = libstdc++.so.`echo $(VERSION) | sed 's/\([0-9][.][0-9]\).*/\1/'`
+MSHLINK = libstdc++.so.`echo $(VERSION) | sed 's/\([0-9]*[.][0-9]*\).*/\1/'`
SHFLAGS =
SHDEPS =
@@ -130,6 +131,7 @@ cstdlibi.o: cstdlibi.cc
cmathi.o: cmathi.cc
stdexcepti.o: stdexcepti.cc
stlinst.o: stlinst.cc
+valarray.o: valarray.cc
# Later do wide strings, too.
stmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \
@@ -269,7 +271,7 @@ install:
fi ; \
chmod a-x $(gxx_include_dir)/$$FILE ; \
done ; \
- for FILE in *.h std/*.h std/*.cc; do \
+ for FILE in *.h std/*.h std/*.cc std/*.tcc; do \
rm -f $(gxx_include_dir)/$$FILE ; \
$(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \
chmod a-x $(gxx_include_dir)/$$FILE ; \
diff --git a/libstdc++/configure.in b/libstdc++/configure.in
index 8262565bd88..bd2c9c71e43 100644
--- a/libstdc++/configure.in
+++ b/libstdc++/configure.in
@@ -2,18 +2,6 @@
# necessary for a configure script to process the program in
# this directory. For more information, look at ../configure.
-# find a possible extension of the just-built C++ compiler. Note that this
-# is not the only choice, taking into cross and canadian cross into
-# account, and we need to search for with and without the extension.
-case "${host_alias}" in
-*cygwin* | *mingw32*)
- EXEEXT=.exe
- ;;
-*)
- EXEEXT=
- ;;
-esac
-
# If the language specific compiler does not exist, but the "gcc" directory
# does, we do not build anything. Note, $r is set by the top-level Makefile.
# Note that when we look for the compiler, we search both with and without
@@ -25,7 +13,7 @@ rm -f skip-this-dir
if test -n "$r" && [ -z "$norecursion" ] ; then
if test -d "$r"/gcc; then
if test -f "$r"/gcc/$compiler_name \
- || test -f "$r"/gcc/$compiler_name$EXEEXT; then
+ || test -f "$r"/gcc/$compiler_name.exe; then
true
else
echo "rm -f multilib.out" > skip-this-dir
@@ -83,7 +71,7 @@ if [ "${shared}" = "yes" ]; then
*-*-hpux*) frags="${frags} hpux.ml" ;;
*-*-irix[56]*) frags="${frags} irix5.ml" ;;
*-*-linux*aout*) ;;
- *-*-freebsd2) ;;
+ *-*-freebsd2*) ;;
*-*-freebsd*) frags="${frags} freebsd.ml" ;;
*-*-linux*) frags="${frags} linux.ml" ;;
*-*-openbsd*) frags="${frags} openbsd.ml" ;;
diff --git a/libstdc++/sstream b/libstdc++/sstream
new file mode 100644
index 00000000000..45393b14761
--- /dev/null
+++ b/libstdc++/sstream
@@ -0,0 +1,343 @@
+/* This is part of libio/iostream, providing -*- C++ -*- input/output.
+Copyright (C) 2000 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+/* Written by Magnus Fromreide (magfr@lysator.liu.se). */
+/* seekoff and ideas for overflow is largely borrowed from libstdc++-v3 */
+
+#ifndef __SSTREAM__
+#define __SSTREAM__
+
+#include <iostream.h>
+#include <streambuf.h>
+#include <string>
+
+namespace std
+{
+ class stringbuf : public streambuf
+ {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ stringbuf(int which=ios::in|ios::out)
+ : streambuf(), mode(static_cast<ios::open_mode>(which)),
+ stream(NULL), stream_len(0)
+ {
+ stringbuf_init();
+ }
+
+ explicit
+ stringbuf(const string &str, int which=ios::in|ios::out)
+ : streambuf(), mode(static_cast<ios::open_mode>(which)),
+ stream(NULL), stream_len(0)
+ {
+ if (mode & (ios::in|ios::out))
+ {
+ stream_len = str.size();
+ stream = new char_type[stream_len];
+ str.copy(stream, stream_len);
+ }
+ stringbuf_init();
+ }
+
+ virtual
+ ~stringbuf()
+ {
+ delete[] stream;
+ }
+
+ string
+ str() const
+ {
+ if (pbase() != 0)
+ return string(stream, pptr()-pbase());
+ else
+ return string();
+ }
+
+ void
+ str(const string& str)
+ {
+ delete[] stream;
+ stream_len = str.size();
+ stream = new char_type[stream_len];
+ str.copy(stream, stream_len);
+ stringbuf_init();
+ }
+
+ protected:
+ // The buffer is already in gptr, so if it ends then it is out of data.
+ virtual int
+ underflow()
+ {
+ return EOF;
+ }
+
+ virtual int
+ overflow(int c = EOF)
+ {
+ int res;
+ if (mode & ios::out)
+ {
+ if (c != EOF)
+ {
+ streamsize old_stream_len = stream_len;
+ stream_len += 1;
+ char_type* new_stream = new char_type[stream_len];
+ memcpy(new_stream, stream, old_stream_len);
+ delete[] stream;
+ stream = new_stream;
+ stringbuf_sync(gptr()-eback(), pptr()-pbase());
+ sputc(c);
+ res = c;
+ }
+ else
+ res = EOF;
+ }
+ else
+ res = 0;
+ return res;
+ }
+
+ virtual streambuf*
+ setbuf(char_type* s, streamsize n)
+ {
+ if (n != 0)
+ {
+ delete[] stream;
+ stream = new char_type[n];
+ memcpy(stream, s, n);
+ stream_len = n;
+ stringbuf_sync(0, 0);
+ }
+ return this;
+ }
+
+ virtual pos_type
+ seekoff(off_type off, ios::seek_dir way, int which = ios::in | ios::out)
+ {
+ pos_type ret = pos_type(off_type(-1));
+ bool testin = which & ios::in && mode & ios::in;
+ bool testout = which & ios::out && mode & ios::out;
+ bool testboth = testin && testout && way != ios::cur;
+
+ if (stream_len && ((testin != testout) || testboth))
+ {
+ char_type* beg = stream;
+ char_type* curi = NULL;
+ char_type* curo = NULL;
+ char_type* endi = NULL;
+ char_type* endo = NULL;
+
+ if (testin)
+ {
+ curi = gptr();
+ endi = egptr();
+ }
+ if (testout)
+ {
+ curo = pptr();
+ endo = epptr();
+ }
+
+ off_type newoffi = 0;
+ off_type newoffo = 0;
+ if (way == ios::beg)
+ {
+ newoffi = beg - curi;
+ newoffo = beg - curo;
+ }
+ else if (way == ios::end)
+ {
+ newoffi = endi - curi;
+ newoffo = endo - curo;
+ }
+
+ if (testin && newoffi + off + curi - beg >= 0 &&
+ endi - beg >= newoffi + off + curi - beg)
+ {
+ gbump(newoffi + off);
+ ret = pos_type(newoffi + off + curi);
+ }
+ if (testout && newoffo + off + curo - beg >= 0 &&
+ endo - beg >= newoffo + off + curo - beg)
+ {
+ pbump(newoffo + off);
+ ret = pos_type(newoffo + off + curo);
+ }
+ }
+ return ret;
+ }
+
+ virtual pos_type
+ seekpos(pos_type sp, int which = ios::in | ios::out)
+ {
+ pos_type ret = seekoff(sp, ios::beg, which);
+ return ret;
+ }
+
+ private:
+ void
+ stringbuf_sync(streamsize i, streamsize o)
+ {
+ if (mode & ios::in)
+ setg(stream, stream + i, stream + stream_len);
+ if (mode & ios::out)
+ {
+ setp(stream, stream + stream_len);
+ pbump(o);
+ }
+ }
+ void
+ stringbuf_init()
+ {
+ if (mode & ios::ate)
+ stringbuf_sync(0, stream_len);
+ else
+ stringbuf_sync(0, 0);
+ }
+
+ private:
+ ios::open_mode mode;
+ char_type* stream;
+ streamsize stream_len;
+ };
+
+ class istringstream : public istream {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ istringstream(int which=ios::in)
+ : istream(&sb), sb(which | ios::in)
+ { }
+
+ explicit
+ istringstream(const string& str, int which=ios::in)
+ : istream(&sb), sb(str, which | ios::in)
+ { }
+
+ stringbuf*
+ rdbuf() const
+ {
+ return const_cast<stringbuf*>(&sb);
+ }
+
+ string
+ str() const
+ {
+ return rdbuf()->str();
+ }
+ void
+ str(const string& s)
+ {
+ rdbuf()->str(s);
+ }
+ private:
+ stringbuf sb;
+ };
+
+ class ostringstream : public ostream {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ ostringstream(int which=ios::out)
+ : ostream(&sb), sb(which | ios::out)
+ { }
+
+ explicit
+ ostringstream(const string& str, int which=ios::out)
+ : ostream(&sb), sb(str, which | ios::out)
+ { }
+
+ stringbuf*
+ rdbuf() const
+ {
+ return const_cast<stringbuf*>(&sb);
+ }
+
+ string
+ str() const
+ {
+ return rdbuf()->str();
+ }
+
+ void str(const string& s)
+ {
+ rdbuf()->str(s);
+ }
+ private:
+ stringbuf sb;
+ };
+
+ class stringstream : public iostream {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ stringstream(int which=ios::out|ios::in)
+ : iostream(&sb), sb(which)
+ { }
+
+ explicit
+ stringstream(const string& str, int which=ios::out|ios::in)
+ : iostream(&sb), sb(str, which)
+ { }
+
+ stringbuf*
+ rdbuf() const
+ {
+ return const_cast<stringbuf*>(&sb);
+ }
+
+ string
+ str() const
+ {
+ return rdbuf()->str();
+ }
+
+ void
+ str(const string& s)
+ {
+ rdbuf()->str(s);
+ }
+ private:
+ stringbuf sb;
+ };
+};
+
+#endif /* not __STRSTREAM__ */
diff --git a/libstdc++/std/bastring.cc b/libstdc++/std/bastring.cc
index 3093b9e129d..f86f6d30157 100644
--- a/libstdc++/std/bastring.cc
+++ b/libstdc++/std/bastring.cc
@@ -1,5 +1,5 @@
// Member templates for the -*- C++ -*- string classes.
-// Copyright (C) 1994 Free Software Foundation
+// Copyright (C) 1994, 1999 Free Software Foundation
// This file is part of the GNU ANSI C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -94,14 +94,14 @@ check_realloc (basic_string::size_type s) const
template <class charT, class traits, class Allocator>
void basic_string <charT, traits, Allocator>::
-alloc (basic_string::size_type size, bool save)
+alloc (basic_string::size_type __size, bool __save)
{
- if (! check_realloc (size))
+ if (! check_realloc (__size))
return;
- Rep *p = Rep::create (size);
+ Rep *p = Rep::create (__size);
- if (save)
+ if (__save)
{
p->copy (0, data (), length ());
p->len = length ();
diff --git a/libstdc++/std/bastring.h b/libstdc++/std/bastring.h
index 6206713b6c9..bbe873085ea 100644
--- a/libstdc++/std/bastring.h
+++ b/libstdc++/std/bastring.h
@@ -1,5 +1,5 @@
// Main templates for the -*- C++ -*- string classes.
-// Copyright (C) 1994, 1995 Free Software Foundation
+// Copyright (C) 1994, 1995, 1999 Free Software Foundation
// This file is part of the GNU ANSI C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -77,8 +77,15 @@ private:
void release ()
{
size_t __val;
- asm ("lock; xaddl %0, %2"
- : "=r" (__val) : "0" (-1), "m" (ref) : "memory");
+ // This opcode exists as a .byte instead of as a mnemonic for the
+ // benefit of SCO OpenServer 5. The system assembler (which is
+ // essentially required on this target) can't assemble xaddl in
+ //COFF mode.
+ asm (".byte 0xf0, 0x0f, 0xc1, 0x02" // lock; xaddl %eax, (%edx)
+ : "=a" (__val)
+ : "0" (-1), "m" (ref), "d" (&ref)
+ : "memory");
+
if (__val == 1)
delete this;
}
@@ -173,11 +180,11 @@ public:
: dat (nilRep.grab ()) { assign (n, c); }
#ifdef __STL_MEMBER_TEMPLATES
template<class InputIterator>
- basic_string(InputIterator begin, InputIterator end)
+ basic_string(InputIterator __begin, InputIterator __end)
#else
- basic_string(const_iterator begin, const_iterator end)
+ basic_string(const_iterator __begin, const_iterator __end)
#endif
- : dat (nilRep.grab ()) { assign (begin, end); }
+ : dat (nilRep.grab ()) { assign (__begin, __end); }
~basic_string ()
{ rep ()->release (); }
@@ -201,6 +208,9 @@ public:
#endif
{ return replace (iend (), iend (), first, last); }
+ void push_back(charT __c)
+ { append(1, __c); }
+
basic_string& assign (const basic_string& str, size_type pos = 0,
size_type n = npos)
{ return replace (0, npos, str, pos, n); }
diff --git a/libstdc++/std/complext.cc b/libstdc++/std/complext.cc
index d50bf0871f6..60227f21329 100644
--- a/libstdc++/std/complext.cc
+++ b/libstdc++/std/complext.cc
@@ -236,7 +236,7 @@ pow (const complex<FLOAT>& xin, int y)
if (y < 0)
{
y = -y;
- x = 1/x;
+ x = FLOAT(1)/x;
}
for (;;)
{
diff --git a/libstdc++/std/gslice.h b/libstdc++/std/gslice.h
new file mode 100644
index 00000000000..4f6e854a14c
--- /dev/null
+++ b/libstdc++/std/gslice.h
@@ -0,0 +1,111 @@
+// The template and inlines for the -*- C++ -*- gslice class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __GSLICE__
+#define __GSLICE__
+
+extern "C++" {
+
+struct _Indexer {
+ size_t _M_count;
+ size_t _M_start;
+ valarray<size_t> _M_size;
+ valarray<size_t> _M_stride;
+ valarray<size_t> _M_index;
+ _Indexer(size_t, const valarray<size_t>&, const valarray<size_t>&);
+ void _M_increment_use() { ++_M_count; }
+ size_t _M_decrement_use() { return --_M_count; }
+};
+
+
+class gslice
+{
+public:
+ gslice ();
+ gslice (size_t, const valarray<size_t>&, const valarray<size_t>&);
+ gslice(const gslice&);
+ ~gslice();
+
+ gslice& operator= (const gslice&);
+ size_t start () const;
+ valarray<size_t> size () const;
+ valarray<size_t> stride () const;
+
+private:
+ _Indexer* _M_index;
+
+ template<typename _Tp> friend class valarray;
+};
+
+inline size_t
+gslice::start () const
+{ return _M_index ? _M_index->_M_start : 0; }
+
+inline valarray<size_t>
+gslice::size () const
+{ return _M_index ? _M_index->_M_size : valarray<size_t>(); }
+
+inline valarray<size_t>
+gslice::stride () const
+{ return _M_index ? _M_index->_M_stride : valarray<size_t>(); }
+
+inline gslice::gslice () : _M_index(0) {}
+
+inline
+gslice::gslice(size_t __o, const valarray<size_t>& __l,
+ const valarray<size_t>& __s)
+ : _M_index(new _Indexer(__o, __l, __s)) {}
+
+inline
+gslice::gslice(const gslice& __g) : _M_index(__g._M_index)
+{ if (_M_index) _M_index->_M_increment_use(); }
+
+inline
+gslice::~gslice()
+{ if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; }
+
+inline gslice&
+gslice::operator= (const gslice& __g)
+{
+ if (__g._M_index) __g._M_index->_M_increment_use();
+ if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index;
+ _M_index = __g._M_index;
+ return *this;
+}
+
+
+} // extern "C++"
+
+#endif // __GSLICE__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/gslice_array.h b/libstdc++/std/gslice_array.h
new file mode 100644
index 00000000000..8a67cac9050
--- /dev/null
+++ b/libstdc++/std/gslice_array.h
@@ -0,0 +1,170 @@
+// The template and inlines for the -*- C++ -*- gslice_array class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __GSLICE_ARRAY__
+#define __GSLICE_ARRAY__
+
+extern "C++" {
+
+template<typename _Tp> class gslice_array
+{
+public:
+ typedef _Tp value_type;
+
+ void operator= (const valarray<_Tp>&) const;
+ void operator*= (const valarray<_Tp>&) const;
+ void operator/= (const valarray<_Tp>&) const;
+ void operator%= (const valarray<_Tp>&) const;
+ void operator+= (const valarray<_Tp>&) const;
+ void operator-= (const valarray<_Tp>&) const;
+ void operator^= (const valarray<_Tp>&) const;
+ void operator&= (const valarray<_Tp>&) const;
+ void operator|= (const valarray<_Tp>&) const;
+ void operator<<=(const valarray<_Tp>&) const;
+ void operator>>=(const valarray<_Tp>&) const;
+ void operator=(const _Tp&);
+
+ template<class _Dom>
+ void operator= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator*= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator/= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator%= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator+= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator-= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator^= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator&= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator|= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator<<= (const _Expr<_Dom,_Tp>&) const;
+ template<class _Dom>
+ void operator>>= (const _Expr<_Dom,_Tp>&) const;
+
+private:
+ _Array<_Tp> _M_array;
+ const valarray<size_t>& _M_index;
+
+ friend class valarray<_Tp>;
+
+ gslice_array (_Array<_Tp>, const valarray<size_t>&);
+
+ // this constructor needs to be implemented.
+ gslice_array (const gslice_array&);
+
+ // not implemented
+ gslice_array();
+ gslice_array& operator= (const gslice_array&);
+};
+
+template<typename _Tp>
+inline
+gslice_array<_Tp>::gslice_array (_Array<_Tp> __a,
+ const valarray<size_t>& __i)
+ : _M_array (__a), _M_index (__i) {}
+
+
+template<typename _Tp>
+inline
+gslice_array<_Tp>::gslice_array (const gslice_array<_Tp>& __a)
+ : _M_array (__a._M_array), _M_index (__a._M_index) {}
+
+
+template<typename _Tp>
+inline void
+gslice_array<_Tp>::operator= (const _Tp& __t)
+{
+ __valarray_fill (_M_array, _Array<size_t>(_M_index),
+ _M_index.size(), __t);
+}
+
+template<typename _Tp>
+inline void
+gslice_array<_Tp>::operator= (const valarray<_Tp>& __v) const
+{
+ __valarray_copy (_Array<_Tp> (__v), __v.size (),
+ _M_array, _Array<size_t>(_M_index));
+}
+
+template<typename _Tp>
+template<class E>
+inline void
+gslice_array<_Tp>::operator= (const _Expr<E, _Tp>& __e) const
+{
+ __valarray_copy (__e, _M_index.size(), _M_array,
+ _Array<size_t>(_M_index));
+}
+
+#undef _DEFINE_VALARRAY_OPERATOR
+#define _DEFINE_VALARRAY_OPERATOR(op, name) \
+template<typename _Tp> \
+inline void \
+gslice_array<_Tp>::operator##op##= (const valarray<_Tp>& __v) const \
+{ \
+ _Array_augmented_##name (_M_array, _Array<size_t>(_M_index), \
+ _Array<_Tp> (__v), __v.size ()); \
+} \
+ \
+template<typename _Tp> template<class E> \
+inline void \
+gslice_array<_Tp>::operator##op##= (const _Expr<E, _Tp>& __e) const \
+{ \
+ _Array_augmented_##name (_M_array, _Array<size_t>(_M_index), __e, \
+ _M_index.size()); \
+}
+
+_DEFINE_VALARRAY_OPERATOR(*, multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, divides)
+_DEFINE_VALARRAY_OPERATOR(%, modulus)
+_DEFINE_VALARRAY_OPERATOR(+, plus)
+_DEFINE_VALARRAY_OPERATOR(-, minus)
+_DEFINE_VALARRAY_OPERATOR(^, xor)
+_DEFINE_VALARRAY_OPERATOR(&, and)
+_DEFINE_VALARRAY_OPERATOR(|, or)
+_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+
+#undef _DEFINE_VALARRAY_OPERATOR
+
+} // extern "C++"
+
+
+#endif // __GSLICE_ARRAY__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/indirect_array.h b/libstdc++/std/indirect_array.h
new file mode 100644
index 00000000000..bb5b79fb834
--- /dev/null
+++ b/libstdc++/std/indirect_array.h
@@ -0,0 +1,157 @@
+// The template and inlines for the -*- C++ -*- indirect_array class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __INDIRECT_ARRAY__
+#define __INDIRECT_ARRAY__
+
+extern "C++" {
+
+template <class _Tp> class indirect_array
+{
+public:
+ typedef _Tp value_type;
+
+ void operator= (const valarray<_Tp>&) const;
+ void operator*= (const valarray<_Tp>&) const;
+ void operator/= (const valarray<_Tp>&) const;
+ void operator%= (const valarray<_Tp>&) const;
+ void operator+= (const valarray<_Tp>&) const;
+ void operator-= (const valarray<_Tp>&) const;
+ void operator^= (const valarray<_Tp>&) const;
+ void operator&= (const valarray<_Tp>&) const;
+ void operator|= (const valarray<_Tp>&) const;
+ void operator<<= (const valarray<_Tp>&) const;
+ void operator>>= (const valarray<_Tp>&) const;
+ void operator= (const _Tp&);
+
+ template<class _Dom>
+ void operator= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator*= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator/= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator%= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator+= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator-= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator^= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator&= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator|= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator<<= (const _Expr<_Dom, _Tp>&) const;
+ template<class _Dom>
+ void operator>>= (const _Expr<_Dom, _Tp>&) const;
+
+private:
+ indirect_array (const indirect_array&);
+ indirect_array (_Array<_Tp>, size_t, _Array<size_t>);
+
+ friend class valarray<_Tp>;
+ friend class gslice_array<_Tp>;
+
+ const size_t _M_sz;
+ const _Array<size_t> _M_index;
+ const _Array<_Tp> _M_array;
+
+ // not implemented
+ indirect_array ();
+ indirect_array& operator= (const indirect_array&);
+};
+
+template<typename _Tp>
+inline indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a)
+ : _M_sz (__a._M_sz), _M_index (__a._M_index),
+ _M_array (__a._M_array) {}
+
+template<typename _Tp>
+inline
+indirect_array<_Tp>::indirect_array (_Array<_Tp> __a, size_t __s,
+ _Array<size_t> __i)
+ : _M_sz (__s), _M_index (__i), _M_array (__a) {}
+
+
+template<typename _Tp>
+inline void
+indirect_array<_Tp>::operator= (const _Tp& __t)
+{ __valarray_fill(_M_array, _M_index, _M_sz, __t); }
+
+template<typename _Tp>
+inline void
+indirect_array<_Tp>::operator= (const valarray<_Tp>& __v) const
+{ __valarray_copy (_Array<_Tp> (__v), _M_sz, _M_array, _M_index); }
+
+template<typename _Tp>
+template<class _Dom>
+inline void
+indirect_array<_Tp>::operator= (const _Expr<_Dom,_Tp>& __e) const
+{ __valarray_copy (__e, _M_sz, _M_array, _M_index); }
+
+#undef _DEFINE_VALARRAY_OPERATOR
+#define _DEFINE_VALARRAY_OPERATOR(op, name) \
+template<typename _Tp> \
+inline void \
+indirect_array<_Tp>::operator##op##= (const valarray<_Tp>& __v) const \
+{ \
+ _Array_augmented_##name (_M_array, _M_index, _Array<_Tp> (__v), _M_sz); \
+} \
+ \
+template<typename _Tp> template<class _Dom> \
+inline void \
+indirect_array<_Tp>::operator##op##= (const _Expr<_Dom,_Tp>& __e) const \
+{ \
+ _Array_augmented_##name (_M_array, _M_index, __e, _M_sz); \
+}
+
+_DEFINE_VALARRAY_OPERATOR(*, multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, divides)
+_DEFINE_VALARRAY_OPERATOR(%, modulus)
+_DEFINE_VALARRAY_OPERATOR(+, plus)
+_DEFINE_VALARRAY_OPERATOR(-, minus)
+_DEFINE_VALARRAY_OPERATOR(^, xor)
+_DEFINE_VALARRAY_OPERATOR(&, and)
+_DEFINE_VALARRAY_OPERATOR(|, or)
+_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+
+#undef _DEFINE_VALARRAY_OPERATOR
+
+} // extern "C++"
+
+#endif // __INDIRECT_ARRAY__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/mask_array.h b/libstdc++/std/mask_array.h
new file mode 100644
index 00000000000..d431be4e97f
--- /dev/null
+++ b/libstdc++/std/mask_array.h
@@ -0,0 +1,154 @@
+// The template and inlines for the -*- C++ -*- mask_array class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __MASK_ARRAY__
+#define __MASK_ARRAY__
+
+extern "C++" {
+
+template <class _T> class mask_array
+{
+public:
+ typedef _T value_type;
+
+ void operator= (const valarray<_T>&) const;
+ void operator*= (const valarray<_T>&) const;
+ void operator/= (const valarray<_T>&) const;
+ void operator%= (const valarray<_T>&) const;
+ void operator+= (const valarray<_T>&) const;
+ void operator-= (const valarray<_T>&) const;
+ void operator^= (const valarray<_T>&) const;
+ void operator&= (const valarray<_T>&) const;
+ void operator|= (const valarray<_T>&) const;
+ void operator<<=(const valarray<_T>&) const;
+ void operator>>=(const valarray<_T>&) const;
+ void operator= (const _T&);
+
+ template<class _Dom>
+ void operator= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator*= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator/= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator%= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator+= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator-= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator^= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator&= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator|= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator<<=(const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator>>=(const _Expr<_Dom,_T>&) const;
+
+private:
+ mask_array (_Array<_T>, size_t, _Array<bool>);
+ friend class valarray<_T>;
+
+ const size_t _M_sz;
+ const _Array<bool> _M_mask;
+ const _Array<_T> _M_array;
+
+ mask_array (const mask_array&);
+
+ // not implemented
+ mask_array ();
+ mask_array& operator= (const mask_array&);
+};
+
+template<typename _Tp>
+inline mask_array<_Tp>::mask_array (const mask_array<_Tp>& a)
+ : _M_sz (a._M_sz), _M_mask (a._M_mask), _M_array (a._M_array) {}
+
+template<typename _T>
+inline
+mask_array<_T>::mask_array (_Array<_T> __a, size_t __s, _Array<bool> __m)
+ : _M_sz (__s), _M_mask (__m), _M_array (__a) {}
+
+template<typename _T>
+inline void
+mask_array<_T>::operator= (const _T& __t)
+{ __valarray_fill (_M_array, _M_sz, _M_mask, __t); }
+
+template<typename _T>
+inline void
+mask_array<_T>::operator= (const valarray<_T>& __v) const
+{ __valarray_copy (_Array<_T> (__v), __v.size (), _M_array, _M_mask); }
+
+template<typename _T>
+template<class E>
+inline void
+mask_array<_T>::operator= (const _Expr<E, _T>& __e) const
+{ __valarray_copy (__e, __e.size (), _M_array, _M_mask); }
+
+#undef _DEFINE_VALARRAY_OPERATOR
+#define _DEFINE_VALARRAY_OPERATOR(op, name) \
+template<typename _T> \
+inline void \
+mask_array<_T>::operator##op##= (const valarray<_T>& __v) const \
+{ \
+ _Array_augmented_##name (_M_array, _M_mask, \
+ _Array<_T> (__v), __v.size ()); \
+} \
+ \
+template<typename _T> template<class E> \
+inline void \
+mask_array<_T>::operator##op##= (const _Expr<E, _T>& __e) const \
+{ \
+ _Array_augmented_##name (_M_array, _M_mask, __e, __e.size ()); \
+}
+
+_DEFINE_VALARRAY_OPERATOR(*, multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, divides)
+_DEFINE_VALARRAY_OPERATOR(%, modulus)
+_DEFINE_VALARRAY_OPERATOR(+, plus)
+_DEFINE_VALARRAY_OPERATOR(-, minus)
+_DEFINE_VALARRAY_OPERATOR(^, xor)
+_DEFINE_VALARRAY_OPERATOR(&, and)
+_DEFINE_VALARRAY_OPERATOR(|, or)
+_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+
+#undef _DEFINE_VALARRAY_OPERATOR
+
+} // extern "C++"
+
+#endif // __MASK_ARRAY__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/slice.h b/libstdc++/std/slice.h
new file mode 100644
index 00000000000..cf2fb283de9
--- /dev/null
+++ b/libstdc++/std/slice.h
@@ -0,0 +1,76 @@
+// The template and inlines for the -*- C++ -*- slice class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __SLICE__
+#define __SLICE__
+
+extern "C++" {
+
+class slice
+{
+public:
+ slice ();
+ slice (size_t, size_t, size_t);
+
+ size_t start () const;
+ size_t size () const;
+ size_t stride () const;
+
+private:
+ size_t _M_off; // offset
+ size_t _M_sz; // size
+ size_t _M_st; // stride unit
+};
+
+inline slice::slice () {}
+
+inline slice::slice (size_t __o, size_t __d, size_t __s)
+ : _M_off (__o), _M_sz (__d), _M_st (__s) {}
+
+inline size_t
+slice::start () const
+ { return _M_off; }
+
+inline size_t
+slice::size () const
+ { return _M_sz; }
+
+inline size_t
+slice::stride () const
+ { return _M_st; }
+
+} // extern "C++"
+
+#endif // __SLICE__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/slice_array.h b/libstdc++/std/slice_array.h
new file mode 100644
index 00000000000..dc1aa34d355
--- /dev/null
+++ b/libstdc++/std/slice_array.h
@@ -0,0 +1,156 @@
+// The template and inlines for the -*- C++ -*- slice_array class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __SLICE_ARRAY__
+#define __SLICE_ARRAY__
+
+extern "C++" {
+
+template<typename _T>
+class slice_array
+{
+public:
+ typedef _T value_type;
+
+ void operator= (const valarray<_T>&) const;
+ void operator*= (const valarray<_T>&) const;
+ void operator/= (const valarray<_T>&) const;
+ void operator%= (const valarray<_T>&) const;
+ void operator+= (const valarray<_T>&) const;
+ void operator-= (const valarray<_T>&) const;
+ void operator^= (const valarray<_T>&) const;
+ void operator&= (const valarray<_T>&) const;
+ void operator|= (const valarray<_T>&) const;
+ void operator<<= (const valarray<_T>&) const;
+ void operator>>= (const valarray<_T>&) const;
+ void operator= (const _T &);
+
+ template<class _Dom>
+ void operator= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator*= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator/= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator%= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator+= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator-= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator^= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator&= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator|= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator<<= (const _Expr<_Dom,_T>&) const;
+ template<class _Dom>
+ void operator>>= (const _Expr<_Dom,_T>&) const;
+
+private:
+ friend class valarray<_T>;
+ slice_array(_Array<_T>, const slice&);
+
+ const size_t _M_sz;
+ const size_t _M_stride;
+ const _Array<_T> _M_array;
+
+ // this constructor is implemented since we need to return a value.
+ slice_array (const slice_array&);
+
+ // not implemented
+ slice_array ();
+ slice_array& operator= (const slice_array&);
+};
+
+template<typename _T>
+inline slice_array<_T>::slice_array (_Array<_T> __a, const slice& __s)
+ : _M_sz (__s.size ()), _M_stride (__s.stride ()),
+ _M_array (__a.begin () + __s.start ()) {}
+
+template<typename _Tp>
+inline slice_array<_Tp>::slice_array(const slice_array<_Tp>& a)
+ : _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {}
+
+template<typename _T>
+inline void
+slice_array<_T>::operator= (const _T& __t)
+{ __valarray_fill (_M_array, _M_sz, _M_stride, __t); }
+
+template<typename _T>
+inline void
+slice_array<_T>::operator= (const valarray<_T>& __v) const
+{ __valarray_copy (_Array<_T> (__v), _M_array, _M_sz, _M_stride); }
+
+template<typename _T>
+template<class _Dom>
+inline void
+slice_array<_T>::operator= (const _Expr<_Dom,_T>& __e) const
+{ __valarray_copy (__e, _M_sz, _M_array, _M_stride); }
+
+#undef _DEFINE_VALARRAY_OPERATOR
+#define _DEFINE_VALARRAY_OPERATOR(op, name) \
+template<typename _T> \
+inline void \
+slice_array<_T>::operator##op##= (const valarray<_T>& __v) const \
+{ \
+ _Array_augmented_##name (_M_array, _M_sz, _M_stride, _Array<_T> (__v));\
+} \
+ \
+template<typename _T> template<class _Dom> \
+inline void \
+slice_array<_T>::operator##op##= (const _Expr<_Dom,_T>& __e) const \
+{ \
+ _Array_augmented_##name (_M_array, _M_stride, __e, _M_sz); \
+}
+
+
+_DEFINE_VALARRAY_OPERATOR(*, multiplies)
+_DEFINE_VALARRAY_OPERATOR(/, divides)
+_DEFINE_VALARRAY_OPERATOR(%, modulus)
+_DEFINE_VALARRAY_OPERATOR(+, plus)
+_DEFINE_VALARRAY_OPERATOR(-, minus)
+_DEFINE_VALARRAY_OPERATOR(^, xor)
+_DEFINE_VALARRAY_OPERATOR(&, and)
+_DEFINE_VALARRAY_OPERATOR(|, or)
+_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
+_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
+
+#undef _DEFINE_VALARRAY_OPERATOR
+
+} // extern "C++"
+
+#endif // __SLICE_ARRAY__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/std_valarray.h b/libstdc++/std/std_valarray.h
new file mode 100644
index 00000000000..b3006555547
--- /dev/null
+++ b/libstdc++/std/std_valarray.h
@@ -0,0 +1,728 @@
+// The template and inlines for the -*- C++ -*- valarray class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __STD_VALARRAY__
+#define __STD_VALARRAY__
+#define _G_NO_VALARRAY_TEMPLATE_EXPORT 1
+
+#include <cstddef>
+#include <cmath>
+#include <cstdlib>
+#include <numeric>
+#include <functional>
+#include <algorithm>
+
+#ifndef alloca
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else /* not GNU C. */
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
+#include <alloca.h>
+#else /* not sparc */
+#if defined (MSDOS) && !defined (__TURBOC__)
+#include <malloc.h>
+#else /* not MSDOS, or __TURBOC__ */
+#if defined(_AIX)
+#include <malloc.h>
+ #pragma alloca
+#else /* not MSDOS, __TURBOC__, or _AIX */
+#ifdef __hpux
+#endif /* __hpux */
+#endif /* not _AIX */
+#endif /* not MSDOS, or __TURBOC__ */
+#endif /* not sparc. */
+#endif /* not GNU C. */
+#endif /* alloca not defined. */
+
+extern "C" {
+ void* alloca(size_t);
+}
+
+
+extern "C++" {
+
+template<class _Clos, typename _Tp> class _Expr;
+
+template<typename _Tp1, typename _Tp2> class _ValArray;
+
+template<template<class> class _Oper,
+ template<class, class> class _Meta, class _Dom> struct _UnClos;
+
+template<template<class> class _Oper,
+ template<class, class> class _Meta1,
+ template<class, class> class _Meta2,
+ class _Dom1, class _Dom2> class _BinClos;
+
+template<template<class, class> class _Meta, class _Dom> class _SClos;
+
+template<template<class, class> class _Meta, class _Dom> class _GClos;
+
+template<template<class, class> class _Meta, class _Dom> class _IClos;
+
+template<template<class, class> class _Meta, class _Dom> class _ValFunClos;
+
+template<template<class, class> class _Meta, class _Dom> class _RefFunClos;
+
+template<class _Tp> struct _Unary_plus;
+template<class _Tp> struct _Bitwise_and;
+template<class _Tp> struct _Bitwise_or;
+template<class _Tp> struct _Bitwise_xor;
+template<class _Tp> struct _Bitwise_not;
+template<class _Tp> struct _Shift_left;
+template<class _Tp> struct _Shift_right;
+
+template<class _Tp> class valarray; // An array of type _Tp
+class slice; // BLAS-like slice out of an array
+template<class _Tp> class slice_array;
+class gslice; // generalized slice out of an array
+template<class _Tp> class gslice_array;
+template<class _Tp> class mask_array; // masked array
+template<class _Tp> class indirect_array; // indirected array
+
+} // extern "C++"
+
+#include <std/valarray_array.h>
+#include <std/valarray_meta.h>
+
+extern "C++" {
+
+template<class _Tp> class valarray
+{
+public:
+ typedef _Tp value_type;
+
+ // _lib.valarray.cons_ construct/destroy:
+ valarray();
+ explicit valarray(size_t);
+ valarray(const _Tp&, size_t);
+ valarray(const _Tp* __restrict__, size_t);
+ valarray(const valarray&);
+ valarray(const slice_array<_Tp>&);
+ valarray(const gslice_array<_Tp>&);
+ valarray(const mask_array<_Tp>&);
+ valarray(const indirect_array<_Tp>&);
+ template<class _Dom>
+ valarray(const _Expr<_Dom,_Tp>& __e);
+ ~valarray();
+
+ // _lib.valarray.assign_ assignment:
+ valarray<_Tp>& operator=(const valarray<_Tp>&);
+ valarray<_Tp>& operator=(const _Tp&);
+ valarray<_Tp>& operator=(const slice_array<_Tp>&);
+ valarray<_Tp>& operator=(const gslice_array<_Tp>&);
+ valarray<_Tp>& operator=(const mask_array<_Tp>&);
+ valarray<_Tp>& operator=(const indirect_array<_Tp>&);
+
+ template<class _Dom> valarray<_Tp>&
+ operator= (const _Expr<_Dom,_Tp>&);
+
+ // _lib.valarray.access_ element access:
+ _Tp operator[](size_t) const;
+ _Tp& operator[](size_t);
+ // _lib.valarray.sub_ subset operations:
+ _Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const;
+ slice_array<_Tp> operator[](slice);
+ _Expr<_GClos<_ValArray,_Tp>, _Tp> operator[](const gslice&) const;
+ gslice_array<_Tp> operator[](const gslice&);
+ valarray<_Tp> operator[](const valarray<bool>&) const;
+ mask_array<_Tp> operator[](const valarray<bool>&);
+ _Expr<_IClos<_ValArray, _Tp>, _Tp>
+ operator[](const valarray<size_t>&) const;
+ indirect_array<_Tp> operator[](const valarray<size_t>&);
+
+ // _lib.valarray.unary_ unary operators:
+ _Expr<_UnClos<_Unary_plus,_ValArray,_Tp>,_Tp> operator+ () const;
+ _Expr<_UnClos<negate,_ValArray,_Tp>,_Tp> operator- () const;
+ _Expr<_UnClos<_Bitwise_not,_ValArray,_Tp>,_Tp> operator~ () const;
+ _Expr<_UnClos<logical_not,_ValArray,_Tp>,bool> operator! () const;
+
+ // _lib.valarray.cassign_ computed assignment:
+ valarray<_Tp>& operator*= (const _Tp&);
+ valarray<_Tp>& operator/= (const _Tp&);
+ valarray<_Tp>& operator%= (const _Tp&);
+ valarray<_Tp>& operator+= (const _Tp&);
+ valarray<_Tp>& operator-= (const _Tp&);
+ valarray<_Tp>& operator^= (const _Tp&);
+ valarray<_Tp>& operator&= (const _Tp&);
+ valarray<_Tp>& operator|= (const _Tp&);
+ valarray<_Tp>& operator<<=(const _Tp&);
+ valarray<_Tp>& operator>>=(const _Tp&);
+ valarray<_Tp>& operator*= (const valarray<_Tp>&);
+ valarray<_Tp>& operator/= (const valarray<_Tp>&);
+ valarray<_Tp>& operator%= (const valarray<_Tp>&);
+ valarray<_Tp>& operator+= (const valarray<_Tp>&);
+ valarray<_Tp>& operator-= (const valarray<_Tp>&);
+ valarray<_Tp>& operator^= (const valarray<_Tp>&);
+ valarray<_Tp>& operator|= (const valarray<_Tp>&);
+ valarray<_Tp>& operator&= (const valarray<_Tp>&);
+ valarray<_Tp>& operator<<=(const valarray<_Tp>&);
+ valarray<_Tp>& operator>>=(const valarray<_Tp>&);
+
+ template<class _Dom>
+ valarray<_Tp>& operator*= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator/= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator%= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator+= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator-= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator^= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator|= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator&= (const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
+
+
+ // _lib.valarray.members_ member functions:
+ size_t size() const;
+ _Tp sum() const;
+ _Tp min() const;
+ _Tp max() const;
+
+ // FIXME: Extension
+ _Tp product () const;
+
+ valarray<_Tp> shift (int) const;
+ valarray<_Tp> cshift(int) const;
+ _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(_Tp)) const;
+ _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
+ void resize(size_t __size, _Tp __c = _Tp());
+
+private:
+ size_t _M_size;
+ _Tp* __restrict__ _M_data;
+
+ friend class _Array<_Tp>;
+};
+
+
+template<typename _Tp> struct _Unary_plus : unary_function<_Tp,_Tp> {
+ _Tp operator() (const _Tp& __t) const { return __t; }
+};
+
+template<typename _Tp> struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> {
+ _Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; }
+};
+
+template<typename _Tp> struct _Bitwise_or : binary_function<_Tp,_Tp,_Tp> {
+ _Tp operator() (_Tp __x, _Tp __y) const { return __x | __y; }
+};
+
+template<typename _Tp> struct _Bitwise_xor : binary_function<_Tp,_Tp,_Tp> {
+ _Tp operator() (_Tp __x, _Tp __y) const { return __x ^ __y; }
+};
+
+template<typename _Tp> struct _Bitwise_not : unary_function<_Tp,_Tp> {
+ _Tp operator() (_Tp __t) const { return ~__t; }
+};
+
+template<typename _Tp> struct _Shift_left : unary_function<_Tp,_Tp> {
+ _Tp operator() (_Tp __x, _Tp __y) const { return __x << __y; }
+};
+
+template<typename _Tp> struct _Shift_right : unary_function<_Tp,_Tp> {
+ _Tp operator() (_Tp __x, _Tp __y) const { return __x >> __y; }
+};
+
+
+template<typename _Tp>
+inline _Tp
+valarray<_Tp>::operator[] (size_t __i) const
+{ return _M_data[__i]; }
+
+template<typename _Tp>
+inline _Tp&
+valarray<_Tp>::operator[] (size_t __i)
+{ return _M_data[__i]; }
+
+} // extern "C++"
+
+#include <std/slice.h>
+#include <std/slice_array.h>
+#include <std/gslice.h>
+#include <std/gslice_array.h>
+#include <std/mask_array.h>
+#include <std/indirect_array.h>
+
+extern "C++" {
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray () : _M_size (0), _M_data (0) {}
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (size_t __n)
+ : _M_size (__n), _M_data (new _Tp[__n]) {}
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (const _Tp& __t, size_t __n)
+ : _M_size (__n), _M_data (new _Tp[__n])
+{ __valarray_fill (_M_data, _M_size, __t); }
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (const _Tp* __restrict__ __pT, size_t __n)
+ : _M_size (__n), _M_data (new _Tp[__n])
+{ __valarray_copy (__pT, __n, _M_data); }
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (const valarray<_Tp>& __v)
+ : _M_size (__v._M_size), _M_data (new _Tp[__v._M_size])
+{ __valarray_copy (__v._M_data, _M_size, _M_data); }
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (const slice_array<_Tp>& __sa)
+ : _M_size (__sa._M_sz), _M_data (new _Tp[__sa._M_sz])
+{ __valarray_copy (__sa._M_array, __sa._M_sz, __sa._M_stride,
+ _Array<_Tp>(_M_data)); }
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (const gslice_array<_Tp>& __ga)
+ : _M_size (__ga._M_index.size()), _M_data (new _Tp[_M_size])
+{ __valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
+ _Array<_Tp>(_M_data), _M_size); }
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (const mask_array<_Tp>& __ma)
+ : _M_size (__ma._M_sz), _M_data (new _Tp[__ma._M_sz])
+{ __valarray_copy (__ma._M_array, __ma._M_mask,
+ _Array<_Tp>(_M_data), _M_size); }
+
+template<typename _Tp>
+inline valarray<_Tp>::valarray (const indirect_array<_Tp>& __ia)
+ : _M_size (__ia._M_sz), _M_data (new _Tp[__ia._M_sz])
+{ __valarray_copy (__ia._M_array, __ia._M_index,
+ _Array<_Tp>(_M_data), _M_size); }
+
+template<typename _Tp> template<class _Dom>
+inline valarray<_Tp>::valarray (const _Expr<_Dom, _Tp>& __e)
+ : _M_size (__e.size ()), _M_data (new _Tp[_M_size])
+{ __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); }
+
+template<typename _Tp>
+inline valarray<_Tp>::~valarray () { delete[] _M_data; }
+
+template<typename _Tp>
+inline valarray<_Tp>&
+valarray<_Tp>::operator= (const valarray<_Tp>& __v)
+{
+ __valarray_copy(__v._M_data, _M_size, _M_data);
+ return *this;
+}
+
+template<typename _Tp>
+inline valarray<_Tp>&
+valarray<_Tp>::operator= (const _Tp& __t)
+{
+ __valarray_fill (_M_data, _M_size, __t);
+ return *this;
+}
+
+template<typename _Tp>
+inline valarray<_Tp>&
+valarray<_Tp>::operator= (const slice_array<_Tp>& __sa)
+{
+ __valarray_copy (__sa._M_array, __sa._M_sz,
+ __sa._M_stride, _Array<_Tp>(_M_data));
+ return *this;
+}
+
+template<typename _Tp>
+inline valarray<_Tp>&
+valarray<_Tp>::operator= (const gslice_array<_Tp>& __ga)
+{
+ __valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
+ _Array<_Tp>(_M_data), _M_size);
+ return *this;
+}
+
+template<typename _Tp>
+inline valarray<_Tp>&
+valarray<_Tp>::operator= (const mask_array<_Tp>& __ma)
+{
+ __valarray_copy (__ma._M_array, __ma._M_mask,
+ _Array<_Tp>(_M_data), _M_size);
+ return *this;
+}
+
+template<typename _Tp>
+inline valarray<_Tp>&
+valarray<_Tp>::operator= (const indirect_array<_Tp>& __ia)
+{
+ __valarray_copy (__ia._M_array, __ia._M_index,
+ _Array<_Tp>(_M_data), _M_size);
+ return *this;
+}
+
+template<typename _Tp> template<class _Dom>
+inline valarray<_Tp>&
+valarray<_Tp>::operator= (const _Expr<_Dom, _Tp>& __e)
+{
+ __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data));
+ return *this;
+}
+
+template<typename _Tp>
+inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
+valarray<_Tp>::operator[] (slice __s) const
+{
+ typedef _SClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure, _Tp> (_Closure (_Array<_Tp>(_M_data), __s));
+}
+
+template<typename _Tp>
+inline slice_array<_Tp>
+valarray<_Tp>::operator[] (slice __s)
+{
+ return slice_array<_Tp> (_Array<_Tp>(_M_data), __s);
+}
+
+template<typename _Tp>
+inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
+valarray<_Tp>::operator[] (const gslice& __gs) const
+{
+ typedef _GClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure, _Tp>
+ (_Closure (_Array<_Tp>(_M_data), __gs._M_index->_M_index));
+}
+
+template<typename _Tp>
+inline gslice_array<_Tp>
+valarray<_Tp>::operator[] (const gslice& __gs)
+{
+ return gslice_array<_Tp>
+ (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
+}
+
+template<typename _Tp>
+inline valarray<_Tp>
+valarray<_Tp>::operator[] (const valarray<bool>& __m) const
+{
+ size_t __s (0);
+ size_t __e (__m.size ());
+ for (size_t __i=0; __i<__e; ++__i)
+ if (__m[__i]) ++__s;
+ return valarray<_Tp> (mask_array<_Tp> (_Array<_Tp>(_M_data), __s,
+ _Array<bool> (__m)));
+}
+
+template<typename _Tp>
+inline mask_array<_Tp>
+valarray<_Tp>::operator[] (const valarray<bool>& __m)
+{
+ size_t __s (0);
+ size_t __e (__m.size ());
+ for (size_t __i=0; __i<__e; ++__i)
+ if (__m[__i]) ++__s;
+ return mask_array<_Tp> (_Array<_Tp>(_M_data), __s, _Array<bool> (__m));
+}
+
+template<typename _Tp>
+inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
+valarray<_Tp>::operator[] (const valarray<size_t>& __i) const
+{
+ typedef _IClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure, _Tp> (_Closure (*this, __i));
+}
+
+template<typename _Tp>
+inline indirect_array<_Tp>
+valarray<_Tp>::operator[] (const valarray<size_t>& __i)
+{
+ return indirect_array<_Tp> (_Array<_Tp>(_M_data), __i.size(),
+ _Array<size_t> (__i));
+}
+
+template<class _Tp>
+inline size_t valarray<_Tp>::size () const { return _M_size; }
+
+template<class _Tp>
+inline _Tp
+valarray<_Tp>::sum () const
+{
+ return accumulate (_M_data, _M_data + _M_size, _Tp ());
+}
+
+template<typename _Tp>
+inline _Tp
+valarray<_Tp>::product () const
+{
+ return accumulate (_M_data, _M_data+_M_size, _Tp(1), multiplies<_Tp> ());
+}
+
+template <class _Tp>
+inline valarray<_Tp>
+valarray<_Tp>::shift (int __n) const
+{
+ _Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size));
+ if (! __n) // __n == 0: no shift
+ __valarray_copy (_M_data, _M_size, __a);
+ else if (__n > 0) { // __n > 0: shift left
+ if (__n > _M_size)
+ __valarray_fill(__a, __n, _Tp());
+ else {
+ __valarray_copy (_M_data+__n, _M_size-__n, __a);
+ __valarray_fill (__a+_M_size-__n, __n, _Tp());
+ }
+ }
+ else { // __n < 0: shift right
+ __valarray_copy (_M_data, _M_size+__n, __a-__n);
+ __valarray_fill(__a, -__n, _Tp());
+ }
+ return valarray<_Tp> (__a, _M_size);
+}
+
+template <class _Tp>
+inline valarray<_Tp>
+valarray<_Tp>::cshift (int __n) const
+{
+ _Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size));
+ if (! __n) // __n == 0: no cshift
+ __valarray_copy(_M_data, _M_size, __a);
+ else if (__n > 0) { // __n > 0: cshift left
+ __valarray_copy (_M_data, __n, __a + _M_size-__n);
+ __valarray_copy (_M_data + __n, _M_size-__n, __a);
+ }
+ else { // __n < 0: cshift right
+ __valarray_copy (_M_data + _M_size + __n, -__n, __a);
+ __valarray_copy (_M_data, _M_size + __n, __a - __n);
+ }
+ return valarray<_Tp> (__a, _M_size);
+}
+
+template <class _Tp>
+inline void
+valarray<_Tp>::resize (size_t __n, _Tp __c)
+{
+ if (_M_size != __n) {
+ delete[] _M_data;
+ _M_size = __n;
+ _M_data = new _Tp[_M_size];
+ }
+ __valarray_fill (_M_data, _M_size, __c);
+}
+
+template<typename _Tp>
+inline _Tp
+valarray<_Tp>::min() const
+{
+ return *min_element (_M_data, _M_data+_M_size);
+}
+
+template<typename _Tp>
+inline _Tp
+valarray<_Tp>::max() const
+{
+ return *max_element (_M_data, _M_data+_M_size);
+}
+
+template<class _Tp>
+inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp>
+valarray<_Tp>::apply (_Tp func (_Tp)) const
+{
+ typedef _ValFunClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure,_Tp> (_Closure (*this, func));
+}
+
+template<class _Tp>
+inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp>
+valarray<_Tp>::apply (_Tp func (const _Tp &)) const
+{
+ typedef _RefFunClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure,_Tp> (_Closure (*this, func));
+}
+
+#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline _Expr<_UnClos<_Name,_ValArray,_Tp>, _Tp> \
+ valarray<_Tp>::operator##_Op() const \
+ { \
+ typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
+ return _Expr<_Closure, _Tp> (_Closure (*this)); \
+ }
+
+ _DEFINE_VALARRAY_UNARY_OPERATOR(+, _Unary_plus)
+ _DEFINE_VALARRAY_UNARY_OPERATOR(-, negate)
+ _DEFINE_VALARRAY_UNARY_OPERATOR(~, _Bitwise_not)
+
+#undef _DEFINE_VALARRAY_UNARY_OPERATOR
+
+ template<typename _Tp>
+ inline _Expr<_UnClos<logical_not,_ValArray,_Tp>, bool>
+ valarray<_Tp>::operator!() const
+ {
+ typedef _UnClos<logical_not,_ValArray,_Tp> _Closure;
+ return _Expr<_Closure, bool> (_Closure (*this));
+ }
+
+#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
+ template<class _Tp> \
+ inline valarray<_Tp> & \
+ valarray<_Tp>::operator##_Op##= (const _Tp &__t) \
+ { \
+ _Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, __t); \
+ return *this; \
+ } \
+ \
+ template<class _Tp> \
+ inline valarray<_Tp> & \
+ valarray<_Tp>::operator##_Op##= (const valarray<_Tp> &__v) \
+ { \
+ _Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, \
+ _Array<_Tp>(__v._M_data)); \
+ return *this; \
+ }
+
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, plus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, minus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, multiplies)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, divides)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, modulus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, xor)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, and)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, or)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, shift_left)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, shift_right)
+
+#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT
+
+
+#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
+ template<class _Tp> template<class _Dom> \
+ inline valarray<_Tp> & \
+ valarray<_Tp>::operator##_Op##= (const _Expr<_Dom,_Tp> &__e) \
+ { \
+ _Array_augmented_##_Name (_Array<_Tp>(_M_data), __e, _M_size); \
+ return *this; \
+ }
+
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, plus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, minus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, multiplies)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, divides)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, modulus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, xor)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, and)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, or)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, shift_left)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, shift_right)
+
+#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT
+
+
+#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
+ operator##_Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
+ { \
+ typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure, _Tp> (_Closure (__v, __w)); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,_Tp> \
+ operator##_Op (const valarray<_Tp> &__v, const _Tp &__t) \
+ { \
+ typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure, _Tp> (_Closure (__v, __t)); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,_Tp> \
+ operator##_Op (const _Tp &__t, const valarray<_Tp> &__v) \
+ { \
+ typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure, _Tp> (_Closure (__t, __v)); \
+ }
+
+_DEFINE_BINARY_OPERATOR(+, plus)
+_DEFINE_BINARY_OPERATOR(-, minus)
+_DEFINE_BINARY_OPERATOR(*, multiplies)
+_DEFINE_BINARY_OPERATOR(/, divides)
+_DEFINE_BINARY_OPERATOR(%, modulus)
+_DEFINE_BINARY_OPERATOR(^, _Bitwise_xor)
+_DEFINE_BINARY_OPERATOR(&, _Bitwise_and)
+_DEFINE_BINARY_OPERATOR(|, _Bitwise_or)
+_DEFINE_BINARY_OPERATOR(<<, _Shift_left)
+_DEFINE_BINARY_OPERATOR(>>, _Shift_right)
+
+#undef _DEFINE_BINARY_OPERATOR
+
+#define _DEFINE_LOGICAL_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>,bool> \
+ operator##_Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
+ { \
+ typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure, bool> (_Closure (__v, __w)); \
+ } \
+ \
+ template<class _Tp> \
+ inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,bool> \
+ operator##_Op (const valarray<_Tp> &__v, const _Tp &__t) \
+ { \
+ typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure, bool> (_Closure (__v, __t)); \
+ } \
+ \
+ template<class _Tp> \
+ inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,bool> \
+ operator##_Op (const _Tp &__t, const valarray<_Tp> &__v) \
+ { \
+ typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure, bool> (_Closure (__t, __v)); \
+ }
+
+_DEFINE_LOGICAL_OPERATOR(&&, logical_and)
+_DEFINE_LOGICAL_OPERATOR(||, logical_or)
+_DEFINE_LOGICAL_OPERATOR(==, equal_to)
+_DEFINE_LOGICAL_OPERATOR(!=, not_equal_to)
+_DEFINE_LOGICAL_OPERATOR(<, less)
+_DEFINE_LOGICAL_OPERATOR(>, greater)
+_DEFINE_LOGICAL_OPERATOR(<=, less_equal)
+_DEFINE_LOGICAL_OPERATOR(>=, greater_equal)
+
+#undef _DEFINE_VALARRAY_OPERATOR
+
+#undef _G_NO_VALARRAY_TEMPLATE_EXPORT
+
+} // extern "C++"
+
+#endif // __STD_VALARRAY__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/valarray_array.h b/libstdc++/std/valarray_array.h
new file mode 100644
index 00000000000..a0b5818fd8b
--- /dev/null
+++ b/libstdc++/std/valarray_array.h
@@ -0,0 +1,346 @@
+// The template and inlines for the -*- C++ -*- internal _Array helper class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __VALARRAY_ARRAY__
+#define __VALARRAY_ARRAY__
+
+#include <cstdlib>
+#include <cstring>
+
+extern "C++" {
+
+//
+// Helper functions on raw pointers
+//
+
+// fill plain array __a[<__n>] with __t
+template<typename _Tp>
+inline void
+__valarray_fill (_Tp* __restrict__ __a, size_t __n, const _Tp& __t)
+{ while (__n--) *__a++ = __t; }
+
+// fill strided array __a[<__n-1 : __s>] with __t
+template<typename _Tp>
+inline void
+__valarray_fill (_Tp* __restrict__ __a, size_t __n,
+ size_t __s, const _Tp& __t)
+{ for (size_t __i=0; __i<__n; ++__i, __a+=__s) *__a = __t; }
+
+// fill indirect array __a[__i[<__n>]] with __i
+template<typename _Tp>
+inline void
+__valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i,
+ size_t __n, const _Tp& __t)
+{ for (size_t __j=0; __j<__n; ++__j, ++__i) __a[*__i] = __t; }
+
+// copy plain array __a[<__n>] in __b[<__n>]
+template<typename _Tp>
+inline void
+__valarray_copy (const _Tp* __restrict__ __a, size_t __n,
+ _Tp* __restrict__ __b)
+{ memcpy (__b, __a, __n * sizeof(_Tp)); }
+
+// copy strided array __a[<__n : __s>] in plain __b[<__n>]
+template<typename _Tp>
+inline void
+__valarray_copy (const _Tp* __restrict__ __a, size_t __n, size_t __s,
+ _Tp* __restrict__ __b)
+{ for (size_t __i=0; __i<__n; ++__i, ++__b, __a += __s) *__b = *__a; }
+
+// copy plain __a[<__n>] in strided __b[<__n : __s>]
+template<typename _Tp>
+inline void
+__valarray_copy (const _Tp* __restrict__ __a, _Tp* __restrict__ __b,
+ size_t __n, size_t __s)
+{ for (size_t __i=0; __i<__n; ++__i, ++__a, __b+=__s) *__b = *__a; }
+
+// copy indexed __a[__i[<__n>]] in plain __b[<__n>]
+template<typename _Tp>
+inline void
+__valarray_copy (const _Tp* __restrict__ __a,
+ const size_t* __restrict__ __i,
+ _Tp* __restrict__ __b, size_t __n)
+{ for (size_t __j=0; __j<__n; ++__j, ++__b, ++__i) *__b = __a[*__i]; }
+
+// copy plain __a[<__n>] in indexed __b[__i[<__n>]]
+template<typename _Tp>
+inline void
+__valarray_copy (const _Tp* __restrict__ __a, size_t __n,
+ _Tp* __restrict__ __b, const size_t* __restrict__ __i)
+{ for (size_t __j=0; __j<__n; ++__j, ++__a, ++__i) __b[*__i] = *__a; }
+
+//
+// Helper class _Array, first layer of valarray abstraction.
+// All operations on valarray should be forwarded to this class
+// whenever possible. -- gdr
+//
+
+template<typename _Tp> struct _Array {
+
+ explicit _Array (size_t);
+ explicit _Array (_Tp* const __restrict__);
+ explicit _Array (const valarray<_Tp>&);
+ _Array (const _Tp* __restrict__, size_t);
+
+ void free_data() const;
+ _Tp* begin () const;
+
+ _Tp* const __restrict__ _M_data;
+};
+
+template<typename _Tp>
+inline void
+__valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t)
+{ __valarray_fill (__a._M_data, __n, __t); }
+
+template<typename _Tp>
+inline void
+__valarray_fill (_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t)
+{ __valarray_fill (__a._M_data, __n, __s, __t); }
+
+template<typename _Tp>
+inline void
+__valarray_fill (_Array<_Tp> __a, _Array<size_t> __i,
+ size_t __n, const _Tp& __t)
+{ __valarray_fill (__a._M_data, __i._M_data, __n, __t); }
+
+template<typename _Tp>
+inline void
+__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b)
+{ __valarray_copy (__a._M_data, __n, __b._M_data); }
+
+template<typename _Tp>
+inline void
+__valarray_copy (_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b)
+{ __valarray_copy(__a._M_data, __n, __s, __b._M_data); }
+
+template<typename _Tp>
+inline void
+__valarray_copy (_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s)
+{ __valarray_copy (__a._M_data, __b._M_data, __n, __s); }
+
+template<typename _Tp>
+inline void
+__valarray_copy (_Array<_Tp> __a, _Array<size_t> __i,
+ _Array<_Tp> __b, size_t __n)
+{ __valarray_copy (__a._M_data, __i._M_data, __b._M_data, __n); }
+
+template<typename _Tp>
+inline void
+__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b,
+ _Array<size_t> __i)
+{ __valarray_copy (__a._M_data, __n, __b._M_data, __i._M_data); }
+
+template<typename _Tp>
+inline
+_Array<_Tp>::_Array (size_t __n) : _M_data (new _Tp[__n]) {}
+
+template<typename _Tp>
+inline
+_Array<_Tp>::_Array (_Tp* const __restrict__ __p) : _M_data (__p) {}
+
+template<typename _Tp>
+inline _Array<_Tp>::_Array (const valarray<_Tp>& __v)
+ : _M_data (__v._M_data) {}
+
+template<typename _Tp>
+inline
+_Array<_Tp>::_Array (const _Tp* __restrict__ __b, size_t __s)
+ : _M_data (new _Tp[__s]) { __valarray_copy (__b, __s, _M_data); }
+
+template<typename _Tp>
+inline void
+_Array<_Tp>::free_data() const { delete[] _M_data; }
+
+template<typename _Tp>
+inline _Tp*
+_Array<_Tp>::begin () const
+{ return _M_data; }
+
+#define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \
+template<typename _Tp> \
+inline void \
+_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, const _Tp& __t) \
+{ \
+ for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p) \
+ *__p _Op##= __t; \
+} \
+ \
+template<typename _Tp> \
+inline void \
+_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \
+{ \
+ _Tp* __p (__a._M_data); \
+ for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__p, ++__q) \
+ *__p _Op##= *__q; \
+} \
+ \
+template<typename _Tp, class _Dom> \
+void \
+_Array_augmented_##_Name (_Array<_Tp> __a, \
+ const _Expr<_Dom,_Tp>& __e, size_t __n) \
+{ \
+ _Tp* __p (__a._M_data); \
+ for (size_t __i=0; __i<__n; ++__i, ++__p) *__p _Op##= __e[__i]; \
+} \
+ \
+template<typename _Tp> \
+inline void \
+_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, size_t __s, \
+ _Array<_Tp> __b) \
+{ \
+ _Tp* __q (__b._M_data); \
+ for (_Tp* __p=__a._M_data; __p<__a._M_data+__s*__n; __p+=__s, ++__q) \
+ *__p _Op##= *__q; \
+} \
+ \
+template<typename _Tp> \
+inline void \
+_Array_augmented_##_Name (_Array<_Tp> __a, _Array<_Tp> __b, \
+ size_t __n, size_t __s) \
+{ \
+ _Tp* __q (__b._M_data); \
+ for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, __q+=__s) \
+ *__p _Op##= *__q; \
+} \
+ \
+template<typename _Tp, class _Dom> \
+void \
+_Array_augmented_##_Name (_Array<_Tp> __a, size_t __s, \
+ const _Expr<_Dom,_Tp>& __e, size_t __n) \
+{ \
+ _Tp* __p (__a._M_data); \
+ for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p _Op##= __e[__i]; \
+} \
+ \
+template<typename _Tp> \
+inline void \
+_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \
+ _Array<_Tp> __b, size_t __n) \
+{ \
+ _Tp* __q (__b._M_data); \
+ for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__q) \
+ __a._M_data[*__j] _Op##= *__q; \
+} \
+ \
+template<typename _Tp> \
+inline void \
+_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \
+ _Array<_Tp> __b, _Array<size_t> __i) \
+{ \
+ _Tp* __p (__a._M_data); \
+ for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__p) \
+ *__p _Op##= __b._M_data[*__j]; \
+} \
+ \
+template<typename _Tp, class _Dom> \
+void \
+_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \
+ const _Expr<_Dom, _Tp>& __e, size_t __n) \
+{ \
+ size_t* __j (__i._M_data); \
+ for (size_t __k=0; __k<__n; ++__k, ++__j) \
+ __a._M_data[*__j] _Op##= __e[__k]; \
+} \
+ \
+template<typename _Tp> \
+void \
+_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \
+ _Array<_Tp> __b, size_t __n) \
+{ \
+ bool* ok (__m._M_data); \
+ _Tp* __p (__a._M_data); \
+ for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++ok, ++__p) { \
+ while (! *ok) { \
+ ++ok; \
+ ++__p; \
+ } \
+ *__p _Op##= *__q; \
+ } \
+} \
+ \
+template<typename _Tp> \
+void \
+_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \
+ _Array<_Tp> __b, _Array<bool> __m) \
+{ \
+ bool* ok (__m._M_data); \
+ _Tp* __q (__b._M_data); \
+ for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++ok, ++__q) { \
+ while (! *ok) { \
+ ++ok; \
+ ++__q; \
+ } \
+ *__p _Op##= *__q; \
+ } \
+} \
+ \
+template<typename _Tp, class _Dom> \
+void \
+_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \
+ const _Expr<_Dom, _Tp>& __e, size_t __n) \
+{ \
+ bool* ok(__m._M_data); \
+ _Tp* __p (__a._M_data); \
+ for (size_t __i=0; __i<__n; ++__i, ++ok, ++__p) { \
+ while (! *ok) { \
+ ++ok; \
+ ++__p; \
+ } \
+ *__p _Op##= __e[__i]; \
+ } \
+}
+
+_DEFINE_ARRAY_FUNCTION(+, plus)
+_DEFINE_ARRAY_FUNCTION(-, minus)
+_DEFINE_ARRAY_FUNCTION(*, multiplies)
+_DEFINE_ARRAY_FUNCTION(/, divides)
+_DEFINE_ARRAY_FUNCTION(%, modulus)
+_DEFINE_ARRAY_FUNCTION(^, xor)
+_DEFINE_ARRAY_FUNCTION(|, or)
+_DEFINE_ARRAY_FUNCTION(&, and)
+_DEFINE_ARRAY_FUNCTION(<<, shift_left)
+_DEFINE_ARRAY_FUNCTION(>>, shift_right)
+
+#undef _DEFINE_ARRAY_FUNCTION
+
+} // extern "C++"
+
+#ifdef _G_NO_VALARRAY_TEMPLATE_EXPORT
+# define export
+# include <std/valarray_array.tcc>
+#endif
+
+#endif // __VALARRAY_ARRAY__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/valarray_array.tcc b/libstdc++/std/valarray_array.tcc
new file mode 100644
index 00000000000..bd6692571fd
--- /dev/null
+++ b/libstdc++/std/valarray_array.tcc
@@ -0,0 +1,130 @@
+// The template and inlines for the -*- C++ -*- internal _Array helper class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef __VALARRAY_ARRAY_TCC__
+#define __VALARRAY_ARRAY_TCC__
+
+extern "C++" {
+
+export template<typename _Tp>
+void
+__valarray_fill (_Array<_Tp> __a, size_t __n, _Array<bool> __m, const _Tp& __t)
+{
+ _Tp* __p = __a._M_data;
+ bool* __ok (__m._M_data);
+ for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) {
+ while (! *__ok) {
+ ++__ok;
+ ++__p;
+ }
+ *__p = __t;
+ }
+}
+
+export template<typename _Tp>
+void
+__valarray_copy (_Array<_Tp> __a, _Array<bool> __m, _Array<_Tp> __b, size_t __n)
+{
+ _Tp* __p (__a._M_data);
+ bool* __ok (__m._M_data);
+ for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++__ok, ++__p) {
+ while (! *__ok) {
+ ++__ok;
+ ++__p;
+ }
+ *__q = *__p;
+ }
+}
+
+export template<typename _Tp>
+void
+__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, _Array<bool> __m)
+{
+ _Tp* __q (__b._M_data);
+ bool* __ok (__m._M_data);
+ for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++__ok, ++__q) {
+ while (! *__ok) {
+ ++__ok;
+ ++__q;
+ }
+ *__q = *__p;
+ }
+}
+
+export template<typename _Tp, class _Dom>
+void
+__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
+{
+ _Tp* __p (__a._M_data);
+ for (size_t __i=0; __i<__n; ++__i, ++__p) *__p = __e[__i];
+}
+
+export template<typename _Tp, class _Dom>
+void
+__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
+ _Array<_Tp> __a, size_t __s)
+{
+ _Tp* __p (__a._M_data);
+ for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p = __e[__i];
+}
+
+export template<typename _Tp, class _Dom>
+void
+__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
+ _Array<_Tp> __a, _Array<size_t> __i)
+{
+ size_t* __j (__i._M_data);
+ for (size_t __k=0; __k<__n; ++__k, ++__j) __a._M_data[*__j] = __e[__k];
+}
+
+export template<typename _Tp, class _Dom>
+void
+__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
+ _Array<_Tp> __a, _Array<bool> __m)
+{
+ bool* __ok (__m._M_data);
+ _Tp* __p (__a._M_data);
+ for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) {
+ while (! *__ok) {
+ ++__ok;
+ ++__p;
+ }
+ *__p = __e[__i];
+ }
+}
+
+} // extern "C++"
+
+#endif // __VALARRAY_ARRAY_TCC__
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/std/valarray_meta.h b/libstdc++/std/valarray_meta.h
new file mode 100644
index 00000000000..48fb21371f7
--- /dev/null
+++ b/libstdc++/std/valarray_meta.h
@@ -0,0 +1,1046 @@
+// The template and inlines for the -*- C++ -*- internal _Meta class.
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
+
+#ifndef _CPP_VALARRAY_META_H
+#define _CPP_VALARRAY_META_H 1
+
+//
+// Implementing a loosened valarray return value is tricky.
+// First we need to meet 26.3.1/3: we should not add more than
+// two levels of template nesting. Therefore we resort to template
+// template to "flatten" loosened return value types.
+// At some point we use partial specialization to remove one level
+// template nesting due to _Expr<>
+//
+
+
+// This class is NOT defined. It doesn't need to.
+template<typename _Tp1, typename _Tp2> class _Constant;
+
+//
+// Unary function application closure.
+//
+template<class _Dom> class _UnFunBase {
+public:
+ typedef typename _Dom::value_type value_type;
+ typedef value_type _Vt;
+
+ _UnFunBase (const _Dom& __e, _Vt __f(_Vt))
+ : _M_expr(__e), _M_func(__f) {}
+
+ _Vt operator[] (size_t __i) const { return _M_func(_M_expr[__i]); }
+ size_t size () const { return _M_expr.size(); }
+
+private:
+ const _Dom& _M_expr;
+ _Vt (*_M_func)(_Vt);
+};
+
+template<template<class, class> class _Meta, class _Dom> class _UnFunClos;
+
+template<class _Dom>
+struct _UnFunClos<_Expr,_Dom> : _UnFunBase<_Dom> {
+ typedef _UnFunBase<_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _UnFunClos (const _Dom& __e, value_type __f(value_type))
+ : _Base (__e, __f) {}
+};
+
+template<typename _Tp>
+struct _UnFunClos<_ValArray,_Tp> : _UnFunBase<valarray<_Tp> > {
+ typedef _UnFunBase<valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _UnFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
+ : _Base (__v, __f) {}
+};
+
+//
+// Binary function application closure.
+//
+template<template<class, class> class _Meta1,
+ template<class, class> class Meta2,
+ class _Dom1, class _Dom2> class _BinFunClos;
+
+template<class _Dom1, class _Dom2> class _BinFunBase {
+public:
+ typedef typename _Dom1::value_type value_type;
+ typedef value_type _Vt;
+
+ _BinFunBase (const _Dom1& __e1, const _Dom2& __e2,
+ _Vt __f (_Vt, _Vt))
+ : _M_expr1 (__e1), _M_expr2 (__e2), _M_func (__f) {}
+
+ value_type operator[] (size_t __i) const
+ { return _M_func (_M_expr1[__i], _M_expr2[__i]); }
+ size_t size () const { return _M_expr1.size (); }
+
+private:
+ const _Dom1& _M_expr1;
+ const _Dom2& _M_expr2;
+ _Vt (*_M_func)(_Vt, _Vt);
+};
+
+template<class _Dom> class _BinFunBase1 {
+public:
+ typedef typename _Dom::value_type value_type ;
+ typedef value_type _Vt;
+
+ _BinFunBase1 (const _Vt& __c, const _Dom& __e, _Vt __f(_Vt, _Vt))
+ : _M_expr1 (__c), _M_expr2 (__e), _M_func (__f) {}
+
+ value_type operator[] (size_t __i) const
+ { return _M_func (_M_expr1, _M_expr2[__i]); }
+ size_t size () const { return _M_expr2.size (); }
+
+private:
+ const _Vt& _M_expr1;
+ const _Dom& _M_expr2;
+ _Vt (*_M_func)(_Vt, _Vt);
+};
+
+template<class _Dom> class _BinFunBase2 {
+public:
+ typedef typename _Dom::value_type value_type;
+ typedef value_type _Vt;
+
+ _BinFunBase2 (const _Dom& __e, const _Vt& __c, _Vt __f(_Vt, _Vt))
+ : _M_expr1 (__e), _M_expr2 (__c), _M_func (__f) {}
+
+ value_type operator[] (size_t __i) const
+ { return _M_func (_M_expr1[__i], _M_expr2); }
+ size_t size () const { return _M_expr1.size (); }
+
+private:
+ const _Dom& _M_expr1;
+ const _Vt& _M_expr2;
+ _Vt (*_M_func)(_Vt, _Vt);
+};
+
+template<class _Dom1, class _Dom2>
+struct _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> : _BinFunBase<_Dom1,_Dom2> {
+ typedef _BinFunBase<_Dom1,_Dom2> _Base;
+ typedef typename _Base::value_type value_type;
+ typedef value_type _Tp;
+
+ _BinFunClos (const _Dom1& __e1, const _Dom2& __e2,
+ _Tp __f(_Tp, _Tp))
+ : _Base (__e1, __e2, __f) {}
+};
+
+template<typename _Tp>
+struct _BinFunClos<_ValArray,_ValArray,_Tp,_Tp>
+ : _BinFunBase<valarray<_Tp>, valarray<_Tp> > {
+ typedef _BinFunBase<valarray<_Tp>, valarray<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _BinFunClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w,
+ _Tp __f(_Tp, _Tp))
+ : _Base (__v, __w, __f) {}
+};
+
+template<class _Dom>
+struct _BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>
+ : _BinFunBase<_Dom,valarray<typename _Dom::value_type> > {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _BinFunClos (const _Dom& __e, const valarray<_Tp>& __v,
+ _Tp __f(_Tp, _Tp))
+ : _Base (__e, __v, __f) {}
+};
+
+template<class _Dom>
+struct _BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>
+ : _BinFunBase<valarray<typename _Dom::value_type>,_Dom> {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _BinFunClos (const valarray<_Tp>& __v, const _Dom& __e,
+ _Tp __f(_Tp, _Tp))
+ : _Base (__v, __e, __f) {}
+};
+
+template<class _Dom>
+struct _BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>
+ : _BinFunBase2<_Dom> {
+ typedef typename _Dom::value_type _Tp;
+ typedef _Tp value_type;
+ typedef _BinFunBase2<_Dom> _Base;
+
+ _BinFunClos (const _Dom& __e, const _Tp& __t, _Tp __f (_Tp, _Tp))
+ : _Base (__e, __t, __f) {}
+};
+
+template<class _Dom>
+struct _BinFunClos<_Constant,_Expr,_Dom,typename _Dom::value_type>
+ : _BinFunBase1<_Dom> {
+ typedef typename _Dom::value_type _Tp;
+ typedef _Tp value_type;
+ typedef _BinFunBase1<_Dom> _Base;
+
+ _BinFunClos (const _Tp& __t, const _Dom& __e, _Tp __f (_Tp, _Tp))
+ : _Base (__t, __e, __f) {}
+};
+
+template<typename _Tp>
+struct _BinFunClos<_ValArray,_Constant,_Tp,_Tp>
+ : _BinFunBase2<valarray<_Tp> > {
+ typedef _BinFunBase2<valarray<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _BinFunClos (const valarray<_Tp>& __v, const _Tp& __t,
+ _Tp __f(_Tp, _Tp))
+ : _Base (__v, __t, __f) {}
+};
+
+template<typename _Tp>
+struct _BinFunClos<_Constant,_ValArray,_Tp,_Tp>
+ : _BinFunBase1<valarray<_Tp> > {
+ typedef _BinFunBase1<valarray<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _BinFunClos (const _Tp& __t, const valarray<_Tp>& __v,
+ _Tp __f (_Tp, _Tp))
+ : _Base (__t, __v, __f) {}
+};
+
+//
+// Apply function taking a value/const reference closure
+//
+
+template<typename _Dom, typename _Arg> class _FunBase {
+public:
+ typedef typename _Dom::value_type value_type;
+
+ _FunBase (const _Dom& __e, value_type __f(_Arg))
+ : _M_expr (__e), _M_func (__f) {}
+
+ value_type operator[] (size_t __i) const
+ { return _M_func (_M_expr[__i]); }
+ size_t size() const { return _M_expr.size ();}
+
+private:
+ const _Dom& _M_expr;
+ value_type (*_M_func)(_Arg);
+};
+
+template<class _Dom>
+struct _ValFunClos<_Expr,_Dom>
+ : _FunBase<_Dom, typename _Dom::value_type> {
+ typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
+ typedef typename _Base::value_type value_type;
+ typedef value_type _Tp;
+
+ _ValFunClos (const _Dom& __e, _Tp __f (_Tp)) : _Base (__e, __f) {}
+};
+
+template<typename _Tp>
+struct _ValFunClos<_ValArray,_Tp>
+ : _FunBase<valarray<_Tp>, _Tp> {
+ typedef _FunBase<valarray<_Tp>, _Tp> _Base;
+ typedef _Tp value_type;
+
+ _ValFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
+ : _Base (__v, __f) {}
+};
+
+template<class _Dom>
+struct _RefFunClos<_Expr,_Dom> :
+ _FunBase<_Dom, const typename _Dom::value_type&> {
+ typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
+ typedef typename _Base::value_type value_type;
+ typedef value_type _Tp;
+
+ _RefFunClos (const _Dom& __e, _Tp __f (const _Tp&))
+ : _Base (__e, __f) {}
+};
+
+template<typename _Tp>
+struct _RefFunClos<_ValArray,_Tp>
+ : _FunBase<valarray<_Tp>, const _Tp&> {
+ typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
+ typedef _Tp value_type;
+
+ _RefFunClos (const valarray<_Tp>& __v, _Tp __f(const _Tp&))
+ : _Base (__v, __f) {}
+};
+
+//
+// Unary expression closure.
+//
+
+template<template<class> class _Oper, typename _Arg>
+class _UnBase {
+public:
+ typedef _Oper<typename _Arg::value_type> _Op;
+ typedef typename _Op::result_type value_type;
+
+ _UnBase (const _Arg& __e) : _M_expr(__e) {}
+ value_type operator[] (size_t) const;
+ size_t size () const { return _M_expr.size (); }
+
+private:
+ const _Arg& _M_expr;
+};
+
+template<template<class> class _Oper, typename _Arg>
+inline typename _UnBase<_Oper, _Arg>::value_type
+_UnBase<_Oper, _Arg>::operator[] (size_t __i) const
+{ return _Op() (_M_expr[__i]); }
+
+template<template<class> class _Oper, class _Dom>
+struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom> {
+ typedef _Dom _Arg;
+ typedef _UnBase<_Oper, _Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _UnClos (const _Arg& __e) : _Base(__e) {}
+};
+
+template<template<class> class _Oper, typename _Tp>
+struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > {
+ typedef valarray<_Tp> _Arg;
+ typedef _UnBase<_Oper, valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _UnClos (const _Arg& __e) : _Base(__e) {}
+};
+
+
+//
+// Binary expression closure.
+//
+
+template<template<class> class _Oper, typename _FirstArg, typename _SecondArg>
+class _BinBase {
+public:
+ typedef _Oper<typename _FirstArg::value_type> _Op;
+ typedef typename _Op::result_type value_type;
+
+ _BinBase (const _FirstArg& __e1, const _SecondArg& __e2)
+ : _M_expr1 (__e1), _M_expr2 (__e2) {}
+ value_type operator[] (size_t) const;
+ size_t size () const { return _M_expr1.size (); }
+
+private:
+ const _FirstArg& _M_expr1;
+ const _SecondArg& _M_expr2;
+};
+
+template<template<class> class _Oper, typename _FirstArg, typename _SecondArg>
+inline typename _BinBase<_Oper,_FirstArg,_SecondArg>::value_type
+_BinBase<_Oper,_FirstArg,_SecondArg>::operator[] (size_t __i) const
+{ return _Op() (_M_expr1[__i], _M_expr2[__i]); }
+
+
+template<template<class> class _Oper, class _Clos>
+class _BinBase2 {
+public:
+ typedef typename _Clos::value_type _Vt;
+ typedef _Oper<_Vt> _Op;
+ typedef typename _Op::result_type value_type;
+
+ _BinBase2 (const _Clos& __e, const _Vt& __t)
+ : _M_expr1 (__e), _M_expr2 (__t) {}
+ value_type operator[] (size_t) const;
+ size_t size () const { return _M_expr1.size (); }
+
+private:
+ const _Clos& _M_expr1;
+ const _Vt& _M_expr2;
+};
+
+template<template<class> class _Oper, class _Clos>
+inline typename _BinBase2<_Oper,_Clos>::value_type
+_BinBase2<_Oper,_Clos>::operator[] (size_t __i) const
+{ return _Op() (_M_expr1[__i], _M_expr2); }
+
+
+template<template<class> class _Oper, class _Clos>
+class _BinBase1 {
+public:
+ typedef typename _Clos::value_type _Vt;
+ typedef _Oper<_Vt> _Op;
+ typedef typename _Op::result_type value_type;
+
+ _BinBase1 (const _Vt& __t, const _Clos& __e)
+ : _M_expr1 (__t), _M_expr2 (__e) {}
+ value_type operator[] (size_t) const;
+ size_t size () const { return _M_expr2.size (); }
+
+private:
+ const _Vt& _M_expr1;
+ const _Clos& _M_expr2;
+};
+
+template<template<class> class _Oper, class _Clos>
+inline typename
+_BinBase1<_Oper,_Clos>::value_type
+_BinBase1<_Oper,_Clos>:: operator[] (size_t __i) const
+{ return _Op() (_M_expr1, _M_expr2[__i]); }
+
+
+template<template<class> class _Oper, class _Dom1, class _Dom2>
+struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
+ : _BinBase<_Oper,_Dom1,_Dom2> {
+ typedef _BinBase<_Oper,_Dom1,_Dom2> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
+};
+
+template<template<class> class _Oper, typename _Tp>
+struct _BinClos<_Oper,_ValArray,_ValArray,_Tp,_Tp>
+ : _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > {
+ typedef _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _BinClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w)
+ : _Base (__v, __w) {}
+};
+
+template<template<class> class _Oper, class _Dom>
+struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type>
+ : _BinBase<_Oper,_Dom,valarray<typename _Dom::value_type> > {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
+ : _Base (__e1, __e2) {}
+};
+
+template<template<class> class _Oper, class _Dom>
+struct _BinClos<_Oper,_ValArray,_Expr,typename _Dom::value_type,_Dom>
+ : _BinBase<_Oper,valarray<typename _Dom::value_type>,_Dom> {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase<_Oper,valarray<_Tp>,_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos (const valarray<_Tp>& __e1, const _Dom& __e2)
+ : _Base (__e1, __e2) {}
+};
+
+template<template<class> class _Oper, class _Dom>
+struct _BinClos<_Oper,_Expr,_Constant,_Dom,typename _Dom::value_type>
+ : _BinBase2<_Oper,_Dom> {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase2<_Oper,_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos (const _Dom& __e1, const _Tp& __e2) : _Base (__e1, __e2) {}
+};
+
+template<template<class> class _Oper, class _Dom>
+struct _BinClos<_Oper,_Constant,_Expr,typename _Dom::value_type,_Dom>
+ : _BinBase1<_Oper,_Dom> {
+ typedef typename _Dom::value_type _Tp;
+ typedef _BinBase1<_Oper,_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos (const _Tp& __e1, const _Dom& __e2) : _Base (__e1, __e2) {}
+};
+
+template<template<class> class _Oper, typename _Tp>
+struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp>
+ : _BinBase2<_Oper,valarray<_Tp> > {
+ typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos (const valarray<_Tp>& __v, const _Tp& __t)
+ : _Base (__v, __t) {}
+};
+
+template<template<class> class _Oper, typename _Tp>
+struct _BinClos<_Oper,_Constant,_ValArray,_Tp,_Tp>
+ : _BinBase1<_Oper,valarray<_Tp> > {
+ typedef _BinBase1<_Oper,valarray<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _BinClos (const _Tp& __t, const valarray<_Tp>& __v)
+ : _Base (__t, __v) {}
+};
+
+
+//
+// slice_array closure.
+//
+template<typename _Dom> class _SBase {
+public:
+ typedef typename _Dom::value_type value_type;
+
+ _SBase (const _Dom& __e, const slice& __s)
+ : _M_expr (__e), _M_slice (__s) {}
+ value_type operator[] (size_t __i) const
+ { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; }
+ size_t size() const { return _M_slice.size (); }
+
+private:
+ const _Dom& _M_expr;
+ const slice& _M_slice;
+};
+
+template<typename _Tp> class _SBase<_Array<_Tp> > {
+public:
+ typedef _Tp value_type;
+
+ _SBase (_Array<_Tp> __a, const slice& __s)
+ : _M_array (__a._M_data+__s.start()), _M_size (__s.size()),
+ _M_stride (__s.stride()) {}
+ value_type operator[] (size_t __i) const
+ { return _M_array._M_data[__i * _M_stride]; }
+ size_t size() const { return _M_size; }
+
+private:
+ const _Array<_Tp> _M_array;
+ const size_t _M_size;
+ const size_t _M_stride;
+};
+
+template<class _Dom> struct _SClos<_Expr,_Dom> : _SBase<_Dom> {
+ typedef _SBase<_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {}
+};
+
+template<typename _Tp>
+struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > {
+ typedef _SBase<_Array<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {}
+};
+
+//
+// gslice_array closure.
+//
+template<class _Dom> class _GBase {
+public:
+ typedef typename _Dom::value_type value_type;
+
+ _GBase (const _Dom& __e, const valarray<size_t>& __i)
+ : _M_expr (__e), _M_index(__i) {}
+ value_type operator[] (size_t __i) const
+ { return _M_expr[_M_index[__i]]; }
+ size_t size () const { return _M_index.size(); }
+
+private:
+ const _Dom& _M_expr;
+ const valarray<size_t>& _M_index;
+};
+
+template<typename _Tp> class _GBase<_Array<_Tp> > {
+public:
+ typedef _Tp value_type;
+
+ _GBase (_Array<_Tp> __a, const valarray<size_t>& __i)
+ : _M_array (__a), _M_index(__i) {}
+ value_type operator[] (size_t __i) const
+ { return _M_array._M_data[_M_index[__i]]; }
+ size_t size () const { return _M_index.size(); }
+
+private:
+ const _Array<_Tp> _M_array;
+ const valarray<size_t>& _M_index;
+};
+
+template<class _Dom> struct _GClos<_Expr,_Dom> : _GBase<_Dom> {
+ typedef _GBase<_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _GClos (const _Dom& __e, const valarray<size_t>& __i)
+ : _Base (__e, __i) {}
+};
+
+template<typename _Tp>
+struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > {
+ typedef _GBase<_Array<_Tp> > _Base;
+ typedef typename _Base::value_type value_type;
+
+ _GClos (_Array<_Tp> __a, const valarray<size_t>& __i)
+ : _Base (__a, __i) {}
+};
+
+//
+// indirect_array closure
+//
+
+template<class _Dom> class _IBase {
+public:
+ typedef typename _Dom::value_type value_type;
+
+ _IBase (const _Dom& __e, const valarray<size_t>& __i)
+ : _M_expr (__e), _M_index (__i) {}
+ value_type operator[] (size_t __i) const
+ { return _M_expr[_M_index[__i]]; }
+ size_t size() const { return _M_index.size(); }
+
+private:
+ const _Dom& _M_expr;
+ const valarray<size_t>& _M_index;
+};
+
+template<class _Dom> struct _IClos<_Expr,_Dom> : _IBase<_Dom> {
+ typedef _IBase<_Dom> _Base;
+ typedef typename _Base::value_type value_type;
+
+ _IClos (const _Dom& __e, const valarray<size_t>& __i)
+ : _Base (__e, __i) {}
+};
+
+template<typename _Tp>
+struct _IClos<_ValArray,_Tp> : _IBase<valarray<_Tp> > {
+ typedef _IBase<valarray<_Tp> > _Base;
+ typedef _Tp value_type;
+
+ _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i)
+ : _Base (__a, __i) {}
+};
+
+//
+// class _Expr
+//
+template<class _Clos, typename _Tp> class _Expr {
+public:
+ typedef _Tp value_type;
+
+ _Expr (const _Clos&);
+
+ const _Clos& operator() () const;
+
+ value_type operator[] (size_t) const;
+ valarray<value_type> operator[] (slice) const;
+ valarray<value_type> operator[] (const gslice&) const;
+ valarray<value_type> operator[] (const valarray<bool>&) const;
+ valarray<value_type> operator[] (const valarray<size_t>&) const;
+
+ _Expr<_UnClos<_Unary_plus,_Expr,_Clos>, value_type>
+ operator+ () const;
+
+ _Expr<_UnClos<negate,_Expr,_Clos>, value_type>
+ operator- () const;
+
+ _Expr<_UnClos<_Bitwise_not,_Expr,_Clos>, value_type>
+ operator~ () const;
+
+ _Expr<_UnClos<logical_not,_Expr,_Clos>, bool>
+ operator! () const;
+
+ size_t size () const;
+ value_type sum () const;
+
+ valarray<value_type> shift (int) const;
+ valarray<value_type> cshift (int) const;
+// _Meta<_ApplyFunctionWithValue<_Expr>, value_type>
+// apply (value_type _M_func (value_type)) const;
+// _Meta<_ApplyFunctionWithConstRef<_Expr>, value_type>
+// apply (value_type _M_func (const value_type&)) const;
+
+private:
+ const _Clos _M_closure;
+};
+
+template<class _Clos, typename _Tp>
+inline
+_Expr<_Clos,_Tp>::_Expr (const _Clos& __c) : _M_closure(__c) {}
+
+template<class _Clos, typename _Tp>
+inline const _Clos&
+_Expr<_Clos,_Tp>::operator() () const
+{ return _M_closure; }
+
+template<class _Clos, typename _Tp>
+inline _Tp
+_Expr<_Clos,_Tp>::operator[] (size_t __i) const
+{ return _M_closure[__i]; }
+
+template<class _Clos, typename _Tp>
+inline valarray<_Tp>
+_Expr<_Clos,_Tp>::operator[] (slice __s) const
+{ return _M_closure[__s]; }
+
+template<class _Clos, typename _Tp>
+inline valarray<_Tp>
+_Expr<_Clos,_Tp>::operator[] (const gslice& __gs) const
+{ return _M_closure[__gs]; }
+
+template<class _Clos, typename _Tp>
+inline valarray<_Tp>
+_Expr<_Clos,_Tp>::operator[] (const valarray<bool>& __m) const
+{ return _M_closure[__m]; }
+
+template<class _Clos, typename _Tp>
+inline valarray<_Tp>
+_Expr<_Clos,_Tp>::operator[] (const valarray<size_t>& __i) const
+{ return _M_closure[__i]; }
+
+template<class _Clos, typename _Tp>
+inline size_t
+_Expr<_Clos,_Tp>::size () const { return _M_closure.size (); }
+
+// XXX: replace this with a more robust summation algorithm.
+template<class _Clos, typename _Tp>
+inline _Tp
+_Expr<_Clos,_Tp>::sum () const
+{
+ _Tp __s(_Tp());
+ size_t __n (_M_closure.size ());
+ for (size_t __i=0; __i<__n; ++__i) __s += _M_closure[__i];
+ return __s;
+}
+
+template<class _Dom, typename _Tp>
+inline _Tp
+min (const _Expr<_Dom,_Tp>& __e)
+{
+ size_t __s (__e.size ());
+ _Tp __m (__e[0]);
+ for (size_t __i=1; __i<__s; ++__i)
+ if (__m > __e[__i]) __m = __e[__i];
+ return __m;
+}
+
+template<class _Dom, typename _Tp>
+inline _Tp
+max (const _Expr<_Dom,_Tp>& __e)
+{
+ size_t __s (__e.size());
+ _Tp __m (__e[0]);
+ for (size_t __i=1; __i<__s; ++__i)
+ if (__m < __e[__i]) __m = __e[__i];
+ return __m;
+}
+
+template<class _Dom, typename _Tp>
+inline _Expr<_UnClos<logical_not,_Expr,_Dom>, bool>
+_Expr<_Dom,_Tp>::operator! () const
+{
+ typedef _UnClos<logical_not,_Expr,_Dom> _Closure;
+ return _Expr<_Closure,_Tp> (_Closure(this->_M_closure));
+}
+
+#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
+template<class _Dom, typename _Tp> \
+inline _Expr<_UnClos<_Name,_Expr,_Dom>,_Tp> \
+_Expr<_Dom,_Tp>::operator##_Op () const \
+{ \
+ typedef _UnClos<_Name,_Expr,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp> (_Closure (this->_M_closure)); \
+}
+
+ _DEFINE_EXPR_UNARY_OPERATOR(+, _Unary_plus)
+ _DEFINE_EXPR_UNARY_OPERATOR(-, negate)
+ _DEFINE_EXPR_UNARY_OPERATOR(~, _Bitwise_not)
+
+#undef _DEFINE_EXPR_UNARY_OPERATOR
+
+
+#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \
+template<class _Dom1, class _Dom2> \
+inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \
+ typename _Name<typename _Dom1::value_type>::result_type> \
+operator##_Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
+ const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
+{ \
+ typedef typename _Dom1::value_type _Arg; \
+ typedef typename _Name<_Arg>::result_type _Value; \
+ typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
+ return _Expr<_Closure,_Value> (_Closure (__v (), __w ())); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
+ typename _Name<typename _Dom::value_type>::result_type> \
+operator##_Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
+ const typename _Dom::value_type& __t) \
+{ \
+ typedef typename _Dom::value_type _Arg; \
+ typedef typename _Name<_Arg>::result_type _Value; \
+ typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
+ return _Expr<_Closure,_Value> (_Closure (__v (), __t)); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
+ typename _Name<typename _Dom::value_type>::result_type> \
+operator##_Op (const typename _Dom::value_type& __t, \
+ const _Expr<_Dom,typename _Dom::value_type>& __v) \
+{ \
+ typedef typename _Dom::value_type _Arg; \
+ typedef typename _Name<_Arg>::result_type _Value; \
+ typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
+ return _Expr<_Closure,_Value> (_Closure (__t, __v ())); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
+ typename _Name<typename _Dom::value_type>::result_type> \
+operator##_Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
+ const valarray<typename _Dom::value_type>& __v) \
+{ \
+ typedef typename _Dom::value_type _Arg; \
+ typedef typename _Name<_Arg>::result_type _Value; \
+ typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \
+ return _Expr<_Closure,_Value> (_Closure (__e (), __v)); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
+ typename _Name<typename _Dom::value_type>::result_type> \
+operator##_Op (const valarray<typename _Dom::value_type>& __v, \
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef typename _Name<_Tp>::result_type _Value; \
+ typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
+ return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \
+}
+
+ _DEFINE_EXPR_BINARY_OPERATOR(+, plus)
+ _DEFINE_EXPR_BINARY_OPERATOR(-, minus)
+ _DEFINE_EXPR_BINARY_OPERATOR(*, multiplies)
+ _DEFINE_EXPR_BINARY_OPERATOR(/, divides)
+ _DEFINE_EXPR_BINARY_OPERATOR(%, modulus)
+ _DEFINE_EXPR_BINARY_OPERATOR(^, _Bitwise_xor)
+ _DEFINE_EXPR_BINARY_OPERATOR(&, _Bitwise_and)
+ _DEFINE_EXPR_BINARY_OPERATOR(|, _Bitwise_or)
+ _DEFINE_EXPR_BINARY_OPERATOR(<<, _Shift_left)
+ _DEFINE_EXPR_BINARY_OPERATOR(>>, _Shift_right)
+
+#undef _DEFINE_EXPR_BINARY_OPERATOR
+
+#define _DEFINE_EXPR_RELATIONAL_OPERATOR(_Op, _Name) \
+template<class _Dom1, class _Dom2> \
+inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, bool> \
+operator##_Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
+ const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
+{ \
+ typedef typename _Dom1::value_type _Arg; \
+ typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
+ return _Expr<_Closure,bool> (_Closure (__v (), __w ())); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
+ bool> \
+operator##_Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
+ const typename _Dom::value_type& __t) \
+{ \
+ typedef typename _Dom::value_type _Arg; \
+ typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
+ return _Expr<_Closure,bool> (_Closure (__v (), __t)); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
+ bool> \
+operator##_Op (const typename _Dom::value_type& __t, \
+ const _Expr<_Dom,typename _Dom::value_type>& __v) \
+{ \
+ typedef typename _Dom::value_type _Arg; \
+ typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
+ return _Expr<_Closure,bool> (_Closure (__t, __v ())); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
+ bool> \
+operator##_Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
+ const valarray<typename _Dom::value_type>& __v) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Tp> _Closure; \
+ return _Expr<_Closure,bool> (_Closure (__e (), __v)); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
+ bool> \
+operator##_Op (const valarray<typename _Dom::value_type>& __v, \
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
+ return _Expr<_Closure,bool> (_Closure (__v, __e ())); \
+}
+
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(&&, logical_and)
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(||, logical_or)
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(==, equal_to)
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(!=, not_equal_to)
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(<, less)
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(>, greater)
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(<=, less_equal)
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(>=, greater_equal)
+
+#undef _DEFINE_EXPR_RELATIONAL_OPERATOR
+
+
+
+#define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
+template<class _Dom> \
+inline _Expr<_UnFunClos<_Expr,_Dom>,typename _Dom::value_type> \
+_Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _UnFunClos<_Expr,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp>(_Closure(__e(), (_Tp(*)(_Tp))(&_Name))); \
+} \
+ \
+template<typename _Tp> \
+inline _Expr<_UnFunClos<_ValArray,_Tp>,_Tp> \
+_Name(const valarray<_Tp>& __v) \
+{ \
+ typedef _UnFunClos<_ValArray,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp> (_Closure (__v, (_Tp(*)(_Tp))(&_Name))); \
+}
+
+
+ _DEFINE_EXPR_UNARY_FUNCTION(abs)
+ _DEFINE_EXPR_UNARY_FUNCTION(cos)
+ _DEFINE_EXPR_UNARY_FUNCTION(acos)
+ _DEFINE_EXPR_UNARY_FUNCTION(cosh)
+ _DEFINE_EXPR_UNARY_FUNCTION(sin)
+ _DEFINE_EXPR_UNARY_FUNCTION(asin)
+ _DEFINE_EXPR_UNARY_FUNCTION(sinh)
+ _DEFINE_EXPR_UNARY_FUNCTION(tan)
+ _DEFINE_EXPR_UNARY_FUNCTION(tanh)
+ _DEFINE_EXPR_UNARY_FUNCTION(atan)
+ _DEFINE_EXPR_UNARY_FUNCTION(exp)
+ _DEFINE_EXPR_UNARY_FUNCTION(log)
+ _DEFINE_EXPR_UNARY_FUNCTION(log10)
+ _DEFINE_EXPR_UNARY_FUNCTION(sqrt)
+
+#undef _DEFINE_EXPR_UNARY_FUNCTION
+
+
+#define _DEFINE_EXPR_BINARY_FUNCTION(_Name) \
+template<class _Dom1, class _Dom2> \
+inline _Expr<_BinFunClos<_Expr,_Expr,_Dom1,_Dom2>,typename _Dom1::value_type>\
+_Name (const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \
+ const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \
+{ \
+ typedef typename _Dom1::value_type _Tp; \
+ typedef _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__e1 (), __e2 (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
+ typename _Dom::value_type> \
+_Name (const _Expr<_Dom,typename _Dom::value_type>& __e, \
+ const valarray<typename _Dom::value_type>& __v) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinFunClos<_Expr,_ValArray,_Dom,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__e (), __v, (_Tp(*)(_Tp, _Tp))(&_Name))); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
+ typename _Dom::value_type> \
+_Name (const valarray<typename _Dom::valarray>& __v, \
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinFunClos<_ValArray,_Expr,_Tp,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__v, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>, \
+ typename _Dom::value_type> \
+_Name (const _Expr<_Dom, typename _Dom::value_type>& __e, \
+ const typename _Dom::value_type& __t) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinFunClos<_Expr,_Constant,_Dom,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__e (), __t, (_Tp(*)(_Tp, _Tp))(&_Name))); \
+} \
+ \
+template<class _Dom> \
+inline _Expr<_BinFunClos<_Constant,_Expr,typename _Dom::value_type,_Dom>, \
+ typename _Dom::value_type> \
+_Name (const typename _Dom::value_type& __t, \
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
+{ \
+ typedef typename _Dom::value_type _Tp; \
+ typedef _BinFunClos<_Constant,_Expr,_Tp,_Dom> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__t, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
+} \
+ \
+template<typename _Tp> \
+inline _Expr<_BinFunClos<_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
+_Name (const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
+{ \
+ typedef _BinFunClos<_ValArray,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__v, __w, (_Tp(*)(_Tp,_Tp))(&_Name))); \
+} \
+ \
+template<typename _Tp> \
+inline _Expr<_BinFunClos<_ValArray,_Constant,_Tp,_Tp>,_Tp> \
+_Name (const valarray<_Tp>& __v, const _Tp& __t) \
+{ \
+ typedef _BinFunClos<_ValArray,_Constant,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__v, __t, (_Tp(*)(_Tp,_Tp))(&_Name))); \
+} \
+ \
+template<typename _Tp> \
+inline _Expr<_BinFunClos<_Constant,_ValArray,_Tp,_Tp>,_Tp> \
+_Name (const _Tp& __t, const valarray<_Tp>& __v) \
+{ \
+ typedef _BinFunClos<_Constant,_ValArray,_Tp,_Tp> _Closure; \
+ return _Expr<_Closure,_Tp> \
+ (_Closure (__t, __v, (_Tp(*)(_Tp,_Tp))(&_Name))); \
+}
+
+_DEFINE_EXPR_BINARY_FUNCTION(atan2)
+_DEFINE_EXPR_BINARY_FUNCTION(pow)
+
+#undef _DEFINE_EXPR_BINARY_FUNCTION
+
+#endif // _CPP_VALARRAY_META_H
+
+// Local Variables:
+// mode:c++
+// End:
diff --git a/libstdc++/stdexcepti.cc b/libstdc++/stdexcepti.cc
index 3b03acd63f4..9c02c71f497 100644
--- a/libstdc++/stdexcepti.cc
+++ b/libstdc++/stdexcepti.cc
@@ -12,10 +12,10 @@
void
__out_of_range (const char *s)
{
- throw out_of_range (s);
+ throw std::out_of_range (s);
}
void __length_error (const char *s)
{
- throw length_error (s);
+ throw std::length_error (s);
}
diff --git a/libstdc++/stl/ChangeLog b/libstdc++/stl/ChangeLog
index f23f4fb1937..785fb587e82 100644
--- a/libstdc++/stl/ChangeLog
+++ b/libstdc++/stl/ChangeLog
@@ -1,3 +1,45 @@
+1999-11-06 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+
+ * bitset (class bitset): Declare reference as our friend.
+ * bitset: Include limits.h.
+
+Sun Oct 24 23:54:10 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.2 Released.
+
+Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.1 Released.
+
+Sun Aug 8 21:06:16 1999 Alexandre Oliva <oliva@dcc.unicamp.br>
+
+ * pthread_alloc: Solaris' ctype.h defines _U to 01; use _Up as
+ template parameter instead.
+
+Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+1999-07-11 Martin v. Löwis (loewis@informatik.hu-berlin.de)
+
+ * stl_function.h (bind1st, bind2nd): Rename __opr to __oper,
+ as __opr is used internally by egcs.
+ * stl_numeric.h (__power, power): Likewise.
+
+1999-06-18 Martin von Löwis <loewis@informatik.hu-berlin.de>
+
+ * stl_queue.h: Rename _M_c to c, and _M_comp to comp.
+
+1999-06-17 Alexandre Oliva <oliva@dcc.unicamp.br>
+
+ * stl_algo.h (transform): Rename __opr to __oper, as __opr is used
+ internally by egcs.
+ Reported by Harri Porten <porten@tu-harburg.de>
+
1999-05-17 Mark Kettenis <kettenis@gnu.org>
* stl_config.h: Only define __STL_PTHREADS with GLIBC >= 2 for
diff --git a/libstdc++/stl/bitset b/libstdc++/stl/bitset
index e26845ed045..8b4f8b1a0f8 100644
--- a/libstdc++/stl/bitset
+++ b/libstdc++/stl/bitset
@@ -36,6 +36,7 @@
#include <stddef.h> // for size_t
+#include <limits.h> // for CHAR_BIT
#include <string>
#include <stdexcept> // for invalid_argument, out_of_range, overflow_error
#include <iostream.h> // for istream, ostream
@@ -568,6 +569,8 @@ private:
public:
// bit reference:
+ class reference;
+ friend class reference;
class reference {
friend class bitset;
diff --git a/libstdc++/stl/pthread_alloc b/libstdc++/stl/pthread_alloc
index 887d8e8a154..1852908095b 100644
--- a/libstdc++/stl/pthread_alloc
+++ b/libstdc++/stl/pthread_alloc
@@ -376,13 +376,13 @@ public:
typedef const _Tp& const_reference;
typedef _Tp value_type;
- template <class _U> struct rebind {
- typedef pthread_allocator<_U> other;
+ template <class _Up> struct rebind {
+ typedef pthread_allocator<_Up> other;
};
pthread_allocator() __STL_NOTHROW {}
pthread_allocator(const pthread_allocator& a) __STL_NOTHROW {}
- template <class _U> pthread_allocator(const pthread_allocator<_U>&)
+ template <class _Up> pthread_allocator(const pthread_allocator<_Up>&)
__STL_NOTHROW {}
~pthread_allocator() __STL_NOTHROW {}
@@ -416,8 +416,8 @@ public:
typedef const void* const_pointer;
typedef void value_type;
- template <class _U> struct rebind {
- typedef pthread_allocator<_U> other;
+ template <class _Up> struct rebind {
+ typedef pthread_allocator<_Up> other;
};
};
@@ -451,16 +451,16 @@ struct _Alloc_traits<_Tp, _Pthread_alloc_template<_Max_size> >
allocator_type;
};
-template <class _Tp, class _U, size_t _Max>
-struct _Alloc_traits<_Tp, __allocator<_U, _Pthread_alloc_template<_Max> > >
+template <class _Tp, class _Up, size_t _Max>
+struct _Alloc_traits<_Tp, __allocator<_Up, _Pthread_alloc_template<_Max> > >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, _Pthread_alloc_template<_Max> > _Alloc_type;
typedef __allocator<_Tp, _Pthread_alloc_template<_Max> > allocator_type;
};
-template <class _Tp, class _U>
-struct _Alloc_traits<_Tp, pthread_allocator<_U> >
+template <class _Tp, class _Up>
+struct _Alloc_traits<_Tp, pthread_allocator<_Up> >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, _Pthread_alloc_template<> > _Alloc_type;
diff --git a/libstdc++/stl/stl_algo.h b/libstdc++/stl/stl_algo.h
index 57607ba5d49..e9beaee15f1 100644
--- a/libstdc++/stl/stl_algo.h
+++ b/libstdc++/stl/stl_algo.h
@@ -446,9 +446,9 @@ _ForwardIter2 swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1,
template <class _InputIter, class _OutputIter, class _UnaryOperation>
_OutputIter transform(_InputIter __first, _InputIter __last,
- _OutputIter __result, _UnaryOperation __opr) {
+ _OutputIter __result, _UnaryOperation __oper) {
for ( ; __first != __last; ++__first, ++__result)
- *__result = __opr(*__first);
+ *__result = __oper(*__first);
return __result;
}
diff --git a/libstdc++/stl/stl_deque.h b/libstdc++/stl/stl_deque.h
index 48a4c76d55a..24a8bfb1bc8 100644
--- a/libstdc++/stl/stl_deque.h
+++ b/libstdc++/stl/stl_deque.h
@@ -342,7 +342,7 @@ public:
_Base;
typedef typename _Base::allocator_type allocator_type;
typedef _Deque_iterator<_Tp,_Tp&,_Tp*,__bufsiz> iterator;
- typedef _Deque_iterator<_Tp,const _Tp&,const _Tp&, __bufsiz> const_iterator;
+ typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*, __bufsiz> const_iterator;
_Deque_base(const allocator_type& __a, size_t __num_elements)
: _Base(__a), _M_start(), _M_finish()
@@ -815,7 +815,7 @@ public: // Erase
iterator __next = __pos;
++__next;
difference_type __index = __pos - _M_start;
- if (__index < (size() >> 1)) {
+ if (static_cast<size_type>(__index) < (size() >> 1)) {
copy_backward(_M_start, __pos, __next);
pop_front();
}
@@ -1048,7 +1048,7 @@ deque<_Tp,_Alloc,__bufsize>::erase(iterator __first, iterator __last)
else {
difference_type __n = __last - __first;
difference_type __elems_before = __first - _M_start;
- if (__elems_before < (size() - __n) / 2) {
+ if (static_cast<size_type>(__elems_before) < (size() - __n) / 2) {
copy_backward(_M_start, __first, __last);
iterator __new_start = _M_start + __n;
destroy(_M_start, __new_start);
@@ -1282,7 +1282,7 @@ deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos,
{
difference_type __index = __pos - _M_start;
value_type __x_copy = __x;
- if (__index < size() / 2) {
+ if (static_cast<size_type>(__index) < size() / 2) {
push_front(front());
iterator __front1 = _M_start;
++__front1;
@@ -1311,7 +1311,7 @@ typename deque<_Tp,_Alloc,__bufsize>::iterator
deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos)
{
difference_type __index = __pos - _M_start;
- if (__index < size() / 2) {
+ if (static_cast<size_type>(__index) < size() / 2) {
push_front(front());
iterator __front1 = _M_start;
++__front1;
@@ -1344,7 +1344,7 @@ deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos,
const difference_type __elems_before = __pos - _M_start;
size_type __length = size();
value_type __x_copy = __x;
- if (__elems_before < __length / 2) {
+ if (static_cast<size_type>(__elems_before) < __length / 2) {
iterator __new_start = _M_reserve_elements_at_front(__n);
iterator __old_start = _M_start;
__pos = _M_start + __elems_before;
@@ -1403,7 +1403,7 @@ deque<_Tp,_Alloc,__bufsize>::_M_insert_aux(iterator __pos,
{
const difference_type __elemsbefore = __pos - _M_start;
size_type __length = size();
- if (__elemsbefore < __length / 2) {
+ if (static_cast<size_type>(__elemsbefore) < __length / 2) {
iterator __new_start = _M_reserve_elements_at_front(__n);
iterator __old_start = _M_start;
__pos = _M_start + __elemsbefore;
diff --git a/libstdc++/stl/stl_function.h b/libstdc++/stl/stl_function.h
index cd07c1c6730..a5a8486576e 100644
--- a/libstdc++/stl/stl_function.h
+++ b/libstdc++/stl/stl_function.h
@@ -202,10 +202,10 @@ public:
template <class _Operation, class _Tp>
inline binder1st<_Operation>
-bind1st(const _Operation& __opr, const _Tp& __x)
+bind1st(const _Operation& __oper, const _Tp& __x)
{
typedef typename _Operation::first_argument_type _Arg1_type;
- return binder1st<_Operation>(__opr, _Arg1_type(__x));
+ return binder1st<_Operation>(__oper, _Arg1_type(__x));
}
template <class _Operation>
@@ -227,10 +227,10 @@ public:
template <class _Operation, class _Tp>
inline binder2nd<_Operation>
-bind2nd(const _Operation& __opr, const _Tp& __x)
+bind2nd(const _Operation& __oper, const _Tp& __x)
{
typedef typename _Operation::second_argument_type _Arg2_type;
- return binder2nd<_Operation>(__opr, _Arg2_type(__x));
+ return binder2nd<_Operation>(__oper, _Arg2_type(__x));
}
// unary_compose and binary_compose (extensions, not part of the standard).
diff --git a/libstdc++/stl/stl_numeric.h b/libstdc++/stl/stl_numeric.h
index da7865498ca..392515a3d87 100644
--- a/libstdc++/stl/stl_numeric.h
+++ b/libstdc++/stl/stl_numeric.h
@@ -177,22 +177,22 @@ adjacent_difference(_InputIterator __first, _InputIterator __last,
template <class _Tp, class _Integer, class _MonoidOperation>
-_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr)
+_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __oper)
{
if (__n == 0)
- return identity_element(__opr);
+ return identity_element(__oper);
else {
while ((__n & 1) == 0) {
__n >>= 1;
- __x = __opr(__x, __x);
+ __x = __oper(__x, __x);
}
_Tp __result = __x;
__n >>= 1;
while (__n != 0) {
- __x = __opr(__x, __x);
+ __x = __oper(__x, __x);
if ((__n & 1) != 0)
- __result = __opr(__result, __x);
+ __result = __oper(__result, __x);
__n >>= 1;
}
return __result;
@@ -209,9 +209,9 @@ inline _Tp __power(_Tp __x, _Integer __n)
// not part of the C++ standard.
template <class _Tp, class _Integer, class _MonoidOperation>
-inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr)
+inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __oper)
{
- return __power(__x, __n, __opr);
+ return __power(__x, __n, __oper);
}
template <class _Tp, class _Integer>
diff --git a/libstdc++/stl/stl_queue.h b/libstdc++/stl/stl_queue.h
index 489cc4ac442..c1e2b698440 100644
--- a/libstdc++/stl/stl_queue.h
+++ b/libstdc++/stl/stl_queue.h
@@ -49,33 +49,33 @@ public:
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
protected:
- _Sequence _M_c;
+ _Sequence c;
public:
- queue() : _M_c() {}
- explicit queue(const _Sequence& __c) : _M_c(__c) {}
-
- bool empty() const { return _M_c.empty(); }
- size_type size() const { return _M_c.size(); }
- reference front() { return _M_c.front(); }
- const_reference front() const { return _M_c.front(); }
- reference back() { return _M_c.back(); }
- const_reference back() const { return _M_c.back(); }
- void push(const value_type& __x) { _M_c.push_back(__x); }
- void pop() { _M_c.pop_front(); }
+ queue() : c() {}
+ explicit queue(const _Sequence& __c) : c(__c) {}
+
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ reference front() { return c.front(); }
+ const_reference front() const { return c.front(); }
+ reference back() { return c.back(); }
+ const_reference back() const { return c.back(); }
+ void push(const value_type& __x) { c.push_back(__x); }
+ void pop() { c.pop_front(); }
};
template <class _Tp, class _Sequence>
bool
operator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{
- return __x._M_c == __y._M_c;
+ return __x.c == __y.c;
}
template <class _Tp, class _Sequence>
bool
operator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{
- return __x._M_c < __y._M_c;
+ return __x.c < __y.c;
}
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
@@ -125,69 +125,69 @@ public:
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
protected:
- _Sequence _M_c;
- _Compare _M_comp;
+ _Sequence c;
+ _Compare comp;
public:
- priority_queue() : _M_c() {}
- explicit priority_queue(const _Compare& __x) : _M_c(), _M_comp(__x) {}
+ priority_queue() : c() {}
+ explicit priority_queue(const _Compare& __x) : c(), comp(__x) {}
priority_queue(const _Compare& __x, const _Sequence& __s)
- : _M_c(__s), _M_comp(__x)
- { make_heap(_M_c.begin(), _M_c.end(), _M_comp); }
+ : c(__s), comp(__x)
+ { make_heap(c.begin(), c.end(), comp); }
#ifdef __STL_MEMBER_TEMPLATES
template <class _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last)
- : _M_c(__first, __last) { make_heap(_M_c.begin(), _M_c.end(), _M_comp); }
+ : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
template <class _InputIterator>
priority_queue(_InputIterator __first,
_InputIterator __last, const _Compare& __x)
- : _M_c(__first, __last), _M_comp(__x)
- { make_heap(_M_c.begin(), _M_c.end(), _M_comp); }
+ : c(__first, __last), comp(__x)
+ { make_heap(c.begin(), c.end(), comp); }
template <class _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x, const _Sequence& __s)
- : _M_c(__s), _M_comp(__x)
+ : c(__s), comp(__x)
{
- _M_c.insert(_M_c.end(), __first, __last);
- make_heap(_M_c.begin(), _M_c.end(), _M_comp);
+ c.insert(c.end(), __first, __last);
+ make_heap(c.begin(), c.end(), comp);
}
#else /* __STL_MEMBER_TEMPLATES */
priority_queue(const value_type* __first, const value_type* __last)
- : _M_c(__first, __last) { make_heap(_M_c.begin(), _M_c.end(), _M_comp); }
+ : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
priority_queue(const value_type* __first, const value_type* __last,
const _Compare& __x)
- : _M_c(__first, __last), _M_comp(__x)
- { make_heap(_M_c.begin(), _M_c.end(), _M_comp); }
+ : c(__first, __last), comp(__x)
+ { make_heap(c.begin(), c.end(), comp); }
priority_queue(const value_type* __first, const value_type* __last,
const _Compare& __x, const _Sequence& __c)
- : _M_c(__c), _M_comp(__x)
+ : c(__c), comp(__x)
{
- _M_c.insert(_M_c.end(), __first, __last);
- make_heap(_M_c.begin(), _M_c.end(), _M_comp);
+ c.insert(c.end(), __first, __last);
+ make_heap(c.begin(), c.end(), comp);
}
#endif /* __STL_MEMBER_TEMPLATES */
- bool empty() const { return _M_c.empty(); }
- size_type size() const { return _M_c.size(); }
- const_reference top() const { return _M_c.front(); }
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ const_reference top() const { return c.front(); }
void push(const value_type& __x) {
__STL_TRY {
- _M_c.push_back(__x);
- push_heap(_M_c.begin(), _M_c.end(), _M_comp);
+ c.push_back(__x);
+ push_heap(c.begin(), c.end(), comp);
}
- __STL_UNWIND(_M_c.clear());
+ __STL_UNWIND(c.clear());
}
void pop() {
__STL_TRY {
- pop_heap(_M_c.begin(), _M_c.end(), _M_comp);
- _M_c.pop_back();
+ pop_heap(c.begin(), c.end(), comp);
+ c.pop_back();
}
- __STL_UNWIND(_M_c.clear());
+ __STL_UNWIND(c.clear());
}
};
diff --git a/libstdc++/stl/stl_rope.h b/libstdc++/stl/stl_rope.h
index 44f51aed1ae..fa1e848c065 100644
--- a/libstdc++/stl/stl_rope.h
+++ b/libstdc++/stl/stl_rope.h
@@ -386,8 +386,8 @@ struct _Rope_RopeRep : public _Rope_rep_base<_CharT,_Alloc> {
typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type;
_Rope_RopeRep(_Tag __t, int __d, bool __b, size_t __size,
allocator_type __a)
- : _M_tag(__t), _M_depth(__d), _M_is_balanced(__b), _M_c_string(0),
- _Rope_rep_base<_CharT,_Alloc>(__size, __a)
+ : _Rope_rep_base<_CharT,_Alloc>(__size, __a),
+ _M_tag(__t), _M_depth(__d), _M_is_balanced(__b), _M_c_string(0)
{
# ifndef __GC
_M_refcount = 1;
@@ -562,8 +562,8 @@ struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> {
/* doesn't matter. */
typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type;
_Rope_RopeLeaf(__GC_CONST _CharT* __d, size_t __size, allocator_type __a)
- : _M_data(__d)
- , _Rope_RopeRep<_CharT,_Alloc>(_S_leaf, 0, true, __size, __a)
+ : _Rope_RopeRep<_CharT,_Alloc>(_S_leaf, 0, true, __size, __a),
+ _M_data(__d)
{
__stl_assert(__size > 0);
if (_S_is_basic_char_type((_CharT *)0)) {
@@ -593,10 +593,10 @@ struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT,_Alloc> {
_Rope_RopeConcatenation(_Rope_RopeRep<_CharT,_Alloc>* __l,
_Rope_RopeRep<_CharT,_Alloc>* __r,
allocator_type __a)
- : _M_left(__l), _M_right(__r)
- , _Rope_RopeRep<_CharT,_Alloc>(
+ : _Rope_RopeRep<_CharT,_Alloc>(
_S_concat, max(__l->_M_depth, __r->_M_depth) + 1, false,
- __l->_M_size + __r->_M_size, __a)
+ __l->_M_size + __r->_M_size, __a),
+ _M_left(__l), _M_right(__r)
{}
# ifndef __GC
~_Rope_RopeConcatenation() {
@@ -629,11 +629,12 @@ struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT,_Alloc> {
typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type;
_Rope_RopeFunction(char_producer<_CharT>* __f, size_t __size,
bool __d, allocator_type __a)
- : _M_fn(__f)
+ :_Rope_RopeRep<_CharT,_Alloc>(_S_function, 0, true, __size, __a),
+ _M_fn(__f)
# ifndef __GC
, _M_delete_when_done(__d)
# endif
- , _Rope_RopeRep<_CharT,_Alloc>(_S_function, 0, true, __size, __a) {
+ {
__stl_assert(__size > 0);
# ifdef __GC
if (__d) {
@@ -693,9 +694,8 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
typedef _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type;
_Rope_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s,
size_t __l, allocator_type __a)
- : _M_base(__b)
+ : _Rope_RopeFunction<_CharT,_Alloc>(this, __l, false, __a), _M_base(__b)
, _M_start(__s)
- , _Rope_RopeFunction<_CharT,_Alloc>(this, __l, false, __a)
{
__stl_assert(__l > 0);
__stl_assert(__s + __l <= __b->_M_size);
@@ -766,16 +766,16 @@ class _Rope_char_ref_proxy {
_My_rope* _M_root; // The whole rope.
public:
_Rope_char_ref_proxy(_My_rope* __r, size_t __p) :
- _M_pos(__p), _M_root(__r), _M_current_valid(false) {}
+ _M_pos(__p), _M_current_valid(false), _M_root(__r) {}
_Rope_char_ref_proxy(const _Rope_char_ref_proxy& __x) :
- _M_pos(__x._M_pos), _M_root(__x._M_root), _M_current_valid(false) {}
+ _M_pos(__x._M_pos), _M_current_valid(false), _M_root(__x._M_root) {}
// Don't preserve cache if the reference can outlive the
// expression. We claim that's not possible without calling
// a copy constructor or generating reference to a proxy
// reference. We declare the latter to have undefined semantics.
_Rope_char_ref_proxy(_My_rope* __r, size_t __p,
_CharT __c) :
- _M_pos(__p), _M_root(__r), _M_current(__c), _M_current_valid(true) {}
+ _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) {}
inline operator _CharT () const;
_Rope_char_ref_proxy& operator= (_CharT __c);
_Rope_char_ptr_proxy<_CharT,_Alloc> operator& () const;
diff --git a/libstdc++/tests/ChangeLog b/libstdc++/tests/ChangeLog
index 87ce0fc6c19..458f08ad484 100644
--- a/libstdc++/tests/ChangeLog
+++ b/libstdc++/tests/ChangeLog
@@ -1,3 +1,19 @@
+Sun Oct 24 23:54:10 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.2 Released.
+
+Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.1 Released.
+
+Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
1998-07-17 Jason Merrill <jason@yorick.cygnus.com>
* tmap.cc: Use less<int>.
diff --git a/libstdc++/testsuite/ChangeLog b/libstdc++/testsuite/ChangeLog
index 7b1a9f0c3c5..4e983e9b5ff 100644
--- a/libstdc++/testsuite/ChangeLog
+++ b/libstdc++/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+Sun Oct 24 23:54:10 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.2 Released.
+
+Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.1 Released.
+
+Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
Wed Nov 25 01:00:07 1998 Marc Espie <espie@quatramaran.ens.fr>
* Makefile.in (just-check): Ignore errors.
diff --git a/libstdc++/valarray b/libstdc++/valarray
new file mode 100644
index 00000000000..a938b6a6863
--- /dev/null
+++ b/libstdc++/valarray
@@ -0,0 +1,8 @@
+// Main header for -*- C++ -*- valarray classes.
+
+#ifndef __VALARRAY__
+#define __VALARRAY__
+
+#include <std/std_valarray.h>
+
+#endif
diff --git a/libstdc++/valarray.cc b/libstdc++/valarray.cc
new file mode 100644
index 00000000000..5e7fe0cf05f
--- /dev/null
+++ b/libstdc++/valarray.cc
@@ -0,0 +1,50 @@
+#include <std/std_valarray.h>
+
+// Some Explicit Instanciations.
+template class multiplies<size_t>;
+template size_t accumulate(size_t*, size_t*, size_t, multiplies<size_t>);
+
+template void
+ __valarray_fill(size_t* __restrict__, size_t, const size_t&);
+
+template void
+ __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__);
+
+template valarray<size_t>::valarray(size_t);
+template valarray<size_t>::~valarray();
+template valarray<size_t>::valarray(const valarray<size_t>&);
+template size_t valarray<size_t>::size() const;
+template size_t& valarray<size_t>::operator[](size_t);
+template size_t valarray<size_t>::product() const;
+
+
+void __gslice_to_index(size_t __o, const valarray<size_t>& __l,
+ const valarray<size_t>& __s,
+ valarray<size_t>& __i)
+{
+ const size_t __n = __l.size();
+ size_t* const __t = static_cast<size_t*>(alloca(__n*sizeof(size_t)));
+ __valarray_fill(__t, __n, size_t(0));
+ const size_t __z = __i.size();
+ __valarray_fill(&__i[0], __z, __o);
+ for (size_t __j=0; __j<__z; ++__j) {
+ for (size_t __k=0; __k<__n; ++__k)
+ __i[__j] += __s[__k]*__t[__k];
+ ++__t[__n-1];
+ for (size_t __k=__n-1; __k; --__k) {
+ if (__t[__k] >= __l[__k]) {
+ __t[__k] = 0;
+ ++__t[__k-1];
+ }
+ }
+ }
+}
+
+_Indexer::_Indexer(size_t __o, const valarray<size_t>& __l,
+ const valarray<size_t>& __s)
+ : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
+ _M_index(__l.size() ? __l.product() : 0)
+{ __gslice_to_index(__o, __l, __s, _M_index); }
+
+
+