简体   繁体   中英

Unordered_map to binary file

Why I can't write unordered_map structure to a file ?

std::ostream& operator<<(std::ostream& stream, PassLibrary const& data){
    stream << data.local_login << " " //std::string
           << data.local_pass << " "  //std::string
           << data.libs;              //std::unordered_map - error
    return stream;
}

Best regards.

The compiler doesn't know how to print a unordered_map to a file. It's up to you doing it. As @Barry said you can define the function operator<<(std::ostream&, std::unordered_map<K, T, H, KE, A> const&) in order to tell the compiler how to do it. And maybe you also want to intruct him it on how to load it back from file.

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