Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-30 14:35:55

On Wednesday 30 January 2002 12:58 pm, you wrote:
> Another way would be to make "manager" to handle everything, including
> invocation. Of course, it'll increase the cost of the call.

I'm not entirely sure how to do such a thing. To be able to invoke a routine,
we need to have all of its arguments available, and we can't synthesize
arguments. The only thing I can think of would be to pass through a set of
boost::any objects that either contain the arguments (if we're invoking) or
are empty (if we're managing). I think that falls into the "unreasonable
overhead" category :(.

> > > So, returning to the original suggestion ('bind(&my:foo, this)'
> > > optimization) - can we have it? :)
> >
> > Here's a start: by the end of this weekend, I promise to have
> > the "stateless function objects" optimization implemented, and
> > I'll try to get unbound member function pointers optimized as
> > well
> Thanks, looking forward to it!

It's done. Member function pointers aren't optimized, however, because both
MSVC and Borland refuse to cast between member function pointers (even when
one of them is to an incomplete type. grrrrr).

> Hmm.. what do you think of the following
> alteration to 14.5.5 [temp.fct]:
> 3 A non-type _template-parameter_ of a function template can be used in
> place of the function _parameter-declaration_. A _template-argument_ for a
> such _template-parameter_ can be deduced from a corresponding function call
> expression, given that it satisfies the requirements in 14.3.2.
[snip example code]

My first reaction was that this is a completely radical change that would
have horrible repercussions language-wide, but on second thought I really
like it. It'll give library designers the ability to perform partial
evaluation without forcing new syntax on the user.

I presume we're going under the assumption that matching a template parameter
is a better conversion than even an "exact match"? So for something like:

// Declare pow...
double pow(double, int); // #1
double pow(double, double); // #2
template<int N> double pow(double, N); //#3

// User code
double x; // x gets some value
pow(x, 3);

The call to pow(x, 3) would resolve to #3, because #2 is a better match than
#1 (no conversion required on the second parameter) and #3 is a better match
than #2 (because the second parameter binds to a template parameter instead
of being exact match). That feels intuitive to me.


Boost list run by bdawes at, gregod at, cpdaniel at, john at