|
Boost : |
From: Marco (mrcekets_at_[hidden])
Date: 2007-10-05 08:24:25
On Tue, 02 Oct 2007 21:15:06 +0200, Marco Costalba <mcostalba_at_[hidden]>
wrote:
> On 10/2/07, Marco <mrcekets_at_[hidden]> wrote:
>>
>> However your last changes makes the code too complicated, IMO.
>> I made up a metafunction called wrapper that should do the work.
>>
>
> Yes your metafunction is nice but I wanted to reuse the same
> 'do_compose' struct already used for getting the linear hineritance
> adding only a couple of lines (2 in the primary template, 1 in the
> specialization).
>
> Your is a general metafunction wrapper, my hack is very tailored for
> this task only.
>
> Marco
I see, I tested your code and it works fine. :-)
In the meanwhile, I'm trying a different approach.
I would like to be able to deduce the signature of a functor without the
need of using index.
example:
int foo1(char )
{
return 123;
}
double foo2(int, char)
{
return 123.456;
}
int main()
{
overload<int(char ), double(int, char )> f;
f = &foo1; // no index needed
f = &foo2; // the right assignment
// is achieved by deducing
// the argument signature
int i = f('x');
double d = f(123, 'x');
BOOST_ASSERT(i == 123);
BOOST_ASSERT(d > 123.455 && d < 123.457);
return boost::report_errors();
}
this is enough simple when the argument is a function pointer but can be
more complex in other cases.
I hope to be able to post some result, soon.
Kind Regards,
Marco Cecchetti
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk