|
Boost : |
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2006-05-02 08:53:51
I'd like to use boost::function to wrap (pointer to) function to pass to
template functions that expect function objects. I'm just wondering,
though, if using boost::function wrapper will introduce additional overhead
into the function call?
example:
template<typename in_t, typename out_t, typename func_t>
inline void apply (in_t const& in, out_t out, func_t const&f) {
typename boost::range_const_iterator<in_t>::type i = boost::begin (in);
typename boost::range_iterator<out_t>::type o = boost::begin (out);
for (; i != boost::end (in); ++i, ++o)
*o = f (*i);
}
template<typename in_t, typename out_t>
inline void phaseDouble (in_t const& in, out_t &out) {
apply (in, out, lvalue_cast (boost::function<typename
boost::range_value<out_t>::type (typename boost::range_value<in_t>::type)>
(some function)));
}
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk