streaming to cout boost tuple composed of user defined structs
I'm trying to stream to cout a boost tuple composed of structs but I get an compilation error. According to:

http://www.boost.org/doc/libs/1_48_0/libs/tuple/doc/tuple_users_guide.html#streaming

> The global operator<< has been overloaded for std::ostream such that
> tuples are output by recursively calling operator<< for each element.

This works fine for basic types but haven't been able to make it work for user defined types. I don't know if it is enough to define the << operator for the tuple elements (in this case the struct) for this to work. Anyhow this is what I'm trying to do:

    #include "boost/tuple/tuple_io.hpp"
    #include <iostream>
 
    struct caca{
    int a;
    int b;
    }
    
    std::ostream& operator<<(std::ostream& s, caca& c)
    {
       s<<"["<<c.a<<" "<<c.b<<"]";
       return s;
    }
    
    int main (int argc, char** argv) {
    caca mojon(100,101);
    mytuple t(mojon);
    std::cout<<t<<std::endl;
    return 0;
    }


I get this error, unfortunately unintelligible to me:

    In file included from main.cpp:1:
    /usr/include/boost/tuple/tuple_io.hpp: In function ‘std::basic_ostream<_CharT, _Traits>& boost::tuples::detail::print(std::basic_ostream<_CharT, _Traits>&, const boost::tuples::cons<T1, boost::tuples::null_type>&) [with CharType = char, CharTrait = std::char_traits<char>, T1 = caca]’:
    /usr/include/boost/tuple/tuple_io.hpp:353:   instantiated from ‘std::basic_ostream<_CharT, _Traits>& boost::tuples::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::tuples::cons<T1, T2>&) [with CharType = char, CharTrait = std::char_traits<char>, T1 = caca, T2 = boost::tuples::null_type]’
    main.cpp:68:   instantiated from here
    /usr/include/boost/tuple/tuple_io.hpp:255: error: no match for ‘operator<<’ in ‘o << t->boost::tuples::cons<caca, boost::tuples::null_type>::head’
    /usr/include/c++/4.4/ostream:108: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:117: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:127: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:165: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:169: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:173: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/bits/ostream.tcc:91: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:180: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/bits/ostream.tcc:105: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:191: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:200: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:204: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:209: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:213: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:221: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:225: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/bits/ostream.tcc:119: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
    main.cpp:36: note:                 std::ostream& operator<<(std::ostream&, caca&)


Any ideas how I can achieve this?
streaming to cout boost tuple composed of user defined structs
===

I'm trying to stream to cout a boost tuple composed of structs but I get an compilation error. According to:

http://www.boost.org/doc/libs/1_48_0/libs/tuple/doc/tuple_users_guide.html#streaming

> The global operator<< has been overloaded for std::ostream such that
> tuples are output by recursively calling operator<< for each element.

This works fine for basic types but haven't been able to make it work for user defined types. I don't know if it is enough to define the << operator for the tuple elements (in this case the struct) for this to work. Anyhow this is what I'm trying to do:

    #include "boost/tuple/tuple_io.hpp"
    #include <iostream>
 
    struct caca{
    int a;
    int b;
    }
    
    std::ostream& operator<<(std::ostream& s, caca& c)
    {
       s<<"["<<c.a<<" "<<c.b<<"]";
       return s;
    }
    
    int main (int argc, char** argv) {
    caca mojon(100,101);
    mytuple t(mojon);
    std::cout<<t<<std::endl;
    return 0;
    }


I get this error, unfortunately unintelligible to me:

    In file included from main.cpp:1:
    /usr/include/boost/tuple/tuple_io.hpp: In function ‘std::basic_ostream<_CharT, _Traits>& boost::tuples::detail::print(std::basic_ostream<_CharT, _Traits>&, const boost::tuples::cons<T1, boost::tuples::null_type>&) [with CharType = char, CharTrait = std::char_traits<char>, T1 = caca]’:
    /usr/include/boost/tuple/tuple_io.hpp:353:   instantiated from ‘std::basic_ostream<_CharT, _Traits>& boost::tuples::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::tuples::cons<T1, T2>&) [with CharType = char, CharTrait = std::char_traits<char>, T1 = caca, T2 = boost::tuples::null_type]’
    main.cpp:68:   instantiated from here
    /usr/include/boost/tuple/tuple_io.hpp:255: error: no match for ‘operator<<’ in ‘o << t->boost::tuples::cons<caca, boost::tuples::null_type>::head’
    /usr/include/c++/4.4/ostream:108: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:117: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:127: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:165: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:169: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:173: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/bits/ostream.tcc:91: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:180: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/bits/ostream.tcc:105: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:191: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:200: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:204: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:209: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:213: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:221: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/ostream:225: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]
    /usr/include/c++/4.4/bits/ostream.tcc:119: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
    main.cpp:36: note:                 std::ostream& operator<<(std::ostream&, caca&)


Any ideas how I can achieve this?