<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/80410>80410</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            explicit template instantiation wrongly checks decomposition of private members
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          schaumb
      </td>
    </tr>
</table>

<pre>
    The following code does not compile:

```cpp
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

```
<source>:25:73: error: cannot decompose private member 'a' of 'A'
   25 | template struct First<A, decltype(+[] (A &v) -> decltype(auto) { auto& [x, y] = v; return x; })>;
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVM-O-yYQfprxZbSRA_GfHHxwshuph95-L4DxOKbFxgKc3bx9BSSbZNVDe2qliGCYP9988w3COXWeiRooDlC8Z2L1o7GNk6NYpy7rTH9tfo2Eg9HafKr5jNL0hL0hh7PxKM20KE3AW8jfIb-vZZ5-clnSiadp0cIT8KPUwjn8BeyIaft7B_wjmTlvV-nxpKzzCNUBL0b1OACrge2BHxCqd-CH51w3lzaYpxNExPbbJZ0tVl1i-vZho2aPIgZlJ2AnXKzpRKevsTA_Kock3BW9QSm0XAN89IGLiG6iqSMLrHLorwttXuN2D5QRMb7Qk9aUNTEovDIzrrPyuE3XbcDK21shr9XdXcWMqyPsKQQxToUgD6vIIvBjG6juSeqAM4Y7pG4jsLpFYOUlZHgD_vFsJlZvbpkx7UuE4vAVol2jN3_HS6jNkl_tjF_3BgXeP3DYPuoOcIbtZvjRlWD8j3lh_0pJUTh3BqJJuoykDk-kvkK4R8dnJf5nHD6Jk6w19sd0PQP_zaMbzap77ISjHs0ctXoMQNkBnRdzL2wPvMXR-8UFImJkIr1RDthJJtPeisEDOwUmNm4hCYyfaSYr9Fv5t0N---RHZ1YrKbHMCuBtxUO-BJ23Qa9htO5yJbxN5W2WEFglgFVohrBtgVXf6mEFQnXE_117flCR9Q3v93wvMmq2VV7WZbUvt9nY7IhVXSHySlZlUQ31jgspRJ1zJsqh7FimGpazXc5ylu-L_bbeDH1fbLtyVxWFrOucYJfTJJTeaH2ZNsaeM-XcSk2d77Z5pkVH2sVXnLGZPjFeAmPhUbdN8Hnr1rODXa6V8-4RxSuvqaGvRSup_INhNQfNeJUm8NOa-ayvKEeSf7rXFyf067WTLlutbl51dlZ-XLuNNBOwU8h--3tbrPmDZJBcxBykGGv6KwAA__80oeTW">