boost 1.32 breaks my code 2
Ok I have an example, int f(int, int); struct X { int m_i; }; X x; int i = boost::bind(&f, 1, _1)(boost::bind(&KTstbX::m_i, _1)(x)); UNREF(i); I guess the new boost does not return ref for members (in react on a previous email). Be aware however that functions them selves can still return references. Wkr, me _________________________________________________________________ Talk with your online friends with MSN Messenger http://messenger.msn.nl/
gast 128 wrote:
Ok I have an example,
int f(int, int); struct X { int m_i; };
X x; int i = boost::bind(&f, 1, _1)(boost::bind(&KTstbX::m_i, _1)(x)); UNREF(i);
I guess the new boost does not return ref for members (in react on a previous email).
Yes, you are right. I don't quite see the point of the example, though... the inner bind is not a nested bind expression. Is this an oversimplified version? The problem is that bind( f, 1, _1 ) can't take an rvalue as a parameter. This hasn't changed. It's just that the second bind now returns the member by value by default. If you are using a reasonably conforming compiler, you can use bind<int&>(&KTstbX::m_i, _1) to get the reference.
Yes you are right, it was a simplification. We have a STL extension library here (which by the way is a good idea for boost), which applies <algortihms> to complete containers, like: template <class MapType, class Func> Func map_for_all_key(const MapType& rMap, Func func) { return detail::for_each_adapter_impl(rMap.begin(), rMap.end(), boost::bind (&MapType::value_type::first, _1), func); } template <class In, class Adapter, class Func> Func for_each_adapter_impl(In first, In last, Adapter adapter, Func func) { for (; first != last; ++first) { func(adapter(*first)); } return func; } You can now understand why it broke my code. Wkr, me
participants (3)
-
gast 128
-
gast128
-
Peter Dimov