By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,507 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,507 IT Pros & Developers. It's quick & easy.

vector<int> and vector<bool>

P: n/a
------ foo.cpp ------
#include <vector>
using namespace std;

int main()
{
const vector<int> v1 (10);
const vector<bool> v2 (10);

&v1[0];
&v2[0]; // Line#10

return 0;
}
---------------------

--- Compilation ---

// g++ 3.3.3

$ g++ -W -Wall foo.cpp
foo.cpp: In function `int main()':
foo.cpp:10: error: non-lvalue in unary `&'

-------------------
Why can't we get a pointer to the first element of vector<bool> ?

--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn


Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Alex Vinokur" <al****@big-foot.com> wrote in message
------ foo.cpp ------
#include <vector>
using namespace std;

int main()
{
const vector<int> v1 (10);
const vector<bool> v2 (10);

&v1[0];
&v2[0]; // Line#10

return 0;
}
---------------------

--- Compilation ---

// g++ 3.3.3

$ g++ -W -Wall foo.cpp
foo.cpp: In function `int main()':
foo.cpp:10: error: non-lvalue in unary `&'

-------------------
Why can't we get a pointer to the first element of vector<bool> ?


vector<bool> is not a container and it does not contain bools. Read this -
http://www.gotw.ca/publications/mill09.htm

Sharad


Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.