![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is there a specific reason why subscript_iterator doesn't have a - operator? |
#3
| |||
| |||
|
|
alan.alvarez (AT) us (DOT) army.mil wrote: Is there a specific reason why subscript_iterator doesn't have a - operator? From the ChangeLog, v2.0.0: o Removed arrow operator (->) for iterator returned by Fields, Result and Row containers. It was inherently buggy, because a correct arrow operator must return the address of an object, but the underlying element access functions in these classes (e.g. at()) return objects by value, of necessity. Therefore, this operator could only return the address of a temporary, which cannot be safely dereferenced. |
#4
| |||
| |||
|
|
Check boost.org, there are techniques to work around this problem by returning a small proxy-class or something like that. |

#5
| |||
| |||
|
|
Paul wrote: Check boost.org, there are techniques to work around this problem by returning a small proxy-class or something like that. I have a better idea. How about you prepare a patch implementing this, and we'll evaluate the concept in situ. ![]() |
#6
| |||
| |||
|
|
alan.alvarez (AT) us (DOT) army.mil wrote: Is there a specific reason why subscript_iterator doesn't have a - operator? From the ChangeLog, v2.0.0: o Removed arrow operator (->) for iterator returned by Fields, Result and Row containers. It was inherently buggy, because a correct arrow operator must return the address of an object, but the underlying element access functions in these classes (e.g. at()) return objects by value, of necessity. Therefore, this operator could only return the address of a temporary, which cannot be safely dereferenced. -- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsu...(DOT) army.mil |
#7
| |||
| |||
|
|
Would saving a std::auto_ptr in the iterator object save this problem? |
#8
| |||
| |||
|
|
alan.alvarez (AT) us (DOT) army.mil wrote: Would saving a std::auto_ptr in the iterator object save this problem? I don't see how this solves the problem. Even if it did work, it would be arm-twisting the very purpose of auto_ptr, so I think you're looking in the wrong place. auto_ptr is not a universal smart pointer; there's a very limited scope within which it makes sense. I suggest you study the 1.7.40 version with the erroneous arrow operator. Once you can see what the error is, you will be in a better position to propose fixes. I guess you should also look at the Boost stuff Paul refered to. Beware: if the fix introduces a mandatory dependency on Boost, that alone might be grounds for rejection. At the moment, all I've talked myself into are optional features that may depend on Boost. Mandatory dependencies make configuration much more complex, particularly given some of the weirdnesses of Boost itself. P.S. You keep replying to me personally. Again: keep this traffic on the mailing list. |
#9
| |||
| |||
|
|
Hi list, Alan, Warren, Definately not std::auto_ptr Try reading here for a start: http://www.boost.org/libs/utility/operators.htm#deref and http://www.boost.org/libs/iterator/d...acade.html#id2 I understand Warren's position on including Boost libraries, but usually you can just extract out the key technique from the boost header files and use it for your own purposes. The advantage of depending on Boost is that you wouldn't have to worry about making that technique work with various compilers. The disadvantage of depending on Boost is that its an extra dependency thats not terribly useful in this case. Also check out TR1, it is bits of Boost that have been approved to be included in the C++ standard libraries in the near future. the operator->() is a tricky problem, but there are solutions. Personally I'd just (*iterator).whatever() in the meantime. Paul Warren Young wrote: alan.alvarez (AT) us (DOT) army.mil wrote: Would saving a std::auto_ptr in the iterator object save this problem? I don't see how this solves the problem. Even if it did work, it would be arm-twisting the very purpose of auto_ptr, so I think you're looking in the wrong place. auto_ptr is not a universal smart pointer; there's a very limited scope within which it makes sense. I suggest you study the 1.7.40 version with the erroneous arrow operator. Once you can see what the error is, you will be in a better position to propose fixes. I guess you should also look at the Boost stuff Paul refered to. Beware: if the fix introduces a mandatory dependency on Boost, that alone might be grounds for rejection. At the moment, all I've talked myself into are optional features that may depend on Boost. Mandatory dependencies make configuration much more complex, particularly given some of the weirdnesses of Boost itself. P.S. You keep replying to me personally. Again: keep this traffic on the mailing list. |
![]() |
| Thread Tools | |
| Display Modes | |
| |