Gabriel Dos Reis wrote:
| Coming to the specific issue, and *assuming* we agree about the
| usefulness of warning for signed -> unsigned, maybe we are "lucky", in
| this sense: Table 65 says *explicitely* that size_type can represent
| any non-negative value of difference_type. Thus, as I see the issue,
| we can safely cast from the latter to the former, if we want, without
| entering in the larger discussions mentioned above... What do you
| think?
My concern is for vectors whose size() exceeds
numeric_limits<difference_type>::max() -- even if we would like to avoid
the general discussion.
My understanding -- and I would like to hear of others' -- is that the
semantics description in the table 65 is a constraint on
implementations. Concretely, it means that we cannot have a vector
whose size() is numeric_limits<size_type>::max() because otherwise
the difference between end() and begin() will overflow.
That implies that max_size() would have to return
numeric_limit<difference_type>::max().
I agree with your reasoning, and indeed, this is essentially the point
which I raised to Howard, time ago ;)
However, in order not to mix different issues, I think we should try
first to resolve the much more limited issue at hand, which, I note, has
to do with *deallocation*, not with *allocation*. In the other terms, we
are *already* liberally computing difference_types, without caring much
about overflows, and we are only additionally wondering whether we can
cast those values to size_type. I think that, given Table 65, definitely
we can.
Paolo.