Advertisement
Guest User

Untitled

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