libstdc++/10783: std::vector::reverse_iterator could be smaller

Nathan Myers ncm-nospam@cantrip.org
Fri May 23 18:05:00 GMT 2003


On Thu, May 22, 2003 at 06:42:54PM +0200, Sylvain Pion wrote:
> On Thu, May 22, 2003 at 06:39:40PM +0200, Paolo Carlini wrote:
> > I'm not a language lawyer, perhaps Nathan or others will have more to 
> > say, but it seems to me that, according to 24.4.1.1 you cannot simply 
> > remove that derivation.
> 
> I am not proposing to remove the derivation from reverse_iterator, I
> propose to remove the derivation from __normal_iterator, which is not
> standard and doesn't have these derivation requirements.

I haven't found anything in chapters 23 or 24 that requires 
std::vector<>::iterator to be derived from std::iterator<>.   
It suffices for it to supply the required members.   (I.e. Paolo's
patch looks good.)

This is a very interesting implication of the empty-base optimization:
reversible iterator definitions should not avail themselves of the 
convenience of deriving from std::iterator<>, because it makes all
the other iterator adapter instantiations wastefully big.  (I wonder
how much we use std::iterator<>, otherwise, in the library.)

This seems worth mentioning to the committee.  Maybe we can add a
(defaulted) dummy argument to std::iterator<> so that different 
derivations may have different base types, and not collide with
the empty-base optimization.

Nathan Myers
ncm-nospam@cantrip.org



More information about the Libstdc++ mailing list