Skip to content

C++20 constexpr _Copy_s and simplify char8_t compare - #861

Merged
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:masterfrom
StephanTLavavej:char_traits
May 30, 2020
Merged

C++20 constexpr _Copy_s and simplify char8_t compare#861
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:masterfrom
StephanTLavavej:char_traits

Conversation

@StephanTLavavej

Copy link
Copy Markdown
Member

Followup to #491, in response to #491 (comment) and #491 (comment).

  • Mark our non-Standard extension char_traits::_Copy_s and basic_string_view::_Copy_s as _CONSTEXPR20. Similarly to how Misc constexpr #491 changed copy, previously _Copy_s was always constexpr in basic_string_view but never in char_traits; I similarly argue that this will not affect users because it would have required them to notice and provide a custom traits class (and in this case, the non-Standard extension is far more obscure than the Standard function). Making these constexpr in C++20 mode only is simpler to explain.

  • Simplify char_traits::compare for char8_t. This is possible because memcmp and __builtin_memcmp take const void* and return int, and their behavior is correct for char8_t. The other u8 intrinsics are type-sensitive so they can't be unified like this.

Comment thread stl/inc/xstring
@StephanTLavavej

Copy link
Copy Markdown
Member Author

Thanks, Casey Carter (@CaseyCarter), for these improvement ideas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants