|
Boost : |
From: Marco Costalba (mcostalba_at_[hidden])
Date: 2008-05-15 02:07:30
On Thu, May 15, 2008 at 3:06 AM, Daniel Walker
<daniel.j.walker_at_[hidden]> wrote:
>
> I've attached a file that provides a simple unary implementation of
> all this as a proof of concept and to give an idea of what the
> boilerplate would look like. It should work for both C++03 and 0x. I
> tested with gcc 4.3. If there's interest, maybe this and Marco's work
> and possible parts of Egg could be organized into something really
> useful.
>
Hi Daniel,
thanks a lot definitely there is interest, I will take a deep look
at Egg (that I don't know) and also to your polymorphic_function<>
On this I have a naive question, just to clear the things for me.
The point of Giovanni is to use a generalized callback for type
erasure of underlying function, but when you write
function<int(int,int)> f0
= functional_cast<plus(int,int)>(add_floats);
function<float(float,float)> f1
= functional_cast<plus(float,float)>(add_ints);
The fact that the poly class is "plus" it's explicit anyway. IOW
what's the difference of the above from
function<int(int,int)> f0 = plus();
function<float(float,float)> f1 = plus();
Again, in other words, does functional cast support this ?
struct g {
template <class> struct result;
template <class T>
struct result<g(T)> {
typedef T type;
};
template<class T>
T operator()(T t) { return t; }
int internal_state;
g() : internal_state(0) {}
};
function<float(float,float)> add_floats = plus();
add_floats.internal_state = 7;
function<int(int,int)> add_ints = plus();
std::cout << add_ints.internal_state; // it's 0 of course
function<int(int,int)> f0
= functional_cast<plus(int,int)>(add_floats);
std::cout << f0.internal_state; // if it's 7 then you have made
something very very interesting
Thanks
Marco
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk