-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
explicit template instantiation wrongly checks decomposition of private members #80410
Comments
@llvm/issue-subscribers-clang-frontend Author: Bela Schaum (schaumb)
The following code does not compile:
template<class T, class Mb>
struct First { void f(); };
struct A {
A();
private:
int a; // probably not this easy to calculate the first member's type.
int b;
};
// compilation unit 1
A::A() {
// can use decomposition
First<A, decltype(+[] (A &v) -> decltype(auto) { auto& [x, y] = v; return x; })> f1;
f1.f();
}
// compilation unit 2
template<class T, class Mb>
void First<T, Mb>::f() {}
template struct First<A, decltype(+[] (A &v) -> decltype(auto) { auto& [x, y] = v; return x; })>; // error It should based on the C++ standard: https://eel.is/c++draft/temp.spec#general-6
|
Note no implementation accepts this code as well-formed: https://godbolt.org/z/x5brEYsW4 and this is expected as per dcl.struct.bind p5 which says:
|
@shafik // compilation unit 1
A::A() {
First<A, decltype(+[] (A &v) -> decltype(auto) { return v.a; })> f1;
f1.f();
}
// compilation unit 2
template<class T, class Mb>
void First<T, Mb>::f() {}
template struct First<A, decltype(+[] (A &v) -> decltype(auto) { return v.a; })>; As I linked, Please reopen the issue. |
CC @zygoloid do you believe this was meant to be supported? It looks like it came in via: https://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0692r1.html but it is pretty bare bones wrt examples. The second examples the OP provided has mixed support: https://godbolt.org/z/1v4zq5a3T |
@shafik can you reopen it until a final decision is made? |
The following code does not compile:
It should based on the C++ standard: https://eel.is/c++draft/temp.spec#general-6
godbolt
The text was updated successfully, but these errors were encountered: