繁体   English   中英

打印升压:: circular_buffer <T>

[英]Print boost::circular_buffer<T>

我想做一个模板函数来输出boost :: circular_buffer的内容。 这是有问题的代码:

template <typename T>
std::ostream& operator<<(std::ostream& os, const boost::circular_buffer<T>& cb){
   boost::circular_buffer<T>::const_iterator it;
   for(it=cb.begin(); it!=cb.end(); it++){
      os << it;
   }
   os << std::endl;
   return os;
}

发生以下错误:

need ‘typename’ before boost::circular_buffer<T>::const_iterator’ because ‘boost::circular_buffer<T>’ is a dependent scope

提前谢谢。

下次请看一下错误消息,很明显是错误的:

在boost :: circular_buffer :: const_iterator之前需要'typename',因为'boost :: circular_buffer'是一个依赖范围

是的,只要执行错误消息中所说的内容即可:

typename boost::circular_buffer<T>::const_iterator it;

您可以在此线程中阅读有关依赖名称的信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM