-
-
Notifications
You must be signed in to change notification settings - Fork 705
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
add copy constructor to byUTF() #6900
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. 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#6900" |
fc775f9
to
1427d49
Compare
1427d49
to
448e5e2
Compare
|
Continuing to call |
Wait, wait, wait. Are you trying to say that copy constructors are supposed to replace So, you can't just copy a range and expect the behavior of |
| @@ -4270,6 +4270,19 @@ if (isSomeChar!C) | |||
| { | |||
| static struct Result | |||
| { | |||
| this(return R r) | |||
| { | |||
| this.r = r; | |||
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.
Okay. I probably need to re-read the copy constructor DIP, but this looks like it's defined to only copy the range being wrapped and not the other members. If so, then how is this range being copied properly? Also, was it the intention to make it equivalent to calling save? If so, then it's not, because it doesn't call save on the range being wrapped, and what happens then depends entirely on how that particular range is implemented (e.g. if it's a class, it's not being saved).
|
@jmdavis I think you got confused about what is happening here. This PR added two constructors, none of which are copy-constructors in the C++ sense (
All in all, implementing |
A ForwardRange's
save()function has a confusing relationship with the copy constructor. This helps clarify it.save()acts like a copy constructor, but it uses assignment semantics instead of construction semantics, carrying the seeds of bugs, besides making it impossible to callsave()on aconstobject. This PR hassave()use a constructor to construct the copy.