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

    <tr>
        <th>Summary</th>
        <td>
            [libc++] Are some standard overloads of `std::pow` missing?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          frederick-vs-ja
      </td>
    </tr>
</table>

<pre>
    I'm referring to C++20/[WG21 N4868](https://wg21.link/n4868) here, because the changes of additional overloads of `std::pow` introduced in C++23 by [P1467R9](https://wg21.link/p1467r9) look defective and libc++ hasn't implemented P1467R9 yet.

In [N4868 [complex.syn]](https://timsong-cpp.github.io/cppwp/n4868/complex.syn) there were 3 explicitly specified standard overloads of `pow`:
```C++
 template<class T> complex<T> pow  (const complex<T>&, const T&);
 template<class T> complex<T> pow  (const complex<T>&, const complex<T>&);
 template<class T> complex<T> pow  (const T&, const complex<T>&);
```

And then, several additional overloads were specified in [N4868 [cmplx.over]/3](https://timsong-cpp.github.io/cppwp/n4868/cmplx.over#3), but their exact forms were not specified.

Currently, libc++ provides 4 overloads:
https://github.com/llvm/llvm-project/blob/1c26e2b6f90253efdf38a5a70d011722d4eb1216/libcxx/include/complex#L1095-L1116

If I understood correctly, only the first one is an explicitly specified overload, and the rest are additional overloads. So it seems that the remaining 2 overloads are missing.

However, when I attempted to added them during handling #110235, I found that it's very hard, if not impossible, to portably verify that these overloads are added. Because instantiating `std::complex<NonFP>` is unspecified and in some cases `std::complex<std::complex<T>>` would be instantiated when using braced-init-list due to the form of these overloads.
E.g. according to the current standard overload set, `std::pow(std::complex<float>(1.0f), {1l, 1l})` would cause `pow(const T&, const complex<T>&)` (where `T` is `complex<float>`) to be detected, which in turn instantiates (probably nonsense) `std::complex<std::complex<float>>`.

It's not clear to me
1. whether libc++ is effectively conforming now, i.e. lacking of these 2 overloads isn't observable in any conforming program, and
2. whether there's any defect in the specification of explicitly overloads (effectively unchanged since C++20, see [[complex.syn]](https://eel.is/c++draft/complex.syn)) as they possibly cause `std::complex<std::complex<T>>` to be instantiated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vt9v27oO_muUF6KGLSe285CH_ljuLTAMw70FzrMs0YlWWTIkOWn--wPKXpJ2Gc6G4QBFaksW9ZH8-JEiBL2ziBu2emCrp4UY4975TedRodfy9e4Q7r6JRevUafPMeN2Dxw6913YH0cEj4w-MP_Cc8S1bPfz1H17Al2VTNWz1xHizj3EIrLynXb497niRGW1fGd_a9BFfwx49Mv4ILUoxBoS4R5B7YXcYwHUglNJROysMuAN644RK66zKQ1Rkurwf3JFVOWgbvVOjRAXanpGV0J6ArR6-Fsuq_t_6n3AN9JlfEzLj3Cso7FBGfUAQVoHRrZzswl4Ey3gdQfeDwR5tRAXzJXDCmLH8ieX30--zJQgpMPQgHZ15y8LJEp4bkKLug7O7OzkM2U7H_dhm2jG-lcNwHC7h215b4msKnkc40k8J-DYYLXU0JwgDSt1pVBCisEp49UM0pyASgAl3lU9_cxynVYjYD0ZEZOWjNCIEeGHlJ5hRsPIxvQ7uCMB4I50N8cMm4xVle9p6SW9rVv475m9s_dldL79u_hy_axrcW0UpsmQj4AG9MLcJnjJ4SZr-QJ9-MG8ZfZ2osy3_iEEXY7wsyQUqxjESUO0B34SM0Dnfz6isixdk70j-OHqPNpoTWbiqlMG7g1YYYHnx8Myz96BnoNL1jG-NOXz_dzd49w1lZHzbGtcyvi0kr5C3VbfO-arETnVlI1aizlVeFDXnaoltwYuKDOhWvr0xvtVWmlHhpWwYLz8X-Xp197koiupdwXbwDKNV6EN0ToF03qOcfXPWnJJOddqHCM4i6ADC3q647z7TSTERADyGCMLjzexn8H8HOkJA7APEvYjzmV5oS7rLr5hCRnodgra7d8n4rztiyukjHPdo4RlEJMaTSkVH92KC0oMak5jvhVWGHhgviyLn5YrOPkPnxgRaRNCR8TrAAf0J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