<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57797>57797</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang 15.0.0: Template type deduction fails in C++20 mode
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkl97
</td>
</tr>
</table>
<pre>
The following code fails to compile with clang 15.0.0 in C++20 mode:
```c++
#include <list>
#include <memory>
#include <string>
template<typename T, typename S>
std::list<T> mapType(const std::list<S>& /*p_values*/, const std::function<T (const S&)>& /*p_map*/)
{
return std::list<T>();
}
int main()
{
std::list<std::string> sourceList;
std::list<std::shared_ptr<std::string>> targetList=mapType<std::shared_ptr<std::string>,std::string>(sourceList,&std::make_shared<std::string,const std::string&>);
return 0;
}
```
This error occurs:
```
[user@host]$ clang++ -std=c++20 -Wall -Wextra main.cpp
main.cpp:14:56: error: no matching function for call to 'mapType'
std::list<std::shared_ptr<std::string>> targetList=mapType<std::shared_ptr<std::string>,std::string>(sourceList,&std::make_shared<std::string,const std::string&>);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:6:14: note: candidate function template not viable: no overload of 'make_shared' matching 'const std::function<shared_ptr<string> (const string &)>' for 2nd argument
std::list<T> mapType(const std::list<S>& p_values, const std::function<T (const S&)>& p_map)
^
2 warnings and 1 error generated.
```
However the code compiles fine with clang 15.0.0 in C++17 mode (-std=c++17), clang 11.0.1 in C++20 mode and with Visual Studio 2019 19.11.18 (cl 19.29) also in C++20 mode. Could this be a bug in the compiler frontend or am I missing something?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlVl2PozYU_TXk5WoQNgTCAw_ZZKNW6ttE7ePIASe4a2xkm5nOv--1-chskq3aVR9W2ggRrj8O514fH3PSzXt1bDmctZT6TagL1LrBkAlpwWmMul5IDm_Ct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