on-internet
← Community

explicitly deleted conversion operator causes different results from MSVC/GCC and Clang

Stack Overflow ·

Example code could be found below or from Compiler Explorer. The template conversion operator T with various integral types causes ambiguity for shiftable. I don't understand why MSVC and GCC believe the ambiguity is gone with an extra explicitly deleted operator bool? #include <concepts> struct X { operator bool() const = delete; // MSVC, gcc and clang all compile fine if we comment out this line template<typename T> requires std::integral<T> && (!std::same_as<T, bool>) operator T() const { return 1; } }; template<typename T> concept shiftable = requires(T x) { 1 << x; }; static_assert(!std::

Comments

Sign in or sign up to comment and upvote.

No comments yet.