[Issue 13099] New: @nogc std.range.stride
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jul 11 10:32:10 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13099
Issue ID: 13099
Summary: @nogc std.range.stride
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
void main() @nogc {
import std.range: stride;
int[] a;
a.stride(2);
}
dmd 2.066beta gives:
test.d(4,13): Error: @nogc function 'D main' cannot call non- at nogc function
'std.range.stride!(int[]).stride'
Currently std.range.stride is not @nogc just because of this enforce:
auto stride(Range)(Range r, size_t n) @nogc
if (isInputRange!(Unqual!Range))
{
import std.exception : enforce;
enforce(n > 0, "Stride cannot have step zero.");
...
The given code compiles if you replace the enforce with:
immutable static exc = new Exception("Stride cannot have step zero.");
if (n == 0)
throw exc;
But look at the comment by monarchdodra in Issue 12768 .
--
More information about the Digitalmars-d-bugs
mailing list