-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpplint: allow using-directive for user-defined literals namespaces #204
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
We (internally) had a long discussion recently and came to the conclusion that using directives are never ever ever ever safe for use in a codebase of any significant size - we cannot endorse this, even just once. Sorry. (I'm working on finding a proper forum to share some of the Google-internal guidance, hopefully early next year.) |
Understood, thanks for the feedback. |
@tituswinters does that apply to all I can understand the guidance on never using the However, for the very narrow and specific case of std library defined literals, I think it should be acceptable to do something like
So only the std library can define literals like It is also a convenience feature that cannot be used conveniently without the
So, the std library wisely decided to not make these literals accessible by default, to avoid surprise I would guess, but they intend to expose the feature through the use of |
@wjwwood - Using directives are of the form "using namespace blah;" I'm only talking about directives. For the specific case of the standard-defined UDLs which can (allegedly) never collide with anything else, I agree that this would be fine. However, in our experience anything that weakens the limitation on using directives leads pretty directly to abuse, and the cost to a large repo for cleaning up that abuse is substantial. We distrust using directives at scale sufficiently that we're OK throwing out ease-of-use for UDLs at the same time. (The "allegedly" in there is really because non-standard UDLs are not allowed to not be prefixed with a _, but that doesn't mean it won't happen.) Part of that is that UDLs are troubling in their own right - any signfiicant use of UDLs requires using directives or using declarations to the point that every UDL in a codebase is effectively sharing the same UDL logical namespace. For small and medium projects that might be fine - for large shared codebases it's a recipe for collision, confusion, and subtlely hard to maintain code. The benefits aren't there. |
Got it, thanks for the clarification.
At least in GCC, Clang, and VS 2015 Update 3, a UDL without a leading
I understand your reasoning, thanks for spending the time to express it. One last question, I promise to stop wasting your time after that 😄, is there a standing policy for this repository on pull requests that add options to diverge from the accepted Google style? For example, if I were to create a pull request which added an option to classify using directives that match That way the default behavior would be unchanged, but we could enable that option and ignore just the new rule, rather than ignoring all |
I don't think there's policy on it, but in general we avoid such things because the maintenance cost is a hassle, and we aren't big on supporting configurations that we don't have good ways to test. That could conceivably change, but we're in the middle of shuffling a lot of this stuff - so I'd be a bit surprised if we changed that policy right now. |
This change adds an exception to the
using namespace
directives check,to allow user-defined literals namespaces for source files (not headers).