question about call cpp class constructer without new , and define cpp delegate
Rémy Mouëza
remy.moueza at gmail.com
Thu Jun 27 17:00:01 UTC 2019
On Thursday, 27 June 2019 at 05:57:49 UTC, evilrat wrote:
> On Thursday, 27 June 2019 at 05:37:08 UTC, ChangLoong wrote:
>> If I want call cpp class constructer without new method, is
>> there a way to do that ?
>
> If what you really want is to actually allocate using C++ new
> operator from D, then that is very problematic and not portable
> even across compilers on same OS.
>
> If C++ side has poor design around this specific issue and
> expects passed object to be delete'd (using the C++ delete
> operator) later then you are in trouble. In that case you have
> to make simple wrapper on C++ side to be able to call
> new/delete from D.
I though support for C++ allocation had improved. In a recent
release, there was the addition of core.stdcpp.new, but I didn't
try it out:
- http://dpldocs.info/experimental-docs/core.stdcpp.new_.html
- https://en.cppreference.com/w/cpp/memory/new/operator_new
Are there still pitfalls to be wary of?
More information about the Digitalmars-d-learn
mailing list