Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-02-20 07:01:17


From: "Gary Powell" <powellg_at_[hidden]>
> >>--------------------------------------------
> What I want to be able to do is call bind with the constructor
>
> bind (Foo::Foo(int), _1);
>
> bind (Foo::Foo );
>
> bind (template<class T>Foo::Foo(T&), _1);
>
> But the parsing is horrible. Does the above call the constructor or is it
an
> identifier? Time for another key word??
> <<--------------------------------------------------------
>
> I nominate "addressof()" It says what it means, it isn't used. While it
> may conflict with user variable names, all new keywords have this problem.
[...]

template<class T, class A1> T construct(A1 a1)
{
    return T(a1);
}

bind(&construct<Foo, int>, _1);

or, if you want polymorphism,

template<class T> struct construct
{
    typedef T result_type;
    result_type operator()() const { return T(); }
    template<class A1> result_type operator()(A1 a1) const { return T(a1); }
// impl-def number of additional overloads ;-)
};

bind(&construct<Foo>, _1);


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