Boost logo

Boost Users :

Subject: [Boost-users] [format] compilation error
From: Johan Råde (rade_at_[hidden])
Date: 2009-09-18 05:17:46


Hi,

I'm using Boost 1.38 and Visual Studio 2008.
The following code

        #include <boost/format.hpp>
        #include <ostream>
        #include <vector>

        using boost::format;
        using std::ostream;
        using std::vector;

        ostream& operator<<(ostream& os, const vector<int>& v)
        {
                os << '[';
                for(size_t i = 0; i < v.size(); ++i) {
                        if(i > 0) os << ' ';
                        os << v[i];
                }
                os << ']';
                return os;
        }

        void f()
        {
                vector<int> v;
                str(format("%1%") % v);

        }

fails to compile with the error message

        1>c:\libraries\boost\boost_1_38_0\boost\format\feed_args.hpp(100) : error C2679: binary '<<' : no
operator found which takes a right-hand operand of type 'const std::vector<_Ty>' (or there is no
acceptable conversion)
        1> with
        1> [
        1> _Ty=int
        1> ]

Why? How do I fix this?

Thank you,
Johan Råde


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