From: jkharris01 (john.harris_at_[hidden])
Date: 2002-02-20 18:15:57
Should bind() be extended to include binding to member data? If it
already allows convenient binding to member functions, wouldn't
member data be a natural extension?
Perhaps the operator() of the class resulting from such a bind would
return a reference to the member data.
I've run this by the author of boost::function, Douglas Gregor
(privately), and he thinks it would be a useful addition.
The specific problem that got me thinking about this is that I
couldn't find an easy way to make a predicate compare only
the ".second" member of a pair, as in a map lookup by value:
typedef std::map<int,float> map_t;
// find the map entry whose value is 3.14
void findpi(const map_t& themap)
My solution to this, by the way, goes like this:
template<typename R, typename T>
MemData_t(R T::* pmd_)
const R& operator()(const T& inst_)
R T::* pmd; // ptr to member data
template <typename T, typename R> boost::function<bool,T>
member_equal(R T::* pmd_, R stator_)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk