【STL】list的构造函数
来源:互联网 发布:iphone录制视频软件 编辑:程序博客网 时间:2024/05/16 04:56
构造函数的声明:
explicit list( const Allocator& _Al ); explicit list( size_type _Count ); list( size_type _Count, const Type& _Val ); list( size_type _Count, const Type& _Val, const Allocator& _Al ); list( const list& _Right ); template<class InputIterator> list( InputIterator _First, InputIterator _Last ); template<class InputIterator > list( InputIterator _First, InputIterator _Last, const Allocator& _Al ); list( list&& _Right );例子:
// list的构造函数void test_list_constructor(){std::list<int>::iterator c4_Iter, c5_Iter;// 0. Create an empty list c0std::list<int> c0;// 1. Create a list c1 with 3 elements of default value 0std::list<int> c1(3);// 2. Create a list c2 with 5 elements of value 2std::list<int> c2(5, 2);// 3. Create a list c3 with 3 elements of value 1 and with the // allocator of list c2std::list<int> c3(3, 1, c2.get_allocator());// 4. Create a copy, list c4, of list c2std::list<int> c4(c2);// 5. Create a list c5 by copying the range c4[_First, _Last)c4_Iter = c4.begin();c4_Iter++;c4_Iter++;std::list<int> c5(c4.begin(), c4_Iter);// 6. Create a list c6 by copying the range c4[_First, _Last) and with // the allocator of list c2c4_Iter = c4.begin();c4_Iter++;c4_Iter++;c4_Iter++;std::list<int> c6(c4.begin(), c4_Iter, c2.get_allocator());std::cout << "c1 = ";std::copy(c1.begin(), c1.end(), std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl;std::cout << "c2 = ";std::copy(c2.begin(), c2.end(), std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl;std::cout << "c3 = ";std::copy(c3.begin(), c3.end(), std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl;std::cout << "c4 = ";std::copy(c4.begin(), c4.end(), std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl;std::cout << "c5 = ";std::copy(c5.begin(), c5.end(), std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl;std::cout << "c6 = ";std::copy(c6.begin(), c6.end(), std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl;}
- 【STL】list的构造函数
- list的构造函数
- STL容器的构造函数
- STL的list成员函数
- 【STL】vector的五种构造函数
- STL deque的构造函数(2)
- 关于STL中list的erase()函数
- 【STL】list常用函数的例子
- STL 中list的sort函数实现
- STL list的成员函数sort解析
- STL之list的sort函数
- [STL] list merge 函数
- [STL] list merge 函数
- STL list常用函数
- STL <list> 常用函数
- STL vector的构造函数和析构函数(2)
- STL的remove函数和list的remove成员函数
- STL的remove函数和list的remove成员函数
- Android中集成第三方软件包(.jar, .so)
- 玛丽向右走
- unity3d解析json
- RST Annotation Tool
- 题目:利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示......
- 【STL】list的构造函数
- 编写高效的Android代码
- 初步认识webservices
- 远程视频会议技术之未来
- 数据类型的一些问题
- 一些题的总结
- HDU2768二分图求最大独立集
- MFC UI库知多少
- C#设计模式(23种设计模式)