c++ - How to typecast wxObject to wxVariant? -
i have map of wxobject..but want typecast wxvariant.
void mwdataviewtable::initcolumnvalues(wxstring targetcolumn,wxstring sourcecolumn , std::map<wxobject,wxobject> srctargetvalue) { wxvariant srcvalue; wxvariant tgtvalue; int srccolumnpos = getcolumnposition(sourcecolumn); int tgtcolumnpos = getcolumnposition(targetcolumn); int rows = m_rowdatalist.size()-1; //without header for(int i=0;i< rows;i++) { getvalue(srcvalue,i,srccolumnpos); tgtvalue = (wxvariant)srctargetvalue[srcvalue] ;// typecasting setvalue(tgtvalue,i,tgtcolumnpos/*toggle-column*/); } }
in highlighted line doing typecasting..but giving me error says "error 1 error c2678: binary '<' : no operator found takes left-hand operand of type 'const wxobject'" error coming in xstddef.h file. dont have idea why happening or if typecasting wrongly. please..!
in std::map
, key values used sort , uniquely identify elements
.
in code both key , value of wxobject
type. wxobject
class doesn't seems overload less operator method ( have no idea these wx objects are).
std::map
requires less operator
method perform comparison required sorting key values. should either pass own comparison function std::map compare 2 wxobjects.
the template container std::map takes compare function third agument.
template < class key, // map::key_type class t, // map::mapped_type class compare = less<key>, // map::key_compare class alloc = allocator<pair<const key,t> > // map::allocator_type > class map;
compare binary predicate have follwing definition in case:
bool mycompare( const wxobject& , const wxobject&) { \\compare logic returns true or false }
you can have own map using compare method:
typedef std::map<wxobject,wxobject,&mycompare> mymap; mymap srctargetvalue;
Comments
Post a Comment