<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW " title="NEW --- - Initializer list alias cannot be used in template type inferring scenarios" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23689&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=xEke56NnmFsZgTHsXZrn6ixOK1azryXF4pADqYsgh7o&s=UhGj298dBJghL3VnKUhnushPDDTG5VNDB0jjKZVh0c0&e=">23689</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Initializer list alias cannot be used in template type inferring scenarios
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>daniel@octaforge.org
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Clang doesn't like when I alias std::initializer_list (using template type
alias) and use that in a function that infers its inner type. Here's an
example:
==========
#include <stdio.h>
#include <initializer_list>
template<typename T>
using IList = std::initializer_list<T>;
template<typename T>
T foo(IList<T> x) {
return *x.begin();
}
int main() {
printf("%d\n", foo({ 5, 10, 15 }));
return 0;
}
========
This wil fail with:
========
ilist.cpp:13:20: error: no matching function for call to 'foo'
printf("%d\n", foo({ 5, 10, 15 }));
^~~
ilist.cpp:8:3: note: candidate template ignored: couldn't infer template
argument 'T'
T foo(IList<T> x) {
^
1 error generated.
========
Changing it to initializer_list (i.e. not using the alias) works. When the
template type is explicitly specified, it also works (thus it's not a problem
for example in class constructors).
Regards,
Daniel</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>