- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直将指针视为迭代器的一种特殊形式,用于在对象连续存储在内存中的特殊情况下。但是,我发现Allocator成员类型pointer
(然后在迭代器和容器上定义了相同的成员类型)不需要是真正的指针,但是根据cppreference,它可能是所谓的花式指针,
is used to access objects allocated in address spaces that differ from the homogeneous virtual address space.
std::vector
,它不会以连续的方式分配对象。对我而言,这已不再是媒介。如果我不希望对象在内存中是连续的,请使用列表而不是带有自定义分配器的 vector 。它们看起来像是造成困惑的一大根源,为什么要引入它们呢?
最佳答案
I've always seen pointers as a specialization of iterators
why were [fancy pointers] introduced?
Such pointers were introduced to support segmented memory architectures ...
... and are used today to access objects allocated in address spaces that differ from the homogeneous virtual address space that is accessed by raw pointers. An example of a fancy pointer is the mapping address-independent pointer boost::interprocess::offset_ptr, which makes it possible to allocate node-based data structures such as std::set in shared memory and memory mapped files mapped in different addresses in every process.
- Scenario A. "Offset" pointers with a modified bit-level representation.
- Scenario B. Small-data-area "near" pointers.
- Scenario C. High-memory-area "far" pointers.
- Scenario D. "Fat" pointers carrying metadata for dereference-time.
- Scenario E. "Segmented" pointers carrying metadata for deallocate-time.
关于c++ - 为什么花哨的指针存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62700637/
我有一个网站,其 Vanity URL 模块实现得非常糟糕,并且在某些时间段的负载非常高。由于url模块存在一些bug,系统需要经常重启。所以,我想重写一个该死的模块,使其变得更好并且更少错误....
我是一名优秀的程序员,十分优秀!