mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
std.traits: use assumePurein the public example
This commit is contained in:
parent
18c424816a
commit
c1c6c80909
1 changed files with 13 additions and 0 deletions
13
std/traits.d
13
std/traits.d
|
@ -2446,6 +2446,19 @@ if (is(T == function))
|
||||||
enum attrs = functionAttributes!T | FunctionAttribute.pure_;
|
enum attrs = functionAttributes!T | FunctionAttribute.pure_;
|
||||||
return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t;
|
return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int f()
|
||||||
|
{
|
||||||
|
import core.thread : getpid;
|
||||||
|
return getpid();
|
||||||
|
}
|
||||||
|
|
||||||
|
int g() pure @trusted
|
||||||
|
{
|
||||||
|
auto pureF = assumePure(&f);
|
||||||
|
return pureF();
|
||||||
|
}
|
||||||
|
assert(g() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
version (unittest)
|
version (unittest)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue