Compile problem JsonObject.hpp
stubob95 opened this issue · comments
I generate the project using cmake 3.4.3, compiling with vc 2013 Professional.
Problem is when HairBcsdf::toJson tries to create a JsonObject
Here is the error output
HairBcsdf.cpp
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\type_traits(1520): error C2440: 'return' : cannot convert from 'const char [5]' to 'const char (&&)[5]'
You cannot bind an lvalue to an rvalue reference
C:\Users\stubob95\Documents\tungsten-master\src\core\io/JsonObject.hpp(41) : see reference to function template instantiation 'const char (&&std::move<const char(&)[5]>(_Ty) throw())[5]' being compiled
with
[
_Ty=const char (&)[5]
]
C:\Users\stubob95\Documents\tungsten-master\src\core\io/JsonObject.hpp(30) : see reference to function template instantiation 'void Tungsten::JsonObject::add<0x05,const char(&)[5],const char(&)[12],const float&,const char(&)[10],const float&>(const char (&)[5],T,const char (&)[12],const float &,const char (&)[10],const float &)' being compiled
with
[
T=const char (&)[5]
]
C:\Users\stubob95\Documents\tungsten-master\src\core\bcsdfs\HairBcsdf.cpp(172) : see reference to function template instantiation 'Tungsten::JsonObject::JsonObject<const char(&)[5],const char(&)[5],const char(&)[12],const float&,const char(&)[10],const float&>(rapidjson::Value,Tungsten::JsonObject::Allocator &,const char (&)[5],const char (&)[5],const char (&)[12],const float &,const char (&)[10],const float &)' being compiled
Am I missing a compiler setting or something?
The source might be the lack of a std::forward() somewhere not converting an lvalue back to an rvalue reference, but I'm not sure.
Just an FYI, I've seen your comments and hopefully I'll have time to look at it on the weekend. Sorry for the delay.
Thanks!
I just pushed a commit that should fix the build on Visual Studio 2013.
I'm not entirely sure why, but MSVC does not like std::move() on string literals - rather than interpreting it as a const char * which is trivially copyable, it instantiates std::move with template parameter const char (&)[N], which is an array and not movable.
Can you confirm that this fixes things?
Thanks!
Sorry for the delay, I've been on vacation.
All fixed for me, thanks for that!
Great! Thanks