[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Toon-members] Re: STL containers with TooN

From: E. Rosten
Subject: Re: [Toon-members] Re: STL containers with TooN
Date: Mon, 18 Jan 2010 13:16:22 +0000 (GMT)
User-agent: Alpine 2.00 (LSU 1167 2008-08-23)

On Wed, 13 Jan 2010, Gerhard Reitmayr wrote:

By the way, this would of course mean there will be an extra if in each 
assignment from vectors or operators.

ok, I understand that. but there is one already for the size mismatch I assume ?

Yes, but it is swithed off if you compile with NDEBUG or TOON_NDEBUG.

I implemented such a system for Vector<Resizable> which I subsequently removed.

cvs up -D 20090926

should get you there. Each allocator implements a try_resize() member. This may do 
nothing (for static and Dynamic), or it may do something 9for Resizable). This member 
is called at the beginning of operator=. Then the size checks occur. This system 
could be reinstated so that try_resize works first time on Vector<Dynamic> and 
is a noop all other times.

However, STL vector can call operator=

that is true... in this case the Dynamic solution doesn't make sense. Probably forget it and make Resizable assignable, then that should be used. that looks like the best solution to me right now :/

One other hack is available, and it is quite nasty. That is to make Vector<Resizable> only resize automatically when it is assigned from another Vector<Resizable>. That would make it work in STL containers safely, but it would otherwise behave in the normal manner.

This would introduce rather unpleasantly inconsistent bahaviour for Vector<Resizable>, but have the benefit of having Vector<Resizable> behave more like Vector<Dynamic>.

Personally, I prefer making Vector<Resizable> behave like a fully-featured resizable vector with resize on assignment working everywhere.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]