Is it reasonable to use std::basic_string as a contiguous buffer when targeting C++03?

前端 未结 5 494
挽巷
挽巷 2020-11-27 06:59

I know that in C++03, technically the std::basic_string template is not required to have contiguous memory. However, I\'m curious how many implementations exist

5条回答
  •  生来不讨喜
    2020-11-27 07:53

    The result is undefined and I would not do it. The cost of reading into a vector and then converting to a string is trivial in modern c++ heaps. VS the risk that your code will die in windows 9

    also, doesnt that need a const_cast on &buffer[0]?

提交回复
热议问题