It can be used if you properly define it. But .... just because it can be used, does not mean that it should be used.
Use std::copy_n
:
std::copy_n(data, n, std::stream_iterator<X>(std::cout, " "));
That will print all the n
items from data
to the stdout, each separated by a space. Note that in the above code, X
is the type of data[i]
.
Or write a proper function (not macro) to print in your own defined format. Preferably a function template with begin
and end
as function parameters. Have a look at how algorithms from the Standard library work and are implemented. That will help you to come up with a good generic design of your code. Explore and experiment with the library generic functions!