[Interprocess] Compile error with VC10

I am trying Interprocess with VS2010, and got some compile error, the error message is: 1>ClCompile: 1>boost/interprocess/detail/move.hpp(358): error C2440: 'return' : cannot convert from 'boost::interprocess::mapped_region' to 'boost::interprocess::mapped_region &&' 1> You cannot bind an lvalue to an rvalue reference Any quick fix for it?

On 22/04/2010 14:38, cg wrote:
I am trying Interprocess with VS2010, and got some compile error, the error message is:
1>ClCompile: 1>boost/interprocess/detail/move.hpp(358): error C2440: 'return' : cannot convert from 'boost::interprocess::mapped_region' to 'boost::interprocess::mapped_region &&' 1> You cannot bind an lvalue to an rvalue reference
Any quick fix for it?
Not with such little information. We need the boost version (try with the latest one), and more context of the error is needed. Has VC10 activated rvalue references by default or you've activated this feature? Best, Ion

On 4/22/2010 9:30 PM, Ion Gaztañaga wrote:
1>ClCompile: 1>boost/interprocess/detail/move.hpp(358): error C2440: 'return' : cannot convert from 'boost::interprocess::mapped_region' to 'boost::interprocess::mapped_region &&' 1> You cannot bind an lvalue to an rvalue reference
Any quick fix for it?
Not with such little information. We need the boost version (try with the latest one), and more context of the error is needed.
I am using boost trunk.
Has VC10 activated rvalue references by default or you've activated this feature?
I think VC10 should activate rvalue reference by default. And I have tried to compile the code with and without BOOST_HAS_RVALUE_REFS defined, but got the same error.

On 22/04/2010 15:57, cg wrote:
I think VC10 should activate rvalue reference by default. And I have tried to compile the code with and without BOOST_HAS_RVALUE_REFS defined, but got the same error.
Can you find the definition of std::move and std::forward in the standard library of Visual 2010? I know it changed between beta and the release. I think changing the definition of move to template <class T> inline typename remove_reference<T>::type&& move(T&& t) { return static_cast<remove_reference<T>::type&&>(t); } should work. This approach provokes a warning in the old gcc-4.3 approach ("returning reference to temporary"), but it should be a quick solution for you. Best, Ion

On 4/23/2010 7:07 AM, Ion Gaztañaga wrote:
Can you find the definition of std::move and std::forward in the standard library of Visual 2010? I know it changed between beta and the release.
I think changing the definition of move to
template <class T> inline typename remove_reference<T>::type&& move(T&& t) { return static_cast<remove_reference<T>::type&&>(t); }
should work. This approach provokes a warning in the old gcc-4.3 approach ("returning reference to temporary"), but it should be a quick solution for you.
Yes, this fixes it. And VC10 has std::move and std::forward. Thanks

On Thu, Apr 22, 2010 at 6:21 PM, cg <chengang31@gmail.com> wrote:
On 4/23/2010 7:07 AM, Ion Gaztañaga wrote:
Can you find the definition of std::move and std::forward in the standard library of Visual 2010? I know it changed between beta and the release.
I think changing the definition of move to
template <class T> inline typename remove_reference<T>::type&& move(T&& t) { return static_cast<remove_reference<T>::type&&>(t); }
should work. This approach provokes a warning in the old gcc-4.3 approach ("returning reference to temporary"), but it should be a quick solution for you.
Yes, this fixes it. And VC10 has std::move and std::forward.
Thanks
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
That warning isn't ignorable and will break people on 4.3/4.4. Like I mentioned in my previous mail, you should just use std::move.

On 29/04/2010 19:26, Ahmed Charles wrote:
That warning isn't ignorable and will break people on 4.3/4.4. Like I mentioned in my previous mail, you should just use std::move.
It's just a quick fix for him, not committed to trunk. We can use std::move, but std::forward definition is not the one in the latest draft. Best, Ion

On 22/04/2010 15:57, cg wrote:
I think VC10 should activate rvalue reference by default. And I have tried to compile the code with and without BOOST_HAS_RVALUE_REFS defined, but got the same error.
However I think VC10 move semantics are broken, e.g. this does not compile //Movable is not copyable, private copy constructor movable function() { movable m; return boost::move(m); } int main() { //ERROR: error C2248: 'movable::movable' : //cannot access private member declared in class 'movable' movable m(function()); return 0; } So I'm afraid

2010/4/24 Ion Gaztañaga <igaztanaga@gmail.com>:
On 22/04/2010 15:57, cg wrote:
I think VC10 should activate rvalue reference by default. And I have tried to compile the code with and without BOOST_HAS_RVALUE_REFS defined, but got the same error.
However I think VC10 move semantics are broken, e.g. this does not compile
//Movable is not copyable, private copy constructor movable function() { movable m; return boost::move(m); }
int main() { //ERROR: error C2248: 'movable::movable' : //cannot access private member declared in class 'movable' movable m(function()); return 0; }
I imagine boost::move is written with rvalue references v1 and therefore doesn't work with vc2010, which implements v2. Is there a reason why boost has to implement its own version of move? Every compiler/library supporting rvalue references should have std::move which will do the right thing.

On 29/04/2010 19:24, Ahmed Charles wrote:
I imagine boost::move is written with rvalue references v1 and therefore doesn't work with vc2010, which implements v2. Is there a reason why boost has to implement its own version of move? Every compiler/library supporting rvalue references should have std::move which will do the right thing.
Move emulation for C++03 compilers and code portability between C++0x and C++03 compilers. Ion

Ion Gaztañaga wrote:
On 22/04/2010 14:38, cg wrote:
I am trying Interprocess with VS2010, and got some compile error, the error message is:
1>ClCompile: 1>boost/interprocess/detail/move.hpp(358): error C2440: 'return' : cannot convert from 'boost::interprocess::mapped_region' to 'boost::interprocess::mapped_region &&' 1> You cannot bind an lvalue to an rvalue reference
Any quick fix for it?
Not with such little information.
You need to static_cast to &&, the new rvalue references no longer bind to lvalues without a cast. Or use std::move which should know what to do.

On 22/04/2010 16:19, Peter Dimov wrote:
You need to static_cast to &&, the new rvalue references no longer bind to lvalues without a cast. Or use std::move which should know what to do.
Ok, thanks. I want to support both the old (for installed gccs) and the new approach (msvc 2010). Best, Ion
participants (4)
-
Ahmed Charles
-
cg
-
Ion Gaztañaga
-
Peter Dimov