std::forward_list optim for always equal allocator

Daniel Krügler daniel.kruegler@gmail.com
Mon Sep 11 05:44:00 GMT 2017


2017-09-11 7:12 GMT+02:00 François Dumont <frs.dumont@gmail.com>:
> When user declare a container iterator like that:
>
> std::forward_list<int>::iterator it;
>
> There is no reason to initialize it with a null node pointer. It is just an
> uninitialized iterator which is invalid to use except to initialize it.

While that is correct, for every forward iterator (and
std::forward_list<int>::iterator meets these requirements), it is also
required that a value-initialized iterator can be compared against
other initialized iterators, so this reduces the amount of freedom to
define a default constructor for such iterators even when used to
default-initialize. This is not meant as a showstopper argument, since
I have not fully understood of what you are planning, but just a
reminder.

- Daniel



More information about the Gcc-patches mailing list