在哪里可以找到 std::bitset 的数据成员?
Where can I find data member of std::bitset?
当我阅读cpp首选项上的bitset页面时,我试图找到一些数据成员列来查看数据的存储方式。我发现没有这样的列,也没有另一个 std 类,例如std:string
.然后我去 https://github.com/llvm-mirror/libcxx/blob/master/include/bitset,检查位集概要注释部分,我找不到关于它的数据成员。为什么?我在这里错过了什么?任何标准类的示例将不胜感激。
CppReference记录了公共接口,这是标准要求的唯一内容,也是您应该关心的内容。
libc++ 标头的概要也是如此:它只是标准的复制粘贴,可能作为库实现者的参考放在那里。您可以在下面找到实现的细节。
STL 容器的数据成员是你不应该关心的实现细节,并且可能会发生变化,无论是在各种标准库实现之间,还是对于同一库的不同版本,甚至不同的编译标志。
检查libcxx实现,以下受保护的数据成员是实际位的实现方式。
https://github.com/llvm-mirror/libcxx/blob/master/include/bitset#L163
template <size_t _N_words, size_t _Size>
class __bitset {
public:
typedef size_t __storage_type;
// ...
protected:
// ...
__storage_type __first_[_N_words]; // <========= the data
};
// ...
template <size_t _Size>
class _LIBCPP_TEMPLATE_VIS bitset
: private __bitset<
_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size>
{ /* ... */ };
相关文章:
- 用于访问容器<T>数据成员的正确 API
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 数据成员SFINAE的C++17测试:gcc vs clang
- 派生类是否可以在抽象工厂设计模式中具有数据成员
- 如何在c++中定义以struct为数据成员的类中的构造函数
- 静态数据成员模板专用化的实例化点在哪里
- int数据类型的指针指向的是什么,如果是一个类的私有数据成员,我们创建了该类的两个对象?
- 使用指针访问数组中的对象数据成员
- 友元函数无法访问私有数据成员 (c++)
- 我可以在 C++ 中将数据成员/变量从其定义之外添加到结构中吗?
- 为什么将一个结构的引用设置为等于另一个结构只会更改一个数据成员?
- 将私有数据成员添加到野牛生成的类中
- 输入数据成员未按要求工作
- 二维矢量数据成员
- 在类 A 中创建类型为 B 类的向量 - 访问数据 [C++] [成员在两个类中都是私有的]
- 调用在 HXX 文件中声明的静态数据成员
- 是否可以根据其数据成员的类型确定类型的大小
- 访问数据成员(本身是对象)的数据成员,就好像它们是类成员一样
- 使公共数据成员在C++中无法访问
- 在哪里可以找到 std::bitset 的数据成员?