I know that using the %s format specifier and std::string , as this leads to undefined behavior:
std::string myString = "test"; printf("%s", myString);
But is it possible to use the same qualifier and 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 indicates (const) char* , but I provide std::string . Could this lead to UB?
Ronald mcbean
source share