nothrow function callbacks in extern(C) code - solution
anonymous via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jun 19 16:31:01 PDT 2014
On Thursday, 19 June 2014 at 22:22:33 UTC, w0rp wrote:
> I haven't yet figured out a good way to make opApply
> implementations get all of the nice qualifiers without writing
> a bunch of overloads.
I don't know how practical this is, but since attributes are
inferred for templated methods ...
struct S
{
int opApply(Dg : int delegate(ref int))(Dg dg)
{
int e;
return dg(e);
}
}
void f1() pure nothrow @nogc @safe
{
S s;
foreach(int x; s) {}
}
void f2()
{
S s;
import std.stdio;
foreach(int x; s) writeln(x);
}
void main()
{
f1();
f2();
}
More information about the Digitalmars-d
mailing list