template<typename T> struct S {};
template<typename T> struct R {};
int main() {
typedef S<double> s1;
typedef S<int> s2;
typedef R<int> s3;
static_assert(xxx<s1, s2>::value,
"No, assertion must not be raised");
static_assert(xxx<s2, s3>::value,
"Yes, assertion must be raised");
}
तो, मैं xxx<s1, s2>::value
सच वापस जाने के लिए है, जबकि xxx<s2, s3>::value
संकलन समय के दौरान झूठी वापस जाने के लिए चाहते हैं।सी ++ टेम्पलेट इन्स्टेन्शियशन दौरान मूल struct/वर्ग के नाम प्राप्त
क्या सी ++ में xxx असंभव है? या, सी ++ में सैद्धांतिक रूप से संभव xxx का अस्तित्व संभव है लेकिन संभवतः किसी ने इसे अभी तक नहीं किया है?
template<
typename T,
typename V>
struct xxx;
template<
template <class> class A,
template <class> class B,
typename X,
typename Y>
struct xxx<A<X>, B<Y>> {
static constexpr const int value = false;
};
template<
template <class> class U,
typename X,
typename Y>
struct xxx<U<X>, U<Y>> {
static constexpr const int value = true;
};
नोट::
तो, 'xxx :: मूल्य' 'true' iff' t' और 'U' समान टेम्पलेट के विशेषज्ञ हैं? –
Quentin
@ क्वांटिन: हाँ :) –