Daily bit(e) of C++ | std::move_iterator
Daily bit(e) of C++ ♻️43, The iterator adapter that dereferences into an r-value: std::move_iterator.
Moving data efficiently (before C++23) can get tricky when we work with heterogeneous containers since move construction and move assignment are only supported by containers of the same type.
One viable option is using std::move_iterator and the iterator constructor, which will result in an element-wise move construction between containers of different types or mismatched allocators.
The std::move_iterator works precisely like the underlying iterator, except when dereferenced, it produces an r-value.