【发布时间】:2015-04-12 22:15:49
【问题描述】:
说我有
std::vector<T, allocator1=default allocator in STL> A
std::vector<T, allocator2=some other allocator> B
我在 Cilk Plus 中使用 __offload::shared_allocator 作为 allocator2 从主机 CPU 卸载到 Xeon Phi 协处理器
我可以从 B 构造 A 吗?
std::vector<T> A{B.begin(), B.end()};
更一般地说,不同分配器对哪种 STL 函数很重要?
【问题讨论】:
-
你调用的不是拷贝构造函数。
-
好吧对不起...我会改标题
-
只要它们不是微不足道的指针,
std::vector<T, std::allocator<T>>::iterator不是与std::vector<T, __offload::shared_allocator<T>>::iterator不同的类型吗? -
@nabijaczleweli 没关系(如果迭代器是 SCARY,它们也不需要),双迭代器构造函数接受所有输入迭代器。
-
@T.C.刚查了一下,你是对的。我是个白痴/正在考虑别的事情,对不起。
标签: c++ stl allocation xeon-phi cilk-plus