Namespaces
Variants
Views
Actions

Talk:cpp/utility/functional/bind

From cppreference.com

[edit] using namespace std::placeholders

I disagree with the recent edit to the example which changed _1 to std::placeholders::_1 etc: Using _1, _2, etc, after a function-level using directive has been the established practice since the beginning of boost.bind (at least in my personal experience in the industry). In C++, this usage pattern mirrors the old using namespace std::rel_ops; or the various new using namespace std::literals::... (which are all required to enable their repective functionality), in other words, nested namespaces within std are designed for a function-level namespace using --Cubbi (talk) 07:16, 11 October 2013 (PDT)

I'm inclined to agree with you, Cubbi. I've seen this usage pattern in a fair amount of other code. In addition, I feel that the extra length added by all of those qualifiers makes the example harder to parse visually.
I guess one counter-argument might be that if the reader hasn't seen _1 etc. before, they might also be confused. However, if the example is short enough, the using declaration (with its explanatory comment) should be close to the usage of _1 etc., and that will help a bit. Perhaps we should give A-rapEST (and others) a few days to chime in on the discussion, and then consider reverting back. --Nate (talk) 14:56, 11 October 2013 (PDT)
I guess we could add a comment with something along the lines "_1, _2 are from std::placeholders namespace" at the first usage site. This way there would no chance for confusion and the code would still be written according to the best practices. --P12 01:52, 13 October 2013 (PDT)
Done. --Nate (talk) 19:01, 13 October 2013 (PDT)