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 negative indexing support to stl_bind. #1882

Merged
merged 3 commits into from
Aug 15, 2019

Conversation

ali-beep
Copy link
Contributor

No description provided.

@wjakob
Copy link
Member

wjakob commented Aug 14, 2019

This is a nice feature addition, but the variable update in an conditional expression is a no-go for me :). I think that it would be cleanest to factor out the arithmetic & throw statement into a small lambda function that takes the array size and requested entry index.

auto wrap_i = [](DiffType i, SizeType n) {
if (i < 0)
i += n;
if (i < 0)
Copy link
Member

@wjakob wjakob Aug 15, 2019

Choose a reason for hiding this comment

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

Wouldn't it be better to make this check if (i < 0 || i >= n) and then remove the exceptions elsewhere?

@wjakob wjakob merged commit 5ef13eb into pybind:master Aug 15, 2019
@wjakob
Copy link
Member

wjakob commented Aug 15, 2019

Merged, thanks!

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