- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经声明了以下 node
继承自 boost::intrusive::slist_base_hook<>
:
class InputBufferSglNode : public boost::intrusive::slist_base_hook<>
包含这些节点的列表的声明:
class InputBufferSglList : public boost::intrusive::slist<InputBufferSglNode, boost::intrusive::cache_last<true>>
我想从InputBufferSglList
得到根节点成员函数,所以我尝试这样做:
InputBufferSglNode* node = this->get_root_node();
但我得到一个错误:
error: cannot initialize a variable of type 'InputBufferSglNode *' with an rvalue of type 'node_ptr' (aka 'boost::intrusive::slist_node<void *> *')
我应该投 node_ptr
吗?至 InputBufferSglNode*
?应该是哪个铸件?
最佳答案
get_root_node
不是记录的 API 的一部分。
你在找什么
InputBufferSglNode& node = *this->begin();
如果你对反向感兴趣:
更新:
我在文档中阅读了更多内容,并且有一种方法可以通过使用列表类型的派生 value_traits 来做你想做的事:
InputBufferSglNode* node =
InputBufferSglList::value_traits::to_value_ptr(list.get_root_node());
这使用了 ValueTraits interface 是所有侵入式容器的基础。
对于所有常见的节点默认 Hook ,它会导致一些偏移算法(例如,从成员地址到节点地址)。但在实践中,它可能涉及类层次结构的上下转换(尤其是在涉及虚拟基础时)。
对于任何trivial_value_traits to_value_ptr
和 to_node_ptr
都是恒等函数。
关于c++ - 如何将 slist 'node_ptr' 转换为我自己的节点类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27215366/
我使用的是 Windows 7 SP1 64 位。在 WinDBG 中,我打开一个可执行文件,然后输入命令 !slist $teb _EXCEPTION_REGISTRATION_RECORD 0 但
我正在使用 Boost 1.60 adjacency_list 并希望将 slistS 用于模板参数 OutEdgeList: using Graph = boost::adjacency_list;
我已经声明了以下 node继承自 boost::intrusive::slist_base_hook<> : class InputBufferSglNode : public boost::intr
我需要的只是一个动态增长的数组。我不需要随机访问,我总是插到最后,从头读到尾。 slist 似乎是首选,因为它提供了我所需要的。但是,我不知道使用 slist 而不是 vector 有什么好处。此外,
我是 STL 新手。我发现 slist(单链表)不是标准 C++ 标准的一部分。那么如何在我的程序中使用它呢? 我下载了 slist.h并粘贴在 C:\Program Files (x86)\Micr
当我尝试将我的 Win32 代码从 Microsoft 工具链移植到 MinGW 时,大多数代码都可以正常编译,但也有少数异常(exception)。 MinGW 中似乎缺少的一个特定 API 是 S
我一直在研究如何使用 sys/queue.h 中定义的宏来使用单链表,但我有一些疑问。目前我正在尝试使用相同的方法创建一个简单的列表。请注意,下面的程序是不完整的,我只输入了我认为相关的部分。 int
在两个boost::intrusive::slist>之间转移节点是否有效对象?类似下面的内容 auto one = boost::intrusive::slist>{}; auto two = bo
Windows 提供了一个无锁的单向链表,如本页所述: Win32 SList 我想知道是否有围绕此功能的现有良好 C++ 包装器。当我说好时,我的意思是它尽可能地导出通常的 STL 接口(inter
我正在使用 Ubuntu。 g++ 版本 4.7.2。 任何人都可以帮我处理 gnu-extension 单列表吗?我在这里编译了这些东西,并在执行时得到了一个核心转储。 我调试了它,看到核心转储发生
我正在尝试让一些旧的第三方软件在 OS X 10.9 上编译。通过调整 Makefile 中的设置,我设法摆脱了大多数编译问题,这些 Makefile 最初是为 gcc 编写的,大概是在 2005 年
对于一个不需要随机访问列表元素的简单链表,使用 std::list 代替 std 是否有任何显着优势(性能或其他方面): : vector ?如果需要向后遍历,在遍历其元素之前使用 std::slis
我是一名优秀的程序员,十分优秀!