I have a map where the value is a weak pointer. This works: While I can write this:
for_each( IFoo::foo_wptr obj, objects | range::map_values ) {
IFoo::foo_ptr myObj = obj.lock();
if( myObj ) myObj->notify();
}
I'd much rather have a new range that transforms to a locked shared pointer. Something like this:
for_each( IFoo::foo_ptr obj, objects | range::map_values | range::locked ) {
if( obj ) obj->notify();
}
however, I've been unable to figure out what that transform should look like; or if it should even be a transform.
Does anyone have an idea? I'm convinced this pattern may quite common.