Patch for stl_vector.h and vector.tcc.

Dhruv Matani dhruvbird@gmx.net
Mon Feb 16 12:11:00 GMT 2004


On Mon, 2004-02-16 at 16:54, Felix Yen wrote:
> I wrote:
>  >  This defect is not a regression [...]
> 
> Sorry, I was hallucinating when I wrote that.  It is a regression, so 
> the patch is critical.  I'm trying to reproduce the problem now (and 
> not having any success).

Doesn't the test case prouce seg-faults or it's equivalent when compiled
with the older vector implementation?



> You wrote:
> *  I need some help in the test case where [...]
> 
> I don't understand your question, 

I was talking about this statement:

cout<<"Size of ABI_MAGIC_HERE is: "<<pic->size()<<endl;

Where ABI_MAGIC gets replaced by the name of the container, which is
actually the container type.


> but the performance tests use a hack 
> that lets the compiler determine whether to insert an integer or a pair 
> of them.  That's how we support std::map.  The trick involves defining 
> a class like the following:
> 
> struct value_type : public pair<int, int>
> {
>    value_type()
>    : pair<int, int>(0, 0)
>    {}
> 
>    inline value_type operator++() {return ++first, *this;}
>    inline operator int() const {return first;}
> };
> 
> Then, you add to the container by calling insert, e.g.
> 
> value_type value;
> pic->insert(pic->end(), ++value);

Neat trick! Thanks! I would have needed this information sometime or the
other.






-- 
	-Dhruv Matani.
http://www.geocities.com/dhruvbird/





More information about the Libstdc++ mailing list