it++ sets off my pedantic C++ alarm, it's idiomatic to preincrement iterators (ie, ++it).
You should probably save off the result of *it into it's own variable. Because it is a proxy iterator, each time you dereference it you're getting a new instance of the message/attachment/folder object, etc. It's not very efficient and can cause problems
if you think *it always refers to the same object - like if you're creating and comparing iterators from *it for example.
The only purpose of a node_stream_device is to be an argument to construct a node_stream; you shouldn't ever need to reference the variable directly. So you pretty much always want