Boost logo

Boost :

From: Giovanni Bajo (giovannibajo_at_[hidden])
Date: 2002-04-17 12:52:39


----- Original Message -----
From: "Andrei Alexandrescu" <andrewalex_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.devel
To: <boost_at_[hidden]>
Sent: Wednesday, April 17, 2002 6:52 PM
Subject: [boost] Re: Loki Functor

> Indeed, the most important reason for which I added chaining was its
> everyday usefulness. As I also wrote in the book, I decided to stop
> there before adding much more features like Chain, because they drift
> away from Functor's charter.

Right. I think that Loki::Functor Chain implementation is incomplete because
it misses a complete support for parameters (see my previous message). What
you need is chaining two generic functors with their free parameters;
forcing them to have the same free parameters (both number and types) is a
bit annoying. Check my previous message about my proposal.

> On the other point about Loki::Functor's constructor taking an object
> and a pointer to member function: the bind() function does the same,
> so it's all right as it is. I do like the constructor for the sake of
> purity: everything that can be called like a function ought to be
> accomodated as a constructor of Loki::Functor.

This makes me think, there is another entity that can be called exactly with
the same syntax of a function: a template function.
My dream:

template <class T, class U>
void Foo(T parm1, U parm2)
{ ... }

boost::bind(Foo, _1, _2)(20, 30); // call Foo<int,int>(20,30), type
deduction at call-time

I've thought a bit, and I really can't find a way to implement this. Any
idea from you all metaprogramming masters?
On the other hand, I managed to store an explicit instantiation of a
function template:

// Foo defined as above
boost::bind(Foo<int,int>, _1, _2)(20, 30);

Of course, this is useful in different conditions (my dream would be to be
able to have type deduction at call time, not at bind time). The doubt here
is that Comeau/EDG does not compile this (GCC does), since it fails deducing
the template parameters for bind. My workaround is this:

boost::bind<...... annoying list here ..... >(Foo<int,int>, _1, _2);

So, I'm fuzzy if the above is a GCC extension/bug and EDG is right, or it's
simply a bug in the latter.

Giovanni Bajo


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