I use Boost.Filesystem to create a list of files in a directory. I use boost::filesystem::recursive_directory_iteratorand std::copyto put every path in std :: vector as an object boost::filesystem::directory_entry. I want to output the file to std :: strings, but I did the following (\ n to avoid using <<):
std::vector<boost::filesystem::directory_entry> buffer;
...
std::vector<std::string> buffer_native(buffer.size());
std::transform(buffer.begin(),buffer.end(),buffer_native.begin(), [](boost::filesystem::directory_entry de)->std::string
{
std::string temp=de.path().string();
temp+="\n";
return temp;
}
buffer.clear();
std::copy(buffer_native.begin(),buffer_native.end(),std::ostream_iterator<std::string>(out_file));
However, the problem with this is that it creates two vectors, the original of which is immediately cleared, because it is not needed. This sounds like an ideal place for move semantics, but n3242 provides only the same two conversion overloads as in C ++ 98. Is it possible to implement move semantics with std::transform? If this is not the case, would writing a user loop be better?
I am using GCC 4.5.2 (MinGW) on Windows XP.