C++ 从阵列的共享ptr访问共享ptr

C++ 从阵列的共享ptr访问共享ptr,c++,c++14,shared-ptr,shared-memory,unique-ptr,C++,C++14,Shared Ptr,Shared Memory,Unique Ptr,我有一个函数,它将一些值复制到我要传递的对象 像这样的 void functionReturnObjects(int* ptr); 我将像这样调用上面的函数 std::shared_ptr<int> sp( new int[10], std::default_delete<int[]>() ); functionReturnObjects(sp.get()); => so this will copy int objects to sp. std::share

我有一个函数,它将一些值复制到我要传递的对象

像这样的

void functionReturnObjects(int* ptr);
我将像这样调用上面的函数

std::shared_ptr<int> sp( new int[10], std::default_delete<int[]>() );
functionReturnObjects(sp.get());  => so this will copy int objects to sp.
std::shared_ptr sp(新int[10],std::default_delete());
functionReturnObjects(sp.get());=>因此,这将把int对象复制到sp。
现在,我想从上面的10个共享ptr中提取一个单独的ptr,并想制作单独的副本或与其他共享ptr共享

大概是

std::shared_ptr<int> newCopy = sp[1] ==> This is not working I am just showing what I want.
std::shared\u ptr newCopy=sp[1]==>这不起作用,我只是在展示我想要的东西。
基本上,我想在不分配新内存的情况下,将所有权从10个共享指针转移到新的单个共享ptr

如果问题不清楚,请告诉我。

使用(过载8):

如果你的“单个”指针没有与其他sared指针共享所有权,那么你必须为它分配其他一些其他指针没有共享的内容。不,不要阅读“教程”。买一本合适的书。
template< class Y > 
shared_ptr( const shared_ptr<Y>& r, element_type *ptr );
std::shared_ptr<int> newCopy(sp, sp.get() + 1);
std::shared_ptr newCopy(sp, &sp[1]);