I want to write template function which can print container like std::vector
, std::list.
Below is my function, just overload <<
.
The problem is that the templated type Container can match any type, not just containers. That includes the " "
you are trying to print.
If you look at the error message from a different compiler: https://godbolt.org/g/3YKtca
Perhaps you want a partial specialization of vector
to only take vectors. Determining if a type is a container is a more complicated problem.
#include
#include
template
std::ostream& operator<<(std::ostream& out, const std::vector& c){
for(auto item:c){
out<- iVec{5, 9, 1, 4, 6};
std::cout<
https://godbolt.org/g/NJNwmN