我想重用istringstream变量。使用构造函数很容易初始化istringstream变量。但是当我尝试使用day = forms.CharField(label="Day", required=False)
start_session1 = forms.TimeField(label="Session-1 Start", required=False)
end_session1 = forms.TimeField(label="Session-1 End", required=False)
start_session2 = forms.TimeField(label="Session-2 Start", required=False)
end_session2 = forms.TimeField(label="Session-2 End", required=False)
或=
将其重新分配给新值时,我收到了错误消息。我正在使用c ++ 11。使用<<
在vs 2015中似乎没有编译错误。但是gcc 4.8.2(Centos 6.4 x86_64上的devtools-2)会出错。
如下代码:
=
配置文件应为:
std::string line;
int simmulationtimes; double InitialIDensity;
// deploy configuration file
std::ifstream config(configfile);
if (!config.is_open())
{
return false;
}
std::getline(config, line);
std::istringstream sline(line);
std::string sInitialIDensity;
while(std::getline(sline, sInitialIDensity, '='));
InitialIDensity = std::stod(sInitialIDensity);
std::getline(config, line);
std::string ssimmulationtimes;
sline.str(""); sline.clear();
sline = std::istringstream(line);
while (std::getline(sline, ssimmulationtimes, '='));
simmulationtimes = std::stoi(ssimmulationtimes);
错误:
IDensity=0.5
times=5
关于重用stringstream的stackoverflow上的解决方案(如how-to-initialize-a-stdstringstream)对我不起作用。关于重用istringstream的任何想法?谢谢你的考虑。