Re: C++0x: unfortunate interaction of rvalue references and concepts
On 10 Dez., 14:58, David Abrahams <d...@boostpro.com> wrote:
http://www.boostpro.com/writing/n2812_08-0322_soundness.html
The std::forward solution does look odd, though:
template<typename T>
inline T& forward(typename std::identity<T>::type& x)
{ return x; }
Shouldn't it be T&& as return type? I was thinking of...
template<typename T>
inline T&& forward(typename remove_reference<T>::type & x)
{ return static_cast<T&&>(x); }
template<typename T>
inline T&& forward(typename remove_reference<T>::type && x)
{ return static_cast<T&&>(x); }
SFINAE doesn't seem to be necessary. The functions only differ
in their argument type (lvalue ref versus rvalue ref). T&& might
be an lvalue reference or rvalue reference in either of both
functions. So, an explicit cast is necessary.
Do we actually need the 2nd version at all? The arguments for
std::forward are lvalues in the cases it was designed for.
Cheers!
SG
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]