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

Fix std::min conflict with min/max definitions from windows.h #109

Merged
merged 2 commits into from
Aug 5, 2021

Conversation

Chuvi-w
Copy link
Contributor

@Chuvi-w Chuvi-w commented Aug 4, 2021

No description provided.

@skrobinson
Copy link
Contributor

What about std::min<size_t>? Does specifying a type stop the macro replacement on Windows?

@Chuvi-w
Copy link
Contributor Author

Chuvi-w commented Aug 4, 2021

Seems that specifying a type also works well.

Both methods are acceptable.
But with parentheses you sholdn't change type if you'll change type of args sometime.

@skrobinson
Copy link
Contributor

I agree about a type change. But in this case the type is size_t, which is unlikely to change soon.

Another option woud be std::min<decltype(std::declval<T>().size())>. Then the type would be correct for any container T with a size function.

@Chuvi-w
Copy link
Contributor Author

Chuvi-w commented Aug 4, 2021

I've thought about decltype.
But it looks llike... a bit overprinted.

@Bedzior
Copy link
Contributor

Bedzior commented Aug 4, 2021

Hi, my two cents: I guess std::size_t is more appropriate in a C++ library.

@skrobinson
Copy link
Contributor

@Bedzior

Yes, you're right. I copied size_t from the definition of repr_max_container_size, but std::size_t is more correct.

Looking through the rest of the file, there is an opportunity for someone to convert many size_t.

@Chuvi-w
Copy link
Contributor Author

Chuvi-w commented Aug 5, 2021

Ok, but replacing size_t to std::size_t is not purpose of this PR.
Can you take it like this, and then somehow add std :: to the types?

@Chuvi-w
Copy link
Contributor Author

Chuvi-w commented Aug 5, 2021

Thanks

@Chuvi-w Chuvi-w deleted the fix_std_min_conflict branch August 5, 2021 12:26
Chuvi-w added a commit to Chuvi-w/argparse that referenced this pull request Aug 5, 2021
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.

4 participants