> On 11. Oct 2017, at 22:11, Guillaume Lessard <[email protected]>
> wrote:
>
>
>> On Oct 10, 2017, at 01:50, Martin R via swift-users <[email protected]>
>> wrote:
>>
>> Thank you Howard for you response! However, I have a follow-up question:
>>
>> Why are UnsafeMutableBufferPointer methods which modify not the buffer
>> pointer itself, but only the pointed-to memory, mutating at all?
>
> Don’t forget that UnsafeMutableBufferPointer conforms to MutableCollection,
> and that many MutableCollection methods (such as swapAt) must be mutating.
> The BufferPointer types are unusual among Collection conformers in not having
> value semantics.
>
> Cheers,
> Guillaume Lessard
>
But an implementation of a mutating protocol method does not have to be
mutating:
protocol Foo {
mutating func test()
}
struct Bar: Foo {
func test() { }
}
let bar = Bar()
bar.test()
Isn't that a similar situation as with the subscript setter, which is mutating
in general for MutableCollection, but non-mutating for
UnsafeMutableBufferPointer?
Martin
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users