error: type 'std::__1::basic_string<char>' does not provide a call operator

error: type 'std::__1::basic_string<char>' does not provide a call operator

我有一个由字符串和整数组成的对向量,例如:{("ABC", 15), ("DEFG", 29)}。我想将字符串拆分为向量中的单独字符,因此 {'A'、'B'、'C'}。我的代码是:

for (std::pair<std::string, int> i: code) 
  {
    std::vector <char> letters;
    for (char b: i.first()) 

'Code'是原始向量。此代码给我错误:

error: type 'std::__1::basic_string<char>' does not provide a call operator
    for (char b: i.first()) 
                 ^~~~~~~

我不明白这个问题,有什么办法可以解决这个问题吗?

std::pairfirst是成员变量,不是方法。去掉first.

后面的括号