fix static_shared_vector_cast<>() no-op casting
Turns out that Enablers as typically used for member functions don't work to select constructors. Move this selection logic to struct detail::static_shared_vector_caster<> to correctly allow no-op casts (eg. void to void). Previously this would not compile. Allows PVScalarArray getAs() and putFrom() using shared_vector<const void>.
This commit is contained in:
@@ -177,11 +177,32 @@ static void testShare()
|
||||
testOk1(!cdata.unique());
|
||||
}
|
||||
|
||||
static void testVoid()
|
||||
{
|
||||
testDiag("Check PVScalarArray put/get from void");
|
||||
|
||||
PVIntArrayPtr iarr = static_pointer_cast<PVIntArray>(getPVDataCreate()->createPVScalarArray(pvInt));
|
||||
|
||||
PVIntArray::const_svector idata(4, 1);
|
||||
iarr->PVScalarArray::putFrom(idata);
|
||||
idata.clear();
|
||||
|
||||
shared_vector<const void> cvbuf;
|
||||
iarr->PVScalarArray::getAs(cvbuf);
|
||||
|
||||
idata = static_shared_vector_cast<const PVIntArray::value_type>(cvbuf);
|
||||
testOk1(idata.size()==4);
|
||||
|
||||
iarr->PVScalarArray::putFrom(cvbuf);
|
||||
|
||||
testOk1(iarr->getLength()==4);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
MAIN(testPVScalarArray)
|
||||
{
|
||||
testPlan(156);
|
||||
testPlan(158);
|
||||
testFactory();
|
||||
testBasic<PVByteArray>();
|
||||
testBasic<PVUByteArray>();
|
||||
@@ -189,5 +210,6 @@ MAIN(testPVScalarArray)
|
||||
testBasic<PVDoubleArray>();
|
||||
testBasic<PVStringArray>();
|
||||
testShare();
|
||||
testVoid();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user