I'm rather proud of Abseil's implementation: https://github.com/abseil/abseil-cpp/blob/887d0eee6bab358472...
As I recall another colleague wrote the original version (I do not remember who.) I bitbashed and optimized it, and added the comments, mainly because I wanted to make sure I understood the reasons it was right.