std::vector<char> RequestCmder::getRefreshBeds()
{
std::vector<char> data = {(char)0xfd, (char)0xfd, (char)0xfd, (char)0xfd, 0x01, 0x01, 0x05, 0x00,
0x02, 0x01, 0x03, 0x00, 0x0d};
return data;
}
对返回值为自定义类型,以值形式返回时,会多一次复制构造,使用std::move
返回右值减少构造。
c++11后的编译器对此类数据返回有优化,会直接在调用此函数的位置构造返回值,所以不加std::move
也没事。
另外参考资料
https://stackoverflow.com/questions/14856344/when-should-stdmove-be-used-on-a-function-return-value