boost - C++ Adapter - For Methods With Same Name But Different Return Type -
boost - C++ Adapter - For Methods With Same Name But Different Return Type -
i've been trying find adapter solution in c++ 2 external interfaces, similar differs in homecoming types in enumerations.
enum { same_value1, same_value2 } enumtypea enum { same_value1, same_value2, different_value3 } enumtypeb class // not inherited { enumtypea method(); } class b // not inherited { enumtypeb method(); } do have thought solution can utilize wrapper phone call either interface or b?
returntype? myadapter::method() { // phone call method or b how } regards, burak
note added: i've solved problem using boost.variant
as far know not possible write function has variable homecoming type. hence recommend following:
enum returntypeenum { returntypea, returntypeb }; struct returntype { returntypeenum actualtype; union { enumtypea a; enumtypeb b; }actualvalue; } returntype myadapter::method() { returntype retval; //call method or b, whichever necessary //and build retval accordingly. homecoming retval; } c++ boost adapter
Comments
Post a Comment