[LLVMbugs] [Bug 23689] New: Initializer list alias cannot be used in template type inferring scenarios
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu May 28 12:14:25 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23689
Bug ID: 23689
Summary: Initializer list alias cannot be used in template type
inferring scenarios
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: daniel at octaforge.org
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150528/861bef62/attachment.html>
More information about the llvm-bugs
mailing list