bitset用法总结
来源:互联网 发布:win10重置数据丢失 编辑:程序博客网 时间:2024/05/05 08:16
一般而言,标准库提供的bitset操作更直接、更容易阅读和书写、正确使用的可能性更高。而且,bitset对象的大小不受unsigned数的位数限制。通常来说,bitset优于整形数据的低级位操作。
bitset的几个操作和位运算之间的转化。
bitset<32> bs(88);
unsigned long l=88;
bs.set(6);
l |= 1UL<<6;
bs.reset(6);
l &= ~(1UL<<6)
构造函数可以传入一个string或者unsigned long。
简单介绍bitset的方法,copy msdn(在这里不做翻译了)。
any
The member function tests whether any bit in the sequence is set to 1.
count
The member function returns the number of bits set in the bit sequence.
flip
Toggles the value of all the bits in a bitset or toggles a single bit at a specified position.
这个函数的作用就是将所有的bit求反或者将指定位的bit求反,注意位都是从右边0开始的。
none
Tests if no bit has been set to 1 in a bitset object.
reset
Resets all the bits in a bitset to 0 or resets a bit at a specified position to 0.
set
Sets all the bits in a bitset to 1 or sets a bit at a specified position to 1.
size
Returns the number of bits in a bitset object.
test
Tests whether the bit at a specified position in a bitset is set to 1.
to_string
Converts a bitset object to a string representation.
to_ulong
Converts a bitset object to the integer that would generate the sequence of bits contained if used to initialize the bitset.
- bitset用法总结
- STL bitset用法总结
- STL bitset用法总结
- c++ bitset用法总结
- STL bitset用法总结
- [面试经]STL bitset用法总结
- bitset用法
- bitset用法
- BitSet用法
- bitset 用法
- bitset<>用法
- bitset 用法
- bitset 用法
- bitset用法
- bitset用法
- bitset总结
- bitset用法整理
- bitset用法整理
- 《编写有效用例》学习笔记
- Android 程序开发浅谈
- SWT RCP图片显示问题
- 经典有用的SQL语句收集
- 华为相关
- bitset用法总结
- build.xml文件配置源代码
- 查询并删除回收站内容
- 【笔记】一、场景、实体、结点
- 【笔记】二、摄像机、视口、光照、阴影
- September 27th Sunday
- 爱情没有合适不合适,只有珍惜不珍惜
- 【笔记】三、场景管理器、地形、天空、雾化
- 【笔记】四、帧监听、无缓冲输入