传递 const-reference 问答列表

在 std::thread 参数处引用

作者:Артём Гаркавый 提问时间:2/23/2021

我有两个功能 void f(const int &x) {} void g(int& x) {} 我能做到 int x = 0; std::thread t1(f, x); 但是我不能创造...

按值传递和 std::move 与转发引用

作者:Alex O 提问时间:10/28/2021

我经常遇到按值传递和移动的习语: struct Test { Test(std::string str_) : str{std::move(str_)} {} std::string str; ...


共2条 当前第1页