Skip to content
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

compile error with clang 5.0 -std=c++1z and no string_view #939

Closed
phlptp opened this issue Jan 28, 2018 · 7 comments
Closed

compile error with clang 5.0 -std=c++1z and no string_view #939

phlptp opened this issue Jan 28, 2018 · 7 comments
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead

Comments

@phlptp
Copy link

phlptp commented Jan 28, 2018

Bug Report

Compile error on clang 5.0 with -std=c++1z

In file included from XXXX.cpp:32:
XXXX/json.hpp:9913:66: error: no type named
      'string_view' in namespace 'std'
  ...and not std::is_same<ValueType, typename std::string_view>::value
                                     ~~~~~~~~~~~~~~^~~~~~~~~~~

All other compilers tested thus far work fine.

my fix was to simply comment out that line since I wasn't using std::string_view, but but I am guessing there is a reason for including string_view in the enable_if statement so I don't think my fix is a valid solution and I am not familiar enough with the structures used to integrate a check for the existence of string_view before using it in an is_same template.

The other options was to include <string_view> if JSON_HAS_CPP_17 is enabled but that didn't seem proper either.

@nlohmann
Copy link
Owner

Related: #735.

@nlohmann
Copy link
Owner

We do not include <string_view>, but assume that it is included by <string> (see #735 (comment)). I cannot reproduce the issue, because Travis successfully runs a job with Clang 5 and -std=c++1z.

Please have a look at #735 - in particular, if you can include <string_view>.

@phlptp
Copy link
Author

phlptp commented Jan 28, 2018

I am building with libc++ not libstdc++, on ubuntu 17.10. In the code I am using it in I use a string_view library that is not from the stl since it needed to work with string_view objects without requiring c++1z capability on all compilers so it is in a different namespace, I presume that would cause some interesting issues as well but the uses don't overlap in the code. I think I had the master branch in the code, but develop seems to fail in the same way. I suppose I should check the compile with libstdc++ and see if it fails in the same way.

@phlptp
Copy link
Author

phlptp commented Jan 28, 2018

it compiles properly using libstdc++ and everything else the same, so using libc++ would appear to be the issue.

@nlohmann
Copy link
Owner

Thanks for the feedback. Does <string_view> work with libc++?

@phlptp
Copy link
Author

phlptp commented Jan 28, 2018

No it doesn't, looks like the libc++ used in Ubuntu 17.10 is version 3.9 and string_view was not integrated until 4.0, but the compiler itself has c++17 support and the 3.9 library has partial support.

@nlohmann
Copy link
Owner

Thanks. Then this seems to be a duplicate of #735.

@nlohmann nlohmann added the solution: duplicate the issue is a duplicate; refer to the linked issue instead label Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead
Projects
None yet
Development

No branches or pull requests

2 participants