Jon Stewart on 22 Aug 2003 23:21:03 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [ALACPP] boost::bind and global functions? |
> Here's more code: > > typedef void (*ProcessRowFunc)(FetchRow); > > bool MyQueryResultWrapper::nextRow(ProcessRowFunc func) > { > // blah blah, get aFetchRow from Oracle... > func(aFetchRow); > } > > // read file info from oracle. This is inside an instance method on a Take o > bject > MyQueryResultWrapper wrap(aCursorLikeThingie); > while(wrap.nextRow(boost::bind(&Take::addFile, this, _1))); > > void Take::addFile(FetchRow row) > { > // process the row and add it to myself. > } > > Does this reveal the madness of my ways? I'm afraid I can't post much more of > our Super Secret Important Code in unobfuscated form... Yes, indeed it does. The return value of boost::bind is a boost::function, NOT a simple function pointer. While the returned boost::function will mimic ProcessRowFunc, in terms of calling syntax, they are very different types (for one thing, sizeof(ProcessRowFunc) != sizeof(boost::function< void, FetchRow >)). Rather than worrying about what type ProcessRowFunc is, try this: template<class _FnT> bool MyQueryResultWrapper::nextRow(_FnT func) { // blah blah func(aFetchRow); return true; } It'll work with a function pointer and with the properly parameterized boost::function. Jon -- Jon Stewart Advanced Los Angeles C++ stew1@xxxxxxxxxxx http://www.alacpp.org _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp