Quoting Malte in msg7815:
[...] the amount of boilerplate we get because we currently have to implement
both a feed function and a hash method (because computing the hash method
requires access to the internals) is not good. We decided to go with a global
function because this gives more generality, but this function often refers to
an actual method to have access to private state. In the std library, this is
somewhat analogous to the role of the function std::begin vs. the begin methods
of many classes.
One idea, following the stdlib, is to have a default template implementation of
feed for typename T that delegates to a method T::feed_hash. Then implementors
only need to provide that method, and in the case of OperatorID, we could
directly feed the int.
We would then no longer implement any "hash()" methods for our classes or global
"feed()" functions, only the "feed_hash" methods, reducing boilerplate and
having more choice in which types to use.
|