简体   繁体   中英

No operator “+” matches these operands

for (TPathInfoList::iterator iter = pathInfoList.begin(); iter != pathInfoList.end(); ++iter)
{
    const TPathInfoList::value_type& path = *iter;

    EResult resultCode = MakeMSA(path, &msg);
    fs::path parentPath = path.parent_path();
    std::string shortPath = parentPath.parent_path().filename() + "\\" + parentPath.filename() + "\\" + path.filename();;

    tm t;
    time_t timer;
    timer = time(NULL);
    localtime_s(&t, &timer);

    printf("%04d/%02d/%02d %02d:%02d:%02d [%s] %s\n", 
        t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
        msg.c_str(), shortPath.c_str());
}

I'm try boost 1.60 and i'm stuck to this error. What i'm doing wrong?
http://prntscr.com/a2yync

THe error message screenshot shows that parentPath.parent_path().filename() is not a string but a filesystem::path .

As shortPath is a string , I'd suggest to parentPath.parent_path().filename().string :

std::string shortPath = parentPath.parent_path().filename().string() 
          + "\\" + parentPath.filename().string() 
          + "\\" + path.filename().string(); 

or to make shortPath a path and use concatenation with += operator

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM