C++ 练习记录2---Effective STL中的vector<bool>
2014-12-31 20:29
441 查看
//vs2013 32位win8
cout << sizeof(bool) << endl;//1 deque<bool> d(1);
cout << sizeof(d[0]) << endl;//1
vector<bool> v(1);
cout << sizeof(v[0]) << endl;//16
cout << sizeof(d) << endl;//20
cout << sizeof(v) << endl;//24
v.resize(100);
d.resize(100);
cout << sizeof(d) << endl;//20
cout << sizeof(v) << endl;//24
//bool *p = &v[0];//无法编译
办法
不读源代码的情况下能不能通过外部黑盒测试证明vector<bool>只存储bit而非 字节序?
cout << sizeof(bool) << endl;//1 deque<bool> d(1);
cout << sizeof(d[0]) << endl;//1
vector<bool> v(1);
cout << sizeof(v[0]) << endl;//16
cout << sizeof(d) << endl;//20
cout << sizeof(v) << endl;//24
v.resize(100);
d.resize(100);
cout << sizeof(d) << endl;//20
cout << sizeof(v) << endl;//24
//bool *p = &v[0];//无法编译
办法
不读源代码的情况下能不能通过外部黑盒测试证明vector<bool>只存储bit而非 字节序?
相关文章推荐
- C++ 练习记录1--vector<T> 中T的初始化
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- Effective STL 18 avoid using vector<bool>
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- c++中为什么不提倡使用vector<bool>(转)
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- effective stl 第18条: 避免使用vector<bool>
- c++中bool数组与bitset,vector<bool>的使用与占用空间大小对比
- C++ std::vector<bool>
- C++基础——bitset与vector<bool>
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32