-
Notifications
You must be signed in to change notification settings - Fork 251
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
[BUG] The meaning of operator=
with multiple non-this
parameters
#451
Comments
I considered just using
I thought about proposing to emit an assignment operator with a parameter such that However, if the user were to write both
then non definite first assignment becomes ambiguous (as seen at https://cpp2.godbolt.org/z/GWsKPMzYf). This also highlights two facts. First, the current Next, consider if #321 were fixed.
means it'd be ambiguous with the constructor generated from
|
The alternative is to combine these two monsters |
Unfortunately, braces prevent deduction So perhaps we should just lose the braces |
Here's an example of current vs. proposed (https://cpp2.godbolt.org/z/5vosWPW5n):
Unfortunately, for ranges, the containers use |
Title: The meaning of
operator=
with multiple non-this
parameters.Description:
An
operator=
with multiple non-this
parametersdoesn't work with non definite first assignment.
Looking at #449, it seems like we expect it to work.
I think that is consistent with https://github.com/hsutter/cppfront/wiki/Cpp2:-operator=,-this-&-that#misc-notes's
Besides #449, further integration is also the objective of #368, and perhaps also of #409.
#321 is another such issue, but
= (...)
is intended for anstd::initializer_list
parameter.Minimal reproducer (https://cpp2.godbolt.org/z/q1WvTaEnM):
Commands.
cppfront -clean-cpp1 main.cpp2 clang++17 -std=c++2b -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp
Expected result:
As you can see below,
cppfront
currently lowers toa Cpp1 assignment operator with multiple arguments, which is ill-formed.
In order for this to work, it'd have to be lowered to a Cpp1
cpp2_assign
overload(inspired from the C++ standard library containers
assign
member functions):Here's where it gets contentious with #321.
Cpp2
a = (x, y)
would have to choose betweenCpp1
a = {x, y}
andCpp1
a.cpp2_assign(x, y)
.Actual result and error:
Cpp2 lowered to Cpp1.
The text was updated successfully, but these errors were encountered: