
31 Jan
2012
31 Jan
'12
1:47 p.m.
[Thorsten Ottosen]
However, consider const std::string& ext = iter->path().extension().string(); This is fine on windows, as a temporary is returned, and its lifetime is extended; on linux, extension() returns a temp path object, from where we get a reference. I'm not a 100% sure, but I think the C++ standard does not guarantee that this path object be kept alive.
* The Standard requires the temporary path to be destroyed at the semicolon. * Replace string with wstring, and this becomes problematic on Windows. * Additionally, returning const values like const string/const wstring inhibits move semantics. STL