I'm trying to use arrays in smart pointers, but when I cast smart_ptr to weak_ptr using Apple clang I get an error (I use -std=c++17).
error: cannot initialize a member subobject of type 'std::weak_ptr<int []>::element_type *' (aka 'int (*)[]') with an lvalue of type 'std::shared_ptr<int []>::element_type *const' (aka 'int *const')
: __ptr_(__r.__ptr_),
Here is an example of code I'm trying to compile.
std::shared_ptr<int[]> ptr(new int[5]);
ptr[0] = 1;
ptr[1] = 2;
ptr[2] = 3;
std::weak_ptr<int[]> weakPtr(ptr);
std::cout << ptr[0] << std::endl;
P.S. I can't use std::array as I'm implementing my own container class.