title: Contiguous iterator detection
body: <p>C++17 introduced the concept of ContiguousIterator <a href="http://en.cppreference.com/w/cpp/iterator" rel="nofollow noreferrer">http://en.cppreference.com/w/cpp/iterator</a>.
  However it doesn't seem that there are plans to have a <code>contiguous_iterator_tag</code> (in the same way we now have <code>random_access_iterator_tag</code>) reported by <code>std::iterator_traits&lt;It&gt;::iterator_category</code>.</p>
  <p>Why is <code>contiguous_iterator_tag</code> missing?</p>
  <p>Is there a conventional protocol to determine if an iterator is Contiguous?
  Or a compile time test?</p>
  <p>In the past I mentioned that <em>for containers</em> if there is a <code>.data()</code> member that converts to a pointer to <code>::value</code> type and there is <code>.size()</code> member convertible to pointer differences, then one should assume that the container is contiguous, but I can't pull an analogous feature of iterators.</p>
  <p>One solution could be to have also a <code>data</code> function for contiguous iterators.</p>
  <p>Of course the Contiguous concept works if <code>&amp;(it[n]) == (&amp;(*it)) + n</code>, for all <code>n</code>, but this can't be checked at compile time.</p>
  <hr />
  <p><strong>EDIT</strong>: I found this video which puts this in the more broader context of C++ concepts. <a href="https://youtu.be/N80hpts1SSk?t=2421" rel="nofollow noreferrer" title="CppCon 2016: Building and Extending the Iterator Hierarchy in a Modern, Multicore World">CppCon 2016: &quot;Building and Extending the Iterator Hierarchy in a Modern, Multicore World&quot;</a> by Patrick Niedzielski. The solution uses concepts (Lite) but at the end the idea is that contiguous iterators should implement a <code>pointer_from</code> function (same as my <code>data(...)</code> function).</p>
  <p>The conclusion is that concepts will help formalizing the theory, but they are not magic, in the sense that someone, somewhere will define new especially named functions over iterators that are contiguous.
  The talk generalizes to segmented iterators (with corresponding functions <code>segment</code> and <code>local</code>), unfortunatelly it doesn't say anything about strided pointers.</p>
  <hr />
  <p><strong>EDIT 2020:</strong></p>
  <p>The standard now has</p>
  <pre><code>struct contiguous_iterator_tag: public random_access_iterator_tag { };
  </code></pre>
  <p><a href="https://en.cppreference.com/w/cpp/iterator/iterator_tags" rel="nofollow noreferrer">https://en.cppreference.com/w/cpp/iterator/iterator_tags</a></p>