A
A.L
Does STLPort have a problem with the standard string and assignment?
I am sure I am reading something incorrectly, but I don't know what:
Here is a summary of a few functions
_Self& append(_ForwardIter __first,
_ForwardIter __last,
forward_iterator_tag)
....
/* Get the length of the data we are assigning into the string */
const size_type __old_size = size();
difference_type __n = 0;
distance(__first, __last, __n);
/* If there is there is not enough room for it, then allocate and
copy. Otherwise just copy *.
if (__old_size + __n > capacity()) {
//Allocate and copy
}
else
{
//Copy
}
Now, all of that is fine. If the string is totally empty, then
(begin() and end() are both NULL) then we should allocate and copy.
The only problem is that the capacity function looks like this:
size_type capacity() const
{ return (_M_end_of_storage._M_data - _M_start) - 1; }
So, if the data is 0, and the start is 0, then we subract one and
return it. Unfortunately, the returntype is unsigned, so this becomes
a very large number. This causes the comparision against copy to
succeed when it should fail.
What am I missing?
I am sure I am reading something incorrectly, but I don't know what:
Here is a summary of a few functions
_Self& append(_ForwardIter __first,
_ForwardIter __last,
forward_iterator_tag)
....
/* Get the length of the data we are assigning into the string */
const size_type __old_size = size();
difference_type __n = 0;
distance(__first, __last, __n);
/* If there is there is not enough room for it, then allocate and
copy. Otherwise just copy *.
if (__old_size + __n > capacity()) {
//Allocate and copy
}
else
{
//Copy
}
Now, all of that is fine. If the string is totally empty, then
(begin() and end() are both NULL) then we should allocate and copy.
The only problem is that the capacity function looks like this:
size_type capacity() const
{ return (_M_end_of_storage._M_data - _M_start) - 1; }
So, if the data is 0, and the start is 0, then we subract one and
return it. Unfortunately, the returntype is unsigned, so this becomes
a very large number. This causes the comparision against copy to
succeed when it should fail.
What am I missing?