aboutsummaryrefslogtreecommitdiff
path: root/libstdc++/std
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1997-10-10 06:56:56 +0000
committerJason Merrill <jason@gcc.gnu.org>1997-10-10 02:56:56 -0400
commitda8c445d07f00dc4f10f25d1cc891d4f3ff1523f (patch)
tree47392e51a8359ac6c8decb14f03764f851f5a4aa /libstdc++/std
parent5b76d03baac8a93708b2c8cb4ca30ea095fd8be0 (diff)
downloadgcc-da8c445d07f00dc4f10f25d1cc891d4f3ff1523f.zip
gcc-da8c445d07f00dc4f10f25d1cc891d4f3ff1523f.tar.gz
gcc-da8c445d07f00dc4f10f25d1cc891d4f3ff1523f.tar.bz2
stdexcepti.cc (__out_of_range): New fn.
* stdexcepti.cc (__out_of_range): New fn. (__length_error): New fn. * std/bastring.h (OUTOFRANGE): Fix logic. Use throwing functions. (LENGTHERROR): Likewise. Revert Oct 2 changes. * string: Revert Oct 2 changes. * std/{f,d,ld}complex.h: Replace guiding fns if not -ansi. From-SVN: r15885
Diffstat (limited to 'libstdc++/std')
-rw-r--r--libstdc++/std/bastring.h65
-rw-r--r--libstdc++/std/complext.cc2
-rw-r--r--libstdc++/std/dcomplex.h27
-rw-r--r--libstdc++/std/fcomplex.h27
-rw-r--r--libstdc++/std/ldcomplex.h27
5 files changed, 110 insertions, 38 deletions
diff --git a/libstdc++/std/bastring.h b/libstdc++/std/bastring.h
index 629bb58..9eae46f 100644
--- a/libstdc++/std/bastring.h
+++ b/libstdc++/std/bastring.h
@@ -40,6 +40,24 @@ class istream; class ostream;
#include <iterator>
+#ifdef __STL_USE_EXCEPTIONS
+
+extern void __out_of_range (const char *);
+extern void __length_error (const char *);
+
+#define OUTOFRANGE(cond) \
+ do { if (cond) __out_of_range (#cond); } while (0)
+#define LENGTHERROR(cond) \
+ do { if (cond) __length_error (#cond); } while (0)
+
+#else
+
+#include <cassert>
+#define OUTOFRANGE(cond) assert (!(cond))
+#define LENGTHERROR(cond) assert (!(cond))
+
+#endif
+
template <class charT, class traits = string_char_traits<charT> >
class basic_string
{
@@ -262,8 +280,16 @@ public:
reference operator[] (size_type pos)
{ unique (); return (*rep ())[pos]; }
- inline reference at (size_type pos);
- inline const_reference at (size_type pos) const;
+ reference at (size_type pos)
+ {
+ OUTOFRANGE (pos >= length ());
+ return (*this)[pos];
+ }
+ const_reference at (size_type pos) const
+ {
+ OUTOFRANGE (pos >= length ());
+ return data ()[pos];
+ }
private:
void terminate () const
@@ -359,41 +385,6 @@ private:
charT *dat;
};
-typedef basic_string <char> string;
-// typedef basic_string <wchar_t> wstring;
-
-#ifdef __STL_USE_EXCEPTIONS
-
-#include <stdexcept>
-#define OUTOFRANGE(cond) \
- do { if (!(cond)) throw out_of_range (#cond); } while (0)
-#define LENGTHERROR(cond) \
- do { if (!(cond)) throw length_error (#cond); } while (0)
-
-#else
-
-#include <cassert>
-#define OUTOFRANGE(cond) assert (!(cond))
-#define LENGTHERROR(cond) assert (!(cond))
-
-#endif
-
-template <class charT, class traits>
-inline basic_string <charT, traits>::reference
-basic_string <charT, traits>::at (size_type pos)
-{
- OUTOFRANGE (pos >= length ());
- return (*this)[pos];
-}
-
-template <class charT, class traits>
-inline basic_string <charT, traits>::const_reference
-basic_string <charT, traits>::at (size_type pos) const
-{
- OUTOFRANGE (pos >= length ());
- return data ()[pos];
-}
-
#ifdef __STL_MEMBER_TEMPLATES
template <class charT, class traits> template <class InputIterator>
basic_string <charT, traits>& basic_string <charT, traits>::
diff --git a/libstdc++/std/complext.cc b/libstdc++/std/complext.cc
index 60227f2..d50bf08 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 = FLOAT(1)/x;
+ x = 1/x;
}
for (;;)
{
diff --git a/libstdc++/std/dcomplex.h b/libstdc++/std/dcomplex.h
index 5bc329c..5812d9f 100644
--- a/libstdc++/std/dcomplex.h
+++ b/libstdc++/std/dcomplex.h
@@ -54,6 +54,33 @@ private:
friend complex& __doami<> (complex *, const complex&);
friend complex& __doaml<> (complex *, const complex&);
friend complex& __doadv<> (complex *, const complex&);
+
+#ifndef __STRICT_ANSI__
+ friend inline complex operator + (const complex& x, double y)
+ { return operator+<> (x, y); }
+ friend inline complex operator + (double x, const complex& y)
+ { return operator+<> (x, y); }
+ friend inline complex operator - (const complex& x, double y)
+ { return operator-<> (x, y); }
+ friend inline complex operator - (double x, const complex& y)
+ { return operator-<> (x, y); }
+ friend inline complex operator * (const complex& x, double y)
+ { return operator*<> (x, y); }
+ friend inline complex operator * (double x, const complex& y)
+ { return operator*<> (x, y); }
+ friend inline complex operator / (const complex& x, double y)
+ { return operator/<> (x, y); }
+ friend inline complex operator / (double x, const complex& y)
+ { return operator/<> (x, y); }
+ friend inline bool operator == (const complex& x, double y)
+ { return operator==<> (x, y); }
+ friend inline bool operator == (double x, const complex& y)
+ { return operator==<> (x, y); }
+ friend inline bool operator != (const complex& x, double y)
+ { return operator!=<> (x, y); }
+ friend inline bool operator != (double x, const complex& y)
+ { return operator!=<> (x, y); }
+#endif /* __STRICT_ANSI__ */
};
inline complex<float>::complex (const complex<double>& r)
diff --git a/libstdc++/std/fcomplex.h b/libstdc++/std/fcomplex.h
index 476c4b6..cd9af1a 100644
--- a/libstdc++/std/fcomplex.h
+++ b/libstdc++/std/fcomplex.h
@@ -54,6 +54,33 @@ private:
friend complex& __doami<> (complex *, const complex&);
friend complex& __doaml<> (complex *, const complex&);
friend complex& __doadv<> (complex *, const complex&);
+
+#ifndef __STRICT_ANSI__
+ friend inline complex operator + (const complex& x, float y)
+ { return operator+<> (x, y); }
+ friend inline complex operator + (float x, const complex& y)
+ { return operator+<> (x, y); }
+ friend inline complex operator - (const complex& x, float y)
+ { return operator-<> (x, y); }
+ friend inline complex operator - (float x, const complex& y)
+ { return operator-<> (x, y); }
+ friend inline complex operator * (const complex& x, float y)
+ { return operator*<> (x, y); }
+ friend inline complex operator * (float x, const complex& y)
+ { return operator*<> (x, y); }
+ friend inline complex operator / (const complex& x, float y)
+ { return operator/<> (x, y); }
+ friend inline complex operator / (float x, const complex& y)
+ { return operator/<> (x, y); }
+ friend inline bool operator == (const complex& x, float y)
+ { return operator==<> (x, y); }
+ friend inline bool operator == (float x, const complex& y)
+ { return operator==<> (x, y); }
+ friend inline bool operator != (const complex& x, float y)
+ { return operator!=<> (x, y); }
+ friend inline bool operator != (float x, const complex& y)
+ { return operator!=<> (x, y); }
+#endif /* __STRICT_ANSI__ */
};
} // extern "C++"
diff --git a/libstdc++/std/ldcomplex.h b/libstdc++/std/ldcomplex.h
index dd5cfa3..bc91fa4 100644
--- a/libstdc++/std/ldcomplex.h
+++ b/libstdc++/std/ldcomplex.h
@@ -54,6 +54,33 @@ private:
friend complex& __doami<> (complex *, const complex&);
friend complex& __doaml<> (complex *, const complex&);
friend complex& __doadv<> (complex *, const complex&);
+
+#ifndef __STRICT_ANSI__
+ friend inline complex operator + (const complex& x, long double y)
+ { return operator+<> (x, y); }
+ friend inline complex operator + (long double x, const complex& y)
+ { return operator+<> (x, y); }
+ friend inline complex operator - (const complex& x, long double y)
+ { return operator-<> (x, y); }
+ friend inline complex operator - (long double x, const complex& y)
+ { return operator-<> (x, y); }
+ friend inline complex operator * (const complex& x, long double y)
+ { return operator*<> (x, y); }
+ friend inline complex operator * (long double x, const complex& y)
+ { return operator*<> (x, y); }
+ friend inline complex operator / (const complex& x, long double y)
+ { return operator/<> (x, y); }
+ friend inline complex operator / (long double x, const complex& y)
+ { return operator/<> (x, y); }
+ friend inline bool operator == (const complex& x, long double y)
+ { return operator==<> (x, y); }
+ friend inline bool operator == (long double x, const complex& y)
+ { return operator==<> (x, y); }
+ friend inline bool operator != (const complex& x, long double y)
+ { return operator!=<> (x, y); }
+ friend inline bool operator != (long double x, const complex& y)
+ { return operator!=<> (x, y); }
+#endif /* __STRICT_ANSI__ */
};
inline complex<float>::complex (const complex<long double>& r)