Boost logo

Boost Users :

From: Frank Astier (fastier_at_[hidden])
Date: 2004-11-27 22:25:20


I am pretty sure it's because of my lack of skills with templates...
Still, I don't understand why I can stream a vector if it's on its own,
but not if it's stored in a boost::tuple. And it works with a std::pair!
Any hint?

#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_io.hpp>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using namespace boost;

template <typename T>
ostream& operator<<(ostream& out, const vector<T>& v)
{ copy(v.begin(), v.end(), ostream_iterator<T>(out, " ")); return out; }

template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T, U>& p)
{ return out << p.first << " " << p.second; }

int main(int, char**)
{
        vector<float> v;
        cout << v; // Works fine

        pair<vector<float>, pair<int, int> > p;
        cout << p; // Works fine

        tuple<vector<float> > t;
        cout << t; // <== WON'T COMPILE
}

Thanks,

Frank


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net