Thread overview
C++ Interop
Jan 05, 2018
qznc
Jan 05, 2018
Timothee Cour
Jan 06, 2018
Seb
Jan 06, 2018
Seb
Jan 06, 2018
qznc
Jan 06, 2018
Andres Clari
Jan 07, 2018
Laeeth Isharc
Jan 06, 2018
Mengu
January 05, 2018
I'm exploring [0] C++ interop after watching Walter's presentation [1].

I hit a block with classes as template parameters. This means vector<int> works, but vector<Foo> does not. D seems to map vector!Foo to vector<Foo*>. Likewise shared_ptr<Foo> is a problem. Any way to fix that on the D side? The ugly workaround is to adapt the C++ code.

I understand that this mapping makes sense for function calls because bar(Foo f) in D maps to bar(Foo *f) in C++. And C++ bar(Foo f) has no equivalent in D because classes are reference types.

On a related note, C++ interop requires to redeclare or even reimplement C++ code. Has anybody started a libcpp-in-d project? I'm looking for basics like vector and string.

[0] https://github.com/qznc/d-cpptest
[1] https://youtu.be/IkwaV6k6BmM
January 05, 2018
see also https://github.com/Syniurge/Calypso/ although I'm having lots of issues using it on OSX

On Fri, Jan 5, 2018 at 9:02 AM, qznc via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
> I'm exploring [0] C++ interop after watching Walter's presentation [1].
>
> I hit a block with classes as template parameters. This means vector<int> works, but vector<Foo> does not. D seems to map vector!Foo to vector<Foo*>. Likewise shared_ptr<Foo> is a problem. Any way to fix that on the D side? The ugly workaround is to adapt the C++ code.
>
> I understand that this mapping makes sense for function calls because
> bar(Foo f) in D maps to bar(Foo *f) in C++. And C++ bar(Foo f) has no
> equivalent in D because classes are reference types.
>
> On a related note, C++ interop requires to redeclare or even reimplement C++ code. Has anybody started a libcpp-in-d project? I'm looking for basics like vector and string.
>
> [0] https://github.com/qznc/d-cpptest
> [1] https://youtu.be/IkwaV6k6BmM
January 06, 2018
On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote:
> I'm exploring [0] C++ interop after watching Walter's presentation [1].
>
> [...]

I know about this:

https://github.com/Remedy-Entertainment/binderoo

https://github.com/dlang/druntime/pull/1802
January 06, 2018
On Saturday, 6 January 2018 at 11:17:56 UTC, Seb wrote:
> On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote:
>> I'm exploring [0] C++ interop after watching Walter's presentation [1].
>>
>> [...]
>
> I know about this:
>
> https://github.com/Remedy-Entertainment/binderoo
>
> https://github.com/dlang/druntime/pull/1802

And:

https://github.com/dlang/druntime/pull/1316

Also I think Ian (@ibuclaw) and @Razvan7 are currently working on a header generation tool from D sources to C++ headers.
January 06, 2018
On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote:
> I'm exploring [0] C++ interop after watching Walter's presentation [1].
>
> I hit a block with classes as template parameters. This means vector<int> works, but vector<Foo> does not. D seems to map vector!Foo to vector<Foo*>. Likewise shared_ptr<Foo> is a problem. Any way to fix that on the D side? The ugly workaround is to adapt the C++ code.
>
> I understand that this mapping makes sense for function calls because bar(Foo f) in D maps to bar(Foo *f) in C++. And C++ bar(Foo f) has no equivalent in D because classes are reference types.
>
> On a related note, C++ interop requires to redeclare or even reimplement C++ code. Has anybody started a libcpp-in-d project? I'm looking for basics like vector and string.
>
> [0] https://github.com/qznc/d-cpptest
> [1] https://youtu.be/IkwaV6k6BmM

is C++ support in LDC better than what we have with DMD?

i did checkout your code btw and could not enjoy it more. :)
January 06, 2018
On Saturday, 6 January 2018 at 11:20:01 UTC, Seb wrote:
> On Saturday, 6 January 2018 at 11:17:56 UTC, Seb wrote:
>> On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote:
>>> I'm exploring [0] C++ interop after watching Walter's presentation [1].
>>>
>>> [...]
>>
>> I know about this:
>>
>> https://github.com/Remedy-Entertainment/binderoo
>>
>> https://github.com/dlang/druntime/pull/1802
>
> And:
>
> https://github.com/dlang/druntime/pull/1316
>
> Also I think Ian (@ibuclaw) and @Razvan7 are currently working on a header generation tool from D sources to C++ headers.

It would be great to have std::vector and std::string out of the box in D, but putting it into druntime? Druntime is supposed to be shared among all frontends, isn't it? GCC and Clang probably do not have equivalent vector/string classes that the same D code can be used.
January 06, 2018
On Saturday, 6 January 2018 at 13:51:54 UTC, qznc wrote:
> It would be great to have std::vector and std::string out of the box in D, but putting it into druntime? Druntime is supposed to be shared among all frontends, isn't it? GCC and Clang probably do not have equivalent vector/string classes that the same D code can be used.

+1 Supporting std::vector and std::string would be a major help
January 07, 2018
On Saturday, 6 January 2018 at 11:17:56 UTC, Seb wrote:
> On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote:
>> I'm exploring [0] C++ interop after watching Walter's presentation [1].
>>
>> [...]
>
> I know about this:
>
> https://github.com/Remedy-Entertainment/binderoo
>
> https://github.com/dlang/druntime/pull/1802

Binderoo currently is Windows only.  I am talking to Ethan about extending it to work on Linux too.  Let me know if any other features helpful to add (no promises, but we can see).