|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2006-09-14 14:33:35
Brian Allison <brian_at_[hidden]> writes:
> David Abrahams wrote:
>
>>"Peter Dimov" <pdimov_at_[hidden]> writes:
>>
>>
>>
>>>No, a singular iterator is not a valid object and it fulfills no
>>>invariants.
>>>
>>>
>>
>>That's arguable. From my POV, if it's in a state that a legal program
>>can create, it's within the invariant by definition.
>>
>>
>>
>
> Then (if I read you correctly) even undefined behavior is within the
> invariant?
No, invariants are about state and UB is about behavior. Behaviors
don't fall inside or outside of states.
> Or have I been misunderstanding that legal programs can cause UB?
I don't understand the question, sorry.
When a program causes undefined behavior, that falls into the category
I'm calling "illegal program." I don't just mean those programs that
can be diagnosed as illegal by the compiler.
> I've always considered that UB is to be treated as "not maintaining
> the invariant but it's not my fault".
By whom?
> But then, whether we consider UB within the invariant (and hence
> that an iterator is by definition always within the invariant) or
> whether we consider UB outisde of the invariant but one which
> doesn't break correctness (and hence that unassigned iterators are
> not capable of being within/outside of an invariant)....
>
> ... is there any practical difference between those two points of view?
Sorry, this whole behavior-within/without-the-invariant concept
doesn't make any sense to me. It's probably just my too-literal mind
at work, but if you could rephrase or explain maybe I could answer.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net