BitLib icon indicating copy to clipboard operation
BitLib copied to clipboard

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

Open bkille opened this issue 3 years ago • 0 comments

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 avatar May 02 '22 20:05 bkille