I imagine the placement new
is indeed problematic because TObject
has expectations about memory allocations which new
satisfies (because C++Builder's RTL internally routes C/C++ memory routines to Delphi RTL routines in VCL projects), but which placement new
does not.
boost::make_shared and C++Builder VCL objects
-
30-05-2022 - |
Domanda
I've tried switching some C++Builder 2010 code using new
to use boost::make_shared<>
, as below.
Old:
boost::shared_ptr<TStringList> l(new TStringList());
New:
boost::shared_ptr<TStringList> l(boost::make_shared<TStringList>());
l->Add("foo"); //dies here
The old code works, but the new code dies when I try and use the pointer (AV, or just hangs).
I've used make_shared
and shared_ptr
successfully before, but never with TObject
descendants. Is this a known problem - perhaps something to do withe the way make_shared
uses placement new()
??
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow