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

Feature request: consider support for __VA_OPT__ #78

Open
willwray opened this issue Nov 21, 2022 · 1 comment
Open

Feature request: consider support for __VA_OPT__ #78

willwray opened this issue Nov 21, 2022 · 1 comment

Comments

@willwray
Copy link

__VA_OPT__ is a very useful feature.

Implementations enable it across all std modes (though nominally C++20 / C23).
It ousts non-standard use of the 'comma eating' __VA_ARGS__ extension.

There's no feature-test macro but it's detectable using a snippet from SO

#define VA_ARG1(A0,A1,...) A1
#define VA_EMPTY(...) VA_ARG1(__VA_OPT__(,)0,1,) // (Detects __VA_OPT__)

 // VA_EMPTY(?) is true if __VA_OPT__ is supported

The idea to use #ifdef __VA_OPT__ for detection was considered but dropped -
see Richard Smith's comment here https://reviews.llvm.org/D91913#2526276

It seems ok to enable by default and disable via a commandline flag.

@willwray
Copy link
Author

C++ draft link, includes useful examples for testing purposes
https://eel.is/c++draft/cpp.subst#nt:va-opt-replacement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants