Commit 66a4a23e authored by Kenneth Moreland's avatar Kenneth Moreland

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.)
parent 3f8da6e7
......@@ -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)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment