c++ - Template type is not "seen" by the compiler inside a lambda -
template<typename wcf, typename wdb> void computegenericdropcount(const function<void(wdb *, int)> &func) { wcf::foreach([&](wcf *wcf) { wdb *wdb = wdb::find(wcf->sourceid); // <--- error // error c2653: 'wdb' : not class or namespace name if(wdb) func(wdb, wcf->itemcount); }); }
it's weird because seems "see" wcf
without problems, use it: wcf->itemcount
.
is there workaround or reason why happening?
don't know why doesn't work. here workaround.
template<typename wcf, typename wdb> void computegenericdropcount(const function<void(wdb *, int)> &func) { auto my_find = wdb::find; // allows lambda "capture" correct function. wcf::foreach([&](wcf *wcf) { wdb *wdb = my_find(wcf->sourceid); if(wdb) func(wdb, wcf->itemcount); }); }
Comments
Post a Comment