Carsten Neumann wrote: > Hi Marcus, > > some weeks back you opened ticket #200 with a patch to make boost::bind > work with OpenSG. The ticket says this is for 1.8, is that correct?
Yup. We're not using 2.0, yet. > Do you have some more information on why that patch is necessary, I've > looked over the documentation of boost::bind and could not find any > mention of the need to provide a get_pointer function. It's not in bind, but in mem_fn. My bad, but bind uses mem_fn and I tend to use bind only. Anyway, see the last paragraphs of http://www.boost.org/libs/bind/mem_fn.html#Purpose. So, mem_fn & bind (with member-function) uses that to get the a T* from a smartpointer/pointer/reference. This works for any type of smart-pointer, including user-defined, since it's using Koenig-lookup. So mem_fn() (or bind with mem-fns) does (get_pointer(p)->*(f))(args). There was some discussion (http://lists.boost.org/Archives/boost/2002/11/40483.php) on using &*p instead, but that does not allow p to be null (some smart-pointers assert on dereferencing a null pointer). > Anyway the attached test compiles, if get_pointer overloads for > FCPtr<FCPtrType, FCType> and NodePtr are added, but it crashes at > runtime in FieldContainerPtrBase::operator =. > Do you have a small example that shows how to use boost::bind correctly? These work for me. I don't use the boost::ref() that you did, though. (these two first are a bit academic, I invented them to test it) Nodes: OSG::MFNodePtr& children = *m_node->getMFChildren(); for_each(children.begin(), children.end(), bind(&OSG::Node::invalidateVolume, _1)); General fcptr: OSG::MFStateChunkPtr& chunks = *cm->getMFChunks(); typedef std::vector<const OSG::StateChunkClass*> StateChunkClasses; StateChunkClasses cs; for_each(chunks.begin(), chunks.end(), bind(&StateChunkClasses::push_back, boost::ref(cs), bind(&OSG::StateChunk::getClass, _1))); std::ostream << cs.size() << std::endl; And lastly (this was why I needed it, but I haven't run this one, only compiled it): MFTextureChunkPtr* tcs = OSG::getAttachedTextureChunks(image); for_each(*tcs, bind(&OSG::TextureChunk::imageContentChanged, _1, minx, maxx, miny, maxy, minz, maxz)); Cheers, /Marcus ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Opensg-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-core
