@safe(bool)

HyperParrow via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 17 09:36:52 PDT 2017


On Thursday, 17 August 2017 at 16:32:20 UTC, bitwise wrote:
> This came to mind while working on a set of containers.
>
> [...]
> One solution could be this:
>
> struct Container(T, bool safetyOn = true)
> {
> 	static if(safe)
> 		RefCounted!(T[]) data;
> 	else
> 		T[] data;
> 		
> 	auto opSlice() @safe(safetyOn) {
> 		return Range(data, 0, data.length);
> 	}
> }
>
> A similar solution could be applied to @nogc as well.

Yeah, i like it more than 
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1012.md.


More information about the Digitalmars-d mailing list