Talk:cpp/string/basic string/resize
From cppreference.com
I don't see any complexity requirements in the standard, is this actually guaranteed or just speculation? --Ybab321 (talk) 06:13, 17 September 2021 (PDT)
- You're right, many thanks!! Most likely this is a premature assumption that was taken in 2011 (or even earlier), unless the requirement has been removed from the IS since (e.g. as an aftermath of COW => SSO switching). Right now, I'm removing this Complexity section.
- Theoretically, the Complexity of std::string::resize() is close to the one of
vector::resize()
. --Space Mission (talk) 15:01, 17 September 2021 (PDT)
I've never seen this call to char() as a function. Where is this described and what does it mean? This usage is part of the example on this page. ERCaGuy (Gabriel Staples) (talk) 10:28, 24 May 2022 (PDT)
- same as any T(), it's cpp/language/value_initialization. In new code we mostly write char{} (took a peek at the codebase at work, 16 times char(), 6 times char{}) --Cubbi (talk) 11:03, 24 May 2022 (PDT)
- Thanks. See also: https://stackoverflow.com/a/72367153/4561887. I think some clarity needs to be added to the documentation. I made a small edit. I'm open to alternative wordings, but I think some clarity needs to be added there to make it obvious what is a char() or char(0). ERCaGuy (Gabriel Staples) (talk) 11:58, 24 May 2022 (PDT)
- spec for this line is https://eel.is/c++draft/basic.string#string.capacity-6 - while I don't think strings support element types where T() differs from T(0), given the restrictions in strings.general#1, next person to come across the page will likely switch "CharT(0)" back to "CharT()" as 'an error in cppreference'.. so I switched it back now. But yes, there's merit in showing the value virtually every programmer will see here. --Cubbi (talk) 12:48, 24 May 2022 (PDT)
- Thanks. See also: https://stackoverflow.com/a/72367153/4561887. I think some clarity needs to be added to the documentation. I made a small edit. I'm open to alternative wordings, but I think some clarity needs to be added there to make it obvious what is a char() or char(0). ERCaGuy (Gabriel Staples) (talk) 11:58, 24 May 2022 (PDT)