SetView::variable(void) works for me!

Ok, good. The only problem is that you can't get the pointer back to something you can use... You'd have to add another constructor to SetView that takes a SetVarImp*.



// 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.

SetView and SetVar (and all other views and vars) are nothing but wrappers around a single pointer. This pointer is never affected by any allocation or deallocation of a var or view. That's why nothing goes wrong here. And the pointer is normally kept internal because you cannot do anything useful with it - except maybe for storing it somewhere.

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?

No, you're not. You can't call a propagator with an OffsetView anyway! The posting interface for propagators only accepts SetVars (or IntVars or BoolVars). The offset is not represented in the actual variable data structures, only in the view wrapper. This is an internal mechanism for getting more propagators out of a single implementation (we wrote a paper about this, if you're interested in what can be done with views).

Cheers,
        Guido


_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to