-
std::unique_lock and std::lock_guard
区别: https://blog.csdn.net/bingqingsuimeng/article/details/80606829
-
std::bind
说明: https://blog.csdn.net/tennysonsky/article/details/77447804
如果bind是非static的,std::bind(&MyClass::member, this, ......) -
std::function
使用方法参考https://blog.csdn.net/wangshubo1989/article/details/49134235 -
std::ref 和 std::cref
bind()是一个函数模板,它的原理是根据已有的模板,生成一个函数,但是由于bind()不知道生成的函数执行的时候,传递进来的参数是否还有效。所以它选择参数值传递而不是引用传递。如果想引用传递,std::ref和std::cref就派上用场了
参考 https://blog.csdn.net/lmb1612977696/article/details/81543802 -
std::move
std::move(t) 用来表明对象t 是可以moved from的,它允许高效的从t资源转换到lvalue上.void TestSTLObject() { std::string str = "Hello"; std::vector<std::string> v; // uses the push_back(const T&) overload, which means // we'll incur the cost of copying str v.push_back(str); std::cout << "After copy, str is \"" << str << "\"\n"; // uses the rvalue reference push_back(T&&) overload, // which means no strings will be copied; instead, the contents // of str will be moved into the vector. This is less // expensive, but also means str might now be empty. v.push_back(std::move(str)); std::cout << "After move, str is \"" << str << "\"\n"; std::cout << "The contents of the vector are \"" << v[0] << "\", \"" << v[1] << "\"\n"; } //执行结果: After copy, str is "Hello" After move, str is "" The contents of the vector are "Hello", "Hello
网友评论