-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
in-class initialization for type 'const T' is not yet implemented #591
Comments
Visual Studio 2017 is supported. We run Microsoft (R) Build Engine version 15.1.548.43366 with AppVeyor, see https://ci.appveyor.com/project/nlohmann/json. |
Could you please provide an example that triggers this error? |
Any news on this? |
Sorry for the late reply and thank you! I'm using json.hpp within a plugin for Unreal Engine 4 and included it in the header file: string jsonString = {"timestamp":62572.2,
"norm_pos":[0.524542, 0.49178],
"base_data":[{
"id":0,
"method":"2d c++",
"norm_pos":[0.524542, 0.49178],
"confidence":0.745419,
"timestamp":62572.2,
"diameter":64.9183,
"ellipse":{
"axes":[19.7713, 64.9183],
"center":[335.707, 243.946],
"angle":156.647}
}],
"confidence":0.745419}
I'm trying to access the data with json by parsing it like this: But then I get the error listet above. I tried it on two other computers (Win7 and Win10, VisualStudio 2015 and 2017) where it works fine. I also reinstalled VisualStudio on the computer where it isn't working but the same error occures. |
So this program does not compile with MSVC2017? #include "json.hpp"
using json = nlohmann::json;
int main()
{
std::string jsonString = R"({
"timestamp":62572.2,
"norm_pos":[0.524542, 0.49178],
"base_data":[{
"id":0,
"method":"2d c++",
"norm_pos":[0.524542, 0.49178],
"confidence":0.745419,
"timestamp":62572.2,
"diameter":64.9183,
"ellipse":{
"axes":[19.7713, 64.9183],
"center":[335.707, 243.946],
"angle":156.647}
}],
"confidence":0.745419})";
auto jsonMap = json::parse(jsonString.c_str());
std::cout << jsonMap << std::endl;
} |
Hmm this code works for me. I'm going to figure out how the code I used differs from this one. |
Any news on this? |
I have come across the same problem with Visual Studio Professional 2015. My code is rather simple:
Yet, it return these faults:
Since the topic was closed for @chainke , I'd like to know how. Thanks in advance! |
I also encountered the same problem when developing with vs2015. After reading the comments above, it did not help substantially. After reading the source code, it contains a lot of features above cpp11. In vs2015 and below, it can't even compile normally. |
@chainke i m also trying to use this library inside my plugin in unreal engine. can you help with the steps on how to include it in my unreal engine plugin. I am quite new to unreal, and links would also be helpful. |
Hey there,
I have a problem when compiling a project using json.hpp.
When I use Microsoft Visual Studio 2015 Update 3 on Windows7 everything worsk fine, but when I use Mircosoft Visual Studio 2017 on Windows 10, I get the following error:
\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C4579: 'nlohmann::detail::static_constnlohmann::detail::to_json_fn::value': in-class initialization for type 'const T' is not yet implemented; static member will remain uninitialized at runtime but use in constant-expressions is supported
2> with
2> [
2> T=nlohmann::detail::to_json_fn
2> ]
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(898): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "nlohmann::detail::static_constnlohmann::detail::to_json_fn".
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C2131: Ausdruck wurde nicht zu einer Konstanten ausgewertet.
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): note: Fehler wurde durch Rückgabe der Adresse eines temporären Elements oder eines Verweises zu einem temporären Element verursacht
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C2059: Syntaxfehler: "="
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C4579: 'nlohmann::detail::static_constnlohmann::detail::from_json_fn::value': in-class initialization for type 'const T' is not yet implemented; static member will remain uninitialized at runtime but use in constant-expressions is supported
2> with
2> [
2> T=nlohmann::detail::from_json_fn
2> ]
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(899): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "nlohmann::detail::static_constnlohmann::detail::from_json_fn".
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2784: "_Ty *std::begin(_Ty (&)[_Size]) noexcept": template-Argument für "_Ty (&)[_Size]" konnte nicht von "add_rvalue_reference::type" hergeleitet werden.
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xutility(1250): note: Siehe Deklaration von "std::begin"
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\type_traits(761): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "nlohmann::basic_jsonstd::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer".
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\type_traits(790): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::is_nothrow_constructible<_Ty,nlohmann::basic_jsonstd::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer &&>".
2> with
2> [
2> _Ty=nlohmann::json
2> ]
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(12931): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::is_nothrow_move_constructiblenlohmann::json".
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2893: Funktionsvorlage "unknown-type std::begin(const _Container &)" konnte nicht spezialisiert werden
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: Mit den folgenden Vorlagenargumenten:
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: "_Container=add_rvalue_reference::type"
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2893: Funktionsvorlage "unknown-type std::begin(_Container &)" konnte nicht spezialisiert werden
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: Mit den folgenden Vorlagenargumenten:
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: "_Container=add_rvalue_reference::type"
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2784: "const _Elem *std::begin(std::initializer_list<_Elem>) noexcept": template-Argument für "std::initializer_list<_Elem>" konnte nicht von "add_rvalue_reference::type" hergeleitet werden.
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\initializer_list(60): note: Siehe Deklaration von "std::begin"
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\Source\EyeTrackingPlugin\Private\MultipartMessage.cpp(46): warning C4456: Deklaration von "msg" blendet vorherige lokale Deklaration aus
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\Source\EyeTrackingPlugin\Private\MultipartMessage.cpp(23): note: Siehe Deklaration von "msg"
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C4579: 'nlohmann::detail::static_constnlohmann::detail::to_json_fn::value': in-class initialization for type 'const T' is not yet implemented; static member will remain uninitialized at runtime but use in constant-expressions is supported
2> with
2> [
2> T=nlohmann::detail::to_json_fn
2> ]
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(898): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "nlohmann::detail::static_constnlohmann::detail::to_json_fn".
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C2131: Ausdruck wurde nicht zu einer Konstanten ausgewertet.
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): note: Fehler wurde durch Rückgabe der Adresse eines temporären Elements oder eines Verweises zu einem temporären Element verursacht
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C2059: Syntaxfehler: "="
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(887): error C4579: 'nlohmann::detail::static_constnlohmann::detail::from_json_fn::value': in-class initialization for type 'const T' is not yet implemented; static member will remain uninitialized at runtime but use in constant-expressions is supported
2> with
2> [
2> T=nlohmann::detail::from_json_fn
2> ]
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(899): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "nlohmann::detail::static_constnlohmann::detail::from_json_fn".
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2784: "_Ty *std::begin(_Ty (&)[_Size]) noexcept": template-Argument für "_Ty (&)[_Size]" konnte nicht von "add_rvalue_reference::type" hergeleitet werden.
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xutility(1250): note: Siehe Deklaration von "std::begin"
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\type_traits(761): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "nlohmann::basic_jsonstd::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer".
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\type_traits(790): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::is_nothrow_constructible<_Ty,nlohmann::basic_jsonstd::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer &&>".
2> with
2> [
2> _Ty=nlohmann::json
2> ]
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(12931): note: Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::is_nothrow_move_constructiblenlohmann::json".
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2893: Funktionsvorlage "unknown-type std::begin(const _Container &)" konnte nicht spezialisiert werden
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: Mit den folgenden Vorlagenargumenten:
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: "_Container=add_rvalue_reference::type"
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2893: Funktionsvorlage "unknown-type std::begin(_Container &)" konnte nicht spezialisiert werden
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: Mit den folgenden Vorlagenargumenten:
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): note: "_Container=add_rvalue_reference::type"
2>D:\Uni\Bachelorarbeit\EyeTracking4_15\Plugins\EyeTrackingPlugin\ThirdParty\PupilLabs\include\json.hpp(6482): error C2784: "const _Elem *std::begin(std::initializer_list<_Elem>) noexcept": template-Argument für "std::initializer_list<_Elem>" konnte nicht von "add_rvalue_reference::type" hergeleitet werden.
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\initializer_list(60): note: Siehe Deklaration von "std::begin"
Is either Visual Studio 2017 or Windows 10 not supported yet?
The text was updated successfully, but these errors were encountered: