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
This commit is contained in:
Jason Merrill 1997-10-10 06:56:56 +00:00 committed by Jason Merrill
parent 5b76d03baa
commit da8c445d07
8 changed files with 142 additions and 38 deletions

View 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.

View 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>::

View 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 (;;)
{

View 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)

View 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++"

View 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)

View 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);
}

View 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