矢量< BOOL> [英] vector<bool>

查看:75
本文介绍了矢量< BOOL>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在有效的STL中,它表示不应该使用vector< bool>但是使用

dequeue< bool>相反。


但是可以出列< bool>有随机访问迭代器?我这样做了吗?

dequeue< bool> myboolarray;

if(myboolarray [3]){

//这样做...

}


如果没有,还有其他解决方案吗?


谢谢。

解决方案

< blockquote> Piotr写道:

在有效的STL中,它说不应该使用vector< bool>但是使用
dequeue< bool>相反。

但是可以出列< bool>有随机访问迭代器?我这样做了吗?
dequeue< bool> myboolarray;
if(myboolarray [3]){
//这样做......
}




教一个男人鱼......

http:// www.sgi.com/tech/stl/Deque.html


(哪个有效的C ++项目#是RTFM?)


卢克


PS是的。


Piotr写道:

在有效的STL中,它说不应该使用vector< bool>但是使用
dequeue< bool>代替。


容器称为deque,而不是dequeue。抛开

拼写错误,这通常是一个很好的建议,除非你可以忍受

vector< bool>'的限制。

但是可以出列< bool>有随机访问迭代器?


是的,但同样,它是deque< bool>,而不是dequeue< bool>。

我这样做了吗?
dequeue< ; BOOL> myboolarray;
if(myboolarray [3]){
//这样做......
}




是的,如果你修复拼写错误。


祝你好运,


Tom


< BLOCKQUOTE>谢谢。我尝试了这个,但它失败了这个编译错误:


Matcher.h:11:错误:ISO C ++禁止声明''deque''没有

类型

Matcher.h:11:错误:预期'';''之前''<''令牌


你能否告诉我为什么?

#include< deque>

#include< algorithm>


class Matcher {


受保护:

deque< bool>内容;

};


In effective STL, it said one should not use vector<bool> but use
dequeue<bool> instead.

But can dequeue<bool> has random access iterator? and I do this?
dequeue<bool> myboolarray;
if (myboolarray[3]) {
// do this...
}

if not, is there another solution?

Thank you.

解决方案

Piotr wrote:

In effective STL, it said one should not use vector<bool> but use
dequeue<bool> instead.

But can dequeue<bool> has random access iterator? and I do this?
dequeue<bool> myboolarray;
if (myboolarray[3]) {
// do this...
}



Teach a man to fish...

http://www.sgi.com/tech/stl/Deque.html

(Which Effective C++ Item# is RTFM?)

Luke

P.S. Yes.


Piotr wrote:

In effective STL, it said one should not use vector<bool> but use
dequeue<bool> instead.
The container is called a "deque", not a "dequeue." Leaving aside the
spelling error, that''s often good advice, unless you can live with
vector<bool>''s limitations.
But can dequeue<bool> has random access iterator?
Yes, but again, it''s a deque<bool>, not dequeue<bool>.
and I do this?
dequeue<bool> myboolarray;
if (myboolarray[3]) {
// do this...
}



Yes, if you fix the spelling error.

Best regards,

Tom


Thanks. I tried this, but it fails with this compiler error:

Matcher.h:11: error: ISO C++ forbids declaration of ''deque'' with no
type
Matcher.h:11: error: expected '';'' before ''<'' token

Can you please tell me why?
#include <deque>
#include <algorithm>

class Matcher {

protected:
deque<bool> content;
};


这篇关于矢量&lt; BOOL&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆