I want to optimize a directory listing input iterator so that the WIN32_FIND_DATA can be written directly to a vector (via emplace) instead of being first written inside the iterator.
This is an idea of the code:
/*
std::vector<WIN32_FIND_DATA> vwfd;
struct listing_it:std::iterator<std::input_iterator_tag, WIN32_FIND_DATA>{
HANDLE handle;
WIN32_FIND_DATA wfd;
auto operator*()->wfd&{return *wfd;}
auto operator++()->listing_it &{FindNextFile(handle, &wfd);}
...
}
*/
Eventually used in something like: copy(lising_it_begin, listing_it_end, back_inserter(vwfd));
Of course that code is not really correct nor good (in reality I use smart pointers for the handle, etc).
What I really want is that FindNextFile use the actual location of the WIN32_FIND_DATA in the vector. Is this possible in c++11 or do I have to pay the cost of internal copying and therefore forego the use of input iterators for more optimised method (that are actually much simpler).