bkille / BitLib

Provides a bit-vector, an optimized replacement of the infamous std::vector<:b:ool>. In addition to the bit-vector, the library also provides implementations of STL algorithms tailored for bit-vectors.
BSD 3-Clause "New" or "Revised" License
68 stars 4 forks source link

`auto` deduces type as reference even without `&` #30

Closed bkille closed 1 year ago

bkille commented 2 years ago

auto will deduce the type as a reference type, even without the &. This means that:

bit::bit_vector<unsigned char> bvec{"110110"};
auto b = bvec.front() // Should be copied, auto -> bit_value, but instead auto -> bit_reference
b = ~b;
std::cout << bvec.debug_string() << std::endl; // Outputs 010110
bkille commented 1 year ago

front() should return a reference, so this is as expected