boostorg / dynamic_bitset

Boost.org dynamic_bitset module
http://boost.org/libs/dynamic_bitset
Boost Software License 1.0
38 stars 59 forks source link

With the constructor, assigning the default value does not work ? #78

Closed Jxtopher closed 1 week ago

Jxtopher commented 9 months ago

Hello,

Consider the following code:

#include <boost/dynamic_bitset.hpp>
#include <iostream>

int main() {
    auto bitset = boost::dynamic_bitset<>(10, true);
    std::cout << bitset << std::endl;
    return 0;
}

The result I expected:

1111111111

But the result is

0000000001

This behavior is it normal ?

On Debian with libboost1.74-dev:amd64.

Thanks in advance

jeking3 commented 1 week ago

This is functioning as designed. The documentation states that using a value in the constructor with this signature takes an unsigned long, and a conversion from bool is allowed. If you compile with a newer compiler or pedantic settings, it may warn you about it.