|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-11-11 09:28:41
On Monday 11 November 2002 08:32 am, Alexander Nasonov wrote:
> struct less : function<bool (const arg &, const arg &)>
> {
> template<typename Arg>
> bool operator()(const Arg & a, const Arg & b) const
> {
> return a < b;
> }
> };
I like this a lot.
> Additionally, two types of control are desired:
> 1) Control over real types of arguments. It is a limitation of dynamic_any
> library that arguments must be converted to _one_ type before a call. But
> they can be of different types. Problem can be easily solved by adding
> additional arguments to the 'call' member-function:
>
> template<typename Arg>
> bool less::call(const Arg & a, const std::type_info & ta,
> const Arg & b, const std::type_info & tb) const
> {
> return a < b;
> }
I'm not sure I see why we need this functionality, but perhaps I'm not being
imaginative enough at this hour. Do you have an example where this would
help?
> 2) Controlled behavior when the call cannot be made. I propose to make it
> over 'nocall' member-function. Default handler can be implemented inside
> the 'function' as a single throw statement. Those users who wish other
> behavior can override 'nocall'.
Sounds good.
>
> How do you like it?
Very much. This is a big step toward making it easier to construct polymorphic
adaptors.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk