<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91266>91266</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] Falsely rejected code for `std::unique_ptr` because `__compressed_pair` requires different types.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
SainoNamkho
</td>
</tr>
</table>
<pre>
As shown in https://godbolt.org/z/4K6q9bo3e, only libc++
```c++
#include <memory>
#include <any>
void f(std::any) {}
std::unique_ptr<decltype(f), decltype(f)*> p(f, f);
```
I've not found anywhere in the draft saying this should be rejected.
1. Why does `__compressed_pair` require the two template arguments to be the same and the `_CanBeEmptyBase` traits? If they makes it unable to compress, then an uncompressed layout is automatically produced, with no need to be explicitly rejected. And the indices used by `__compressed_pair_elem` suggest that it handles same types correctly.
2. If it is reasonable to keep the implementation of `__compressed_pair`, is it a good solution to change `unique_ptr` into use something like `conditional_t<same_as<pointer, deleter_type>, __compressed_pair<<pointer, deleter_type>, ...>`?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyElM1u4zYQx5-GvgxWkClbsg862E4ELAr00kOPBiWOJDYURyGHSdWnLyi7G2M3RQDDtobz8Z8fR6NCMINDrMX-LPZPGxV5JF__oYyj39X0MtKmJb3UpwBhpHcHxsHIPAdRnIRshGwG0i1ZzsgPQjb_CNnsfitfjy0VKOQFyNkFrGk7Ic9CnkHkTyI_iTK_fe7mu1UWxnU2agRRXCacyC-ieP7sULmHk_X7jYyGXshDYJ3EFafkI48gqrOonh5df3hEZ14jXmf2orho7CwvMwp56IU8JvG_mE6ieIb59niB1Vacf2rpsdJ3Ias3BEcMPUWnQbnlfUSPiSOPCNqrniGoxbgBeDQr5mg1tAge_8KOUWePGbcZ_DkuoAkDiDK_XjuaZo8hoL7OynhR5uDxNRqPawF-J2CcZqsYQfkhTug4AFOqkByCmhCU0-tDynhR7ozP08zLWQVM-dgrw0EUDXzvk9sCk3rBAIYhOtVaTOn-05HA8IgOlIPoPtSBVQtFBhNARaZJsemUtQvMnnTsUKfAd8MjOAKHqO8a8e_Zms6wXT6AwOmu1zhtOgwQU4F2-ZTIFS1OqY0QhwEDA4-Kk_ZROW0x3Aikaw7QkffYsV3uzGWWWjarao8q0I92XxDnm4RptpigKjbkgPr_u5bUn1mhKRiINASycY1J9EblhpX_w0yWORjHlLqDQBPymKbEmpfVsSOnTYpX9sqiuKQ2riqI4jKTcYz-NsEWGf11neLiOZl-1VZcvgzKsiz9K3NRNBtdF_pYHNUG62213eeykodqM9bHaq9Ryqov87bb747HfIdtVRb77b7FcnvYmFrmcpfv81Lm8pBXmd5Wh6o64C4_7FS1k2KX46SMzax9m9JK2ZgQItbHrSzLjVUt2rCuKik_doqQMq0uX6egb20cgtjl1gQOH2nYsF2X3EPY_gkaZQM-TBZ0pBF68gnwZ2uizKHFTqUb-eLtC6BN36NHx7fhyjbR2_qn5Wl4jG3W0SRkk8Tef77NnpIiIZsVQBCyWRn8GwAA__-yIdcy">