Boost logo

Boost :

Subject: Re: [boost] boost internal compile problems after moving to 1.44 in VC10
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2010-08-18 14:31:43

I refer to this update as "rvalue references v2". When I wrote my blog post (after the VC10 CTP had been released, which was *very* early - this was before VC10 Beta 1), rrv2 hadn't been integrated into the C++0x Working Paper yet. However, it was on the horizon, and I mentioned it at the very end of the blog post. See "the future" section, where I linked to N2812, and explained that std::move() and std::forward()'s implementations would change. Fortunately, rrv2 was finalized in time for us to support it in VC10 Beta 2.

Writing a blog post about rrv2 is on my list of things to do, but I haven't gotten a chance to do it yet. (Despite appearances, I don't quite get to write blog posts all day.)

In std::move()'s implementation, a static_cast is necessary. Due to Dinkumware's conventions, we use C casts instead of C++ casts, but the effect is the same. (According to my understanding, they use C casts because some of the compilers that they support have trouble with C++ casts. VC doesn't have trouble with C++ casts, but we like to keep our implementation in sync with Dinkumware's master sources as much as possible. Amusingly, std::addressof() cannot be implemented properly with C casts, so we had to fix that bug by using C++ casts there, but that's the only special case that I'm aware of. If we followed my conventions, I'd use C++ casts everywhere, and I'd remove redundant parentheses in return statements. :->)

Stephan T. Lavavej
Visual C++ Libraries Developer

-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Christopher Lux
Sent: Wednesday, August 18, 2010 7:08 AM
To: boost_at_[hidden]
Subject: Re: [boost] boost internal compile problems after moving to 1.44 in VC10

time to apologize. I just found this:

an update to the rvalue references specification, which forbids
exactly what the error message says. This makes my previous rant null
and void. The compiler is more up to date.

So sorry..

And the fix for boost.interprocess is as easy as including the cast to
the return type (also proposed in the spec update above).


On Wed, Aug 18, 2010 at 3:51 PM, Christopher Lux
<christopherlux_at_[hidden]> wrote:
> 2010/8/17 Ion Gaztañaga <igaztanaga_at_[hidden]>:
>>> The errors especially are show stoppers here, i am not that into
>>> rvalue references yet to see the problems with the templates in
>>> boost.interprocess.
>> Interprocess has not changed for this release, I had no time to update it
>> for the release (SVN head is updated though). VC10 is not still supported
>> (new move semantics are used by this compiler). You can try to disable
>> native rvalue references for this compiler in
>> boost/interprocess/detail/move.hpp
>> A quick fix is to replace BOOST_HAS_RVALUE_REFS in this header with another
>> non-existing macro.
> Hi,
> i dug into the move and rvalue issues and found the following:
> Everybody knows the following blog entry by Stephan T. Lavavej.
> In this post he has an example for move semantics etc. with the
> following move template:
> template <typename T> typename RemoveReference<T>::type&& Move(T&& t) {
>    return t;
> }
> NOW. I implemented an example very similar to his and got the same
> error as in boost.interprocess:
> 1>e:\...\rvalue_ref_test\main.cpp(34): error C2440: 'return' : cannot
> convert from 'rv_test' to 'rv_test &&'
> 1>          You cannot bind an lvalue to an rvalue reference
> 1>          e:\...\rvalue_ref_test\main.cpp(51) : see reference to
> function template instantiation 'rv_test &&scm_move<rv_test&>(T)'
> being compiled
> 1>          with
> 1>          [
> 1>              T=rv_test &
> 1>          ]
> As i dug into the STL that comes with VC10 i found that they implement
> the move template as follows:
> template<class _Ty> inline typename
> tr1::_Remove_reference<_Ty>::_Type&& move(_Ty&& _Arg)
> {
>    return ((typename tr1::_Remove_reference<_Ty>::_Type&&)_Arg);
> }
> NOW that works, and i am totally pissed off. Why do they publish blog
> posts with the correct way to handle it while their compiler requires
> a C-style cast in the move template function to get it working?
> Steven, i know you read in here. Is there an explanation for this?
> P.S. i attached my repo-example.
> Regards
> -chris
Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at