1

I am using C++ boost's dynamic_bitset.

I have already allocated a variable and I just want to change its value - to construct it anew from an 'unsigned long' like from the constructor, but I don't want to allocate the memory again or to create a temporary variable.

What can I do?

R S
  • 11,359
  • 10
  • 43
  • 50

1 Answers1

1

I suppose you could clear it and then append the new value:

long x, y;
boost::dynamic_bitset<> bs(sizeof(long)*8, x);
bs.clear();
bs.append(y);
UncleBens
  • 40,819
  • 6
  • 57
  • 90