There is no back() method in boost::numeric::ublas::vector,
is it possible to emulate it in user code with preprocessor macro defining somehow array_name[array_name.size()-1]?
array_name[i].rbegin()->operator[] (i) = 1.0 or
array_name[i][array_name[i].size()-1][i] = 1.0 hard to read, array_name[i].back()[i] = 1.0 easy to read, that why i thinking to emulate back() method.
Consider to use
std::array<>instead of C-arrays. Then you'll havearray_name.back()as well. Note, thatstd::array<>comes with no overhead to C-arrays.If it really has to be C-arrays with static size, then
should do the trick, though I have not yet tested. Dynamically sized arrays (those allocated with
newormalloc()) don't carry any length information. You can not determine their last element, without having stored the length somewhere else.BTW.:
boost::numeric::ublas::vectordoes havesize(), so you can doIt also has reverse iterators. You can do
to get the value of the last element.