&foo[0] -> foo.data()
Use the more modern form of accessing the data array of a vector
rather than grabbing the pointer to the first element. The latter
can lead to errors if the vector is of zero length.
Change-Id: Ifc8fc969b06b3ba1a9385e8a3a8d5c50b25db5a8
diff --git a/internal/ceres/block_jacobian_writer.cc b/internal/ceres/block_jacobian_writer.cc
index 727d649..d7e1e95 100644
--- a/internal/ceres/block_jacobian_writer.cc
+++ b/internal/ceres/block_jacobian_writer.cc
@@ -94,7 +94,7 @@
jacobian_layout_storage->resize(num_jacobian_blocks);
int e_block_pos = 0;
- int* jacobian_pos = &(*jacobian_layout_storage)[0];
+ int* jacobian_pos = jacobian_layout_storage->data();
for (int i = 0; i < residual_blocks.size(); ++i) {
const ResidualBlock* residual_block = residual_blocks[i];
const int num_residuals = residual_block->NumResiduals();
@@ -144,7 +144,8 @@
auto preparers = std::make_unique<BlockEvaluatePreparer[]>(num_threads);
for (unsigned i = 0; i < num_threads; i++) {
- preparers[i].Init(&jacobian_layout_[0], max_derivatives_per_residual_block);
+ preparers[i].Init(jacobian_layout_.data(),
+ max_derivatives_per_residual_block);
}
return preparers;
}