title: Is there a faster way to return a formatted string from a member function?
body: <p>I created a mathematical vector class, and because it could be called 60 times a second in real time, I'm concerned that this algorithm is too slow. It basically grabs (x,y) in vector format and returns the string. Is there a faster way to do the same thing?</p>
  
  <p>I researched that placing 'static' before the buffer array is one way. I also don't like the binary copy of the returned string (or assumedly the copy constructor). It does need to return std::string.  </p>
  
  <pre><code>std::string Vector2D::toString() const
  {
      char buffer[20];
  
      snprintf(buffer, 20, "(%.02f, %.02f)", m_x, m_y); 
  
      return std::string(buffer, strlen(buffer));
  }
  </code></pre>