What could have been the reason for this?
Phil Edwards
phil@jaj.com
Mon Jun 3 14:40:00 GMT 2002
Some of the helper routines for insertions in vector et al go like:
an_insert_helper (......., value_type const& x)
{
value_type x_copy = x;
find the right position in the sequence
set up memory
*position = x_copy;
}
None of the pseudocode in the middle two "lines" uses x nor x_copy.
For the life of me I cannot figure out why it's done this way. 'position'
is either of iterator type, and its dereference operator returns a reference,
or of pointer type. Assigning "const reference x" to such a beast should
have the exact same semantics as assigning plain local x_copy, unless I've
forgotten a serious chunk of C++.
What would SGI have gained by using this extra copy? I don't see any
difficulties that would require the proverbial extra level of indirection.
Am I overlooking some design decision?
One of my favorite hard science fiction novels involves a society of
spacefaring traders. Their ships' libraries have accumulated thousands
of years worth of software. As a result, the most needed job on any
trading ship is "Programmer-Archaeologist," someone who can dig through
the centuries of code. I'm beginning to sympathize. :-)
Phil
--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams
More information about the Libstdc++
mailing list