如何使用ostream_iterator<>编译时的通用容器?
我想使用 copy() 打印出 T 类型容器的内容。我尝试过:
template<typename T>
void print_con( const T& con, const string& sep = ", ", const string& ms = "" ) {
cout << ms << endl;
copy( con.begin(), con.end(), ostream_iterator<?>( cout, sep ) );
}
我应该替换什么?和?
谢谢,
陈
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将容器的类型查找为 type
在这种情况下,我相信您想要的是
希望这会有所帮助!
You can look up the type of a container as the type
In this case, I believe what you want is
Hope this helps!