cpp-ru / ideas

Идеи по улучшению языка C++ для обсуждения
https://cpp-ru.github.io/proposals
Creative Commons Zero v1.0 Universal
90 stars 0 forks source link

std::vector<bool> problem #440

Closed kirillgrachoff closed 1 year ago

kirillgrachoff commented 3 years ago

It is rude to write

template <typename T>
auto& get_at(std::vector<T>& container, size_t index) {
    // write to log
    return container[index];
}

std::vector::operator[] returns _Bit_Reference which cannot be cast to bool& or const bool&

It is also rude to write

T& value = container[index]

because of _Bit_Reference.

My suggestion is: Rename std::vector<bool> to std::dynamic_bitset (or similar) to prevent compile-errors because of std::vector<bool> specialization.

apolukhin commented 3 years ago

Это поломает очень много кода, такая идея не пройдёт голосование