r225594 - Don't rely on the default constructor default constructing a begin and

Chandler Carruth chandlerc at gmail.com
Sat Jan 10 17:55:01 PST 2015


On Sat, Jan 10, 2015 at 5:43 PM, Chandler Carruth <chandlerc at gmail.com>
wrote:

> Author: chandlerc
> Date: Sat Jan 10 19:43:06 2015
> New Revision: 225594
>
> URL: http://llvm.org/viewvc/llvm-project?rev=225594&view=rev
> Log:
> Don't rely on the default constructor default constructing a begin and
> end iterator for iterator_range<>. I removed this constructor because
> for some iterators (notably pointers) it left begin and end
> uninitialized. It also is an usual constraint that an iterator default
> constructs to a valid end iterator such that the pair of them for
> a valid range. In the three places where this was used in Clang,
> explicitly build the empty range from the iterators and comment on why
> default constructed iterators make sense here.
>

FYI, I've raised the possibility of making iterator_range<T> require T to
be a forward iterator (or at least require the default constructor and the
fact that default constructed iterators behave as if one-past-the-end of an
empty range), or of detecting this property on the LLVM commit where I
removed the default constructor for iterator_range... Currently, I'm
unconvinced the complexity it adds to iterator_range is worth it for the 3
places in all of LLVM and Clang (and LLD and ...) where I've found code
that used it...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150110/6c4ad3e9/attachment.html>


More information about the cfe-commits mailing list