operator<<オブジェクトが astd::wstringや int などを出力する必要がある場合、出力をどのように記述すればよいですか?
#include <iostream>
struct Foo {
int i;
std::wstring wstr;
};
std::ostream& operator<<(std::ostream& out, Foo const& foo) {
out << foo.i << foo.wstr; // error
return out;
}
int main() {
Foo foo;
std::wcerr << foo << std::endl;
}
言い換えれintば、渡された場合、 s やその他のプリミティブデータ型を出力するにはどうすればよいwcerrですか? 私は必要ですboost::lexical_cast<std::wstring>か、それとも似ていますか?