diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-10-10 06:56:56 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-10-10 06:56:56 +0000 |
commit | 2da4bc3b1904fc8d95a1113aaf081fc54e92b174 (patch) | |
tree | 47392e51a8359ac6c8decb14f03764f851f5a4aa /libstdc++ | |
parent | 776457ede59bb2ed70f69a51f96c40fd7771ddd8 (diff) | |
download | gcc-2da4bc3b1904fc8d95a1113aaf081fc54e92b174.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@15885 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++')
-rw-r--r-- | libstdc++/ChangeLog | 14 | ||||
-rw-r--r-- | libstdc++/std/bastring.h | 65 | ||||
-rw-r--r-- | libstdc++/std/complext.cc | 2 | ||||
-rw-r--r-- | libstdc++/std/dcomplex.h | 27 | ||||
-rw-r--r-- | libstdc++/std/fcomplex.h | 27 | ||||
-rw-r--r-- | libstdc++/std/ldcomplex.h | 27 | ||||
-rw-r--r-- | libstdc++/stdexcepti.cc | 13 | ||||
-rw-r--r-- | libstdc++/string | 5 |
8 files changed, 142 insertions, 38 deletions
diff --git a/libstdc++/ChangeLog b/libstdc++/ChangeLog index f58f3da2d59..cb66cab1add 100644 --- a/libstdc++/ChangeLog +++ b/libstdc++/ChangeLog @@ -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. diff --git a/libstdc++/std/bastring.h b/libstdc++/std/bastring.h index 629bb583f3d..9eae46fce49 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 60227f21329..d50bf0871f6 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 5bc329c9bc9..5812d9fa7df 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 476c4b60d80..cd9af1a2e0c 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 dd5cfa3fc39..bc91fa422bf 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) diff --git a/libstdc++/stdexcepti.cc b/libstdc++/stdexcepti.cc index 1ab8d889043..3b03acd63f4 100644 --- a/libstdc++/stdexcepti.cc +++ b/libstdc++/stdexcepti.cc @@ -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); +} diff --git a/libstdc++/string b/libstdc++/string index f18c1cfbdda..fa6f1abaa70 100644 --- a/libstdc++/string +++ b/libstdc++/string @@ -5,4 +5,9 @@ #include <std/bastring.h> +extern "C++" { +typedef basic_string <char> string; +// typedef basic_string <wchar_t> wstring; +} // extern "C++" + #endif |