मैं थोड़ी देर के साथ खेल रहा हूं, और मैंने "टेस्ट/सेमा टेम्पलेट/आश्रित-टेम्पलेट-पुनर्प्राप्ति सीपीपी" (क्लैंग वितरण में) पर ठोकर खाई है, जिसे टेम्पलेट से पुनर्प्राप्त करने के लिए संकेत प्रदान करना है त्रुटि।उलझन में टेम्पलेट त्रुटि
template<typename T, typename U, int N> struct X {
void f(T* t)
{
// expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}}
t->f0<U>();
}
};
त्रुटि संदेश बजना द्वारा उत्पन्न होने वाले:
tpl.cpp:6:13: error: use 'template' keyword to treat 'f0' as a dependent template name
t->f0<U>();
^
template
1 error generated.
... लेकिन मैं जहां वास्तव में एक कठिन समय समझ है
पूरी बात को आसानी से एक कम से कम उदाहरण के लिए नीचे छीन लिया जा सकता है कोड को वाक्य रचनात्मक रूप से सही करने के लिए template
कीवर्ड डालना चाहिए?
template<typename T, typename U, int N> struct X {
void f(T* t)
{
t->template f0<U>();
}
};
संपादित करें:: यदि आप एक संकलक की तरह लगता है इस नियम के लिए कारण स्पष्ट हो जाता है
क्या आपने इसे डालने का प्रयास किया जहां तीर इंगित कर रहा है? –
[इस] के समान (http://stackoverflow.com/questions/3691420/compiler-error-when-using-integer-as-template-parameter/) और [यह] (http://stackoverflow.com/questions/362171 9/सी-टेम्पलेट-सिंटैक्स) –