-
-
Notifications
You must be signed in to change notification settings - Fork 706
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 18913 - Cannot move static array of non-copyable type #6810
Conversation
|
Thanks for your pull request and interest in making D better, @edi33416! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + phobos#6810" |
|
While working at this, I've noticed that |
std/algorithm/mutation.d
Outdated
| // Primitive data (including pointers and arrays) or class - | ||
| // assignment works great | ||
| target = source; | ||
| } |
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.
I would write the whole thing as:
static if (is(T == struct))
{
// ...
}
else static if (isStaticArray!T)
moveEmplaceAll(source[], target[]);
else
target = source;
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.
Moved the code inside else static if.
Can't use moveEmplaceAll as source[] fails the isInputRange check
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.
Yes, unfortunately the isInputRange constraint is too strict for move[Emplace]{All|Some} functions, as a range, whose elements are not copy-able is the primary use-case for move-ing.
If we adjust isInputRange like so
@@ -168,7 +168,10 @@
enum bool isInputRange(R) =
is(typeof(R.init) == R)
&& is(ReturnType!((R r) => r.empty) == bool)
- && is(typeof((return ref R r) => r.front))
+ && (
+ is(typeof((return ref R r) => r.front)) ||
+ is(typeof((return ref R r) => &r.front()))
+ )
&& !is(ReturnType!((R r) => r.front) == void)
&& is(typeof((R r) => r.popFront));all tests pass.
5df2b9b to
a3fdf76
Compare
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.
Looks good, we can revisit the IsInputRange question in the future.
No description provided.