We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
#include <iostream> #include "variant.hpp" struct sv { sv(const char*) {} }; int main() { mpark::variant<bool, sv> v{"abc"}; std::cout << v.index() << "\n"; return 0; }
With gcc-4.8.5, this code incorrectly prints 0.
It works for later versions of gcc (tested 7.5.0) and prints 1.
I tested against master 3c7fc82
The text was updated successfully, but these errors were encountered:
It looks like the bool conversion logic in overload_leaf is disabled for gcc < 5.0 (I'm guessing because the narrowing conversion check doesn't work).
template <typename Arg, std::size_t I, typename T> struct overload_leaf< Arg, I, T, true #if defined(__clang__) || !defined(__GNUC__) || __GNUC__ >= 5 , lib::enable_if_t< std::is_same<lib::remove_cvref_t<T>, bool>::value ? std::is_same<lib::remove_cvref_t<Arg>, bool>::value : is_non_narrowing_convertible<Arg, T>::value> #endif > { using impl = lib::size_constant<I> (*)(T); operator impl() const { return nullptr; }; };
But could this be changed to
template <typename Arg, std::size_t I, typename T> struct overload_leaf<Arg, I, T, true, enable_if_t<std::is_same<remove_cvref_t<T>, bool>::value ? std::is_same<remove_cvref_t<Arg>, bool>::value : #if defined(__clang__) || !defined(__GNUC__) || __GNUC__ >= 5 is_non_narrowing_convertible<Arg, T>::value #else std::is_convertible<Arg, T>::value #endif >> { using impl = size_constant<I> (*)(T); operator impl() const { return nullptr; }; };
that would be closer to the correct std::variant behavior
Sorry, something went wrong.
No branches or pull requests
With gcc-4.8.5, this code incorrectly prints 0.
It works for later versions of gcc (tested 7.5.0) and prints 1.
I tested against master 3c7fc82
The text was updated successfully, but these errors were encountered: