-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
Fix name resolution errors #22
Conversation
Stream I/O operators defined in a global namespace caused name resolution errors in some cases.
Using better_enums as a nested namespace name along a global better_enums namespace resulted in name clashes.
Looks reasonable. Would you be able to provide an example that shows the problem with the stream I/O operators, without too much trouble? |
Looking into the Travis build, seems like some bit rot, maybe. |
Alright. http://llvm.org/apt/ says:
So don't worry about the Travis builds. They should come back eventually :) It's not a problem – I can test locally on most of those compilers. |
I was able to reproduce the error, it happens when:
I'm not sure why exactly does it happen, I'm not an expert in these complex ADL rules. But it's definitely more appropriate to define an operator in an argument namespace scope rather than in a global one, which is not always searched apparently.
By the way, this reveals a nasty hidden bug: if you omit the strict conversion macro it will compile, but the standard That's why I think that I'd rather drop C++98 support to have a safer library with a better API (or separate C++98 and C++11 code paths), but you'll probably disagree :) |
Thanks! I'll mess around with the repro case. As mentioned in the other issue, there will probably be a delay on my end, though :/ Regarding C++98, I think what I'll do first is work on C++14. That is the most likely thing to definitively convince me to drop C++98. The second most likely, is that it is now 2016 :p I can always point C++98 users to older versions, and provide bugfix releases when things come up. So, dropping C++98 is not that big a deal. I just want to be really sure of it :) This library actually started out as C++11-only. The main reason I started supporting C++98 is MSVC. When I made this public, MSVC still had really awful C++11 support. In fact, the last time I checked several months ago, MSVC was still not able to compile Better Enums with all of its C++11 features enabled. EDIT: the last time was in November, even though issue is from August. Perhaps it's time to check again... :) |
@aantron, is this PR LGTM, could you merge it? |
Hi @cheparukhin, Part 1 of the PR LGTM by inspection. I am not sure about part 2. There shouldn't be any Unfortunately, I can't give the PR the proper, thorough look it deserves, due to being extremely, extremely burned out on open source. So, I've given you commit access to the repo. I'm sure you've already done these, but: run the tests, try the modified macro in a namespace and outside (the tests also cover that), think about any potential corner cases, and glance in If willing, please add a test for this PR, i.e. one or more that would fail without your change. I've been thinking about dropping C++98 support since we discussed it, and I think we can make "strict conversions" the default, as you suggest here, and start moving away from C++98. The guideline I am using is that the Since MSVC has had Switching to So, if you want to take that step, you are welcome to do it (or anything that makes Better Enums even better, really :) ). You will have to delete lines from the AppVeyor build matrix for compilers until whatever release supported As for full-on C++11-only code in If you do want to change things beyond this PR, and want my opinion on anything, or to get my rationale for design decisions I made, I'm perfectly willing to respond by email. Just trigger it through issues/PR, or send directly :) |
@aantron thanks for such a detailed response. Regarding the second commit, there was a global |
Ah, yes, fair enough. Forgot about that :) Both LGTM then, feel free to merge if you dare :) |
better_enums
as a name for both global and nested namespaces is pretty error-prone as the nested one will be chosen by default, unless::better_enums
is specified explicitly. I concatenated the nested namespace names to produce a unique one and prevent the name clash.