r/cpp • u/Separate-Summer-6027 trueform.polydera.com • May 01 '26
The STL for Geometry: Thirty-Year Evolution of C++ Libraries
https://polydera.com/algorithms/the-stl-for-geometryVTK, CGAL, libigl, MeshLib, and what comes next. What the STL philosophy of separating algorithms from data looks like when applied to geometry: semantic ranges, composable policies, and parallel algorithms that operate on them.
In 1994, Alexander Stepanov changed C++ by proving that algorithms should not belong to data structures. If you have m algorithms and n containers, you don't need m × n implementations. You need m + n. The iterator was the bridge. A single sort() works on a vector, a deque, or a raw int*.
This shaped what idiomatic C++ feels like. Yet the geometry processing libraries developed since have not quite felt that way.
6
u/trad_emark May 02 '26
that is interesting.
my question is, how does the library change the size of a buffer that it does not own? eg. when mesh regularization needs to add more vertices? how does such operation fill in data in the buffer that it has no information about, eg. vertex color?
5
u/arthurno1 May 02 '26 edited May 02 '26
I would say the abstraction was the bridge. The iterator is just but a part of the plumbing, but really a symptom of a bigger problem. Iterators are for iterating, not for plumbing :). There is more to plumbing than just accessing elements of a sequence. While C++ is certainly better than Java, the problem they faced was the traditional inheritance-based modelling as the only type generation mechanism. I think STL really stretched what was possible and tried to escape out of the inheritance cage there.
I think a better approach, or a better abstraction to model on, are so called "open methods" or "multi-methods", or whatever you wanna call them, as found in Common Lisp via CLOS. Pair it also with an extensible type system where you can introduce a type without actually using inheritance as in Common Lisp.
Long story short, if Stepanov had open methods back than in C++, he probably would not need iterator for the plumbing. Or at least it would be less needed and less fundamental as the abstraction tool. C++ has got an implementation of open methods lately in Boost's OpenMethod. For some more info about multi methods and comparing with C++, this paper by one of CLOS creators might be an interesting read.
If you are interesting in such fundamental architectural idioms and problem solving I suggest to lookup those things, as well ass mixins as an example of a good use of multiple inheritance, which I believe inspired Java's "interfaces", but I am not sure really.
Just a regression, don't take it too seriously, I myself have been interesting lots about those things in the past.