<div dir="ltr">Along similar lines, with the indexing model change, isn't the following outdated?<div><br></div><div>```</div><div><pre style="white-space:pre-wrap;color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",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)">-></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)">-></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)">-></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)">-></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"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></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,'Liberation Mono',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,'Liberation Mono',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)"><</span>T<span style="color:rgb(167,29,93)">></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)"><</span>T<span style="color:rgb(167,29,93)">></span>)
<span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></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)"><</span>T<span style="color:rgb(167,29,93)">></span>)
<span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></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)"><</span>T<span style="color:rgb(167,29,93)">></span>?)
<span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></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)"><</span>T<span style="color:rgb(167,29,93)">></span>?)
<span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></span>(_ <span style="color:rgb(167,29,93)">:</span> OpaquePointer<span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></span>)
<span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></span>(_ <span style="color:rgb(167,29,93)">:</span> OpaquePointer<span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></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><T>(_ <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)">-></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)"><</span>T<span style="color:rgb(167,29,93)">></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><T>(<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><T>(<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)">-></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><T>(from: <span style="color:rgb(0,134,179)">UnsafePointer</span><span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></span>, count: <span style="color:rgb(0,134,179)">Int</span>) <span style="color:rgb(167,29,93)">-></span> UnsafeBytePointer
<span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">initializeBackward</span><T>(<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)"><</span>T<span style="color:rgb(167,29,93)">></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><T>(_ <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 'assign' methods, matching 'initialize'? Should 'deinitialize' be called 'destroy', matching 'UnsafeMutablePointer'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>