Fix issue of getting pointer from std::vector of size 0

C++11 introduced the `std::vector::data()` method. In addition to being
more syntatically pleasing, it should correctly handle the condition
when the `std::vector` is size 0 and therefore has no real pointer.
(Expressions like `&v[0]` are undefined when the `vector` is empty.)
This commit is contained in:
Kenneth Moreland 2020-09-02 10:56:31 -06:00
parent 3f8da6e7e1
commit 66a4a23ebf

@ -267,7 +267,7 @@ void VTKDataSetReaderBase::ReadCells(vtkm::cont::ArrayHandle<vtkm::Id>& connecti
std::vector<vtkm::Int32> buffer(static_cast<std::size_t>(numInts));
this->ReadArray(buffer);
vtkm::Int32* buffp = &buffer[0];
vtkm::Int32* buffp = buffer.data();
auto connectivityPortal = connectivity.WritePortal();
auto numIndicesPortal = numIndices.WritePortal();
for (vtkm::Id i = 0, connInd = 0; i < numCells; ++i)
@ -292,7 +292,7 @@ void VTKDataSetReaderBase::ReadShapes(vtkm::cont::ArrayHandle<vtkm::UInt8>& shap
std::vector<vtkm::Int32> buffer(static_cast<std::size_t>(numCells));
this->ReadArray(buffer);
vtkm::Int32* buffp = &buffer[0];
vtkm::Int32* buffp = buffer.data();
auto shapesPortal = shapes.WritePortal();
for (vtkm::Id i = 0; i < numCells; ++i)
{