I've got the following preprocessor define:
#define PRINTARRAY(Type, Array, Stream, Separator) \
std::copy(std::begin(Array), std::end(Array), std::ostream_iterator<Type>(Stream, Separator))
I'm wanting to convert this to a template, so it can automatically determine the type for the ostream_iterator, so I don't have to pass it in.
However, I'm wondering what how to do this. My key issues are:
- Getting this to work with all STL containers
- Getting this to work with ordinary arrays (which std::begin / end supports?)
I think the key issue is that the ostream_iterator, afaik, needs to have the type of the contained values, and not the type of the container.
Does anyone have any ideas? Thanks.
Aucun commentaire:
Enregistrer un commentaire