On Wed, Mar 12, 2008 at 05:54:41PM +0100, Abdelrazak Younes wrote:
> Abdelrazak Younes wrote:
>> Richard Heck wrote:
>
>>> This got started because there was a crash that involved passing a 
>>> temporary to Paragraph::setLayout(), and I added a comment to the effect 
>>> that one ought not to do that. Then Andre suggested there must be a 
>>> better way, in particular, that maybe we could make Layout's constructor 
>>> private, etc. Unfortunately, you can't do that, because we have a 
>>> std::vector of Layout's.
>> What's wrong with a vector<Layout *> and a private Layout ctor? You just 
>> need to declare TextClass as friend in the layout class, that's all. I 
>> probably missed something...
>
> I had a look at TextClass, I think that the public typedef (LayoutList and 
> const_iterator) are not really needed. They are only used in 
> GuiToolbars.cpp and GuiDocument.cpp; we can write TextClass helper methods 
> for those cases.

Even an index-based approach (number of items and item at position i)
might be ok. This usually leads to better encapsulation but is less
use for std::algorithms...

Andre'

Reply via email to