You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When iterating over a nlohmann::json object and then casting the values using value.get<std::string>(), we observe that g++ gives a compile error. On clang and msvc everything compiles just fine.
Replacing value.get<std::string>() with std::string(value) fixes the problem on g++. But I wonder why the get function does not work?
Don't use structured bindings or do as the compiler asks. Adding the template keyword to disambiguate the dependent name (which I assume is due to the compiler-generated code for the structured binding) resolves the issue on GCC and still compiles on Clang and MSVC.
Description
When iterating over a
nlohmann::json
object and then casting the values usingvalue.get<std::string>()
, we observe thatg++
gives a compile error. Onclang
andmsvc
everything compiles just fine.Replacing
value.get<std::string>()
withstd::string(value)
fixes the problem ong++
. But I wonder why theget
function does not work?Reproduction steps
See https://godbolt.org/z/Gxv7dbsjW
Expected vs. actual results
I would expect the "minimal code example" to compile as is on
g++
. But it does not.Minimal code example
Error messages
Compiler and operating system
g++ (Linux)
Library version
3.11.1 & trunk
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: