On 1/15/19 12:35 PM, Hans Dembinski via Boost wrote:
Pros: - really terse - you can access methods on the pointee with x->method() as well! (useful when histogram counters are not PODs) - you can iterate over x to get the indices, for (auto i : x) { … } works
Doesn't range-for use operator* so you will get the values?
- since x acts like an array to the indices, you can pass it to functions which accept ranges or iterators (it has .begin() and .end()) - x can be (and is) enhanced with other useful methods * x.bin(N) returns the current bin interval for the N-th axis, allowing you to access the central value, width, edges * x.density() returns the current density (bin value divided by product of current bin widths) Cons: - *x and x[0] do completely different things: *x gives you the bin value, x[0] gives you the first index
An alternative is to rename x[i] to x.index(i).