Also refactor some constraints slightly to be more readable. PR libstdc++/90165 * include/std/variant (variant::__not_self): New helper for the is_same_v, variant>==false constraints. (variant::__to_type_impl): Remove. (variant::__to_type): Add default argument to check pack size, instead of using __to_type_impl. (variant::__accepted_type): Add default argument using __not_self. (variant::__is_in_place_tag, variant::__not_in_place_tag): New helpers for variant(T&&) constructor constraint. (variant::variant(T&&)): Use __not_in_place_tag in constraints. Extract __accepted_type into a named template parameter for reuse in other constraints and in the exception specification. (variant::variant(in_place_type_t, Args&&...)) (variant::variant(in_place_type_t, initializer_list, Args&&...)) (variant::variant(in_place_index_t, Args&&...)) (variant::variant(in_place_index_t, initializer_list, Args&&...)) (variant::operator=T&&)): Remove redundant && from trait arguments. * testsuite/20_util/variant/compile.cc: Check variant(T&&) constructor isn't used for in_place_type or in_place_index arguments. Tested powerpc64le-linux, committed to trunk. I'll consider a simpler version of this for gcc-8-branch, that just applies the __not_in_place_tag constraint to the variant(T&&) ctor.