Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std_lib_facilities.h error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool' #15

Open
ivanusick opened this issue Apr 17, 2022 · 1 comment

Comments

@ivanusick
Copy link

ivanusick commented Apr 17, 2022

When using the subscript operator [] on a vector<bool> i.e

vector<bool> a;

a.push_back(true);

cout << a[0];

results in:

error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool'
87 | return std::vector::operator[](i);

Tested on gcc 11.2.0 and clang 13.0 for C++11

@cloudlakecho
Copy link

@ivanusick Did you check the true is the "bool" type? I guess the error be actually from a.push_back(true);.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants