<div dir="ltr">Along similar lines, with the indexing model change, isn&#39;t the following outdated?<div><br></div><div>```</div><div><pre style="white-space:pre-wrap;color:rgb(51,51,51);font-family:Consolas,&quot;Liberation Mono&quot;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;overflow:auto;border-radius:3px;word-wrap:normal;background-color:rgb(247,247,247)"><span style="color:rgb(167,29,93)">extension</span> UnsafeBytePointer <span style="color:rgb(167,29,93)">:</span> RandomAccessIndex {
  <span style="color:rgb(167,29,93)">typealias</span> Distance <span style="color:rgb(167,29,93)">=</span> <span style="color:rgb(0,134,179)">Int</span>

  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">successor</span>() <span style="color:rgb(167,29,93)">-&gt;</span> UnsafeBytePointer
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">predecessor</span>() <span style="color:rgb(167,29,93)">-&gt;</span> UnsafeBytePointer
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">distance</span>(to <span style="color:rgb(167,29,93)">:</span> UnsafeBytePointer) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Int</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">advanced</span>(by <span style="color:rgb(167,29,93)">:</span> <span style="color:rgb(0,134,179)">Int</span>) <span style="color:rgb(167,29,93)">-&gt;</span> UnsafeBytePointer
}
</pre></div><div>```</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 9, 2016 at 3:20 PM, Joe Groff via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Regarding the UnsafeBytePointer API:<span class=""><div><br></div><div><pre style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"></pre></div><blockquote type="cite"><div><pre style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">struct</span> UnsafeBytePointer <span style="color:rgb(167,29,93)">:</span> <span style="color:rgb(0,134,179)">Hashable</span>, _Pointer {

  <span style="color:rgb(167,29,93)">let</span> _rawValue: Builtin<span style="color:rgb(167,29,93)">.</span>RawPointer

  <span style="color:rgb(167,29,93)">var</span> hashValue: <span style="color:rgb(0,134,179)">Int</span> {<span style="color:rgb(167,29,93)">...</span>}

  <span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>(_ <span style="color:rgb(167,29,93)">:</span> <span style="color:rgb(0,134,179)">UnsafePointer</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>)
  <span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>(_ <span style="color:rgb(167,29,93)">:</span> <span style="color:rgb(0,134,179)">UnsafeMutablePointer</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>)
  <span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>(_ <span style="color:rgb(167,29,93)">:</span> <span style="color:rgb(0,134,179)">UnsafePointer</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>?)
  <span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>(_ <span style="color:rgb(167,29,93)">:</span> <span style="color:rgb(0,134,179)">UnsafeMutablePointer</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>?)

  <span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>(_ <span style="color:rgb(167,29,93)">:</span> OpaquePointer<span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>)
  <span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>(_ <span style="color:rgb(167,29,93)">:</span> OpaquePointer<span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>?)

  <span style="color:rgb(167,29,93)">init</span>?(bitPattern: <span style="color:rgb(0,134,179)">Int</span>)
  <span style="color:rgb(167,29,93)">init</span>?(bitPattern: <span style="color:rgb(0,134,179)">UInt</span>)

  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">load</span>&lt;T&gt;(_ <span style="color:rgb(167,29,93)">:</span> T<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">Type</span>) <span style="color:rgb(167,29,93)">-&gt;</span> T

  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">init</span>(allocatingBytes size: <span style="color:rgb(0,134,179)">Int</span>, alignedTo: <span style="color:rgb(0,134,179)">Int</span>)

  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>(allocatingCapacity count: <span style="color:rgb(0,134,179)">Int</span>, of: T<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">Type</span>)

  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">deallocateBytes</span>(<span style="color:rgb(121,93,163)">_</span> <span>size</span>: <span style="color:rgb(0,134,179)">Int</span>, alignedTo: <span style="color:rgb(0,134,179)">Int</span>)

  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">deallocateCapacity</span>&lt;T&gt;(<span style="color:rgb(121,93,163)">_</span> <span>num</span>: <span style="color:rgb(0,134,179)">Int</span>, of: T<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">Type</span>)

  <span style="color:rgb(150,152,150)">// Returns a pointer one byte after the initialized memory.</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">initialize</span>&lt;T&gt;(<span style="color:rgb(121,93,163)">with</span> <span>newValue</span>: T, count: <span style="color:rgb(0,134,179)">Int</span> <span style="color:rgb(167,29,93)">=</span> <span style="color:rgb(0,134,179)">1</span>) <span style="color:rgb(167,29,93)">-&gt;</span> UnsafeBytePointer

  <span style="color:rgb(150,152,150)">// Returns a pointer one byte after the initialized memory.</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">initialize</span>&lt;T&gt;(from: <span style="color:rgb(0,134,179)">UnsafePointer</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>, count: <span style="color:rgb(0,134,179)">Int</span>) <span style="color:rgb(167,29,93)">-&gt;</span> UnsafeBytePointer

  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">initializeBackward</span>&lt;T&gt;(<span style="color:rgb(121,93,163)">from</span> <span>source</span>: <span style="color:rgb(0,134,179)">UnsafePointer</span><span style="color:rgb(167,29,93)">&lt;</span>T<span style="color:rgb(167,29,93)">&gt;</span>, count: <span style="color:rgb(0,134,179)">Int</span>)

  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">deinitialize</span>&lt;T&gt;(_ <span style="color:rgb(167,29,93)">:</span> T<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">Type</span>, count: <span style="color:rgb(0,134,179)">Int</span> <span style="color:rgb(167,29,93)">=</span> <span style="color:rgb(0,134,179)">1</span>)
}
</pre></div></blockquote><div><br></div></span><div>Should we also have &#39;assign&#39; methods, matching &#39;initialize&#39;? Should &#39;deinitialize&#39; be called &#39;destroy&#39;, matching &#39;UnsafeMutablePointer&#39;s API?</div><div><br></div><div>-Joe</div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div>