← Back to team overview

kicad-developers team mailing list archive

Re: About today bzr update

 

Le 16/05/2012 10:24, Lorenzo Marcantonio a écrit :
Merged from the tip. Problem of the day :P

You declared

typedef boost::ptr_vector<  LIB_ITEM>  LIB_ITEMS;

... which is an IMHO more than reasonable decision.

drawings in LIB_COMPONENT is a LIB_ITEMS.

Then in (for example) GetBoundingBox I have an issue on the

BOOST_FOREACH( const LIB_ITEM&  item, drawings )

An easy fix is to replace
    BOOST_FOREACH( const LIB_ITEM&  item, drawings )
    {
by
    for( unsigned ii = 0; ii < drawings.size(); ii++  )
    {
        const LIB_ITEM& item = drawings[ii];
in const functions.

For obscure reasons, in BOOST 1.49
    BOOST_FOREACH( const LIB_ITEM&  item, drawings )
has problems inside a const function,
and works fine when the function is not declared as const.

(at least for me with gcc 4.6.2)


... obviously because LIB_ITEM is abstract and then you can't take
a reference to it (more precisely, it wants to copy it so the copy
construction is invalid)

Shouldn't be the iteration more like...
BOOST_FOREACH( const LIB_ITEM* item, drawings ) ???

Also the ptr_vector contains *pointers* and the declaration says

T&         operator[]( size_type n );

so, shouldn't the LIB_ITEMS be declared as a collection of LIB_ITEM* ?
(not so sure about this last thing, but from what I remember about class
templates it should work that way...)




--
Jean-Pierre CHARRAS
KiCad Developers team.
KiCad Developers <kicad-developers@xxxxxxxxxxxxxxxxxxx>


Follow ups

References