What use is there for 'ends' these days?

后端 未结 2 1317
长情又很酷
长情又很酷 2021-01-17 10:15

I came across a subtle bug a couple of days ago where the code looked something like this:

ostringstream ss;
int anInt( 7 );

ss << anInt << \"HA         


        
相关标签:
2条回答
  • 2021-01-17 10:56

    There are some APIs that expect a "string array" with multiple zero terminated strings, a double zero to mark the end. Raymond Chang just recently blogged about it, most of all to demonstrate how often that this gets fumbled.

    0 讨论(0)
  • 2021-01-17 11:00

    You've essentially answered your own question is as much detail that's needed. I certainly can't think of any reason to use std::ends when std::string and std::stringstream handle all that for you.

    So, to answer your question explicitly, no, there is no reason to use std::ends in a std::string only environment.

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