diff options
Diffstat (limited to 'gnu/egcs/libstdc++/std')
-rw-r--r-- | gnu/egcs/libstdc++/std/bastring.cc | 524 | ||||
-rw-r--r-- | gnu/egcs/libstdc++/std/bastring.h | 647 | ||||
-rw-r--r-- | gnu/egcs/libstdc++/std/complext.cc | 273 | ||||
-rw-r--r-- | gnu/egcs/libstdc++/std/complext.h | 400 | ||||
-rw-r--r-- | gnu/egcs/libstdc++/std/dcomplex.h | 91 | ||||
-rw-r--r-- | gnu/egcs/libstdc++/std/fcomplex.h | 87 | ||||
-rw-r--r-- | gnu/egcs/libstdc++/std/ldcomplex.h | 95 | ||||
-rw-r--r-- | gnu/egcs/libstdc++/std/straits.h | 161 |
8 files changed, 2278 insertions, 0 deletions
diff --git a/gnu/egcs/libstdc++/std/bastring.cc b/gnu/egcs/libstdc++/std/bastring.cc new file mode 100644 index 00000000000..3093b9e129d --- /dev/null +++ b/gnu/egcs/libstdc++/std/bastring.cc @@ -0,0 +1,524 @@ +// Member templates for the -*- C++ -*- string classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files +// compiled with a GNU compiler to produce an executable, this does not cause +// the resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. + +extern "C++" { +template <class charT, class traits, class Allocator> +inline void * basic_string <charT, traits, Allocator>::Rep:: +operator new (size_t s, size_t extra) +{ + return Allocator::allocate(s + extra * sizeof (charT)); +} + +template <class charT, class traits, class Allocator> +inline void basic_string <charT, traits, Allocator>::Rep:: +operator delete (void * ptr) +{ + Allocator::deallocate(ptr, sizeof(Rep) + + reinterpret_cast<Rep *>(ptr)->res * + sizeof (charT)); +} + +template <class charT, class traits, class Allocator> +inline size_t basic_string <charT, traits, Allocator>::Rep:: +frob_size (size_t s) +{ + size_t i = 16; + while (i < s) i *= 2; + return i; +} + +template <class charT, class traits, class Allocator> +inline basic_string <charT, traits, Allocator>::Rep * +basic_string <charT, traits, Allocator>::Rep:: +create (size_t extra) +{ + extra = frob_size (extra + 1); + Rep *p = new (extra) Rep; + p->res = extra; + p->ref = 1; + p->selfish = false; + return p; +} + +template <class charT, class traits, class Allocator> +charT * basic_string <charT, traits, Allocator>::Rep:: +clone () +{ + Rep *p = Rep::create (len); + p->copy (0, data (), len); + p->len = len; + return p->data (); +} + +template <class charT, class traits, class Allocator> +inline bool basic_string <charT, traits, Allocator>::Rep:: +excess_slop (size_t s, size_t r) +{ + return 2 * (s <= 16 ? 16 : s) < r; +} + +template <class charT, class traits, class Allocator> +inline bool basic_string <charT, traits, Allocator>:: +check_realloc (basic_string::size_type s) const +{ + s += sizeof (charT); + rep ()->selfish = false; + return (rep ()->ref > 1 + || s > capacity () + || Rep::excess_slop (s, capacity ())); +} + +template <class charT, class traits, class Allocator> +void basic_string <charT, traits, Allocator>:: +alloc (basic_string::size_type size, bool save) +{ + if (! check_realloc (size)) + return; + + Rep *p = Rep::create (size); + + if (save) + { + p->copy (0, data (), length ()); + p->len = length (); + } + else + p->len = 0; + + repup (p); +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>& +basic_string <charT, traits, Allocator>:: +replace (size_type pos1, size_type n1, + const basic_string& str, size_type pos2, size_type n2) +{ + const size_t len2 = str.length (); + + if (pos1 == 0 && n1 >= length () && pos2 == 0 && n2 >= len2) + return operator= (str); + + OUTOFRANGE (pos2 > len2); + + if (n2 > len2 - pos2) + n2 = len2 - pos2; + + return replace (pos1, n1, str.data () + pos2, n2); +} + +template <class charT, class traits, class Allocator> +inline void basic_string <charT, traits, Allocator>::Rep:: +copy (size_t pos, const charT *s, size_t n) +{ + if (n) + traits::copy (data () + pos, s, n); +} + +template <class charT, class traits, class Allocator> +inline void basic_string <charT, traits, Allocator>::Rep:: +move (size_t pos, const charT *s, size_t n) +{ + if (n) + traits::move (data () + pos, s, n); +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>& +basic_string <charT, traits, Allocator>:: +replace (size_type pos, size_type n1, const charT* s, size_type n2) +{ + const size_type len = length (); + OUTOFRANGE (pos > len); + if (n1 > len - pos) + n1 = len - pos; + LENGTHERROR (len - n1 > max_size () - n2); + size_t newlen = len - n1 + n2; + + if (check_realloc (newlen)) + { + Rep *p = Rep::create (newlen); + p->copy (0, data (), pos); + p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); + p->copy (pos, s, n2); + repup (p); + } + else + { + rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); + rep ()->copy (pos, s, n2); + } + rep ()->len = newlen; + + return *this; +} + +template <class charT, class traits, class Allocator> +inline void basic_string <charT, traits, Allocator>::Rep:: +set (size_t pos, const charT c, size_t n) +{ + traits::set (data () + pos, c, n); +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>:: +replace (size_type pos, size_type n1, size_type n2, charT c) +{ + const size_t len = length (); + OUTOFRANGE (pos > len); + if (n1 > len - pos) + n1 = len - pos; + LENGTHERROR (len - n1 > max_size () - n2); + size_t newlen = len - n1 + n2; + + if (check_realloc (newlen)) + { + Rep *p = Rep::create (newlen); + p->copy (0, data (), pos); + p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); + p->set (pos, c, n2); + repup (p); + } + else + { + rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); + rep ()->set (pos, c, n2); + } + rep ()->len = newlen; + + return *this; +} + +template <class charT, class traits, class Allocator> +void basic_string <charT, traits, Allocator>:: +resize (size_type n, charT c) +{ + LENGTHERROR (n > max_size ()); + + if (n > length ()) + append (n - length (), c); + else + erase (n); +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +copy (charT* s, size_type n, size_type pos) const +{ + OUTOFRANGE (pos > length ()); + + if (n > length () - pos) + n = length () - pos; + + traits::copy (s, data () + pos, n); + return n; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find (const charT* s, size_type pos, size_type n) const +{ + size_t xpos = pos; + for (; xpos + n <= length (); ++xpos) + if (traits::eq (data () [xpos], *s) + && traits::compare (data () + xpos, s, n) == 0) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +inline basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +_find (const charT* ptr, charT c, size_type xpos, size_type len) +{ + for (; xpos < len; ++xpos) + if (traits::eq (ptr [xpos], c)) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find (charT c, size_type pos) const +{ + return _find (data (), c, pos, length ()); +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +rfind (const charT* s, size_type pos, size_type n) const +{ + if (n > length ()) + return npos; + + size_t xpos = length () - n; + if (xpos > pos) + xpos = pos; + + for (++xpos; xpos-- > 0; ) + if (traits::eq (data () [xpos], *s) + && traits::compare (data () + xpos, s, n) == 0) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +rfind (charT c, size_type pos) const +{ + if (1 > length ()) + return npos; + + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + + for (++xpos; xpos-- > 0; ) + if (traits::eq (data () [xpos], c)) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find_first_of (const charT* s, size_type pos, size_type n) const +{ + size_t xpos = pos; + for (; xpos < length (); ++xpos) + if (_find (s, data () [xpos], 0, n) != npos) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find_last_of (const charT* s, size_type pos, size_type n) const +{ + if (length() == 0) + return npos; + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + for (++xpos; xpos-- > 0;) + if (_find (s, data () [xpos], 0, n) != npos) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find_first_not_of (const charT* s, size_type pos, size_type n) const +{ + size_t xpos = pos; + for (; xpos < length (); ++xpos) + if (_find (s, data () [xpos], 0, n) == npos) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find_first_not_of (charT c, size_type pos) const +{ + size_t xpos = pos; + for (; xpos < length (); ++xpos) + if (traits::ne (data () [xpos], c)) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find_last_not_of (const charT* s, size_type pos, size_type n) const +{ + if (length() == 0) + return npos; + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + for (++xpos; xpos-- > 0;) + if (_find (s, data () [xpos], 0, n) == npos) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>:: +find_last_not_of (charT c, size_type pos) const +{ + if (length() == 0) + return npos; + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + for (++xpos; xpos-- > 0;) + if (traits::ne (data () [xpos], c)) + return xpos; + return npos; +} + +template <class charT, class traits, class Allocator> +int basic_string <charT, traits, Allocator>:: +compare (const basic_string& str, size_type pos, size_type n) const +{ + OUTOFRANGE (pos > length ()); + + size_t rlen = length () - pos; + if (rlen > n) + rlen = n; + if (rlen > str.length ()) + rlen = str.length (); + int r = traits::compare (data () + pos, str.data (), rlen); + if (r != 0) + return r; + if (rlen == n) + return 0; + return (length () - pos) - str.length (); +} + +template <class charT, class traits, class Allocator> +int basic_string <charT, traits, Allocator>:: +compare (const charT* s, size_type pos, size_type n) const +{ + OUTOFRANGE (pos > length ()); + + size_t rlen = length () - pos; + if (rlen > n) + rlen = n; + int r = traits::compare (data () + pos, s, rlen); + if (r != 0) + return r; + return (length () - pos) - n; +} + +#include <iostream.h> + +template <class charT, class traits, class Allocator> +istream & +operator>> (istream &is, basic_string <charT, traits, Allocator> &s) +{ + int w = is.width (0); + if (is.ipfx0 ()) + { + register streambuf *sb = is.rdbuf (); + s.resize (0); + while (1) + { + int ch = sb->sbumpc (); + if (ch == EOF) + { + is.setstate (ios::eofbit); + break; + } + else if (traits::is_del (ch)) + { + sb->sungetc (); + break; + } + s += static_cast<charT> (ch); + if (--w == 1) + break; + } + } + + is.isfx (); + if (s.length () == 0) + is.setstate (ios::failbit); + + return is; +} + +template <class charT, class traits, class Allocator> +ostream & +operator<< (ostream &o, const basic_string <charT, traits, Allocator>& s) +{ + return o.write (s.data (), s.length ()); +} + +template <class charT, class traits, class Allocator> +istream& +getline (istream &is, basic_string <charT, traits, Allocator>& s, charT delim) +{ + if (is.ipfx1 ()) + { + _IO_size_t count = 0; + streambuf *sb = is.rdbuf (); + s.resize (0); + + while (1) + { + int ch = sb->sbumpc (); + if (ch == EOF) + { + is.setstate (count == 0 + ? (ios::failbit|ios::eofbit) + : ios::eofbit); + break; + } + + ++count; + + if (ch == delim) + break; + + s += static_cast<charT> (ch); + + if (s.length () == s.npos - 1) + { + is.setstate (ios::failbit); + break; + } + } + } + + // We need to be friends with istream to do this. + // is._gcount = count; + is.isfx (); + + return is; +} + +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>::Rep +basic_string<charT, traits, Allocator>::nilRep = { 0, 0, 1, false }; + +template <class charT, class traits, class Allocator> +const basic_string <charT, traits, Allocator>::size_type +basic_string <charT, traits, Allocator>::npos; + +} // extern "C++" diff --git a/gnu/egcs/libstdc++/std/bastring.h b/gnu/egcs/libstdc++/std/bastring.h new file mode 100644 index 00000000000..6206713b6c9 --- /dev/null +++ b/gnu/egcs/libstdc++/std/bastring.h @@ -0,0 +1,647 @@ +// Main templates for the -*- C++ -*- string classes. +// Copyright (C) 1994, 1995 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files +// compiled with a GNU compiler to produce an executable, this does not cause +// the resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. + +#ifndef __BASTRING__ +#define __BASTRING__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include <cstddef> +#include <std/straits.h> + +// NOTE : This does NOT conform to the draft standard and is likely to change +#include <alloc.h> + +extern "C++" { +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 Allocator = alloc > +class basic_string +{ +private: + struct Rep { + size_t len, res, ref; + bool selfish; + + charT* data () { return reinterpret_cast<charT *>(this + 1); } + charT& operator[] (size_t s) { return data () [s]; } + charT* grab () { if (selfish) return clone (); ++ref; return data (); } +#if defined __i486__ || defined __i586__ || defined __i686__ + void release () + { + size_t __val; + asm ("lock; xaddl %0, %2" + : "=r" (__val) : "0" (-1), "m" (ref) : "memory"); + if (__val == 1) + delete this; + } +#elif defined __sparcv9__ + void release () + { + size_t __newval, __oldval = ref; + do + { + __newval = __oldval - 1; + __asm__ ("cas [%4], %2, %0" + : "=r" (__oldval), "=m" (ref) + : "r" (__oldval), "m" (ref), "r"(&(ref)), "0" (__newval)); + } + while (__newval != __oldval); + + if (__oldval == 0) + delete this; + } +#else + void release () { if (--ref == 0) delete this; } +#endif + + inline static void * operator new (size_t, size_t); + inline static void operator delete (void *); + inline static Rep* create (size_t); + charT* clone (); + + inline void copy (size_t, const charT *, size_t); + inline void move (size_t, const charT *, size_t); + inline void set (size_t, const charT, size_t); + + inline static bool excess_slop (size_t, size_t); + inline static size_t frob_size (size_t); + + private: + Rep &operator= (const Rep &); + }; + +public: +// types: + typedef traits traits_type; + typedef typename traits::char_type value_type; + typedef Allocator allocator_type; + + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef charT& reference; + typedef const charT& const_reference; + typedef charT* pointer; + typedef const charT* const_pointer; + typedef pointer iterator; + typedef const_pointer const_iterator; + typedef ::reverse_iterator<iterator> reverse_iterator; + typedef ::reverse_iterator<const_iterator> const_reverse_iterator; + static const size_type npos = static_cast<size_type>(-1); + +private: + Rep *rep () const { return reinterpret_cast<Rep *>(dat) - 1; } + void repup (Rep *p) { rep ()->release (); dat = p->data (); } + +public: + const charT* data () const + { return rep ()->data(); } + size_type length () const + { return rep ()->len; } + size_type size () const + { return rep ()->len; } + size_type capacity () const + { return rep ()->res; } + size_type max_size () const + { return (npos - 1)/sizeof (charT); } // XXX + bool empty () const + { return size () == 0; } + +// _lib.string.cons_ construct/copy/destroy: + basic_string& operator= (const basic_string& str) + { + if (&str != this) { rep ()->release (); dat = str.rep ()->grab (); } + return *this; + } + + explicit basic_string (): dat (nilRep.grab ()) { } + basic_string (const basic_string& str): dat (str.rep ()->grab ()) { } + basic_string (const basic_string& str, size_type pos, size_type n = npos) + : dat (nilRep.grab ()) { assign (str, pos, n); } + basic_string (const charT* s, size_type n) + : dat (nilRep.grab ()) { assign (s, n); } + basic_string (const charT* s) + : dat (nilRep.grab ()) { assign (s); } + basic_string (size_type n, charT c) + : dat (nilRep.grab ()) { assign (n, c); } +#ifdef __STL_MEMBER_TEMPLATES + template<class InputIterator> + basic_string(InputIterator begin, InputIterator end) +#else + basic_string(const_iterator begin, const_iterator end) +#endif + : dat (nilRep.grab ()) { assign (begin, end); } + + ~basic_string () + { rep ()->release (); } + + void swap (basic_string &s) { charT *d = dat; dat = s.dat; s.dat = d; } + + basic_string& append (const basic_string& str, size_type pos = 0, + size_type n = npos) + { return replace (length (), 0, str, pos, n); } + basic_string& append (const charT* s, size_type n) + { return replace (length (), 0, s, n); } + basic_string& append (const charT* s) + { return append (s, traits::length (s)); } + basic_string& append (size_type n, charT c) + { return replace (length (), 0, n, c); } +#ifdef __STL_MEMBER_TEMPLATES + template<class InputIterator> + basic_string& append(InputIterator first, InputIterator last) +#else + basic_string& append(const_iterator first, const_iterator last) +#endif + { return replace (iend (), iend (), first, last); } + + basic_string& assign (const basic_string& str, size_type pos = 0, + size_type n = npos) + { return replace (0, npos, str, pos, n); } + basic_string& assign (const charT* s, size_type n) + { return replace (0, npos, s, n); } + basic_string& assign (const charT* s) + { return assign (s, traits::length (s)); } + basic_string& assign (size_type n, charT c) + { return replace (0, npos, n, c); } +#ifdef __STL_MEMBER_TEMPLATES + template<class InputIterator> + basic_string& assign(InputIterator first, InputIterator last) +#else + basic_string& assign(const_iterator first, const_iterator last) +#endif + { return replace (ibegin (), iend (), first, last); } + + basic_string& operator= (const charT* s) + { return assign (s); } + basic_string& operator= (charT c) + { return assign (1, c); } + + basic_string& operator+= (const basic_string& rhs) + { return append (rhs); } + basic_string& operator+= (const charT* s) + { return append (s); } + basic_string& operator+= (charT c) + { return append (1, c); } + + basic_string& insert (size_type pos1, const basic_string& str, + size_type pos2 = 0, size_type n = npos) + { return replace (pos1, 0, str, pos2, n); } + basic_string& insert (size_type pos, const charT* s, size_type n) + { return replace (pos, 0, s, n); } + basic_string& insert (size_type pos, const charT* s) + { return insert (pos, s, traits::length (s)); } + basic_string& insert (size_type pos, size_type n, charT c) + { return replace (pos, 0, n, c); } + iterator insert(iterator p, charT c) + { size_type __o = p - ibegin (); + insert (p - ibegin (), 1, c); selfish (); + return ibegin () + __o; } + iterator insert(iterator p, size_type n, charT c) + { size_type __o = p - ibegin (); + insert (p - ibegin (), n, c); selfish (); + return ibegin () + __o; } +#ifdef __STL_MEMBER_TEMPLATES + template<class InputIterator> + void insert(iterator p, InputIterator first, InputIterator last) +#else + void insert(iterator p, const_iterator first, const_iterator last) +#endif + { replace (p, p, first, last); } + + basic_string& erase (size_type pos = 0, size_type n = npos) + { return replace (pos, n, (size_type)0, (charT)0); } + iterator erase(iterator p) + { size_type __o = p - begin(); + replace (__o, 1, (size_type)0, (charT)0); selfish (); + return ibegin() + __o; } + iterator erase(iterator f, iterator l) + { size_type __o = f - ibegin(); + replace (__o, l-f, (size_type)0, (charT)0);selfish (); + return ibegin() + __o; } + + basic_string& replace (size_type pos1, size_type n1, const basic_string& str, + size_type pos2 = 0, size_type n2 = npos); + basic_string& replace (size_type pos, size_type n1, const charT* s, + size_type n2); + basic_string& replace (size_type pos, size_type n1, const charT* s) + { return replace (pos, n1, s, traits::length (s)); } + basic_string& replace (size_type pos, size_type n1, size_type n2, charT c); + basic_string& replace (size_type pos, size_type n, charT c) + { return replace (pos, n, 1, c); } + basic_string& replace (iterator i1, iterator i2, const basic_string& str) + { return replace (i1 - ibegin (), i2 - i1, str); } + basic_string& replace (iterator i1, iterator i2, const charT* s, size_type n) + { return replace (i1 - ibegin (), i2 - i1, s, n); } + basic_string& replace (iterator i1, iterator i2, const charT* s) + { return replace (i1 - ibegin (), i2 - i1, s); } + basic_string& replace (iterator i1, iterator i2, size_type n, charT c) + { return replace (i1 - ibegin (), i2 - i1, n, c); } +#ifdef __STL_MEMBER_TEMPLATES + template<class InputIterator> + basic_string& replace(iterator i1, iterator i2, + InputIterator j1, InputIterator j2); +#else + basic_string& replace(iterator i1, iterator i2, + const_iterator j1, const_iterator j2); +#endif + +private: + static charT eos () { return traits::eos (); } + void unique () { if (rep ()->ref > 1) alloc (length (), true); } + void selfish () { unique (); rep ()->selfish = true; } + +public: + charT operator[] (size_type pos) const + { + if (pos == length ()) + return eos (); + return data ()[pos]; + } + + reference operator[] (size_type pos) + { selfish (); 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]; + } + +private: + void terminate () const + { traits::assign ((*rep ())[length ()], eos ()); } + +public: + const charT* c_str () const + { if (length () == 0) return ""; terminate (); return data (); } + void resize (size_type n, charT c); + void resize (size_type n) + { resize (n, eos ()); } + void reserve (size_type) { } + + size_type copy (charT* s, size_type n, size_type pos = 0) const; + + size_type find (const basic_string& str, size_type pos = 0) const + { return find (str.data(), pos, str.length()); } + size_type find (const charT* s, size_type pos, size_type n) const; + size_type find (const charT* s, size_type pos = 0) const + { return find (s, pos, traits::length (s)); } + size_type find (charT c, size_type pos = 0) const; + + size_type rfind (const basic_string& str, size_type pos = npos) const + { return rfind (str.data(), pos, str.length()); } + size_type rfind (const charT* s, size_type pos, size_type n) const; + size_type rfind (const charT* s, size_type pos = npos) const + { return rfind (s, pos, traits::length (s)); } + size_type rfind (charT c, size_type pos = npos) const; + + size_type find_first_of (const basic_string& str, size_type pos = 0) const + { return find_first_of (str.data(), pos, str.length()); } + size_type find_first_of (const charT* s, size_type pos, size_type n) const; + size_type find_first_of (const charT* s, size_type pos = 0) const + { return find_first_of (s, pos, traits::length (s)); } + size_type find_first_of (charT c, size_type pos = 0) const + { return find (c, pos); } + + size_type find_last_of (const basic_string& str, size_type pos = npos) const + { return find_last_of (str.data(), pos, str.length()); } + size_type find_last_of (const charT* s, size_type pos, size_type n) const; + size_type find_last_of (const charT* s, size_type pos = npos) const + { return find_last_of (s, pos, traits::length (s)); } + size_type find_last_of (charT c, size_type pos = npos) const + { return rfind (c, pos); } + + size_type find_first_not_of (const basic_string& str, size_type pos = 0) const + { return find_first_not_of (str.data(), pos, str.length()); } + size_type find_first_not_of (const charT* s, size_type pos, size_type n) const; + size_type find_first_not_of (const charT* s, size_type pos = 0) const + { return find_first_not_of (s, pos, traits::length (s)); } + size_type find_first_not_of (charT c, size_type pos = 0) const; + + size_type find_last_not_of (const basic_string& str, size_type pos = npos) const + { return find_last_not_of (str.data(), pos, str.length()); } + size_type find_last_not_of (const charT* s, size_type pos, size_type n) const; + size_type find_last_not_of (const charT* s, size_type pos = npos) const + { return find_last_not_of (s, pos, traits::length (s)); } + size_type find_last_not_of (charT c, size_type pos = npos) const; + + basic_string substr (size_type pos = 0, size_type n = npos) const + { return basic_string (*this, pos, n); } + + int compare (const basic_string& str, size_type pos = 0, size_type n = npos) const; + // There is no 'strncmp' equivalent for charT pointers. + int compare (const charT* s, size_type pos, size_type n) const; + int compare (const charT* s, size_type pos = 0) const + { return compare (s, pos, traits::length (s)); } + + iterator begin () { selfish (); return &(*this)[0]; } + iterator end () { selfish (); return &(*this)[length ()]; } + +private: + iterator ibegin () const { return &(*rep ())[0]; } + iterator iend () const { return &(*rep ())[length ()]; } + +public: + const_iterator begin () const { return ibegin (); } + const_iterator end () const { return iend (); } + + reverse_iterator rbegin() { return reverse_iterator (end ()); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator (end ()); } + reverse_iterator rend() { return reverse_iterator (begin ()); } + const_reverse_iterator rend() const + { return const_reverse_iterator (begin ()); } + +private: + void alloc (size_type size, bool save); + static size_type _find (const charT* ptr, charT c, size_type xpos, size_type len); + inline bool check_realloc (size_type s) const; + + static Rep nilRep; + charT *dat; +}; + +#ifdef __STL_MEMBER_TEMPLATES +template <class charT, class traits, class Allocator> template <class InputIterator> +basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>:: +replace (iterator i1, iterator i2, InputIterator j1, InputIterator j2) +#else +template <class charT, class traits, class Allocator> +basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>:: +replace (iterator i1, iterator i2, const_iterator j1, const_iterator j2) +#endif +{ + const size_type len = length (); + size_type pos = i1 - ibegin (); + size_type n1 = i2 - i1; + size_type n2 = j2 - j1; + + OUTOFRANGE (pos > len); + if (n1 > len - pos) + n1 = len - pos; + LENGTHERROR (len - n1 > max_size () - n2); + size_t newlen = len - n1 + n2; + + if (check_realloc (newlen)) + { + Rep *p = Rep::create (newlen); + p->copy (0, data (), pos); + p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); + for (; j1 != j2; ++j1, ++pos) + traits::assign ((*p)[pos], *j1); + repup (p); + } + else + { + rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); + for (; j1 != j2; ++j1, ++pos) + traits::assign ((*rep ())[pos], *j1); + } + rep ()->len = newlen; + + return *this; +} + +template <class charT, class traits, class Allocator> +inline basic_string <charT, traits, Allocator> +operator+ (const basic_string <charT, traits, Allocator>& lhs, + const basic_string <charT, traits, Allocator>& rhs) +{ + basic_string <charT, traits, Allocator> str (lhs); + str.append (rhs); + return str; +} + +template <class charT, class traits, class Allocator> +inline basic_string <charT, traits, Allocator> +operator+ (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + basic_string <charT, traits, Allocator> str (lhs); + str.append (rhs); + return str; +} + +template <class charT, class traits, class Allocator> +inline basic_string <charT, traits, Allocator> +operator+ (charT lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + basic_string <charT, traits, Allocator> str (1, lhs); + str.append (rhs); + return str; +} + +template <class charT, class traits, class Allocator> +inline basic_string <charT, traits, Allocator> +operator+ (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs) +{ + basic_string <charT, traits, Allocator> str (lhs); + str.append (rhs); + return str; +} + +template <class charT, class traits, class Allocator> +inline basic_string <charT, traits, Allocator> +operator+ (const basic_string <charT, traits, Allocator>& lhs, charT rhs) +{ + basic_string <charT, traits, Allocator> str (lhs); + str.append (1, rhs); + return str; +} + +template <class charT, class traits, class Allocator> +inline bool +operator== (const basic_string <charT, traits, Allocator>& lhs, + const basic_string <charT, traits, Allocator>& rhs) +{ + return (lhs.compare (rhs) == 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator== (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + return (rhs.compare (lhs) == 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator== (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs) +{ + return (lhs.compare (rhs) == 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator!= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + return (rhs.compare (lhs) != 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator!= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs) +{ + return (lhs.compare (rhs) != 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator< (const basic_string <charT, traits, Allocator>& lhs, + const basic_string <charT, traits, Allocator>& rhs) +{ + return (lhs.compare (rhs) < 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator< (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + return (rhs.compare (lhs) > 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator< (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs) +{ + return (lhs.compare (rhs) < 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator> (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + return (rhs.compare (lhs) < 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator> (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs) +{ + return (lhs.compare (rhs) > 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator<= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + return (rhs.compare (lhs) >= 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator<= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs) +{ + return (lhs.compare (rhs) <= 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator>= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs) +{ + return (rhs.compare (lhs) <= 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator>= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs) +{ + return (lhs.compare (rhs) >= 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator!= (const basic_string <charT, traits, Allocator>& lhs, + const basic_string <charT, traits, Allocator>& rhs) +{ + return (lhs.compare (rhs) != 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator> (const basic_string <charT, traits, Allocator>& lhs, + const basic_string <charT, traits, Allocator>& rhs) +{ + return (lhs.compare (rhs) > 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator<= (const basic_string <charT, traits, Allocator>& lhs, + const basic_string <charT, traits, Allocator>& rhs) +{ + return (lhs.compare (rhs) <= 0); +} + +template <class charT, class traits, class Allocator> +inline bool +operator>= (const basic_string <charT, traits, Allocator>& lhs, + const basic_string <charT, traits, Allocator>& rhs) +{ + return (lhs.compare (rhs) >= 0); +} + +class istream; class ostream; +template <class charT, class traits, class Allocator> istream& +operator>> (istream&, basic_string <charT, traits, Allocator>&); +template <class charT, class traits, class Allocator> ostream& +operator<< (ostream&, const basic_string <charT, traits, Allocator>&); +template <class charT, class traits, class Allocator> istream& +getline (istream&, basic_string <charT, traits, Allocator>&, charT delim = '\n'); + +} // extern "C++" + +#include <std/bastring.cc> + +#endif diff --git a/gnu/egcs/libstdc++/std/complext.cc b/gnu/egcs/libstdc++/std/complext.cc new file mode 100644 index 00000000000..d50bf0871f6 --- /dev/null +++ b/gnu/egcs/libstdc++/std/complext.cc @@ -0,0 +1,273 @@ +// Member templates for the -*- C++ -*- complex number classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files +// compiled with a GNU compiler to produce an executable, this does not cause +// the resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#include <complex> + +extern "C++" { +template <class FLOAT> complex<FLOAT> +cos (const complex<FLOAT>& x) +{ + return complex<FLOAT> (cos (real (x)) * cosh (imag (x)), + - sin (real (x)) * sinh (imag (x))); +} + +template <class FLOAT> complex<FLOAT> +cosh (const complex<FLOAT>& x) +{ + return complex<FLOAT> (cosh (real (x)) * cos (imag (x)), + sinh (real (x)) * sin (imag (x))); +} + +template <class FLOAT> complex<FLOAT> +exp (const complex<FLOAT>& x) +{ + return polar (FLOAT (exp (real (x))), imag (x)); +} + +template <class FLOAT> complex<FLOAT> +log (const complex<FLOAT>& x) +{ + return complex<FLOAT> (log (abs (x)), arg (x)); +} + +template <class FLOAT> complex<FLOAT> +pow (const complex<FLOAT>& x, const complex<FLOAT>& y) +{ + FLOAT logr = log (abs (x)); + FLOAT t = arg (x); + + return polar (FLOAT (exp (logr * real (y) - imag (y) * t)), + FLOAT (imag (y) * logr + real (y) * t)); +} + +template <class FLOAT> complex<FLOAT> +pow (const complex<FLOAT>& x, FLOAT y) +{ + return exp (FLOAT (y) * log (x)); +} + +template <class FLOAT> complex<FLOAT> +pow (FLOAT x, const complex<FLOAT>& y) +{ + return exp (y * FLOAT (log (x))); +} + +template <class FLOAT> complex<FLOAT> +sin (const complex<FLOAT>& x) +{ + return complex<FLOAT> (sin (real (x)) * cosh (imag (x)), + cos (real (x)) * sinh (imag (x))); +} + +template <class FLOAT> complex<FLOAT> +sinh (const complex<FLOAT>& x) +{ + return complex<FLOAT> (sinh (real (x)) * cos (imag (x)), + cosh (real (x)) * sin (imag (x))); +} + +#include <iostream.h> + +template <class FLOAT> istream& +operator >> (istream& is, complex<FLOAT>& x) +{ + FLOAT re, im = 0; + char ch = 0; + + if (is.ipfx0 ()) + { + if (is.peek () == '(') + is >> ch; + is >> re; + if (ch == '(') + { + is >> ch; + if (ch == ',') + is >> im >> ch; + } + } + is.isfx (); + + if (ch != 0 && ch != ')') + is.setstate (ios::failbit); + else if (is.good ()) + x = complex<FLOAT> (re, im); + + return is; +} + +template <class FLOAT> ostream& +operator << (ostream& os, const complex<FLOAT>& x) +{ + return os << '(' << real (x) << ',' << imag (x) << ')'; +} + +// The code below is adapted from f2c's libF77, and is subject to this +// copyright: + +/**************************************************************** +Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories and Bellcore. + +Permission to use, copy, modify, and distribute this software +and its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the names of AT&T Bell Laboratories or +Bellcore or any of their entities not be used in advertising or +publicity pertaining to distribution of the software without +specific, written prior permission. + +AT&T and Bellcore disclaim all warranties with regard to this +software, including all implied warranties of merchantability +and fitness. In no event shall AT&T or Bellcore be liable for +any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether +in an action of contract, negligence or other tortious action, +arising out of or in connection with the use or performance of +this software. +****************************************************************/ + +template <class FLOAT> complex<FLOAT>& +__doadv (complex<FLOAT>* ths, const complex<FLOAT>& y) +{ + FLOAT ar = abs (y.re); + FLOAT ai = abs (y.im); + FLOAT nr, ni; + FLOAT t, d; + if (ar <= ai) + { + t = y.re / y.im; + d = y.im * (1 + t*t); + nr = (ths->re * t + ths->im) / d; + ni = (ths->im * t - ths->re) / d; + } + else + { + t = y.im / y.re; + d = y.re * (1 + t*t); + nr = (ths->re + ths->im * t) / d; + ni = (ths->im - ths->re * t) / d; + } + ths->re = nr; + ths->im = ni; + return *ths; +} + +template <class FLOAT> complex<FLOAT> +operator / (const complex<FLOAT>& x, const complex<FLOAT>& y) +{ + FLOAT ar = abs (real (y)); + FLOAT ai = abs (imag (y)); + FLOAT nr, ni; + FLOAT t, d; + if (ar <= ai) + { + t = real (y) / imag (y); + d = imag (y) * (1 + t*t); + nr = (real (x) * t + imag (x)) / d; + ni = (imag (x) * t - real (x)) / d; + } + else + { + t = imag (y) / real (y); + d = real (y) * (1 + t*t); + nr = (real (x) + imag (x) * t) / d; + ni = (imag (x) - real (x) * t) / d; + } + return complex<FLOAT> (nr, ni); +} + +template <class FLOAT> complex<FLOAT> +operator / (FLOAT x, const complex<FLOAT>& y) +{ + FLOAT ar = abs (real (y)); + FLOAT ai = abs (imag (y)); + FLOAT nr, ni; + FLOAT t, d; + if (ar <= ai) + { + t = real (y) / imag (y); + d = imag (y) * (1 + t*t); + nr = x * t / d; + ni = -x / d; + } + else + { + t = imag (y) / real (y); + d = real (y) * (1 + t*t); + nr = x / d; + ni = -x * t / d; + } + return complex<FLOAT> (nr, ni); +} + +template <class FLOAT> complex<FLOAT> +pow (const complex<FLOAT>& xin, int y) +{ + if (y == 0) + return complex<FLOAT> (1.0); + complex<FLOAT> r (1.0); + complex<FLOAT> x (xin); + if (y < 0) + { + y = -y; + x = 1/x; + } + for (;;) + { + if (y & 1) + r *= x; + if (y >>= 1) + x *= x; + else + return r; + } +} + +template <class FLOAT> complex<FLOAT> +sqrt (const complex<FLOAT>& x) +{ + FLOAT r = abs (x); + FLOAT nr, ni; + if (r == 0.0) + nr = ni = r; + else if (real (x) > 0) + { + nr = sqrt (0.5 * (r + real (x))); + ni = imag (x) / nr / 2; + } + else + { + ni = sqrt (0.5 * (r - real (x))); + if (imag (x) < 0) + ni = - ni; + nr = imag (x) / ni / 2; + } + return complex<FLOAT> (nr, ni); +} +} // extern "C++" diff --git a/gnu/egcs/libstdc++/std/complext.h b/gnu/egcs/libstdc++/std/complext.h new file mode 100644 index 00000000000..6c55037bf94 --- /dev/null +++ b/gnu/egcs/libstdc++/std/complext.h @@ -0,0 +1,400 @@ +// The template and inlines for the -*- C++ -*- complex number classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the terms of +// the GNU General Public License as published by the Free Software +// Foundation; either version 2, or (at your option) any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files compiled +// with a GNU compiler to produce an executable, this does not cause the +// resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __COMPLEXT__ +#define __COMPLEXT__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include <cmath> + +#if ! defined (__GNUG__) && ! defined (__attribute__) +#define __attribute__(foo) /* Ignore. */ +#endif + +class istream; +class ostream; + +extern "C++" { +template <class _FLT> class complex; +template <class _FLT> complex<_FLT>& + __doapl (complex<_FLT>* ths, const complex<_FLT>& r); +template <class _FLT> complex<_FLT>& + __doami (complex<_FLT>* ths, const complex<_FLT>& r); +template <class _FLT> complex<_FLT>& + __doaml (complex<_FLT>* ths, const complex<_FLT>& r); +template <class _FLT> complex<_FLT>& + __doadv (complex<_FLT>* ths, const complex<_FLT>& r); + +template <class _FLT> +class complex +{ +public: + complex (_FLT r = 0, _FLT i = 0): re (r), im (i) { } + complex& operator += (const complex&); + complex& operator -= (const complex&); + complex& operator *= (const complex&); + complex& operator /= (const complex&); + _FLT real () const { return re; } + _FLT imag () const { return im; } +private: + _FLT re, im; + + friend complex& __doapl<> (complex *, const complex&); + friend complex& __doami<> (complex *, const complex&); + friend complex& __doaml<> (complex *, const complex&); + friend complex& __doadv<> (complex *, const complex&); +}; + +// Declare specializations. +class complex<float>; +class complex<double>; +class complex<long double>; + +template <class _FLT> +inline complex<_FLT>& +__doapl (complex<_FLT>* ths, const complex<_FLT>& r) +{ + ths->re += r.re; + ths->im += r.im; + return *ths; +} +template <class _FLT> +inline complex<_FLT>& +complex<_FLT>::operator += (const complex<_FLT>& r) +{ + return __doapl (this, r); +} + +template <class _FLT> +inline complex<_FLT>& +__doami (complex<_FLT>* ths, const complex<_FLT>& r) +{ + ths->re -= r.re; + ths->im -= r.im; + return *ths; +} +template <class _FLT> +inline complex<_FLT>& +complex<_FLT>::operator -= (const complex<_FLT>& r) +{ + return __doami (this, r); +} + +template <class _FLT> +inline complex<_FLT>& +__doaml (complex<_FLT>* ths, const complex<_FLT>& r) +{ + _FLT f = ths->re * r.re - ths->im * r.im; + ths->im = ths->re * r.im + ths->im * r.re; + ths->re = f; + return *ths; +} +template <class _FLT> +inline complex<_FLT>& +complex<_FLT>::operator *= (const complex<_FLT>& r) +{ + return __doaml (this, r); +} + +template <class _FLT> +inline complex<_FLT>& +complex<_FLT>::operator /= (const complex<_FLT>& r) +{ + return __doadv (this, r); +} + +template <class _FLT> inline _FLT +imag (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline _FLT +imag (const complex<_FLT>& x) +{ + return x.imag (); +} + +template <class _FLT> inline _FLT +real (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline _FLT +real (const complex<_FLT>& x) +{ + return x.real (); +} + +template <class _FLT> inline complex<_FLT> +operator + (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator + (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return complex<_FLT> (real (x) + real (y), imag (x) + imag (y)); +} + +template <class _FLT> inline complex<_FLT> +operator + (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator + (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) + y, imag (x)); +} + +template <class _FLT> inline complex<_FLT> +operator + (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator + (_FLT x, const complex<_FLT>& y) +{ + return complex<_FLT> (x + real (y), imag (y)); +} + +template <class _FLT> inline complex<_FLT> +operator - (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator - (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return complex<_FLT> (real (x) - real (y), imag (x) - imag (y)); +} + +template <class _FLT> inline complex<_FLT> +operator - (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator - (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) - y, imag (x)); +} + +template <class _FLT> inline complex<_FLT> +operator - (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator - (_FLT x, const complex<_FLT>& y) +{ + return complex<_FLT> (x - real (y), - imag (y)); +} + +template <class _FLT> inline complex<_FLT> +operator * (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator * (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return complex<_FLT> (real (x) * real (y) - imag (x) * imag (y), + real (x) * imag (y) + imag (x) * real (y)); +} + +template <class _FLT> inline complex<_FLT> +operator * (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator * (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) * y, imag (x) * y); +} + +template <class _FLT> inline complex<_FLT> +operator * (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator * (_FLT x, const complex<_FLT>& y) +{ + return complex<_FLT> (x * real (y), x * imag (y)); +} + +template <class _FLT> complex<_FLT> +operator / (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template <class _FLT> complex<_FLT> +operator / (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) / y, imag (x) / y); +} + +template <class _FLT> inline complex<_FLT> +operator + (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator + (const complex<_FLT>& x) +{ + return x; +} + +template <class _FLT> inline complex<_FLT> +operator - (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +operator - (const complex<_FLT>& x) +{ + return complex<_FLT> (-real (x), -imag (x)); +} + +template <class _FLT> inline bool +operator == (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline bool +operator == (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return real (x) == real (y) && imag (x) == imag (y); +} + +template <class _FLT> inline bool +operator == (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template <class _FLT> inline bool +operator == (const complex<_FLT>& x, _FLT y) +{ + return real (x) == y && imag (x) == 0; +} + +template <class _FLT> inline bool +operator == (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline bool +operator == (_FLT x, const complex<_FLT>& y) +{ + return x == real (y) && imag (y) == 0; +} + +template <class _FLT> inline bool +operator != (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline bool +operator != (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return real (x) != real (y) || imag (x) != imag (y); +} + +template <class _FLT> inline bool +operator != (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template <class _FLT> inline bool +operator != (const complex<_FLT>& x, _FLT y) +{ + return real (x) != y || imag (x) != 0; +} + +template <class _FLT> inline bool +operator != (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template <class _FLT> inline bool +operator != (_FLT x, const complex<_FLT>& y) +{ + return x != real (y) || imag (y) != 0; +} + +// Some targets don't provide a prototype for hypot when -ansi. +extern "C" double hypot (double, double) __attribute__ ((const)); + +template <class _FLT> inline _FLT +abs (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline _FLT +abs (const complex<_FLT>& x) +{ + return hypot (real (x), imag (x)); +} + +template <class _FLT> inline _FLT +arg (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline _FLT +arg (const complex<_FLT>& x) +{ + return atan2 (imag (x), real (x)); +} + +template <class _FLT> inline complex<_FLT> +polar (_FLT r, _FLT t) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +polar (_FLT r, _FLT t) +{ + return complex<_FLT> (r * cos (t), r * sin (t)); +} + +template <class _FLT> inline complex<_FLT> +conj (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline complex<_FLT> +conj (const complex<_FLT>& x) +{ + return complex<_FLT> (real (x), -imag (x)); +} + +template <class _FLT> inline _FLT +norm (const complex<_FLT>& x) __attribute__ ((const)); + +template <class _FLT> inline _FLT +norm (const complex<_FLT>& x) +{ + return real (x) * real (x) + imag (x) * imag (x); +} + +// Declarations of templates in complext.ccI + +template <class _FLT> complex<_FLT> + operator / (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + operator / (_FLT, const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + cos (const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + cosh (const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + exp (const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + log (const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + pow (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + pow (const complex<_FLT>&, _FLT) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + pow (const complex<_FLT>&, int) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + pow (_FLT, const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + sin (const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + sinh (const complex<_FLT>&) __attribute__ ((const)); +template <class _FLT> complex<_FLT> + sqrt (const complex<_FLT>&) __attribute__ ((const)); + +template <class _FLT> istream& operator >> (istream&, complex<_FLT>&); +template <class _FLT> ostream& operator << (ostream&, const complex<_FLT>&); +} // extern "C++" + +// Specializations and such + +#include <std/fcomplex.h> +#include <std/dcomplex.h> +#include <std/ldcomplex.h> + +#endif diff --git a/gnu/egcs/libstdc++/std/dcomplex.h b/gnu/egcs/libstdc++/std/dcomplex.h new file mode 100644 index 00000000000..5812d9fa7df --- /dev/null +++ b/gnu/egcs/libstdc++/std/dcomplex.h @@ -0,0 +1,91 @@ +// The -*- C++ -*- double_complex class. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files +// compiled with a GNU compiler to produce an executable, this does not cause +// the resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __DCOMPLEX__ +#define __DCOMPLEX__ + +#ifdef __GNUG__ +#pragma interface "dcomplex" +#endif + +extern "C++" { +class complex<double> +{ +public: + complex (double r = 0, double i = 0): re (r), im (i) { } + complex (const complex<float>& r): re (r.real ()), im (r.imag ()) { } + explicit complex (const complex<long double>& r); + + complex& operator+= (const complex& r) { return __doapl (this, r); } + complex& operator-= (const complex& r) { return __doami (this, r); } + complex& operator*= (const complex& r) { return __doaml (this, r); } + complex& operator/= (const complex& r) { return __doadv (this, r); } + + double real () const { return re; } + double imag () const { return im; } +private: + double re, im; + + friend complex& __doapl<> (complex *, const complex&); + 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) +: re (r.real ()), im (r.imag ()) +{ } +} // extern "C++" + +#endif diff --git a/gnu/egcs/libstdc++/std/fcomplex.h b/gnu/egcs/libstdc++/std/fcomplex.h new file mode 100644 index 00000000000..cd9af1a2e0c --- /dev/null +++ b/gnu/egcs/libstdc++/std/fcomplex.h @@ -0,0 +1,87 @@ +// The -*- C++ -*- float_complex class. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files +// compiled with a GNU compiler to produce an executable, this does not cause +// the resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __FCOMPLEX__ +#define __FCOMPLEX__ + +#ifdef __GNUG__ +#pragma interface "fcomplex" +#endif + +extern "C++" { +class complex<float> +{ +public: + complex (float r = 0, float i = 0): re (r), im (i) { } + explicit complex (const complex<double>& r); + explicit complex (const complex<long double>& r); + + complex& operator+= (const complex& r) { return __doapl (this, r); } + complex& operator-= (const complex& r) { return __doami (this, r); } + complex& operator*= (const complex& r) { return __doaml (this, r); } + complex& operator/= (const complex& r) { return __doadv (this, r); } + + float real () const { return re; } + float imag () const { return im; } +private: + float re, im; + + friend complex& __doapl<> (complex *, const complex&); + 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++" + +#endif diff --git a/gnu/egcs/libstdc++/std/ldcomplex.h b/gnu/egcs/libstdc++/std/ldcomplex.h new file mode 100644 index 00000000000..bc91fa422bf --- /dev/null +++ b/gnu/egcs/libstdc++/std/ldcomplex.h @@ -0,0 +1,95 @@ +// The -*- C++ -*- long_double_complex class. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files +// compiled with a GNU compiler to produce an executable, this does not cause +// the resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __LDCOMPLEX__ +#define __LDCOMPLEX__ + +#ifdef __GNUG__ +#pragma interface "ldcomplex" +#endif + +extern "C++" { +class complex<long double> +{ +public: + complex (long double r = 0, long double i = 0): re (r), im (i) { } + complex (const complex<float>& r): re (r.real ()), im (r.imag ()) { } + complex (const complex<double>& r): re (r.real ()), im (r.imag ()) { } + + complex& operator+= (const complex& r) { return __doapl (this, r); } + complex& operator-= (const complex& r) { return __doami (this, r); } + complex& operator*= (const complex& r) { return __doaml (this, r); } + complex& operator/= (const complex& r) { return __doadv (this, r); } + + long double real () const { return re; } + long double imag () const { return im; } +private: + long double re, im; + + friend complex& __doapl<> (complex *, const complex&); + 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) +: re (r.real ()), im (r.imag ()) +{ } + +inline complex<double>::complex (const complex<long double>& r) +: re (r.real ()), im (r.imag ()) +{ } +} // extern "C++" + +#endif diff --git a/gnu/egcs/libstdc++/std/straits.h b/gnu/egcs/libstdc++/std/straits.h new file mode 100644 index 00000000000..c80e7ab7a68 --- /dev/null +++ b/gnu/egcs/libstdc++/std/straits.h @@ -0,0 +1,161 @@ +// Character traits template for the -*- C++ -*- string classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// As a special exception, if you link this library with files +// compiled with a GNU compiler to produce an executable, this does not cause +// the resulting executable to be covered by the GNU General Public License. +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. + +#ifndef __STRING_CHAR_TRAITS__ +#define __STRING_CHAR_TRAITS__ + +#ifdef __GNUG__ +// For string_char_traits <char> +#pragma interface "std/straits.h" +#endif + +#include <cstddef> + +extern "C++" { +template <class charT> +struct string_char_traits { + typedef charT char_type; // for users to acquire the basic character type + + // constraints + + static void assign (char_type& c1, const char_type& c2) + { c1 = c2; } + static bool eq (const char_type& c1, const char_type& c2) + { return (c1 == c2); } + static bool ne (const char_type& c1, const char_type& c2) + { return !(c1 == c2); } + static bool lt (const char_type& c1, const char_type& c2) + { return (c1 < c2); } + static char_type eos () { return char_type(); } // the null character + static bool is_del(char_type a) { return 0; } + // characteristic function for delimiters of charT + + // speed-up functions + + static int compare (const char_type* s1, const char_type* s2, size_t n) + { + size_t i; + for (i = 0; i < n; ++i) + if (ne (s1[i], s2[i])) + return lt (s1[i], s2[i]) ? -1 : 1; + + return 0; + } + + static size_t length (const char_type* s) + { + size_t l = 0; + while (ne (*s++, eos ())) + ++l; + return l; + } + + static char_type* copy (char_type* s1, const char_type* s2, size_t n) + { + for (; n--; ) + assign (s1[n], s2[n]); + return s1; + } + + static char_type* move (char_type* s1, const char_type* s2, size_t n) + { + char_type a[n]; + size_t i; + for (i = 0; i < n; ++i) + assign (a[i], s2[i]); + for (i = 0; i < n; ++i) + assign (s1[i], a[i]); + return s1; + } + + static char_type* set (char_type* s1, const char_type& c, size_t n) + { + for (; n--; ) + assign (s1[n], c); + return s1; + } +}; + +class istream; +class ostream; +#include <cctype> +#include <cstring> + +struct string_char_traits <char> { + typedef char char_type; + + static void assign (char_type& c1, const char_type& c2) + { c1 = c2; } + static bool eq (const char_type & c1, const char_type& c2) + { return (c1 == c2); } + static bool ne (const char_type& c1, const char_type& c2) + { return (c1 != c2); } + static bool lt (const char_type& c1, const char_type& c2) + { return (c1 < c2); } + static char_type eos () { return 0; } + static bool is_del(char_type a) { return isspace(a); } + + static int compare (const char_type* s1, const char_type* s2, size_t n) + { return memcmp (s1, s2, n); } + static size_t length (const char_type* s) + { return strlen (s); } + static char_type* copy (char_type* s1, const char_type* s2, size_t n) + { return (char_type*) memcpy (s1, s2, n); } + static char_type* move (char_type* s1, const char_type* s2, size_t n) + { return (char_type*) memmove (s1, s2, n); } + static char_type* set (char_type* s1, const char_type& c, size_t n) + { return (char_type*) memset (s1, c, n); } +}; + +#if 0 +#include <cwctype> +struct string_char_traits <wchar_t> { + typedef wchar_t char_type; + + static void assign (char_type& c1, const char_type& c2) + { c1 = c2; } + static bool eq (const char_type & c1, const char_type& c2) + { return (c1 == c2); } + static bool ne (const char_type& c1, const char_type& c2) + { return (c1 != c2); } + static bool lt (const char_type& c1, const char_type& c2) + { return (c1 < c2); } + static char_type eos () { return 0; } + static bool is_del(char_type a) { return iswspace(a); } + + static int compare (const char_type* s1, const char_type* s2, size_t n) + { return wmemcmp (s1, s2, n); } + static size_t length (const char_type* s) + { return wcslen (s); } + static char_type* copy (char_type* s1, const char_type* s2, size_t n) + { return wmemcpy (s1, s2, n); } + static char_type* set (char_type* s1, const char_type& c, size_t n) + { return wmemset (s1, c, n); } +}; +#endif +} // extern "C++" +#endif |