c++ - Templates :Name resolution:Dependent template arguments : -->can any one tell some more examples for this statement? -
this statement iso c++ standard 14.6.2.4: dependent template arguments :
a type template-argument dependent if type specifies dependent.
an integral non-type template-argument dependent if constant expression specifies value dependent.
a non-integral non-type template-argument dependent if type dependent or has either of following forms , contains nested-name-specifier specifies class-name names dependent type.
a template template-argument dependent if names template parameter or qualified-id nested-name-specifier contains class-name names dependent type.
i unable understand these points?
can 1 give examples these statements?
this understand. have marked individual code snippets in code inline marked according line numbers in op.
struct a{ void f(){} }; template<class t> struct b{}; // template argument b<t> type depdent on template parameter t (1) template<class t, class u = b<t> > struct t1{}; // template argument c value dependent on template non type parameter 'c' (2) template<class t, char c, int d = c> struct t2{}; // 2nd template argument type depdent on template parameter t (3) template<class t, void (t::*p)(void) = &t::f> struct t3{}; // template template argument b type depdent on template parameter t (4) template<class t, template<class u = t> class v = b> struct t4{}; int main(){ t1<int> t1; t2<int, 'a', 2> t2; t3<a> t3; t4<a> t4; }
Comments
Post a Comment