|
[
Permlink
| « Hide
]
Martin Sebor added a comment - 05/Nov/07 05:27 AM
Rev 590116 (http://svn.apache.org/viewvc?view=rev&revision=590116
ChangeLog:
The change to tr1/_smartptr.h removes an assertion that _C_ptr is valid. I don't know if the assert was necessary in the first place, but it probably shouldn't be removed without reason.
Also, I think the _RWSTD_ADDRESS_OF() would be easy to accidentally misuse. _RWSTD_ADDRESS_OF (int, i); // cast address of i to an int Wouldn't it make more sense for __rw_address_of to do the heavy lifting, and to write the macro to call through? That would require the free function be moved to rw/_defs.h which might not be ideal. It has the advantage that would remove requirement for the first macro parameter, which would cleanup the code just a little bit. It might also be a good idea to add an overload of __rw_address_of for const references. Also, some places in the standard have `Returns' and `Effects' clauses that say that the operator->() is supposed to return some specific thing. For example, 24.4.1.3.4 [revers.iter.opref] has an effects clause that claims `pointer operator->() const' returns &(operator*()). Of course, with that said, there is nothing that says how container iterators should behave when this situation comes up for their forward iterators. It seems to indicate that the containers should use reverse_iterator for their reverse iterator implementation, which, as mentioned above, is essentially required to not work with types that implement operator& to do something abnormal.
If we make some of these changes it will make our implementation non-compliant, which may be a bad thing. This is one of those issues where it might need to be brought up with the committee for discussion before we have a complete and satisfying solution. Of course the standards committee might have already covered this issue at one point, but if they have, they haven't documented it very well. We need to be careful here. We can't change [revers.iter.opref] or any other function that deliberately relies on the return type of operator&() being [convertible to] pointer.
As for where things should be defined: _defs.h is for macro definitions only. There shouldn't be any other definitions (types, templates, or functions). As an aside, we should be using C++ casts in favor of the C-style ones. Here's how I'd like to propose we proceed: 1) First, to simplify things, eliminate the _RWSTD_ARROW() macro. It's a workaround for a compiler limitation that none of our compilers suffers from anymore (check the generated config headers) and so this is a forward compatible change. 2) For standard container iterators define operator->() in terms of the pointer data member as opposed to in terms of operator&() and avoid having to deal with any conversion issues. 3) Leave reverse_iterator::operator->() unchanged (i.e., return &operator*()). 4) Change istream_iterator::operator->() to simply return &_C_val. 5) Change __rw_debug_iter::operator->() to simply return _C_iter. 6) Discuss how to deal with the uninitialized_xxx() algorithms. Travis, let us know if this approach sounds reasonable to you or if you see a problem.
I'm a little on the fence as to whether item 1 above really is forward compatible or not. There may be some compiler that we aren't testing that requires it, and we would be breaking compatibility there.
I don't really have a problem with letting this issue sit until 4.3 or later. I'm also open to never fixing the issue if someone can provide a reasonable argument for why you would want it to not work. Of course that may require someone to explain why the standards gurus decided to require this interesting behavior in some places. That said, if we are intent on doing something with this issue now, then I think the above is acceptable. I also have no problem deferring this issue for 4.3. It's very much a corner case. Let's see what Farid thinks about it.
As for compatibility, the [still informal] binary compatibility policy is silent on this point but I don't think we need to be concerned with hypothetical compilers when it comes to maintaining compatibility. IMO, we should only be constrained by compilers we do test and support. Err, reassigned to Farid, the author of the attached patch.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||