remove weak_vector

It seems that shared_ptr::use_count() does
not include weak_ptr instances.  Therefore
shared_ptr::use_count()==1 (aka unique())
does *not* ensure exclusive ownership!

This breaks the assumption used by
shared_vector::make_unique() to avoid
allocating a new array in some cases.
This commit is contained in:
Michael Davidsaver
2013-06-10 14:48:59 -04:00
parent b63c3da565
commit be4738f59c
2 changed files with 34 additions and 48 deletions

View File

@@ -382,9 +382,34 @@ static void testNonPOD()
testOk1(structs2[1].get()==temp);
}
static void testWeak()
{
testDiag("Test weak_ptr counting");
epics::pvData::shared_vector<int> data(6);
testOk1(data.unique());
std::tr1::shared_ptr<int> pdata(data.dataPtr());
testOk1(!data.unique());
pdata.reset();
testOk1(data.unique());
std::tr1::weak_ptr<int> wdata(data.dataPtr());
testOk1(data.unique()); // True, but I wish it wasn't!!!
pdata = wdata.lock();
testOk1(!data.unique());
}
MAIN(testSharedVector)
{
testPlan(116);
testPlan(121);
testDiag("Tests for shared_vector");
testDiag("sizeof(shared_vector<int>)=%lu",
@@ -399,5 +424,6 @@ MAIN(testSharedVector)
testSlice();
testVoid();
testNonPOD();
testWeak();
return testDone();
}