c++ - How to disambiguate two instances of template classes with the same template parameter name -
i'm stuck issue , i'm not sure how phrase one-liner. issue templates. here situation: in code have 2 classes same template parameters:
template< typename templt_prm1, typename templt_prm2> class myc_a; template< typename templt_prm1, typename templt_prm2> class myc_b;
now 1 of functions of class myc_a receives argument of type myc_b , that's issue i'm facing is:
template< typename templt_prm1, typename templt_prm2> class myc_a { private: //.... public: void foo( myc_b<templt_prm1, templt_prm2> & binst ) { //.... } };
so instantiate object of type myc_a , object of type myc_b. here instantiation:
myc_a<myc_c, myc_d> myc_a_inst; myc_b<myc_e, myc_f> myc_b_inst; myc_a_inst.foo( myc_b_inst);
this gives me error saying function definition not found. meaning compiler looking void foo( myc_b < myc_c, myc_d > ) , cannot find it. instead myc_b object instance of type myc_b< myc_e, myc_f >.
this believe coming fact template parameters both classes myc_a , myc_b same , cannot change.
any suggestion on how solve issue appreciated.
btw, tried following no luck.
template< typename templt_prm1_b, typename templt_prm2_b> void foo( myc_b<templt_prm1_b, templt_prm2_b> & binst )
you have created myc_b_inst typenames myc_e & myc_f. in function foo parameter passed uses typenames myc_c & myc_d (if don't @ definition of function. used same typenames class myc_a uses, in case, myc_c & myc_d). parameters don't match. possible reason error. try :
myc_b<myc_c, myc_d> myc_b_inst;
instead of
myc_b<myc_e, myc_f> myc_b_inst;
& see results.
Comments
Post a Comment