我需要创建一个具有 avector<self>作为成员变量的结构。Boost 提供了 2 种机制来实现这一点:
1 - 使用boost::recursive_wrapper即:
struct filter
{
uint32_t id;
std::vector< boost::recursive_wrapper< filter > > childFilters;
};
2 - 使用boost::container即:
struct filter
{
uint32_t id;
boost::container::vector< filter > childFilters;
};
每种技术有什么优势吗?第二个boost::container选项涉及较少的语法,我猜它使用类似于boost::recursive_wrapper内部的技术。