I read this post How to print out the contents of a vector?, one beautiful answer to it is to print contents of a vector the following way
std::copy(path.begin(), path.end(), std::ostream_iterator<char>(std::cout, " "));
It works perfectly fine. But what if my vector is of type vector<pair<int, struct node>>
. How do I use the above method to print this vector?
I tried
std::copy(path.begin(), path.end(), std::ostream_iterator<pair<int, struct node>>(std::cout, " "));
I am getting huge error dump, few lines are as follows
In file included from /usr/include/c++/4.9/iterator:64:0,
from dijkstra.cpp:8:
/usr/include/c++/4.9/ostream:548:5: note: template std::basic_ostream& std::operator<<(std::basic_ostream&, const unsigned char*)
operator<<(basic_ostream& __out, const unsigned char* __s) ^
/usr/include/c++/4.9/ostream:548:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.9/iterator:66:0, from dijkstra.cpp:8:
/usr/include/c++/4.9/bits/stream_iterator.h:198:13: note: cannot convert ‘__value’ (type ‘const std::pair’) to type ‘const unsigned char*’ *_M_stream << __value;
Not able to figure out. Any help?