Subject: CGAL users discussion list
List archive
- From: Andreas Fabri <>
- To:
- Subject: Re: [cgal-discuss] using a class-method callback when intersecting boxes
- Date: Thu, 11 Oct 2007 14:12:30 +0200
Matthijs Sypkens Smit wrote:
On Thursday 11 October 2007 12:59, Andreas Fabri wrote:
Hello,
Shouldn't adding
operator()( const Box &box_a, const Box &box_b )
to the class CallbackAid do it ?
I should add a precision. The callback is not passed as a reference, but
as a copy, so if your callback is not lightweight enough you need a
handle.
Thank you, Andreas. The operator indeed works. I'm not really familiar with the use of operators in c++. That's why I never considered using the function call-operator. I tried passing a class-method and its address, but all without success.
I note that it is indeed slower. Is there a reason why the callback is passed as a copy instead of a reference?
Can you clarify what you mean with 'if [...] you need a handle'? How would that work? I cannot just pass a handle to a function as a callback, since that isn't accepted, right?
First of all, we didn't invent this design, but picked it up in the
good old STL and the BGL.
You need this
class CallbackAidHandle {
CallbackAid * ptr;
public:
CallbackAidHandle(CallbackAid* aid)
: ptr(aid)
{}
void operator()( const Box &box_a, const Box &box_b )
{
(*ptr)(box_a, box_b);
}
};
andreas
- using a class-method callback when intersecting boxes, Matthijs Sypkens Smit, 10/11/2007
- Re: [cgal-discuss] using a class-method callback when intersecting boxes, Andreas Fabri, 10/11/2007
- Re: [cgal-discuss] using a class-method callback when intersecting boxes, Andreas Fabri, 10/11/2007
- Re: [cgal-discuss] using a class-method callback when intersecting boxes, Matthijs Sypkens Smit, 10/11/2007
- Re: [cgal-discuss] using a class-method callback when intersecting boxes, Andreas Fabri, 10/11/2007
- Re: [cgal-discuss] using a class-method callback when intersecting boxes, Matthijs Sypkens Smit, 10/11/2007
- Re: [cgal-discuss] using a class-method callback when intersecting boxes, Andreas Fabri, 10/11/2007
- Re: [cgal-discuss] using a class-method callback when intersecting boxes, Andreas Fabri, 10/11/2007
Archive powered by MHonArc 2.6.16.