-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
prototype-bugSomething isn't workingSomething isn't working
Description
Thanks for this great proposal!
I was trying this at https://cppx.godbolt.org. I faced this issue that forward auto does not compile:
https://cppx.godbolt.org/z/ezPz7K
#include <iostream>
using namespace std;
auto myfun(in auto x, forward auto y) {
cout << x << endl;
y = "goodbye";
auto z = 0;
return tuple{y, z};
}
int main() {
auto [y, z] = myfun(1, string("hey"));
cout << y <<endl;
cout << z;
}Error log
<source>:13:19: error: no matching function for call to 'myfun'
auto [y, z] = myfun(1, string("hey"));
^~~~~
<source>:4:6: note: candidate ignored; expected deduced type 'auto' but got 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>'
auto myfun(in auto x, forward auto y) {
^
1 error generated.
ASM generation compiler returned: 1
<source>:13:19: error: no matching function for call to 'myfun'
auto [y, z] = myfun(1, string("hey"));
^~~~~
<source>:4:6: note: candidate ignored; expected deduced type 'auto' but got 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>'
auto myfun(in auto x, forward auto y) {
^
1 error generated.
Execution build compiler returned: 1
In comparison this compiles:
https://cppx.godbolt.org/z/66YbnT
#include <iostream>
using namespace std;
auto myfun(in auto x, forward string y) {
cout << x << endl;
y = "goodbye";
auto z = 0;
return tuple{y, z};
}
int main() {
auto [y, z] = myfun(1, string("hey"));
cout << y <<endl;
cout << z;
}or this
https://cppx.godbolt.org/z/q64YfP
#include <iostream>
using namespace std;
auto myfun(auto x, auto &&y) {
cout << x << endl;
y = "goodbye";
auto z = 0;
return tuple{y, z};
}
int main() {
auto [y, z] = myfun(1, string("hey"));
cout << y <<endl;
cout << z;
}Feel free to transfer this issue to the proper repository that contains the actual implementation.
Metadata
Metadata
Assignees
Labels
prototype-bugSomething isn't workingSomething isn't working