Guest User

Untitled

a guest
Jun 7th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. struct PkString : public std::string
  2. { //Wrapper to make std::string more friendly.
  3.     operator bool           (void) const    { return this->empty(); }
  4.     operator const char *   (void) const    { return this->c_str(); }
  5.     const char *operator+   (void) const    { return this->c_str(); }
  6.     char operator *         (void) const    { return *this->c_str(); }
  7.    
  8.     //We need these so we can still use our other overloads in expressions with temporaries.
  9.     PkString operator+  (const PkString &Ref)   const   { return static_cast<const std::string&>(*this) + +Ref; }
  10.     PkString operator+  (const char *In)        const   { return static_cast<const std::string&>(*this) + In; }
  11.     PkString operator+  (const char Character)  const   { return static_cast<const std::string&>(*this) + Character; }
  12.    
  13.     PkString(const char *Stringy) : std::string(Stringy ? Stringy : "") {}
  14.     PkString(const std::string &Stringy) : std::string(Stringy) {}
  15.     PkString(void) : std::string() {}
  16. };
Advertisement
Add Comment
Please, Sign In to add comment