• Jan Wilken Dörrie's avatar
    [base] Add IsContiguousIterator type trait · 9269f9eb
    Jan Wilken Dörrie authored
    This change implements the base::IsContiguousIterator type trait and
    makes use of it in base::span's constructor to allow construction from
    arbitrary contiguous iterators, and not just pointers.
    
    Given the lack of std::contiguous_iterator_tag in C++14, the type trait
    is especially instantiated for iterators that are known to be
    contiguous. These include pointers, and the iterators for std::array,
    std::string and std::vector<T> (for T != bool).
    
    Lastly, this change adds an implementation of std::to_address, which
    allows obtaining the underlying address from a pointer like type.
    
    TBR=dcheng
    
    Bug: 828324
    Change-Id: I00d44c5edf8d86f811b7b2d32f07fa15e084d987
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093215
    Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
    Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#816543}
    9269f9eb
contiguous_iterator_unittest.cc 10.5 KB