I want to use an alias of std::initializer_list
instead of itself like that:
#include<initializer_list>
template< typename T >
using InitializerList = std::initializer_list<T>;
// note: candidate template ignored: couldn't infer template argument 'T'
template< typename T >
void f(InitializerList<T> list) {
}
int main() {
// error: no matching function for call to 'f'
f({1, 2, 3, 4, 5});
}
That code is fine using gcc & cl. However, using clang I get an error:
<source>:11:3: error: no matching function for call to 'f'
f({1, 2, 3, 4, 5});
^
<source>:7:6: note: candidate template ignored: couldn't infer template argument 'T'
void f(InitializerList<T> list) {
^
1 error generated.
But an direct use of std::initializer_list
compile with no error.
#include<initializer_list>
template< typename T >
void f(std::initializer_list<T> list) {
}
int main() {
f({1, 2, 3, 4, 5});
}
I tried all versions of clang from 3.4.2 to 4.0.0 and got same result. Does clang's behavior meet standard?
Answer: this is a known bug in LLVM as described by Jonas in the comments.
https://bugs.llvm.org//show_bug.cgi?id=23689
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With