草庐IT

012345678901234567890123456789

全部标签

c++ - 以编程方式确定 std::string 是否使用写时复制 (COW) 机制

根据这个question的讨论,我想知道使用nativeC++的人如何以编程方式确定他们正在使用的std::string实现是否利用Copy-On-Write(COW)我有以下功能:#include#includeboolstdstring_supports_cow(){//makesurethestringislongerthanthesizeofpotential//implementationofsmall-string.std::strings1="012345678901234567890123456789""012345678901234567890123456789""0