Gavin Doughtie on 15 Aug 2003 17:18:19 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[ALACPP] container streaming, sigh


ok, how about this. I want operator<<(ostream& str, vector<string> vals)

This is my current implementation:

class Outputter
{
public:
    Outputter(ostream& str)
        :mStr(str) {}

    ostream& operator()(const string &rhs) {
        return mStr << rhs << endl;
    }

private:
    ostream& mStr;
};

ostream& operator << (ostream& str, const vector<string> & rhs)
{
    for_each(rhs.begin(), rhs.end(), Outputter(str));
    return str;
}

But I think the whole Outputter class thingie can be ditched in favor of a clever bind, which I can't seem to get right. Volunteers?

Gavin
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp