#3 SegmentMap.erase(it) does not return iterator type

closed-fixed
5
2003-11-01
2003-08-28
Frank An
No

Line 48 of index.cpp:
it = SegmentMap.erase(it);

The map.erase function does not return iterator type in
STL.

Discussion

  • Matt Beard

    Matt Beard - 2003-08-28
    • assigned_to: nobody --> matt-beard
     
  • Matt Beard

    Matt Beard - 2003-10-16
    • assigned_to: matt-beard --> stuart_hc
     
  • Stuart Cunningham

    Logged In: YES
    user_id=692703

    Fixed in index.cpp revision 1.5.

    ISO C++ specifies that the erase method does not return an
    iterator. Josuttis ("The C++ Standard Library" section
    6.6.2) remarks that having an interator returned pointer to
    the next element would be useful, but that the decision was
    made not to provide such functionality since it may be
    wasteful to compute the next element if it is not going to
    be used.

    The following idiom is presented by Josuttis as being a
    useful idiom for erasing an element and have the iterator
    point to the next element, and it is what MXFlib has adopted:
    SegmentMap.erase(it++);

    Luckily, this usage behaves correctly under the non-ISO C++
    compiler MSVC.

     
  • Stuart Cunningham

    • status: open --> closed-fixed