diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-10-02 17:26:16 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-10-02 17:26:16 +0000 |
commit | 2cd8c0639276c4cb79b66741f8c064f25a40f942 (patch) | |
tree | dfd482af6f25c8ca1b9eaced75135363406f588d /libstdc++/std | |
parent | 14c3eb183ec7dc525722bba59f385ee114725614 (diff) | |
download | gcc-2cd8c0639276c4cb79b66741f8c064f25a40f942.tar.gz |
* std/bastring.h: Move exception stuff after definition of string.
Move typedef of string here.
* string: From here.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@15832 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++/std')
-rw-r--r-- | libstdc++/std/bastring.h | 63 |
1 files changed, 37 insertions, 26 deletions
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 <cstddef> #include <std/straits.h> -#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 - 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 <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>:: |