Просмотр исходного кода

ENH: Added "ostringstream(const kwsys_stl::string& s)" and "void str(const kwsys_stl::string& s)" compatibility methods.

Brad King 21 лет назад
Родитель
Сommit
5290b40c47
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      Source/kwsys/kwsys_ios_sstream.h.in

+ 6 - 0
Source/kwsys/kwsys_ios_sstream.h.in

@@ -83,6 +83,7 @@ class ostringstream: public ostrstream
 public:
   typedef ostrstream Superclass;
   ostringstream() {}
+  ostringstream(const kwsys_stl::string& s) { *this << s.c_str(); }
   kwsys_stl::string str()
     {
     ostringstream_cleanup cleanup(*this);
@@ -91,6 +92,11 @@ public:
     const char* ptr = this->Superclass::str();
     return kwsys_stl::string(ptr?ptr:"", pcount);
     }
+  void str(const kwsys_stl::string& s)
+    {
+    this->~ostringstream();
+    new (this) ostringstream(s);
+    }
 private:
   ostringstream(const ostringstream&);
   void operator=(const ostringstream&);