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

Empty argument list #9

Open
Jiboo opened this issue Aug 13, 2020 · 2 comments
Open

Empty argument list #9

Jiboo opened this issue Aug 13, 2020 · 2 comments

Comments

@Jiboo
Copy link

Jiboo commented Aug 13, 2020

#define TRANSFORM_DECLTYPE(MInput) decltype(MInput)
#define DECLTYPE_LIST(...) MAP_LIST(TRANSFORM_DECLTYPE, __VA_ARGS__)
DECLTYPE_LIST(a,b,c)
DECLTYPE_LIST()

Results in:

decltype(a), decltype(b), decltype(c)
decltype()

I expected the case where no arguments are passed to expand to nothing, note that MAP has the same behaviour.
I fixed for my case by changing definition of TRANSFORM_DECLTYPE to #define TRANSFORM_DECLTYPE(...) __VA_OPT__(decltype(__VA_ARGS__)) but that would only work for C++2a compilers.

@namniav
Copy link

namniav commented Aug 22, 2020

In the above example, MAP_LIST(TRANSFORM_DECLTYPE, __VA_ARGS__) is expanded to MAP_LIST(TRANSFORM_DECLTYPE, ) which has a semicolon and an "empty" argument after it. The semicolon can be avoided using ##__VA_ARGS__. However it doesn't fix the issue.
A shorter example:

#define FOO(A) foo
MAP(FOO)

is expaneded to foo.

@swansontec
Copy link
Owner

Indeed, this seems like the wrong behavior. I don't have much free time to work on this, but I'll prioritize reviewing any PR's that might fix it.

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

3 participants