我需要std::string
用最少的代码获取 an 的第一个字符。
如果可以从 STL 获取一行代码中的第一个字符,那就太好了std::map<std::string, std::string> map_of_strings
。以下代码是否正确:
map_of_strings["type"][0]
编辑 目前,我正在尝试使用这段代码。这段代码正确吗?
if ( !map_of_strings["type"].empty() )
ptr->set_type_nomutex( map_of_strings["type"][0] );
该set_type
函数的原型是:
void set_type_nomutex(const char type);