5
有什么办法可以使这项工作?我希望你明白我的意思,我想通过创建递归对手段boost ::变异递归问题
#include <boost/variant.hpp>
#include <utility>
struct nil {};
typedef boost::make_recursive_variant<nil, std::pair<int, boost::recursive_variant_ >>::type list_t;
int main() {
list_t list = { 1, (list_t){ 2, (list_t){ 3, nil() } } };
return 0;
}
对不起,“带来的仇恨”有点迟,可以这么说,但我只是碰到了一个相关的问题。无需将指针放在boost.variant中 - recursive_variant包装器在内部使用`boost :: shared_ptr`,因此您的'无限大小'声明为false。基于堆栈的方案不能保证,只有在所有构造函数(模板参数)都具有nothrow构造函数的情况下才能使用。你可以在这里阅读更多关于它的信息:http://www.boost.org/doc/libs/1_46_1/doc/html/variant/design.html#variant.design.never-empty(寻找'临时堆备份') 。 – phooji 2011-03-26 15:30:58