C++ (Qt)struct Test{ void foo () && { ::std::cout << "Hello rvalue foo method." << ::std::endl; } void bar () && { ::std::cout << "Hello rvalue bar method." << ::std::endl; }};
C++ (Qt)template<class T> struct wrapper{ T m_value; void exec () && { ::std::move( m_value ).foo(); ::std::move( m_value ).bar(); // 100500 times using of ::std::move( m_value ) }};
C++ (Qt)template<class T> struct wrapper{ T m_value; void exec () && { ::std::forward< T && >( m_value ).foo(); ::std::forward< T && >( m_value ).bar(); }};
C++ (Qt)template<class T> struct wrapper{ T m_value; void exec () & { ::std::forward< T & >( m_value ).foo(); ::std::forward< T & >( m_value ).bar(); } void exec () const && { ::std::forward< T const && >( m_value ).foo(); ::std::forward< T const && >( m_value ).bar(); } // ...};
C++ (Qt)template<class T> struct wrapper{ T m_value; void exec () & { ::std::forward< T & >( m_value ).foo(); ::std::forward< T && >( m_value ).bar(); } void exec () const && { ::std::forward< T const && >( m_value ).foo(); ::std::forward< T const && >( m_value ).bar(); }};
C++ (Qt)template<class T> struct wrapper{ T m_value; void exec () & { static_cast< T & >( m_value ).foo(); static_cast< T && >( m_value ).bar(); } void exec () const && { static_cast< T const && >( m_value ).foo(); static_cast< T const && >( m_value ).bar(); }};
C++ (Qt)wrapper< Test >().m_value; // rvalue
C++ (Qt)Test().foo(); // OkTest test;test.foo(); // Errorstatic_cast< Test && >( test ).foo(); // Ok
C++ (Qt)::std::move( value ).foo(); // что и куда перемещаем? что имеется в виду?container.append( ::std::move( value ) ); // содержимое value перемешается в контейнер и, возможно, сам value некорректен.