reflaxe.CPP icon indicating copy to clipboard operation
reflaxe.CPP copied to clipboard

Do not allocate with `new` expression for Ptr

Open SomeRanDev opened this issue 2 years ago • 3 comments

This should cause error. Allocation should require explicit API function call.

class SomeClass {
    public function new() {}
 }
 
 function main() {
    final a: cxx.Ptr<SomeClass> = new SomeClass();
 }

SomeRanDev avatar Sep 25 '23 10:09 SomeRanDev

That's correct! Although new call in C++ sometime act like anti-pattern. But this issue should be an article in FAQs or wiki best practices.

maihd avatar Sep 27 '23 04:09 maihd

I'll document it. Even give details in the error message 👌 I don't know why I didn't do this from the start, unexpected new allocs are such a hassle. 💀

SomeRanDev avatar Sep 29 '23 15:09 SomeRanDev

👍

maihd avatar Sep 30 '23 06:09 maihd