इस उदाहरण (also available on wandbox) पर विचार करें:सी ++ 17 का कटौती 'ऑटो' गैर-प्रकार 'टेम्पलेट' पैरामीटर पैटर्न-मिलान टेम्पलेट स्पष्ट गैर-प्रकार पैरामीटर के साथ कर सकते हैं?
template <template <auto> class>
void test() { }
template <int>
struct X { };
पर clang++
4.0 (ट्रंक) परिणाम एक संकलन त्रुटि में test<X>()
का दृष्टांत की कोशिश:
error: no matching function for call to 'test'
test<X>();
^~~~~~~
note: candidate template ignored:
invalid explicitly-specified argument for 1st template parameter
void test() { }
मेरे प्रारंभिक धारणा/अंतर्ज्ञान था कि test
का उपयोग किसी भी प्रकार के template
से गैर-प्रकार पैरामीटर होने के लिए किया जा सकता है।
हालांकि, निम्नलिखित कोड स्निपेट सफलतापूर्वक संकलित:
template <template <auto> class>
void test() { }
// vvvv
template <auto>
struct X { };
इस इरादा है? P0127R2 में कुछ भी निर्णायक नहीं मिला।
शीर्षक में, क्या आपका मतलब "घटाया गया" था? –