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 problem JsonObject.hpp #24

Closed
stubob95 opened this issue Feb 7, 2016 · 5 comments
Closed

Compile problem JsonObject.hpp #24

stubob95 opened this issue Feb 7, 2016 · 5 comments

Comments

@stubob95
Copy link

stubob95 commented Feb 7, 2016

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?

@latencyhiding
Copy link

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.

@tunabrain
Copy link
Owner

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!

@tunabrain
Copy link
Owner

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!

@stubob95
Copy link
Author

Sorry for the delay, I've been on vacation.

All fixed for me, thanks for that!

@tunabrain
Copy link
Owner

Great! Thanks

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

No branches or pull requests

3 participants