Formal review of std.buffer.scopebuffer

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Mar 16 16:50:46 PDT 2014


On 3/16/14, 3:47 PM, David Eagen wrote:
> I've started using it in a project to replace a simple dynamic array
> buffer and so far it has fit my needs very well. One thing I ran into
> was a method in the project's API that has this signature:
>
> const(ubyte[]) foo() const
>
> I couldn't return a slice from ScopeBuffer directly because of the
> const. I resolved it by changing opSlice's signature in ScopeBuffer to
> this:
>
> @system inout(T[]) opSlice() inout
>
> So there are two questions:
>
> 1.) Is this a good way to resolve the problem or am I doing something
> horribly wrong?
> 2.) Assuming this isn't horribly wrong should ScopeBuffer use inout like
> this?

good way, it should -- Andrei



More information about the Digitalmars-d mailing list