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

Add type caster for string_view. #68

Merged
merged 3 commits into from
Sep 28, 2022
Merged

Add type caster for string_view. #68

merged 3 commits into from
Sep 28, 2022

Conversation

qnzhou
Copy link
Contributor

@qnzhou qnzhou commented Sep 22, 2022

A small update to automatically type cast std::string_view.

@wjakob
Copy link
Owner

wjakob commented Sep 28, 2022

Thanks @qnzhou — this looks great, but it is missing a testcase. Could you add one for both directions of the conversion?

assert t.identity_string("orange") == "orange"
assert t.identity_string("橘子") == "橘子"
assert t.identity_string("ส้ม") == "ส้ม"
assert t.identity_string("البرتقالي") == "البرتقالي"
Copy link
Owner

Choose a reason for hiding this comment

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

Is there something funny going on with parentheses here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't quite understand. Is there anything wrong with the parentheses?

Copy link
Owner

@wjakob wjakob Sep 28, 2022

Choose a reason for hiding this comment

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

Could it be a rendering issue? At least on the GitHub web interface, I don't see a closing parenthesis after the arabic strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what I see:
image

Copy link
Owner

Choose a reason for hiding this comment

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

Fascinating. That code passes the test suite, so I will believe you ;).

assert t.identity_string_view("orange") == "orange"
assert t.identity_string_view("橘子") == "橘子"
assert t.identity_string_view("ส้ม") == "ส้ม"
assert t.identity_string_view("البرتقالي") == "البرتقالي"
Copy link
Owner

Choose a reason for hiding this comment

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

ditto

@wjakob
Copy link
Owner

wjakob commented Sep 28, 2022

This is what it looks like on my screen.

Screen Shot 2022-09-28 at 17 34 21

@wjakob wjakob merged commit a32cb76 into wjakob:master Sep 28, 2022
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.

None yet

2 participants