[gecode-users] wrapping SetVar

Kilian Sprotte ml13 at onlinehome.de
Wed Feb 7 21:13:57 CET 2007


Hi,

thanks for your help!

Am 07.02.2007 um 05:04 schrieb Guido Tack:

> Hi!
>
>> Now I need to create a SetView from my SetVar, in order
>> to access its lub with LubRanges.
>
> You do not have to use pointers to views, just use the views  
> directly. They are themselves just thin wrappers around a pointer  
> to the actual variable implementation. Allocating a view on the  
> stack costs exactly the same as allocating a pointer variable. If  
> you really want to use pointers, you could consider using the  
> pointer returned by SetView::variable(void).
>

SetView::variable(void) works for me!

>
>> // this function could be called something like
>> // LubRanges_from_SetVar
>> {
>> ...
>> SetVar* set;
>> SetView view(*set);
>> return new LubRanges ranges(view); // (this would not work I  
>> suppose....)
>> }
>
> This will work!

:) And this one two!

But concerning the SetView, when the function returns I think the  
destructor is called and then it is deallocated from the stack,  
right? This does no harm since the LubRanges is working on the  
underlying implementation.

But in general, shouldn't I be able to create an Object like SetView,  
or e.g
Gecode::Int::OffsetView with a function and return it to Lisp directly?

I imagine the case, where I could pass an Int::OffsetView to a  
propagator, freeing me from the need to create a new IntVar to only  
represent a constant addition of 1 for example.
Maybe I am even not supposed to do something like that?

Sorry about the confusion,
   Cheers,
     Kilian






More information about the gecode-users mailing list