I know that using the %s
format specifier and std::string
like this leads to undefined behaviour:
std::string myString = "test";
printf("%s", myString);
But is it save to use the same specifier and a std::string
with boost::format
?
#include <boost/format.hpp>
int main()
{
std::string myString = "test";
boost::format fmt("%s");
fmt % myString;
std::cout << fmt.str();
return 0;
}
%s
specifies a (const) char*
, but I provide a std::string
. Could this lead to UB too?