This question already has an answer here:
My problem:
typedef std::shared_ptr<std::complex<double>[]> ScalarShrPtr; ScalarShrPtr fooPtr (new std::comlex<double>[100]);
with such code compiler reports error:
cannot convert std::complex* to std::complex (*)[] in initialization:_M_ptr(__p), _M_refcount(__p)
If I write:
`typedef std::shared_ptr<std::complex<double>> ScalarShrPtr;
ScalarShrPtr fooPtr (new std::comlex<double>[100]);`
Program compiles but Intel Inspector reports Allocation/Deallocation mismatch. Does memory leaks in second case? I read some other posts about partial specialization of shared_ptr and I don't undestand why the first case doesn't work. Platform: Linux Fedora 21, gcc-4.9.2, compiled with flag -std=c++11.
Aucun commentaire:
Enregistrer un commentaire