下面的代码显示2种溶液(std::to_string和std::stringstream),该转换的int m_currentSoundTime到std::string.是更快std::to_string还是std::stringstream更快?
// Compute current sound time in minute and convert to string
stringstream currentTime;
currentTime << m_currentSoundTime / 60;
m_currentSoundTimeInMinute = currentTime.str();
Run Code Online (Sandbox Code Playgroud)
要么
m_currentSoundTimeInMinute = to_string( m_currentSoundTime / 60 );
Run Code Online (Sandbox Code Playgroud) 从包含名称和值对的文件中读取值时,我设法跳过了名称部分.但是有没有另一种方法可以跳过名称部分而不声明一个虚拟字符串来存储跳过的数据?
示例文本文件:http://i.stack.imgur.com/94l1w.png
void loadConfigFile()
{
ifstream file(folder + "config.txt");
while (!file.eof())
{
file >> skip;
file >> screenMode;
if (screenMode == "on")
notFullScreen = 0;
else if (screenMode == "off")
notFullScreen = 1;
file >> skip;
file >> playerXPosMS;
file >> skip;
file >> playerYPosMS;
file >> skip;
file >> playerGForce;
}
file.close();
}
Run Code Online (Sandbox Code Playgroud) 在函数的最后一行放入还是不放回头有什么不同吗?
void InputClass::KeyDown(unsigned int input)
{
// If a key is pressed then save that state in the key array
m_keys[input] = true;
return;
}
Run Code Online (Sandbox Code Playgroud)