ostream iterator
来源:互联网 发布:excel表格删除重复数据 编辑:程序博客网 时间:2024/06/05 17:26
1.ostream_iterator
template <class _Tp,class _CharT = char, class _Traits = char_traits<_CharT> >
class ostream_iterator {
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_ostream<_CharT, _Traits> ostream_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {}
ostream_iterator(ostream_type& __s, const _CharT*__c)
: _M_stream(&__s),_M_string(__c) {}
ostream_iterator<_Tp>& operator=(const _Tp& __value) {
*_M_stream << __value;
if (_M_string) *_M_stream <<_M_string;
return *this;
}
ostream_iterator<_Tp>& operator*() { return *this; }
ostream_iterator<_Tp>& operator++() { return *this; }
ostream_iterator<_Tp>& operator++(int) { return *this; }
private:
ostream_type* _M_stream;
const _CharT* _M_string;
};
2.示例
http://www.cplusplus.com/reference/iterator/ostream_iterator/
// ostream_iterator example#include <iostream> // std::cout#include <iterator> // std::ostream_iterator#include <vector> // std::vector#include <algorithm> // std::copyint main () { std::vector<int> myvector; for (int i=1; i<10; ++i) myvector.push_back(i*10); std::ostream_iterator<int> out_it (std::cout,", "); std::copy ( myvector.begin(), myvector.end(), out_it ); return 0;}
运行结果:
阅读全文
1 0
- ostream iterator
- ostream&
- OSTREAM
- istream/ostream
- ostream & operator<<()
- ifstream ostream istream ostream 不能声明
- ostream& operator << (ostream& os, Point& pt)
- C++语言中ostream
- ostream这是啥玩意儿
- iostream fstream ostream 用法
- ostringstream, istringstream and ostream
- friend ostream& operator < <
- 深度剖析ostream&
- Make My Ostream!
- ostream头文件
- C++ ostream 常用格式
- c++ fstream, ifstream, ostream
- ostream之cout
- 关于redhat版linux系统安装Centos版yum源
- 多线程问题
- C#非模式窗体show()和模式窗体showdialog()的区别
- Linux驱动程序之阻塞和非阻塞IO
- 使用Xshell连接服务器SSH
- ostream iterator
- Cache-Control与retrofit缓存
- unity Input.GetAxis()函数
- thinkphp
- 欢迎使用CSDN-markdown编辑器
- 单层感知器算法(可用于与或非)
- 软件架构师的能力与特质
- 蓝桥杯-三羊献瑞
- C#中数据类型