Angus Leeming <[EMAIL PROTECTED]> writes: | Lars Gullik Bjønnes wrote: > >> bool BranchList::remove(string const & s) >> { >> List::size_type const size = list.size(); >> - list.remove_if(bind2nd(match(), s)); >> + list.remove_if(bind(equal_to<string>(), >> + bind(&Branch::getBranch, _1), >> + s)); >> return size != list.size(); >> } > | Lars! Be nice to us! Add comments explaining what this stuff is | equivalent to. If you're not careful, your fellow developers will | start to view you as the evil genius who obfuscates their perfectly | reasonable code and then laughs at their confusion, "Mu hah hah hah!"
Where is the obfuscation? Actually I find the new version a lot clearer than the old one. Now you can actually see what "match" is doing: equal_to. std::equal_to takes to parameters, the elements to be compared, in this case: Branch::getBranch() and s. So: remove the element if equal_to is true when supplied with the parameters Branch::getBranc() (for each element of the list) and s. | If you're going to go down this boostification-for-the-sake-of-it | route, then please try and take us all with you. This more the "get-rid-of-smart-local-solutions-and-use-something-that-will-be-in-the-next-stanard-instead" route. (the equivalent of boost::bind will be in the TR1, you might just as well learn how it works right away.) > | Would boost::lambda help here? The code would probably be even clearer with boost::lambda. PS. To get the more "obfuscated" stuff you should have picked the make_function_output_iterator stuff. Or the operator-> stuff... -- Lgb