|
Boost : |
From: Geurt Vos (G.Vos_at_[hidden])
Date: 2001-05-03 02:26:24
Idea 1:
Support for 0 (and only 0) assignment could still be
considered, it does however require a change in the
interface. Here's the idea: 'function' defines an empty
class in its private section, and adds an assignment
operator which takes a pointer to this class. Now the
user can _only_ assign 0 to it. Here's an example:
class function {
class assign0 { };
public:
function& operator=(const assign0 *)
{
clear();
return *this;
}
};
Problems arise when there's an assignment operator
which has a parameter that could also be of type
'int', because then 0 assignment will use that
operator. In function's case, this means that the
assignment operator template has got to go:
template<typename Functor>
function& operator=([const] Functor [&]f)
Idea 2:
function is there to take either a function or a
functor, while bind can be used to turn a member
function into a functor. I was just wondering,
wouldn't it be easier (and maybe even more
consistent) if 'bind' could take either a function
or a member function, and 'function' only functors?
Geurt
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk