C++ Primer (5th edition) gives a number of examples of achieving nice effects by passing an inserter or a move iterator instead of a regular iterator into an std's generic algorithm.
I suspect, however, that being able to do this depends on inside knowledge of the workings of the algorithm, i.e. what precisely it does with its iterator arguments. This is even more severe with the move inserter, since we need to be sure that an object is not accessed after being moved from.
Is my suspicion justified? If it is, then how come the standard library takes an approach that requires the client (me) to know the internals of the provider (STL)?
Aucun commentaire:
Enregistrer un commentaire