-
-
Notifications
You must be signed in to change notification settings - Fork 701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix Issue 14432 - move construction for RefCounted #3171
Conversation
import core.stdc.string : memcpy; | ||
import std.exception : enforce; | ||
|
||
_store = cast(Impl*) enforce(malloc(Impl.sizeof)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't use enforce
for malloc
, use core.exception.onOutOfMemoryError.
See also #3031.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
- add RefCounted!T.this(T) which takes an RValue or a copy and use move to initialized the refcounted store - add refCounted to infer T from the argument and disable RefCounted's autoInit, also move initializes the store
{ | ||
import std.algorithm.searching : endsWith; | ||
|
||
static T empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why put this in TLS instead of the stack? Could also use typeid(T).init()
like destroy
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmh, I just copied the move code. Updated.
Also changed move to use |
Once #3139 is ready, we should specifically handle promoting a Unique!T to a RefCounted!T. |
LGTM |
Well then go ahead merge it ;). |
Ideally a third person would look over it, but it's already been 10 days so... |
Auto-merge toggled on |
fix Issue 14432 - move construction for RefCounted
Ideally we'd handle PR within a few days. |
and use move to initialized the refcounted store
RefCounted's autoInit, also move initializes the store