tzlaine / parser

A C++ parser combinator library.
Boost Software License 1.0
81 stars 12 forks source link

Generation of variants is probably broken if multiple alternatives have the same type #16

Closed tzlaine closed 2 years ago

tzlaine commented 2 years ago

Unverified. If this is the case, this is a fix:

    template<typename... Ts>
    auto to_variant(hana::set<Ts...> const &)
    {
        return std::variant<typename Ts::type...>{};
    }

            auto const types = hana::transform(tuple_of_possible_dupes, [](auto const & x) {
                return hana::type_c<std::remove_cvref_t<decltype(x)>>;
            });
            auto const unique_types = hana::to_set(types);
            return detail::to_variant(unique_types);
tzlaine commented 2 years ago

Confirmed that this is not an issue.