मैं टेम्पलेट मेटा प्रोग्रामिंग में मेरे रास्ते महसूस कर रहा हूँ, धीरे धीरे और मुझे यकीन है कि निम्नलिखित लागू करने के लिए कैसे नहीं कर रहा हूँ के आधार पर:C++ टेम्पलेट विशेषज्ञता संकलन समय मूल्य
// hpp file
enum MyEnum { Alive = 0, Dead };
class A {
public:
template<typename T, typename O, MyEnum ls>
static int Register();
};
// elsewhere in the code...
A::Register<IType1, Type1, Dead>();
संकलन समय मैं क्या पता चल जाएगा पर enum मान तीसरा टेम्पलेट प्रकार है (संकलन-समय invariant), या तो मृत या जीवित। यह रजिस्टर समारोह के लिए दो शरीर को परिभाषित करना संभव तरह कुछ है,:
// desired hpp file
template<typename T, typename O, Alive>
int Register();
template<typename T, typename O, Dead>
int Register();
// corresponding desired .inc file
template<typename T, typename O, Alive>
int Register() { // Alive specific implementation ... }
template<typename T, typename O, Dead>
int Register() { // Dead specific implementation ... }
मैं पर एक नज़र ले लिया है: C++ Template Specialization with Constant Value
लेकिन मैं यह पता लगाने की कैसे इसे लागू करने के लिए करने में सक्षम नहीं किया गया है यह स्थिति।
सही काम करता है! धन्यवाद पब्बी – Short