best D way to port C style array of void*
estew
estewh at gmail.com
Tue Feb 5 19:16:17 PST 2013
Hi All,
I've some old C code which I'm porting to D. It's a learning
exercise so I don't want to just wrap the C lib.
I have an array of void* and an array of callbacks that take
void* pointers for user data.
I'm wondering what is a good way to port this into D and avoid
the void*. My C++ version uses std::function<> for the callbacks
and functors. I'm using std::vector<boost::any> For the array of
void*.
Maybe it's not the best approach but it's my best efforts. For
the D port I'd like to improve on the C++ approach and I'd love
to know a better way to do it.
* Could I replace the boost::any with an array of Variant from
std.variant?
* Can I assign a struct with opCall() to a function pointer,
similar to how std::function<> can take a struct with an
operator().
* Should I forget functors and use a callback that takes a
std.variant (or whatever the boost::any like thing in D is)
instead of void*?
* What would be the best approach do you think to replace use of
void* like this.
Thanks,
Stewart
More information about the Digitalmars-d-learn
mailing list