Replace CString Format()
C / C++ / MFC
2
Posts
2
Posters
6
Views
1
Watching
-
I would like to go over some old code and replace the use of CString (MFC / ATL) with a multiplatform, C++ 20 equivalent. Can I use std::format and if so, then how?
std::format
is not directly compatible withsprintf
formatting codes. From what I've seen there are different ways to go about this: - do sprintf to a temporary buffer and assign buffer to astd::string
- switch to string streams (std::stringstream) and their "<<" operator - switch tostd::format
and their "{}" style formatting. None is automatic and about equally unpleasant.Mircea