JoeMo:
I thank you for your thoughtful and well-researched answers to my question.
I really changed it (according to the lines suggested by milleniumbug: (if (pos == std :: string :: npos) return path, etc.). In addition, I agree with it that the code looks wrong.
The reason the code looks wrong also explains why it looks "elegant"; one pass through the code handles all different cases. There are no statements, etc., There are only two direct statements. It can't be that easy, can it?
But he performs this feat of simplification, using specialized knowledge at different levels of abstraction (knowledge of bit-wize values โโof string :: npos, the way the substrate works in edges, etc.).
It's best to keep things at the same level of abstraction, even at the cost of a little extra code.
Thanks.
Joemo
source share