-
Notifications
You must be signed in to change notification settings - Fork 100
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
Useful traits and Boost.Spirit Qi/Karma support headers for mapbox::variant. #119
base: master
Are you sure you want to change the base?
Conversation
Out of interest this does not work with Boost.Spirit X3, does it? |
No this works only for Boost.Spirit Qi and Karma, X3 being still in development. And X3 can only parse, it cannot generate. It doesn't replace karma for the moment. |
@daminetreg - thanks for the PR! Using as in https://github.com/mapnik/mapnik/blob/master/include/mapnik/util/variant.hpp#L34-L43 Your non-intrusive approach has its merits, indeed. I'll comment more once I'll have time to dig this PR properly. BTW, supporting |
The problem is that this approach works well for Qi. But is not enough for Karma, because Karma is less well designed than Qi to accept other variant type. Or did I miss something ? Therefore the hack here : https://github.com/mapbox/variant/pull/119/files#diff-e54bc111e39a8bcc99b0fa543bd5ea0bR10 I couldn't see anyway to override this implementation from Karma : https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/karma/detail/alternative_function.hpp#L133
I can try it, there is a wiki page on mapbox about this anyway. So I'll dig into adding x3 support. 😄 |
@daminetreg - good point re:boost.karma, I recall now I ended up with rather verbose implementation to dispatch based on a stored type in variant : https://github.com/mapnik/mapnik/blob/master/include/mapnik/wkt/wkt_generator_grammar_impl.hpp#L59-L83 |
What is the difference between mapnik::util::variant and mapbox::util::variant ? Is it a fork ? Do you think your intrusive approach has chances to be better accepted inside mapbox::variant ? If I understand it well it works great for X3 already ? If so and if we can get it working seamlessly for karma, I'm fully happy with it. What we woud love @sauter-hq and personally is to simply don't bother and use mapbox::variant instead of Boost.Variant so long Boost Variant is not fully C++1z variadic. Thank you for reviewing my changes ! 😄 |
Nope,
Yes, I would accept it. This is on my TODO list. As I mentioned I would also like to evaluate your non-intrusive approach.
This is what needs some evaluation ^ I'm recalling |
Dear Mapbox Variant authors,
I would like to contribute support headers for Boost.Spirit.Qi and Karma to mapbox::variant, so that usage of Mapbox::variant with Qi and Karma get really easy.
Why ?
See benchmark code here
So I updated a big codebase which was using Boost.Variant and Boost.Spirit together with Mapbox::variant. And now it compiles faster, makes smaller binaries and we don't need a patched Boost MPL anymore ! 😀 Thank you very much for this variant type.
Features
The small supporting headers I wrote might be useful for users of this library, therefore I would like to contribute the following to Mapbox::Variant :
I would naturally understand that the supporting header for Qi and Karma are not interesting you as part of the library, as they base on the Boost.Spirit traits which are documented only in spirit code but which are used extensively internally by the library and provided as supporting headers since ages (https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/support/extended_variant.hpp).
Following if you are interested in the supporting headers for Boost.Spirit or not I will publish them as a separate library and remove 3. and 4. from this PR.
But I really would love to see the
include/mapbox/traits/is_mapbox_variant.hpp
andinclude/mapbox/traits/is_type_in_variant.hpp
accepted, as they are in my opinion features that should be part of Mapbox Variant.You can test out the supporting headers by running :
make out/boost_spirit_karma && out/boost_spirit_karma
make out/boost_spirit_qi && out/boost_spirit_karma
Cheers