[Patch, libstdc++/64584, libstdc++/64585] Clear basic_regex after imbue and make assign exception tolerant

Jonathan Wakely jwakely.gcc@gmail.com
Sat Apr 11 22:55:00 GMT 2015


On 11 April 2015 at 22:15, Tim Shen wrote:
> On Sat, Apr 11, 2015 at 9:10 PM, Daniel Krügler wrote:
>> 24.2.2 [iterator.iterators] requires them to be CopyConstructible and
>> CopyAssignable, these imply the two more reduced requirements.
>
> Ah I see, sorry for bothering.

You don't need to look in the standard, iterators must be move
constructible, or the whole of <algorithm> needs fixing.

Consider:

struct Container
{
  struct iterator { /*...*/ };
  iterator begin();
  iterator end();
};

Container::begin() and Container::end() return rvalues, and most
algorithms take their arguments by value, so if Container::iterator is
not move constructible this won't compile:

Container c;
std::sort(c.begin(), c.end());

Obviously this code is expected to work, so iterators must be move
constructible.



More information about the Libstdc++ mailing list