Is inc function part of the library ?

Imperatorn johan_forsberg_86 at hotmail.com
Thu May 13 13:21:59 UTC 2021


On Thursday, 13 May 2021 at 12:56:49 UTC, Alain De Vos wrote:
> Writing an inc function is a fascinating voyage.
> A function on module level did not worked because it had no 
> this context.
>
> This works:
> ```
> void main(){
> ref int inc2(ref int x) return pure nothrow @nogc @safe{
> 	++x;
> 	return x;
> }
> int x=0;
> inc2(inc2(x));
> writeln(x);	
> ```
>
> The thing is i don't find the function pure.

Take a look at
https://dlang.org/phobos/core_atomic.html#.atomicOp


More information about the Digitalmars-d-learn mailing list