Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-04-09 08:48:52


--- In boost_at_y..., Doug Gregor <gregod_at_r...> wrote:
> Hello all,
> I've uploaded yet another version of any_function to the
files section at:
>
> http://groups.yahoo.com/group/boost/files/Callback/any_function-04-
08.zip
>
> I would like to solicit input from those interested in
any_function,
> especially regarding the interface & semantics. Barring major
> omissions/oversights/etc, I'll be requesting a formal review within
a few
> days.
>
> ------------------------------
> Interface summary:
>
> template<typename Result, typename Arg1, typename Arg2, ...,
typename ArgN>
> class any_function
> {
> any_function();
> any_function(const any_function&);
> template<typename Functor> any_function(Functor);
> ~any_function();
>
> any_function& operator=(const int); // assignment to zero
clears target
> template<typename Functor> any_function& operator=(Functor);
> any_function& operator=(const any_function&);
>
> void clear(); // clear out the target
>
> bool empty() const; // true if no target
> operator const void*() const; // evaluates true if non-empty
>
> Result operator()(Arg1, Arg2, ..., ArgN); // call target
> };

Looks mostly good to me from this posting, but I need to look at the
actual code yet. The only thing that jumps out is the assignment to
int. This would allow code such as the following:

any_function func(myfunctor);
func = 10; // clears out the target, but this line doesn't make sense

I also worry about possible ambiguities resulting between this
assignment and the templated assignment, though I'm not sure what
interactions could cause this. I'd lean towards eliminating this
assignment entirely, since clear will accomplish the same thing and
is more understandable in any event.

Bill Kempf


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