|
Boost : |
Subject: Re: [boost] VC10 config - some regressions in several libraries
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2010-04-26 15:19:19
This is "rvalue references v2", supported by VC10 RTM and GCC 4.5. rrv2 prohibits rvalue references from binding to lvalues, and additionally permits casting lvalues to rvalues without creating temporaries; see http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2009/n2844.html#changes .
Writing code that works under rvalue references v1 and v2 simultaneously is generally easy. In particular, the move semantics and perfect forwarding idioms are unaffected. However, extreme caution must be used when reimplementing std::move() and std::forward(). Having struggled with this (during VC10's development, as we switched from v1 to v2, our Standard Library implementation had to cope with both), I recommend having separate implementations for v1 and v2 with a compiler version check. Because rrv1 created temporaries when casting lvalues to rvalues, I don't believe it's possible to write a move() that works under both v1 and v2, but I could be wrong.
Stephan T. Lavavej
Visual C++ Libraries Developer
-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of John Maddock
Sent: Monday, April 26, 2010 9:06 AM
To: boost_at_[hidden]
Subject: Re: [boost] VC10 config - some regressions in several libraries
> It seems that my problem with move emulation in projects imported from
> older MSVC to MSVC10 is that some rvalue references rules need language
> extensions option activated. Otherwise we can't have movable-only types.
It seems some explicit casts are required, for example in
boost/interprocess/detail/move.hpp:
template <class T> inline
typename remove_reference<T>::type&& move(T&& t)
{ return t; }
Should be either:
template <class T> inline
typename remove_reference<T>::type&& move(T&& t)
{ return std::move(t); }
or
template <class T> inline
typename remove_reference<T>::type&& move(T&& t)
{ return static_cast<typename remove_reference<T>::type&&>(t); }
Likewise for the "forward" function.
However that still leaves errors deep within the Boost.Preprocessor code:
1> adaptive_node_pool_test.cpp
1>m:\data\boost\trunk\boost\preprocessor\iteration\detail\local.hpp(37):
error C2664: 'boost::interprocess::forward' : cannot convert parameter 1
from
'boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType> '
to 'boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType>
*&&'
1> with
1> [
1> CharType=char,
1>
MemoryAlgorithm=boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
1> IndexType=boost::interprocess::iset_index
1> ]
1> You cannot bind an lvalue to an rvalue reference
1>
m:\data\boost\trunk\libs\interprocess\test\node_pool_test.hpp(146) : see
reference to function template instantiation 'T
*boost::interprocess::detail::named_proxy<SegmentManager,T,is_iterator>::operator
()<boost::interprocess::segment_manager<CharType,MemoryAlgorithm,IndexType>*>(P0
&&) const' being compiled
1> with
1> [
1> T=node_pool_t,
1>
SegmentManager=boost::interprocess::segment_manager<char,boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,boost::interprocess::iset_index>,
1> is_iterator=false,
1> CharType=char,
1>
MemoryAlgorithm=boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
1> IndexType=boost::interprocess::iset_index,
1>
P0=boost::interprocess::segment_manager<char,boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,boost::interprocess::iset_index>
*
1> ]
1>
m:\data\boost\trunk\libs\interprocess\test\adaptive_node_pool_test.cpp(24) :
see reference to function template instantiation 'bool
boost::interprocess::test::test_all_node_pool<node_pool_t>(void)' being
compiled
Which appear to have the same cause, but I'm unable to figure out what needs
changing.
Seems likely that gcc in C++0x mode has the same issues - creating an rvalue
ref needs an explicit cast.
HTH, John.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk