Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Enable C++ iterators in MSVC (and C++98) #77

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

Merged
merged 1 commit into from
Aug 14, 2021

Conversation

martinschmauder
Copy link
Contributor

Iterators (begin() and end() methods) were implemented using decltype for the return types, which seems to be possible only since C++11. Therefore, the code used the value of the __cplusplus pre-processor symbol to check for C++11. This did not work as expected in MSVC, however, because even the recent Visual Studio 2017 defines the symbol as 199711L, effectively disabling iterators.

Replaced the decltype usages with the respective type names; and no longer check the value of __cplusplus. Iterators are now available in MSVC and, as a side-effect, also in C++98.

Tested with Visual Studio 2017 (version 15.6.3) and "g++ -std=c++98".

Added support for MSVC and (rather coincidentally) C++98 by replacing
the decltype keyword and removing the corresponding preprocessor
checks.
@LB--
Copy link
Member

LB-- commented Dec 17, 2018

In Visual Studio 2017 you should specify /Zc:__cplusplus in order to request a correct definition of the __cplusplus macro. It is only left off by default temporarily for legacy reasons: https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=vs-2017

Though, if this change works without needing to use decltype I would agree it's a better fix.

@LB-- LB-- merged commit a58d231 into json-parser:master Aug 14, 2021
@LB-- LB-- added this to the v1.1.1 milestone Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants