3 ms·
I argue that nobody could possibly understand this snippet without reference to the source, even if they have C++ chapter and verse committed to memory. |auto|
by shereadsthenews 8y ago
I argue that nobody could possibly understand this snippet without reference to the source, even if they have C++ chapter and verse committed to memory. |auto| with a factory function sucks because you have to look up the return type. The source code actually uses |auto| as the declared return type which sucks again, they have made their library much harder to read and understand and saved themselves only a tiny amount of typing. Then it’s not even a little obvious that |histogram| is a unary function. You have to read it to see why that works and if it works naturally or because the argument can be implicitly constructed. Basically I hate this.
This would be a lot more readable without the deduced return type and if it had a named function for the fill that could be called from a lambda or bound function.
- zvrba 8y ago> |auto| with a factory function sucks because you have to look up the return type. It's funny how we never hear Ocaml or Haskell programmers complaining about type inference.
- nxpnsv 8y agoWithout reading the post, I read this as make a histogram with 6 bins in range –1 to 2 with name x. Then sort data into the histogram. What I don’t understand is the relevance of x, or why not just have a h.fill() function.
- olq_plo 8y agoLabels are metadata. You can attach arbitrary metadata to each axis or no metadata at all. The metadata is sometimes useful to keep track what each axis range was representing. For example, if you load a serialized histogram into your program that someone else generated. Here is an example which demonstrates the usefulness of labels: https://raw.githubusercontent.com/boostorg/histogram/develop/examples/guide_axis_with_labels.cpp https://raw.githubusercontent.com/boostorg/histogram/develop... The design choice of using operator() or a fill() method was hotly debated. In the bigger picture of things, operator() is better because then 1D histogram have the same fill syntax as the accumulators from Boost::accumulators.