Here is my attempt to write a generic output function but it does not
compile. Can someone correct it for me? The problem is with the call to
widen.

Also, is it possible to make this more generic so it is not specific to
class vector?

Thanks,
Siegfried

template<typename CH, typename TY>
std::basic_ostream<CH>& operator<<(std::basic_ostream<CH>& cout, const
std::vector<TY>& vec){
    std::copy(vec.begin(),vec.end(),
std::ostream_iterator<TY,CH>(cout,cout.widen(',')));
    //for(typename std::vector<TY>::const_iterator pE = vec.begin(); pE
!= vec.end(); pE++) cout<<(pE == vec.begin()?"[":",")<<*pE;  cout
<<"]";
    return cout;
}

_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to