<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87368>87368</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Meaningless constraints (enable_if-s) on basic_string constructors
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AndreyG
</td>
</tr>
</table>
<pre>
Since the commit 76b26852b6be6e54c86741c7c80ca6b5d74eab2e some constructors of `basic_string` are "constrained" by `enable_if` which depends only on template parameters of the class `basic_string` itself. It's meaningless, and I'd say even harmful because it just slows down compilation but doesn't bring any value. For instance,
- https://github.com/llvm/llvm-project/blob/6b7b18a1a7fd37cea5f5d51569309e7ec954cefb/libcxx/include/string#L970
- https://github.com/llvm/llvm-project/blob/6b7b18a1a7fd37cea5f5d51569309e7ec954cefb/libcxx/include/string#L977
- https://github.com/llvm/llvm-project/blob/6b7b18a1a7fd37cea5f5d51569309e7ec954cefb/libcxx/include/string#L1027
(note that `_Allocator` is the template parameter of the class `basic_string`, but not the constructor).
If `_Allocator` doesn't satisfy the requirement `__is_allocator`, then compilation fails during instantiation of `basic_string` (https://gcc.godbolt.org/z/7jbdrheov), it's not SFINAE error, because substitution of the type of NTTP parameter is not invoked lazily (https://gcc.godbolt.org/z/oaWbhbve9).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMlE9v3DYQxT8N9zLwQpqVROmgg-tUhYE2KJAAPRr8M1rRpcithlpn8-kLah3baQK0veWyK4BDvuHw955idsdA1Iv6J1G_26k1TXHpb4Nd6PLLTkd76T-4YAjSRGDiPLsEstHYtDXqRlNDdWXaRlalkaYtjGp0bWVFSiMBxzlvCpyW1aS4MMQRRFNoxc48cFpcOIqmALUQCMRrpXKBrEAEfcm1FJT29ODGXPg0OTOBpRMFyxCDv0AMkGg-eZUITmpRMyW6Cm0de8X8PUmXmPy4h_skUDLMpIILR0_MAu9ABQv3AqUFVhegMwWY1DKPqwdNRq1M4BI8rpyAfXxisPEp5PGcnFfJxQB6TWAjcRAoE-gsCypc4Kz8SnsY4gIucFLBkMA7UbwTxe0NTCmdWBxuBQ4Ch6NL06r3Js4CB-_PX_5uTkt8JJMEDtpHLXBotNRlq0olR3uQhlQ91rYu66Y7FB1JMl1dGRpzqXfafPokcHDB-NWSwOF5Knj4tZPFj9OK_FFaKQt87kVgG2LKZlApU_Vw6300KsVlY4o35r7F8d9ozMhlYEJMzz57sYzAbv-svf3ej9_qvnLGKjkeL9shC_21uoVmCtdWHxw_qDfbsmia6GtsR-U8g103Xq-AJndd-r51Bbb_eB5j9sdodfRpH5ejwOGzwEE-artMFM8CuyzsrrbLF_4w3L-__RloWfJt714Mxqvm5NL6RXwb7eVE-fv9x4-_vxmvu57kwjn-SRa8-uz85b-2FtUfetJn6vKod7Y_2O7QqR31pSyxkLVscTf1ZWWqui6btut0KWtbq4pKYzrZdUofsNu5HgusiqrAsjk0ZbsvOmwKVdeWajJ1OYqqoFk5v8-wZv2dY16pb-WhaXdeafK8xTBioCfYFgViTuWl3wDX65FFVXjHiV9PSS556n97DTB4ydHEeQgvCXrDArscmG8f8at83q2L7_-33bZWWeCwXeXvAAAA___j2xNR">