从结构使用boost :: dynamic_bitset [英] Using boost :: dynamic_bitset from a struct

查看:60
本文介绍了从结构使用boost :: dynamic_bitset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我试图在结构中使用动态位集,然后在运行时初始化大小.对于该结构,它起作用:

结构s {
boost :: dynamic_bitset<> x();
} s1;

但是现在如何在代码中使用它?例如,我将如何调整大小?这对我不起作用:

s1.x.resize(5);

我应该使用什么?

Hello,

I am trying to use a dynamic bitset in a struct and then initialize the size at runtime. For the struct this works:

struct s{
boost::dynamic_bitset<> x();
}s1;

But now how do I use it in the code? For instance how would I resize it? This does not work for me:

s1.x.resize(5);

What am I supposed to use?

推荐答案

"x()"应该仅为"x",那么您可以正确使用它
"x()" should be only "x" then you can use it properly


尝试找到与您的代码有一个(或两个)差异的方法:):
Try to find one (or two) difference(s) to your code :) :
struct {
  int iVar;
} s;
 

void Test()
{
  s.iVar = 0;
}


这篇关于从结构使用boost :: dynamic_bitset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆