J.D*_*Doe 5 c++ pointers stl unique-ptr stdtuple
把一个std::unique_ptr内部std::tuple工作没有任何问题,但是当tuple包含另一个tuple具有共同unique_ptr的元素,则编译器会引发错误。
例子:
std::tuple<int, std::unique_ptr<Entity>> tupleA {1, std::move(new Entity)};
//this line throws an error!
std::tuple<std::tuple<int, int>, std::unique_ptr<Entity>> tupleB {{1, 1}, std::move(new Entity)};
Run Code Online (Sandbox Code Playgroud)
error: no matching constructor for initialization of ´std::tuple<std::tuple<int, int>,std::unique_ptr<Entity>>´
note: candidate constructor template not viable: cannot convert initializer list argument to ´std::allocator_arg_t´
Run Code Online (Sandbox Code Playgroud)
这里的问题究竟是什么?
| 归档时间: |
|
| 查看次数: |
118 次 |
| 最近记录: |