Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emitter: Support std::string_view #1325

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

dendy
Copy link

@dendy dendy commented Oct 20, 2024

Accept Emitter::operator<<(std::string_view).

ABI remains C++11 compatible by exposing new method Emitter::Write(const char*, size_t).

All affected calls optimized to pass std::string values as pointer + size tuple into appropriate routines.

Copy link
Owner

@jbeder jbeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good. Can you add a test case that emits a string_view?

Accept Emitter::operator<<(std::string_view).

ABI remains C++11 compatible by exposing new method
Emitter::Write(const char*, size_t).

All affected calls optimized to pass std::string values as pointer + size
tuple into appropriate routines.
@dendy dendy force-pushed the emitter-support-std-string_view branch from b93817c to e79a3fb Compare December 19, 2024 00:02
@dendy
Copy link
Author

dendy commented Dec 19, 2024

@jbeder Could you please take a look.

  1. Since Emitter's operator<< are inlined it is safe to direct std::string and const char* overloads to the new Write::(const char*, size_t). Older applications will preserve binary compatibility.

  2. Fixed comparing null literals.

  3. Fixed calling RexEx::Matches and added static_assert() to check for accidental passing raw C-string into the Matches.

  4. Added 3 Emitter tests: for std::string, null terminated and unterminated std::string_view.

All tests are passing at my side when I configure yaml-cpp with extra option CMAKE_CXX_STANDARD=17.

@jbeder jbeder merged commit 7470c2d into jbeder:master Dec 22, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants