में initializer_list मुझे लगता है कि जैसे ही के बजाय std::initializer_list
के उपनाम का उपयोग करना चाहते:उर्फ std :: बजना
#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});
}
कि कोड जीसीसी & सीएल का उपयोग कर ठीक है। हालांकि, बजना का उपयोग कर मैं एक त्रुटि मिलती है:
<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.
लेकिन std::initializer_list
के प्रत्यक्ष उपयोग कोई त्रुटि के साथ संकलन।
#include<initializer_list>
template< typename T >
void f(std::initializer_list<T> list) {
}
int main() {
f({1, 2, 3, 4, 5});
}
मैं 4.0.0 को 3.4.2 से बजना के सभी संस्करणों की कोशिश की और एक ही परिणाम मिला है। क्या क्लैंग का व्यवहार मानक मिलता है?
यह 'जीसीसी 6.3' (http://ideone.com/pQir1C) के साथ ठीक संकलित करता है। यह clang imho में एक बग है। – Jonas
इसके बारे में एक [क्लैंग बग] (https://bugs.llvm.org//show_bug.cgi?id=23689) है। – TartanLlama