]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
stdexcepti.cc (__out_of_range): New fn.
authorJason Merrill <jason@yorick.cygnus.com>
Fri, 10 Oct 1997 06:56:56 +0000 (06:56 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 10 Oct 1997 06:56:56 +0000 (02:56 -0400)
* 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

libstdc++/ChangeLog
libstdc++/std/bastring.h
libstdc++/std/complext.cc
libstdc++/std/dcomplex.h
libstdc++/std/fcomplex.h
libstdc++/std/ldcomplex.h
libstdc++/stdexcepti.cc
libstdc++/string

index f58f3da2d596a10ca6a9af57fee03965ecdb1547..cb66cab1add3715a831b4804ea39dc7fda8e4b9c 100644 (file)
@@ -1,3 +1,17 @@
+Thu Oct  9 23:24:36 1997  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * stdexcepti.cc (__out_of_range): New fn.
+       (__length_error): New fn.
+
+       * std/bastring.h (OUTOFRANGE): Fix logic.  Use throwing functions.
+       (LENGTHERROR): Likewise.
+       Revert Oct 2 changes.
+       * string: Revert Oct 2 changes.
+
+Tue Oct  7 00:51:51 1997  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * std/{f,d,ld}complex.h: Replace guiding fns if not -ansi.
+
 Thu Oct  2 00:08:18 1997  Jason Merrill  <jason@yorick.cygnus.com>
 
        * std/bastring.h: Move exception stuff after definition of string.
index 629bb583f3d2ee705a2e81cdfb5d7ccf1c460f8e..9eae46fce49815ae2450310bcdb8ac4f9117c170 100644 (file)
@@ -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>::
index 60227f213299e6e3759ab7283153af9852d95d99..d50bf0871f6111bb2d67b5df39ea1260686fba8d 100644 (file)
@@ -236,7 +236,7 @@ pow (const complex<FLOAT>& xin, int y)
   if (y < 0)
     {
       y = -y;
-      x = FLOAT(1)/x;
+      x = 1/x;
     }
   for (;;)
     {
index 5bc329c9bc945b51b655ff136809ed3e2e0b4ace..5812d9fa7dfd0f3daa01dee6669df143fab55262 100644 (file)
@@ -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)
index 476c4b60d8037a8729e3f98ec6de793acb3c3a74..cd9af1a2e0ceb75d33c3c345951e0da1ecf8cd3b 100644 (file)
@@ -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++"
 
index dd5cfa3fc39b36aba590d3d5750cb49eeebf0218..bc91fa422bf7ee5a1d373346629af8b3c638df25 100644 (file)
@@ -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)
index 1ab8d8890439dd972f1bd156ecc71b05fdd5226a..3b03acd63f44c5a6b2e10129a4ca0444c4bbf92b 100644 (file)
@@ -6,3 +6,16 @@
 #endif
 
 #include <stdexcept>
+
+// Entry points for string.
+
+void
+__out_of_range (const char *s)
+{
+  throw out_of_range (s);
+}
+
+void __length_error (const char *s)
+{
+  throw length_error (s);
+}
index f18c1cfbddafb40058efb3dad40ee9f4eac040e1..fa6f1abaa70c1dcb7f22f14250d9ae5a8a554c02 100644 (file)
@@ -5,4 +5,9 @@
 
 #include <std/bastring.h>
 
+extern "C++" {
+typedef basic_string <char> string;
+// typedef basic_string <wchar_t> wstring;
+} // extern "C++"
+
 #endif