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

BOOST_FUSION_ADAPT_ADT not enough actual parameters for macro #158

Open
Kojoley opened this issue Nov 13, 2017 · 4 comments
Open

BOOST_FUSION_ADAPT_ADT not enough actual parameters for macro #158

Kojoley opened this issue Nov 13, 2017 · 4 comments

Comments

@Kojoley
Copy link
Contributor

Kojoley commented Nov 13, 2017

On MSVC if one wants to leave the setter/getter empty, e.g.:

BOOST_FUSION_ADAPT_ADT(
    data4,
    (boost::optional<int>, boost::optional<int> const&, obj.a(), /**/)
    (boost::optional<double>, boost::optional<double> const&, obj.b(), /**/)
    (boost::optional<std::string>, boost::optional<std::string> const&, obj.c(), /**/)
);

will get a warning message:

..\libs\spirit\test\karma\regression_adapt_adt.cpp(110): warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_SIZE_3'
..\libs\spirit\test\karma\regression_adapt_adt.cpp(110): warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_ELEM_0'

Is it safe to ignore it?
Are there any methods except disabling the warning to fix this? MSVC will compile fine and without the warning if you replace /**/ with () but it does not work for GCC and Clang,

@daminetreg
Copy link
Contributor

The API of BOOST_FUSION_ADAPT_ADT doesn't foresee this use, nor the unit tests do.

Because your snippet lies, it tells that it declare a Random Access Sequence, but yours cannot have the sequence elements modified.

But naturally this is your concern inside your app 👐. Because if you don't do any action modifying the elements you are not going to have any issue. It might happen when someone else will overtake your code without knowing you did that. 😄

But to your very specific question emptiness in parameters is not portable across compilers (sadly). Therefore you can avoid the warning and surprises in the future if you just provide any C++ expression doing nothing. You can use val instead of /**/. In the end the expression will be pasted into a setter function which will do only : val;.

Hope this helps.

@Kojoley
Copy link
Contributor Author

Kojoley commented Nov 14, 2017

The API of BOOST_FUSION_ADAPT_ADT doesn't foresee this use, nor the unit tests do.

But Spirit's do and demonstrates it in an example.

You can use val instead of /**/. In the end the expression will be pasted into a setter function which will do only : val;.

Sadly this will confuse people looking at the code of the example.

Thanks for your answer.

@daminetreg
Copy link
Contributor

Oups 🙊.

I could add a check to BOOST_PP_IS_EMPTY to handle this case. I'll give it a try today.

@Kojoley
Copy link
Contributor Author

Kojoley commented Nov 15, 2017

Huh, fusion have test with omitted arguments too

BOOST_FUSION_ADAPT_STRUCT(empty_struct,)

And produces bunch of warnings http://www.boost.org/development/tests/develop/output/teeks99-09-p-win2012R2-64on64-fusion-msvc-14-1-warnings.html#adapt_adt_named

I could add a check to BOOST_PP_IS_EMPTY to handle this case.

I suspect it was here but had been removed in #124

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

2 participants