I know that stringstreams are the C++ recommended way to create formatted text.  However, they can often become quite verbose, especially when compared to the succinct format strings of `printf` and family.  However, the `printf` family can lead to its own issues, with buffer overflow issues, and so I would rather not use these functions directly

My goal was to make a function to behave similarly to `snprintf`, but return a `std::string`, avoiding any chance of buffer overflow.  Knowing that there are many pitfalls to string manipulation in C++, have I exposed myself to any errors in using this function?

    <!-- language: c++ -->
    #include <cstdio>
    #include <cstdarg>
    #include <string>
    
    std::string string_sprintf(const std::string& format, ...){
      static const int initial_buf_size = 100;
      va_list arglist;
      va_start(arglist, format);
      char buf1[initial_buf_size];
      const int len = vsnprintf(buf1,initial_buf_size,format.c_str(), arglist) + 1;
      va_end(arglist);
    
      if(len<initial_buf_size){
        return buf1;
      } else {
        char buf2[len];
        va_start(arglist,format);
        vsnprintf(buf2,len,format.c_str(),arglist);
        va_end(arglist);
        return buf2;
      }
    }