C++ (Qt)QList<int> lst = this->GeList();
C++ (Qt)QList<int> lst;this->GeList(lst);
C++ (Qt)std::string &&str = std::string("Hello");
C++ (Qt)template < typename _Value >class Wraper{ _Value m_value;public: _Value * operator -> () & { return &m_value; } // ??? operator -> () && { return ???; }};
C++ (Qt) Wraper< My >()->rvalueMethod();
C++ (Qt)#include <iostream> template < typename value >class Wraper{ // _Value m_value; <-- UB value m_value; public: Wraper():m_value(10){} value* lvalueMethod() & { return &m_value; } value* rvalueMethod() && { return &m_value; }}; int main(){ auto r = *Wraper<int>().rvalueMethod(); std::cout << r << '\n';}
C++ (Qt)struct My{ void rvalueMethod () && {} void lvalueMethod () & {}}; template < typename _Value >class Wraper{ _Value m_value;public: _Value * operator -> () & { return &m_value; } // ??? operator -> () && { return ???; }}; void foo (){ Wraper< My >()->rvalueMethod();}
C++ (Qt)#include <iostream>#include <memory>#include <string> struct payload{ std::string m_value = "hello"; std::string& lvalueMethod()& { return m_value; } std::string&& rvalueMethod()&& { return std::forward< std::string&& >(m_value); }}; template<typename value> struct wrapper{ value m_value = {}; value& operator*()& { return m_value; } value&& operator*()&& { return std::forward< value&& >(m_value); }}; int main(){ std::string&& val = (*wrapper<payload>()).rvalueMethod(); // OK std::cout << "val = " << std::endl;}
C++ (Qt)(*&wrapper<payload>()).rvalueMethod();
C++ (Qt)// Потокобезопасный неявно распределенный вектор целочисленных значенийusing ThreadSafeImplisitVector = Instance< Instance< ::std::vector< int >, Implicit >, ThreadSafe >;ThreadSafeImplisitVector featured_vector;// применять обычным способомfor ( int i =0; i < 100; ++i ) featured_vector[i] = i;
C++ (Qt)template < typename _Arg >decltype(auto) foo ( _Arg && arg ){ return ::std::move( arg );} template < typename _Arg >decltype(auto) bar ( _Arg && arg ){ return ::std::forward< _Arg >( arg );}
C++ (Qt)Data value;foo( value ); // rvaluebar( value ); // lvalue foo( Data() ); // rvaluebar( Data() ); // rvalue
C++ (Qt)template<typename value> struct wrapper;