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

Implicit bool conv. for if (args) checking #11

Closed
xparq opened this issue Jan 26, 2023 · 1 comment
Closed

Implicit bool conv. for if (args) checking #11

xparq opened this issue Jan 26, 2023 · 1 comment

Comments

@xparq
Copy link
Owner

xparq commented Jan 26, 2023

No description provided.

xparq pushed a commit that referenced this issue Jan 26, 2023
@xparq
Copy link
Owner Author

xparq commented Jan 26, 2023

From the code:

bool operator !() const { return argc < 2; }
//!!	operator bool() const { return !!*this; }
//! Enabling op bool would break args["opt"] due to a weird ambiguity, where the
//! compiler would suddenly think it may also match the builtin "opt"[int]! :-o
//! It's due to it trying a match with autoconverted bool->int before the "real thing".
//! The hacky workaround below may be good enough tho (but certainly not "good":
//! -> https://www.artima.com/articles/the-safe-bool-idiom)
//! Just comment it out, if you feel offended! ;)
operator const void*() const { return !(*this) ? nullptr : (void*)this; }

@xparq xparq closed this as completed Jan 26, 2023
xparq pushed a commit that referenced this issue Jan 26, 2023
xparq pushed a commit that referenced this issue Jan 26, 2023
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

No branches or pull requests

1 participant