March 13, 2016 Creating template libraries from C++/Boost template libraries | ||||
|---|---|---|---|---|
| ||||
I recently discovered D and absolutely love it. However, I feel like I can't really be productive with it yet because of the profound lack of libraries. I understand that linking to C libraries is trivial and linking to C++ libraries is possible (eventually easy with tools like LDC'c Calypso), but I can't help but feel that doing these things beally hampers the power of the original library. This is primarily for C++, which loses all its generic programming capabilities. To wit, if I want to use a class `foo<T>`, I have to specialize it for every type I plan to use it for in D. This means having either a huge library or having super-human precognition. What I'm wondering is, is it possible to specialize this template for a C++API version of D's Object and then re-use it as a template on the D-side whilst preserving its generic programming properties. I'd imagine this would have the same limitations as using `void*` for generic programming in C, but it would at least allow the retention of class information thought Object's inheritance tree. | ||||
March 13, 2016 Re: Creating template libraries from C++/Boost template libraries | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Lyle Moffitt | On Sun, 13 Mar 2016 12:11:12 +0000, Lyle Moffitt wrote: > is it > possible to specialize this template for a C++API version of D's Object That idea would work. You probably need to define your own base class as extern(C++), though. On the plus side, that lets you add whatever you want to the interface you expose to C++. > I'd imagine this would have the same > limitations as using `void*` for generic programming in C, but it would > at least allow the retention of class information thought Object's > inheritance tree. Should do. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply