Why Don’t You Use String Views (as std::wstring_view) Instead of Passing std::wstring by const&?
Summary
The article argues that in Win32 C++ code, using std::wstring by const& is safer than std::wstring_view for input parameters because Windows APIs expect null-terminated strings. It explains that std::wstring guarantees null-termination via data(), while std::wstring_view does not, which can lead to bugs when interfacing with PCWSTR. It recommends using c_str() for null-terminated inputs and keeping std::wstring in such contexts, with data() only for writeable buffers.