Dear experts,
I have a simple code which uses shared_ptr with arrays.
The line of the code that gives problem is:
std::shared_ptr<double[]> myArray(new double[10]);
I'm using a Mac OS 10.14.1 and Xcode 10.1 from command line:
c++ -std=c++17 -o sharedPtr sharedPtr.cpp
Apparently I think it should work.
Do you see any issue of compatibility with Mac Xcode C++ compiler?
Many thanks.
- Mauro.
What I have tried:
sharedPtr.cpp:70:29: error: no matching constructor for initialization of 'std::shared_ptr<double []>'
std::shared_ptr<double[]> myArray(new double[10]);
^ ~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3703:23: note: candidate
constructor not viable: no known conversion from 'double *' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
_LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3717:5: note: candidate
constructor not viable: no known conversion from 'double *' to 'const std::__1::shared_ptr<double []>' for 1st argument
shared_ptr(const shared_ptr& __r) _NOEXCEPT;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3725:5: note: candidate
constructor not viable: no known conversion from 'double *' to 'std::__1::shared_ptr<double []>' for 1st argument
shared_ptr(shared_ptr&& __r) _NOEXCEPT;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3705:18: note: candidate
template ignored: requirement 'is_convertible<double *, element_type *>::value' was not satisfied [with _Yp = double]
explicit shared_ptr(_Yp* __p,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3720:9: note: candidate template
ignored: could not match 'shared_ptr<type-parameter-0-0>' against 'double *'
shared_ptr(const shared_ptr<_Yp>& __r,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3726:52: note: candidate
template ignored: could not match 'shared_ptr<type-parameter-0-0>' against 'double *'
template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3730:34: note: candidate
template ignored: could not match 'weak_ptr<type-parameter-0-0>' against 'double *'
template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3745:9: note: candidate template
ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'double *'
shared_ptr(unique_ptr<_Yp, _Dp>&&,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3754:9: note: candidate template
ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'double *'
shared_ptr(unique_ptr<_Yp, _Dp>&&,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3708:9: note: candidate
constructor template not viable: requires at least 2 arguments, but 1 was provided
shared_ptr(_Yp* __p, _Dp __d,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3711:9: note: candidate
constructor template not viable: requires at least 3 arguments, but 1 was provided
shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3713:26: note: candidate
constructor template not viable: requires 2 arguments, but 1 was provided
template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3714:40: note: candidate
constructor template not viable: requires 3 arguments, but 1 was provided
template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3715:51: note: candidate
constructor template not viable: requires 2 arguments, but 1 was provided
template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3701:23: note: candidate
constructor not viable: requires 0 arguments, but 1 was provided
_LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;