加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 花式指针是什么样的?

发布时间:2020-12-16 03:44:51 所属栏目:百科 来源:网络整理
导读:C参考文献提到了一个名为 fancy pointers的概念.我从最近一次严重的投票和后来删除的问题中了解到了它们的存在. 这个定义模糊不清: When the member type pointer is not a raw pointer type,it is commonly referred to as a “fancy pointer”. 他们的用
C参考文献提到了一个名为 fancy pointers的概念.我从最近一次严重的投票和后来删除的问题中了解到了它们的存在.

这个定义模糊不清:

When the member type pointer is not a raw pointer type,it is commonly referred to as a “fancy pointer”.

他们的用例示例如下:

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. Fancy pointers can be used independently of the allocator
that provided them,through the class template std::pointer_traits.

我不明白这个解释.创建花式指针的语法是什么?为什么我不能在这种情况下使用常规指针?

解决方法

花哨的指针只是一个像指针一样但不是指针的术语.以一个迭代器为例.几乎所有迭代器都是自定义类类型,但它们的行为就像一个指针(有时会有一些限制,你不能完成指针支持的所有操作,因为它们不提供随机访问,但这是一种幻想的一部分.)

换句话说:一个像指针一样的抽象是一个奇特的指针.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读