提升Dynamic_bitset [英] Boost Dynamic_bitset
问题描述
我正在使用Boost C ++库来做一些工作.为此,我正在使用boost库的Dynamic_bitset,我的代码存在的问题是我无法创建dynamic_bitset的数组
以下是我的完整代码和我想问的问题
I am using Boost C++ library to do some work. For that i am using Dynamic_bitset of boost library, the problem with my code is that i cannot make arrays of the dynamic_bitset
below is my complete code and the questions i want to ask
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <algorithm>
#include <string.h>
#include <sstream>
#include <math.h>
#include <stdio.h>
//#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include "boost/multi_array.hpp"
using namespace std;
#include "stringtoken_class.h"
//------------------------------------------------------------
class orand
{
public:
int numxor;
int numand;
int numlit;
};
orand ornd;
orand ifcontains(string func);
//----------------------------------------------------------
int main(int argc,char *argv[])
{
orand ob;
ob=ifcontains("f21=x0+x2x6x9x10x13+x2x9x10x12+x2x12+x6");
cout<<"Number of XOR= "<<ob.numxor<<endl;
cout<<"Number of AND= "<<ob.numand<<endl;
cout<<"Number of LIT= "<<ob.numlit<<endl;
return 0;
}
orand ifcontains(string func)
{
//--------------------------------------------------------
//variables
int degree,count_plus=0,count_x=0,nextint=0;
int i,j;
string st1,st2;
vector<bool>bl;
//--------------------------------------------------------
StringTokenizer stk1(func,"f");
degree=stk1.nextIntToken();
boost::dynamic_bitset<> product_value(degree);
StringTokenizer stk2(func,"=");
stk2.nextToken();
st1=stk2.nextToken();
StringTokenizer stk3(st1,"+");
count_plus=stk3.countTokens();
for(i=0;i<count_plus;i++)
{
StringTokenizer stk4(stk3.nextToken(),"x");
count_x=stk4.countTokens();
for(j=0;j<count_x;j++)
{
nextint=stk4.nextIntToken();
product_value[nextint]=1;
}
cout<<product_value<<endl;
// bl.push_back(product_value); error at this point please tell me the solution, i dont want to covert this data to Integers i want them in Ints.
product_value.reset();
}
}
我想在数组中存储变量"product_value"的值,该数组的类型为boost :: dynamic_bitset.我不想将"product_value"的值转换为整数等,因为我需要它们具有相同的类型(boost :: dynamic_bitset).
如果有人可以提供帮助,我将非常感谢.
i want to store the value of varaible "product_value" in array the type of this array is boost::dynamic_bitset. I dont want to convert the value of "product_value" to integer etc becuase i need them in same type(boost::dynamic_bitset).
I will be very thankful if someone could help.
推荐答案
我的代码存在的问题是我无法创建dynamic_bitset的数组
the problem with my code is that i cannot make arrays of the dynamic_bitset
我想你真的可以.
I guess you actually can.
vector< bool> bl;
vector<bool>bl;
为什么用这种方式定义bl
?应该是dynamic_bitset
的vector
,不是吗?
:)
Why did you define bl
that way? It should be a vector
of dynamic_bitset
, shouldn''t it?
:)
非常感谢.我纠正了.但是我用的是boost的向量,而不是STL的向量.
thank you very much. I got it corrected. But i used vector of boost rather then STL vectors.
这篇关于提升Dynamic_bitset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!