Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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

C++
#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();
    }

}


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.
Posted
Updated 30-Mar-10 21:50pm
v2

Member 4409383 wrote:
the problem with my code is that i cannot make arrays of the dynamic_bitset

I guess you actually can.


Member 4409383 wrote:
vector<bool>bl;

Why did you define bl that way? It should be a vector of dynamic_bitset, shouldn't it?

:)
 
Share this answer
 
thank you very much. I got it corrected. But i used vector of boost rather then STL vectors.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900