Long story short, I have

#include <vector>

template <class T>
class wrapped_vector {
private:
        std::vector<T> elements;
public:
        wrapped_vector() {
                elements.resize(20);
        }

        T& operator[](int i) {
                return elements[i];
        }

        const T& operator[](int i) const {
                return elements[i];
        }
};

int main(void) {
        wrapped_vector<int> test_int;
        test_int[0] = 1;

        wrapped_vector<bool> test_bool;
        test_bool[0] = true; // remove this line and it all compiles
}

and it gives me the compile error

test.cpp: In instantiation of ‘T& wrapped_vector<T>::operator[](int) [with T = bool]’:
test.cpp:28:13:   required from here
test.cpp:15:34: error: invalid initialization of non-const reference of type ‘bool&’ from an rvalue of type ‘std::vector<bool, std::allocator<bool> >::reference {aka std::_Bit_reference}’
Edit
Report