C++ 中的移动感知容器是什么?我知道 std::vector 是一个移动感知容器。但是我不知道移动感知是什么意思。
最佳答案
移动感知容器这个词出现在这个上下文中:
std::unique_ptr
is commonly used to manage the lifetime of objects, including:
...
* as the element type in move-aware containers, such asstd::vector
, which hold pointers to dynamically-allocated objects (e.g. if polymorphic behavior is desired)
这意味着容器知道如何处理只能移动的类型。 std::unique_ptr
是一个只能移动的类型:它不能被复制。这意味着包含仅移动类型对象的容器本身必须是仅移动的。
关于c++ - 什么是移动感知容器? C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40122545/