Re:The use of `class` for things that should be simple free ...
by jmull on Thursday May 28, 2020 @01:15PM
(#23339838)
Hm, I guess this is moving in the direction of a debate on semantics and API design... which is independent of the original topic.
I don’t know what stable_search is, but it would be a design decision if/how it supports different memory management options for buffers, and isn’t really affected by the decision to use a class or top-level function for implementation. Either way, buffer allocation could be hidden in the implementation and out of the user’s control or exposed to some degree and under the user’s control.
I was only talking about algorithm state here. Check, for example, how the C++ string searching algorithms work to get a feeling of how these APIs work in the wild. For an example of this gone wrong, look no further than C++ stable_search, which does not let the user reuse the merge sort buffer across searches.