📄 06-1.cpp
字号:
//
// Example from ESTL Item 6
//
// Fails under MSVC/native lib, STLPort
//
#include <list>
#include <iostream>
#include <fstream>
#include "ESTLUtil.h"
int main()
{
using namespace std;
using namespace ESTLUtils;
ifstream dataFile("ints.dat");
/* incorrect, but works with some compilers:
{
list<int> data(istream_iterator<int>(dataFile), // warning! this doesn抰 do
istream_iterator<int>()); // what you think it does
cout << "First value in the list is " << *data.begin() << endl;
}
*/
/* correct, but doesn't work with some compilers:
{
list<int> data((istream_iterator<int>(dataFile)), // note new parens
istream_iterator<int>()); // around first argument
// to list抯 constructor
cout << "First value in the list is " << *data.begin() << endl;
}
*/
/* should always work: */
{
istream_iterator<int> dataBegin(dataFile);
istream_iterator<int> dataEnd;
list<int> data(dataBegin, dataEnd);
cout << "First value in the list is " << *data.begin() << endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -