• Brett Wilson's avatar
    Add base::circular_deque container. · 322a5469
    Brett Wilson authored
    This container behaves like a std::deque (minus random access insert/erase) but uses
    an array as the underlying storage. Additional details are documented in the header.
    
    When DCHECK is enabled, the iterators do extra checks to ensure they are not being
    used after container mutations.
    
    A new helper class called base::internal::ArrayBuffer is added to be the low-level storage.
    This split was inspired by WTF::Deque although the functionality is quite different: The
    added one is mostly a holder for template move and destruct helpers, while the WTF one is
    to facilitate copy-on-write and buffer sharing (which is not supported by this one).
    
    The base::void_t is moved from base::internal namespace. This C++17 emulation need not
    be strictly internal to base and once I understood how to use it, it seems quite useful.
    
    Added base::internal::is_iterator to detect if an item is an iterator. This is required
    by one of the STL deque functions but the exact implementation is not specified by the
    standard. This implementation checks for the presence of iterator_category in the
    iterator traits.
    
    Contains minor fixes to move_only_int.h testing helper and the addition to a non-movable
    copy_only_int.h
    
    Related docs by dskiba:
    https://docs.google.com/document/d/1PEuPnSW54LaoWpUIEAHobqGt9nbD2DgQ_W5DdlJOkJU
    https://docs.google.com/document/d/1YL1FORFMWo0FK0lMg7WsImnjNQ3ZpY0nK0NHGjkeHT4
    
    Future plans:
     1. Replace some std::deque uses around the code base as a smoketest.
     2. Add a presubmit to prevent additions of std::deque and std::queue.
     3. Replace the remaining uses.
    
    Change-Id: Ic1a5c804da90514782a6eae4984d916da45c0d32
    Reviewed-on: https://chromium-review.googlesource.com/582498
    Commit-Queue: Brett Wilson <brettw@chromium.org>
    Reviewed-by: default avatarVladimir Levin <vmpstr@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#491883}
    322a5469
copy_only_int.h 1.42 KB