Boost logo

Boost :

From: Marco Costalba (mcostalba_at_[hidden])
Date: 2007-10-06 11:55:26


On 10/6/07, Marco Costalba <mcostalba_at_[hidden]> wrote:
> On 10/5/07, Marco <mrcekets_at_[hidden]> wrote:
> >
> > I hope to be able to post some result, soon.
> >
>
> Waiting for Marco's code I have updated the files at
>
> http://digilander.libero.it/mcostalba/boost_overload/overload.hpp
> http://digilander.libero.it/mcostalba/boost_overload/test.cpp
>
> Now operator<<() is used instead of c'tors, this has three advantages:
>

BTW the test example now looks like:

int main()
{
    typedef boost::tuple<
        int(char)
      , double(int, char)
      , char(std::string)
      , void(std::string, std::string, std::string)
      , int()
>
    Signatures;

    boost::overload<Signatures> f;

    f << &foo2 << foo4 << foo3 << &foo1 << foo5; // in any order...

    int i = f('x');
    double d = f(123, 'x');
    char c = f("hello");
    int k = f();
    f("Hello", ", World", ", I'm Joel");

    BOOST_ASSERT(i == 123);
    BOOST_ASSERT(d > 123.455 && d < 123.457);
    BOOST_ASSERT(c == 'x');
    BOOST_ASSERT(k == 7);

    return boost::report_errors();
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk