From 00771b199146fd9c91dd36675ec402dba27cafb7 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 2 Oct 1997 17:26:16 +0000 Subject: * std/bastring.h: Move exception stuff after definition of string. Move typedef of string here. * string: From here. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@15832 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++/ChangeLog | 6 +++++ libstdc++/std/bastring.h | 63 ++++++++++++++++++++++++++++-------------------- libstdc++/string | 5 ---- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/libstdc++/ChangeLog b/libstdc++/ChangeLog index 94a3460f806..f58f3da2d59 100644 --- a/libstdc++/ChangeLog +++ b/libstdc++/ChangeLog @@ -1,3 +1,9 @@ +Thu Oct 2 00:08:18 1997 Jason Merrill + + * std/bastring.h: Move exception stuff after definition of string. + Move typedef of string here. + * string: From here. + Sat Sep 27 16:48:00 1997 Jason Merrill * std/complext.h: Lose injection decls. diff --git a/libstdc++/std/bastring.h b/libstdc++/std/bastring.h index ba763a901c6..629bb583f3d 100644 --- a/libstdc++/std/bastring.h +++ b/libstdc++/std/bastring.h @@ -35,22 +35,6 @@ #include #include -#ifdef __STL_USE_EXCEPTIONS - -#include -#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 -#define OUTOFRANGE(cond) assert (!(cond)) -#define LENGTHERROR(cond) assert (!(cond)) - -#endif - extern "C++" { class istream; class ostream; @@ -278,16 +262,8 @@ public: reference operator[] (size_type pos) { unique (); return (*rep ())[pos]; } - reference at (size_type pos) - { - OUTOFRANGE (pos >= length ()); - return (*this)[pos]; - } - const_reference at (size_type pos) const - { - OUTOFRANGE (pos >= length ()); - return data ()[pos]; - } + inline reference at (size_type pos); + inline const_reference at (size_type pos) const; private: void terminate () const @@ -383,6 +359,41 @@ private: charT *dat; }; +typedef basic_string string; +// typedef basic_string wstring; + +#ifdef __STL_USE_EXCEPTIONS + +#include +#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 +#define OUTOFRANGE(cond) assert (!(cond)) +#define LENGTHERROR(cond) assert (!(cond)) + +#endif + +template +inline basic_string ::reference +basic_string ::at (size_type pos) +{ + OUTOFRANGE (pos >= length ()); + return (*this)[pos]; +} + +template +inline basic_string ::const_reference +basic_string ::at (size_type pos) const +{ + OUTOFRANGE (pos >= length ()); + return data ()[pos]; +} + #ifdef __STL_MEMBER_TEMPLATES template template basic_string & basic_string :: diff --git a/libstdc++/string b/libstdc++/string index fa6f1abaa70..f18c1cfbdda 100644 --- a/libstdc++/string +++ b/libstdc++/string @@ -5,9 +5,4 @@ #include -extern "C++" { -typedef basic_string string; -// typedef basic_string wstring; -} // extern "C++" - #endif -- cgit v1.2.3