大佬教程收集整理的这篇文章主要介绍了c – 为什么采用迭代器的构造函数需要元素为EmplaceConstructible?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
X(i,j) X a(i,j)
要求容器的元素类型为EmplaceConstructible.@H_772_10@
requires: T shall be EmplaceConstructiblE into X from *i
我认为构造函数可以通过为范围中的每个迭代器调用std :: allocator_Traits :: construct(m,p,* it)方法来实现(其中m – 类型A的分配器,p – 指向内存的指针,它 – 迭代器in [i; j),并且只需要CopyInsertable元素的概念,因为只提供一个参数用于复制/移动,而EmplaceConstructible概念要求元素由一组参数构造.这个决定有什么理由吗?@H_772_10@
char s[] = "Hello World!"; std::vector<int> v(std::begin(s),std::end(s)); // int is EmplaceConstructible from char
一个(人为的)示例,其中T不是CopyInsertable:@H_772_10@
struct nocopy { nocopy(int) {} nocopy(nocopy const&) = delete; nocopy(nocopy&&) = delete; }; int a[]{1,2,3}; std::vector<nocopy> v(std::begin(a),std::end(a));
以上是大佬教程为你收集整理的c – 为什么采用迭代器的构造函数需要元素为EmplaceConstructible?全部内容,希望文章能够帮你解决c – 为什么采用迭代器的构造函数需要元素为EmplaceConstructible?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。