On 02/10/21 12:29 am, Jonathan Wakely wrote: > On Thu, 30 Sept 2021 at 21:27, François Dumont via Libstdc++ > wrote: >> Here is the _Safe_iterator one. >> >> Doing so I noticed that pointer_traits rebind for __normal_iterator was >> wrong and added tests on it. > Oops, thanks! > >> For _Safe_iterator maybe I should specialize only when instantiated with >> __normal_iterator ? Or maybe limit to random_access_iterator_tag ? > Yes, I think that's a good idea, maybe only for __normal_iterator C>. I think that should cover all the cases we actually need to > support. > > And could you change the existing pointer_traits<__normal_iterator C>> partial specialization to only be valid for > __normal_iterator as well? i.e. only for __normal_iterator that > wraps a pointer (which is true for string::iterator, vector::iterator > etc.) Is the attached patch what you had in mind ? At least it is passing tests. > >> Whatever the pointer_to implementation is problematic, we can only >> produce singular iterator as I did ifor now. > Hmm, yes. I think that's OK, because I don't think anybody is actually > going to use that function. What matters is that it works with > std::__to_address for C++17 mode, and that doesn't depend on > pointer_to, so it's OK if it doesn't work usefully. > This is why I think that my patch of the unordered containers to support custom pointers is not so bad because it avoids usage of pointer_traits::to_pointer :-)