-
Notifications
You must be signed in to change notification settings - Fork 161
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
X3: Rework attribute for alternative parser #740
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. A few things need to be resolved:
- I haven't made deep inspection of what could go wrong with doing
variant<unused_type, ...>
, have you? At least the question about how crude isunused_type
in visitor will be, since it has implicit constructor from everything. - A trait to configure monostate type is needed.
- No need to use boost type traits which are available in standard library.
- Put the tests in alternative.cpp/sequence.cpp please.
Hi @Kojoley,
Not really, admittedly. The fact that unused_type is constructible from everything might indeed create problems. I'll do some more analysis and try to come up with some meaningful use cases. In case this turn out to be ugly, it is anyway easy to make the behavior of
Agreed. How do you think that should look like?
OK. |
I am afraid
Something like https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/x3/support/traits/optional_traits.hpp template <typename Variant> struct variant_monostate { using type = unused_type; }; |
It's indeed ugly. Since anything is convertible to
hiding potential mistakes that should be caught at compile time. At this point, I'm thinking that using Thoughts? |
Implement the following rules * Remove duplicates * Simplify variant<X> to X * Make unused_type the first type of the variant * Transform variant<unused_type, T> to optional<T>
c72a628
to
73a865b
Compare
Implement the following behavior, as described in #610
variant<X>
toX
unused_type
the first type of the variantvariant<unused_type, T>
tooptional<T>