Interfacing to const T& or const T* C++ code

2014-06-01 Thread Atila Neves via Digitalmars-d-learn
So I was mucking about with calling C++ from D yesterday and was pleasantly surprised that this worked: D: struct Foo { int i; int j; } extern(C++) void useFoo(ref const(Foo) foo); C++: struct Foo { int i; int j; }; void useFoo(const Foo& foo) { ... } In fact, omitting const

Re: Interfacing to const T& or const T* C++ code

2014-06-01 Thread bearophile via Digitalmars-d-learn
Atila Neves: D: struct Foo { int i; int j; } extern(C++) void useFoo(ref const(Foo) foo); C++: struct Foo { int i; int j; }; void useFoo(const Foo& foo) { ... } This doesn't look very safe because D const is transitive, unlike the C++ const. So in the C++ code you can mut

Re: Interfacing to const T& or const T* C++ code

2014-06-02 Thread Atila Neves via Digitalmars-d-learn
On Sunday, 1 June 2014 at 09:18:50 UTC, bearophile wrote: Atila Neves: D: struct Foo { int i; int j; } extern(C++) void useFoo(ref const(Foo) foo); C++: struct Foo { int i; int j; }; void useFoo(const Foo& foo) { ... } This doesn't look very safe because D const is transitive

Re: Interfacing to const T& or const T* C++ code

2014-06-02 Thread Kagamin via Digitalmars-d-learn
Try to report as a bug.