Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
365 views
in Technique[技术] by (71.8m points)

c++ - What happens when you call data() on a std::vector<bool>?

C++11 has implemented data() member function on std::vector, which gives you a pointer to the memory array. Does this mean the template specialization std::vector<bool> have this member as well? Since this specialization doesn't store the data in terms of bool *, what kind of behavior can you expect from calling data() ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It won't compile, unless your implementation has a non-standard extension. The specialisation of std::vector<bool>, as specified in C++11 23.3.7/1, doesn't declare a data member.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...