Andre Poenitz <[EMAIL PROTECTED]> writes:

| On Mon, Nov 22, 2004 at 12:33:23PM +0100, Lars Gullik Bjønnes wrote:
>> 
>> I am trying to make the inset hierarchy more immune to splicing and
>> wrong usage.
>> 
>> In mathed this construct is used
>> 
>>    *this = SomeClass(foo);
>
| Where? In fact, if this is Cursor/DocIterator code which retains anchor
| information over this assignment, splicing might be intended. 
>
>> (or the variant this->operator(SomeClass(foo)) )
>> 
>> My method of avoiding splicing and wrong usage does not like this very
>> much... so I have replaced this with:
>> 
>>    this->~SomeClass();
>>    new (this) SomeClass(foo);
>> 
>> Does this work as intended? Or am I just way off?
>
| Maybe.

I just had a look in my books and Mr. Sutter calls this the
 "anti-idom" and says to never use it :-)

Just to explain what I am trying to do: I am trying to setup the whole
inset hierarchy so that we avoid wrong usage, slicing in particular.
(I wrote splicing earlier, but really meant slicing.)

What I am going to do first is to make InsetBase::clone use the NVI
 pattern, and make the copy constructor protected.

(And assert on some typeid checking takes care of the rest.)

| However, I certainly do not want do have explicit destructor
| calls and placement new in my code unless it is absolutely needed.

Oh I agree. 

But I also think that code like 

"*this = SomeClass(foo)"

of

"this->operator=(SomeClass(foo))"

is bad.

>> (the best would of course be if neither of these constructs were used,
>> and that we had more simple code in the first place)
>
| Sure. A 'setCursorButNotAnchor' method might do the same.

Right. The actuall code in question is not from Cursor or from the
DocIterator but from f.ex. the read function in math_hullinset.

-- 
        Lgb

Reply via email to