std::vector<bool>表现类似std::vector,但为节省空间,它: 不必作为连续数组存储元素 暴露类std::vector<bool>::reference为访问单个位的方法。尤其是,operator[]以值返回此类型的对象。 不使用std::allocator_traits::construct构造位值。 不保证同一容器中的不同元素能由不同线程同时修改。
std::vector(对于bool以外的T)满足容器(Container)、知分配器容器(AllocatorAwareContainer)、序列容器(SequenceContainer)、连续容器(ContiguousContainer)(C++17 起)及可逆容器(ReversibleContainer)的要求。 std::vector的成员函数都是constexpr的:可以在常量表达式的求值中创建并使用std::vector对象。
std::vector<bool> Member functions vector::vector vector::~vector vector::operator= vector::assign vector::get_allocator Element access vector::at vector::operator[] vector::front vector::back Iterators vector::beginvector::cbegin (C++11) vector::endvector::cend (C++11) vector::rbeginvector...
#include <iostream>#include <vector>voidprint(conststd::vector<bool>&vb){for(constboolb:vb)std::cout<<b;std::cout<<'\n';}intmain(){std::vector<bool>v{0,1,0,1};print(v);v.flip();print(v);} Output: 0101 1010 See also ...
vector<bool> space-efficient dynamic bitset (class template specialization) Iterator invalidation OperationsInvalidated All read only operationsNever. swap,std::swapend() clear,operator=,assignAlways. reserve,shrink_to_fitIf the vector changed capacity, all of them. If not, none. ...
vector<bool> space-efficient dynamic bitset (class template specialization) Iterator invalidation OperationsInvalidated All read only operationsNever. swap,std::swapend() clear,operator=,assignAlways. reserve,shrink_to_fitIf the vector changed capacity, all of them. If not, none. ...
此外,生成的std::atomic特化具有标准布局和平凡的析构函数。 即使结果在浮点类型中不可表示,也不会有操作导致未定义的行为。有效的浮点环境可能与调用线程的浮点环境不同。 类型别名 类型别名为 bool 和所有上述整数类型提供了如下别名: 对所有 std::atomic 的别名 ...
Die Standard-Bibliothek bietet eine Spezialisierung vonstd::vectorfür den Datentypbool, die in Bezug auf Speicherplatz optimiert ist. vector<bool> platzsparendes dynamisches Bitset (Klassen-Template)[edit] Mitglied Typen Mitglied Typ Original: ...
std::hash<std::vector<bool>> (C++11) soutien de hachage pour std::vector<bool> Original: hash support for std::vector<bool> The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe générique sp...
Original: hash support for std::vector<bool> The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (class Template-Spezialisierung) std::hash<std::thread::id> (C++11) Hash-Unterstützung für std::thre...