Is std::ofstream movable?

前端 未结 2 1654
离开以前
离开以前 2020-12-11 16:12

I have this map which compiles fine in MSVC10 :

std::map m_logFiles;

But on ubuntu using g++ 4.5 with C++

相关标签:
2条回答
  • 2020-12-11 16:48

    I asked a similar question earlier, and later found that GCC doesn't seem to support movable fstreams yet (I just tested GCC 4.6.1) as detailed in this answer.

    0 讨论(0)
  • 2020-12-11 16:56

    std::ofstream is movable. This program compiles for me using clang/libc++:

    #include <string>
    #include <fstream>
    #include <map>
    
    int main()
    {
        std::map<std::string, std::ofstream> m_logFiles;
    }
    

    Reference 27.9.1.11 [ofstream.cons].

    0 讨论(0)
提交回复
热议问题