yo/classtemplates/vector/boundfriend.cc
raw| 1 | #include <algorithm> |
| 2 | #include <iostream> |
| 3 | |
| 4 | template<typename T> |
| 5 | class Vector |
| 6 | { |
| 7 | friend std::ostream &operator<< <T> (std::ostream &str, |
| 8 | Vector<T> const &vector); |
| 9 | T *d_data; |
| 10 | T *d_beyond; |
| 11 | }; |
| 12 | |
| 13 | template <typename T> |
| 14 | std::ostream &operator<<(std::ostream &str, Vector<T> const &vector) |
| 15 | { |
| 16 | std::copy(vector.d_data, vector.d_beyond, |
| 17 | std::ostream_iterator<T *>(str, " ")); |
| 18 | return str; |
| 19 | } |