Closed
Description
The following code snippet is rejected with libc++ (Godbolt link):
#include <utility>
#include <type_traits>
// note that *+[]{} dereferences a function pointer converted from the lambda expression
static_assert(std::is_same_v<decltype(std::pair{0, *+[]{}}), std::pair<int, void(*)()>>);
It seems that the related implicit deduction guide synthesized from the constructor (pair(const T1&, const T2&) -> pair<T1, T2>
) should be excluded by SFINAE mechanisms before instantiating invalid pair<int, void()>
, and the decaying explicit deduction guide (pair(T1, T2) -> pair<T1, T2>
) should work.
But libc++ currently makes the instantiation a bit too eager, and then causes hard error. I've roughly verified that this can (and perhaps should) be fixed within the library implementation.