I don't quite understand what you mean by "structure over logic" here though: isn't the structure entirely a logical structure?Quote:
Originally Posted by tiliavirga
One advantage of using the generic algorithm is that the abstraction provides the reader with immediate information, i.e., instead of parsing the loop to figure out what it does, the reader knows that the aim is to try and find something. The logical structure remains essentially the same, except that part of the details is hidden by an abstraction. In this particular case, an additional advantage is that now we only need to break from a non-nested loop, so the simple break does the job.
You are mistaken: the break (whether the keyword or simulated with goto because C++'s break does not allow breaking from within an inner loop out of an outer loop) is not disgusting. Rather, it is appropriate to the logic here, and in fact I notice that it is you who wrote the appropriately used goto in the first place.Quote:
Originally Posted by tiliavirga
I think that the range-based for loop would be sufficient. Using find_if would not necessarily improve the readability of the code because the predicate might not be simpler than the current loop body.Quote:
Originally Posted by tiliavirga
Instead, for abstraction, the entire code snippet could be moved to a separate function instead to abstract away the entire "want to know which PDN it belongs to" search logic.
Removing a break just for the sake of removing a break, without improving the readability of the code, is a misguided approach.Quote:
Originally Posted by tiliavirga

