Bug 4783 – atomicOp!"^^" doesn't work b/c it doesn't have access to std.math

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-09-01T07:34:00Z
Last change time
2016-10-08T21:04:47Z
Assigned to
sean
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2010-09-01T07:34:24Z
import core.atomic; void main() { int num1 = 1; int num2 = 1; int res = atomicOp!"^^"(num1, num2); } Errors: d:\dmd2\windows\bin\..\..\src\druntime\import\core\atomic.di(96): Error: must import std.math to use ^^ operator d:\dmd2\windows\bin\..\..\src\druntime\import\core\atomic.di(6): Error: template instance core.atomic.atomicOp!("^^",int,int) error instantiating
Comment #1 by clugdbug — 2010-09-01T07:55:12Z
That's correct. You need to import std.math if you want to use ^^.
Comment #2 by clugdbug — 2010-09-01T07:59:05Z
(In reply to comment #1) > That's correct. You need to import std.math if you want to use ^^. Oh sorry. Misunderstood. Yes, ^^ should not be used anywhere in core.*
Comment #3 by dsimcha — 2010-09-01T08:10:51Z
Then if ^^ isn't going to be usable w/o importing std.math anytime soon, I guess we need to get rid of it from core.atomic.
Comment #4 by dsimcha — 2010-09-01T08:38:37Z
...or, since the whole thing is based on doing the operation and CASing back the result, we could make a version of atomicOp that takes an arbitrary lambda expression.
Comment #5 by clugdbug — 2010-09-01T11:03:58Z
(In reply to comment #3) > Then if ^^ isn't going to be usable w/o importing std.math anytime soon, I > guess we need to get rid of it from core.atomic. Yes. Something so high level has no business being in core. pow() for floating point exponents is a *huge* function.