https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91807

            Bug ID: 91807
           Summary: [Regression] std::variant with multiple identical
                    types assignment fail
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: raplonu.jb at gmail dot com
  Target Milestone: ---

Created attachment 46895
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46895&action=edit
preprocessed file

Repro:
#include <variant>

struct me_data {
    me_data() = default;

    me_data(const me_data &) {};
    me_data(me_data &&) noexcept {};
    me_data& operator=(const me_data &) = default;
};

int main() {
    std::variant<me_data, me_data> v1, v2;

    v2 = v1;
}

Compiles with 8. Breaks with 9 (see bellow) and 10.0.0 201 (on wandbox :
https://wandbox.org/permlink/3GZeJzWMlElIgqGd ):

In file included from main.cpp:1:
/usr/include/c++/9/variant: In instantiation of
‘std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>
mutable [with auto:3 = const me_data&; auto:4 = std::integral_constant<long
unsigned int, 0>]’:
/usr/include/c++/9/bits/invoke.h:60:36:   required from ‘constexpr _Res
std::__invoke_impl(std::__invoke_other, _Fn&&, _Args&& ...) [with _Res =
std::__detail::__variant::__variant_idx_cookie; _Fn =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 0>}]’
/usr/include/c++/9/bits/invoke.h:95:40:   required from ‘constexpr typename
std::__invoke_result<_Functor, _ArgTypes>::type std::__invoke(_Callable&&,
_Args&& ...) [with _Callable =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 0>};
typename std::__invoke_result<_Functor, _ArgTypes>::type =
std::__detail::__variant::__variant_idx_cookie]’
/usr/include/c++/9/variant:961:24:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__visit_invoke_impl(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:980:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__do_visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:996:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:1005:28:   required from ‘static constexpr auto
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::_S_apply() [with bool __same_return_types = true;
_Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:915:56:   required from ‘static constexpr void
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...), __dimensions ...>, std::tuple<_Variants ...>, std::integer_sequence<long
unsigned int, __indices ...> >::_S_apply_single_alt(_Tp&, _Tp*) [with bool
__do_cookie = true; long unsigned int __index = 0; _Tp =
std::__detail::__variant::_Multi_array<std::__detail::__variant::__variant_idx_cookie
(*)(std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&)>; bool __same_return_types =
true; _Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; long unsigned int ...__dimensions = {2}; _Variants = {const
std::variant<me_data, me_data>&}; long unsigned int ...__indices = {}]’
/usr/include/c++/9/variant:896:47:   required from ‘constexpr const _Array_type
std::__detail::__variant::__gen_vtable<true,
std::__detail::__variant::__variant_idx_cookie,
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&>::_S_vtable’
/usr/include/c++/9/variant:1638:23:   required from ‘constexpr decltype(auto)
std::__do_visit(_Visitor&&, _Variants&& ...) [with bool __use_index = true;
bool __same_return_types = true; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Variants = {const std::variant<me_data, me_data>&}]’
/usr/include/c++/9/variant:586:32:   required from
‘std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]’
/usr/include/c++/9/variant:636:12:   required from here
/usr/include/c++/9/variant:609:6: error: no matching function for call to
‘std::variant<me_data, me_data>::variant(const me_data&)’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1342:2: note: candidate: ‘template<long unsigned int
_Np, class _Up, class ... _Args, class _Tp, class> constexpr
std::variant<_Types>::variant(std::in_place_index_t<_Np>,
std::initializer_list<_Up>, _Args&& ...)’
 1342 |  variant(in_place_index_t<_Np>, initializer_list<_Up> __il,
      |  ^~~~~~~
/usr/include/c++/9/variant:1342:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_index_t<_Idx>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1331:2: note: candidate: ‘template<long unsigned int
_Np, class ... _Args, class _Tp, class> constexpr
std::variant<_Types>::variant(std::in_place_index_t<_Np>, _Args&& ...)’
 1331 |  variant(in_place_index_t<_Np>, _Args&&... __args)
      |  ^~~~~~~
/usr/include/c++/9/variant:1331:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_index_t<_Idx>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1321:2: note: candidate: ‘template<class _Tp, class
_Up, class ... _Args, class> constexpr
std::variant<_Types>::variant(std::in_place_type_t<_Tp>,
std::initializer_list<_Up>, _Args&& ...)’
 1321 |  variant(in_place_type_t<_Tp>, initializer_list<_Up> __il,
      |  ^~~~~~~
/usr/include/c++/9/variant:1321:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_type_t<_Tp>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1311:2: note: candidate: ‘template<class _Tp, class
... _Args, class> constexpr
std::variant<_Types>::variant(std::in_place_type_t<_Tp>, _Args&& ...)’
 1311 |  variant(in_place_type_t<_Tp>, _Args&&... __args)
      |  ^~~~~~~
/usr/include/c++/9/variant:1311:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_type_t<_Tp>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1301:2: note: candidate: ‘template<class _Tp, class,
class, class _Tj, class> constexpr std::variant<_Types>::variant(_Tp&&)’
 1301 |  variant(_Tp&& __t)
      |  ^~~~~~~
/usr/include/c++/9/variant:1301:2: note:   template argument
deduction/substitution failed:
In file included from /usr/include/c++/9/variant:36,
                 from main.cpp:1:
/usr/include/c++/9/type_traits: In substitution of ‘template<bool _Cond, class
_Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond =
(((bool)std::variant<me_data, me_data>::__exactly_once<me_data>) &&
((bool)std::is_constructible_v<me_data, const me_data&>)); _Tp = void]’:
/usr/include/c++/9/variant:1298:9:   required from
‘std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>
mutable [with auto:3 = const me_data&; auto:4 = std::integral_constant<long
unsigned int, 0>]’
/usr/include/c++/9/bits/invoke.h:60:36:   required from ‘constexpr _Res
std::__invoke_impl(std::__invoke_other, _Fn&&, _Args&& ...) [with _Res =
std::__detail::__variant::__variant_idx_cookie; _Fn =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 0>}]’
/usr/include/c++/9/bits/invoke.h:95:40:   required from ‘constexpr typename
std::__invoke_result<_Functor, _ArgTypes>::type std::__invoke(_Callable&&,
_Args&& ...) [with _Callable =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 0>};
typename std::__invoke_result<_Functor, _ArgTypes>::type =
std::__detail::__variant::__variant_idx_cookie]’
/usr/include/c++/9/variant:961:24:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__visit_invoke_impl(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:980:28:   [ skipping 2 instantiation contexts, use
-ftemplate-backtrace-limit=0 to disable ]
/usr/include/c++/9/variant:1005:28:   required from ‘static constexpr auto
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::_S_apply() [with bool __same_return_types = true;
_Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:915:56:   required from ‘static constexpr void
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...), __dimensions ...>, std::tuple<_Variants ...>, std::integer_sequence<long
unsigned int, __indices ...> >::_S_apply_single_alt(_Tp&, _Tp*) [with bool
__do_cookie = true; long unsigned int __index = 0; _Tp =
std::__detail::__variant::_Multi_array<std::__detail::__variant::__variant_idx_cookie
(*)(std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&)>; bool __same_return_types =
true; _Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; long unsigned int ...__dimensions = {2}; _Variants = {const
std::variant<me_data, me_data>&}; long unsigned int ...__indices = {}]’
/usr/include/c++/9/variant:896:47:   required from ‘constexpr const _Array_type
std::__detail::__variant::__gen_vtable<true,
std::__detail::__variant::__variant_idx_cookie,
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&>::_S_vtable’
/usr/include/c++/9/variant:1638:23:   required from ‘constexpr decltype(auto)
std::__do_visit(_Visitor&&, _Variants&& ...) [with bool __use_index = true;
bool __same_return_types = true; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Variants = {const std::variant<me_data, me_data>&}]’
/usr/include/c++/9/variant:586:32:   required from
‘std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]’
/usr/include/c++/9/variant:636:12:   required from here
/usr/include/c++/9/type_traits:2384:11: error: no type named ‘type’ in ‘struct
std::enable_if<false, void>’
 2384 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant: In instantiation of
‘std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>
mutable [with auto:3 = const me_data&; auto:4 = std::integral_constant<long
unsigned int, 0>]’:
/usr/include/c++/9/bits/invoke.h:60:36:   required from ‘constexpr _Res
std::__invoke_impl(std::__invoke_other, _Fn&&, _Args&& ...) [with _Res =
std::__detail::__variant::__variant_idx_cookie; _Fn =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 0>}]’
/usr/include/c++/9/bits/invoke.h:95:40:   required from ‘constexpr typename
std::__invoke_result<_Functor, _ArgTypes>::type std::__invoke(_Callable&&,
_Args&& ...) [with _Callable =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 0>};
typename std::__invoke_result<_Functor, _ArgTypes>::type =
std::__detail::__variant::__variant_idx_cookie]’
/usr/include/c++/9/variant:961:24:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__visit_invoke_impl(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:980:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__do_visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:996:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:1005:28:   required from ‘static constexpr auto
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::_S_apply() [with bool __same_return_types = true;
_Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:915:56:   required from ‘static constexpr void
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...), __dimensions ...>, std::tuple<_Variants ...>, std::integer_sequence<long
unsigned int, __indices ...> >::_S_apply_single_alt(_Tp&, _Tp*) [with bool
__do_cookie = true; long unsigned int __index = 0; _Tp =
std::__detail::__variant::_Multi_array<std::__detail::__variant::__variant_idx_cookie
(*)(std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&)>; bool __same_return_types =
true; _Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; long unsigned int ...__dimensions = {2}; _Variants = {const
std::variant<me_data, me_data>&}; long unsigned int ...__indices = {}]’
/usr/include/c++/9/variant:896:47:   required from ‘constexpr const _Array_type
std::__detail::__variant::__gen_vtable<true,
std::__detail::__variant::__variant_idx_cookie,
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&>::_S_vtable’
/usr/include/c++/9/variant:1638:23:   required from ‘constexpr decltype(auto)
std::__do_visit(_Visitor&&, _Variants&& ...) [with bool __use_index = true;
bool __same_return_types = true; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Variants = {const std::variant<me_data, me_data>&}]’
/usr/include/c++/9/variant:586:32:   required from
‘std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]’
/usr/include/c++/9/variant:636:12:   required from here
/usr/include/c++/9/variant:1289:7: note: candidate:
‘std::variant<_Types>::variant(std::variant<_Types>&&) [with _Types = {me_data,
me_data}]’
 1289 |       variant(variant&&) = default;
      |       ^~~~~~~
/usr/include/c++/9/variant:1289:15: note:   no known conversion for argument 1
from ‘const me_data’ to ‘std::variant<me_data, me_data>&&’
 1289 |       variant(variant&&) = default;
      |               ^~~~~~~~~
/usr/include/c++/9/variant:1288:7: note: candidate:
‘std::variant<_Types>::variant(const std::variant<_Types>&) [with _Types =
{me_data, me_data}]’
 1288 |       variant(const variant& __rhs) = default;
      |       ^~~~~~~
/usr/include/c++/9/variant:1288:30: note:   no known conversion for argument 1
from ‘const me_data’ to ‘const std::variant<me_data, me_data>&’
 1288 |       variant(const variant& __rhs) = default;
      |               ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/9/variant:1287:7: note: candidate: ‘constexpr
std::variant<_Types>::variant() [with _Types = {me_data, me_data}]’
 1287 |       variant() = default;
      |       ^~~~~~~
/usr/include/c++/9/variant:1287:7: note:   candidate expects 0 arguments, 1
provided
In file included from main.cpp:1:
/usr/include/c++/9/variant: In instantiation of
‘std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>
mutable [with auto:3 = const me_data&; auto:4 = std::integral_constant<long
unsigned int, 1>]’:
/usr/include/c++/9/bits/invoke.h:60:36:   required from ‘constexpr _Res
std::__invoke_impl(std::__invoke_other, _Fn&&, _Args&& ...) [with _Res =
std::__detail::__variant::__variant_idx_cookie; _Fn =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 1>}]’
/usr/include/c++/9/bits/invoke.h:95:40:   required from ‘constexpr typename
std::__invoke_result<_Functor, _ArgTypes>::type std::__invoke(_Callable&&,
_Args&& ...) [with _Callable =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Args = {const me_data&, std::integral_constant<long unsigned int, 1>};
typename std::__invoke_result<_Functor, _ArgTypes>::type =
std::__detail::__variant::__variant_idx_cookie]’
/usr/include/c++/9/variant:961:24:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__visit_invoke_impl(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {1}]’
/usr/include/c++/9/variant:980:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__do_visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {1}]’
/usr/include/c++/9/variant:996:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::__visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {1}]’
/usr/include/c++/9/variant:1005:28:   required from ‘static constexpr auto
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence<long unsigned int,
__indices ...> >::_S_apply() [with bool __same_return_types = true;
_Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; _Variants = {const std::variant<me_data, me_data>&}; long unsigned
int ...__indices = {1}]’
/usr/include/c++/9/variant:915:56:   required from ‘static constexpr void
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...), __dimensions ...>, std::tuple<_Variants ...>, std::integer_sequence<long
unsigned int, __indices ...> >::_S_apply_single_alt(_Tp&, _Tp*) [with bool
__do_cookie = true; long unsigned int __index = 1; _Tp =
std::__detail::__variant::_Multi_array<std::__detail::__variant::__variant_idx_cookie
(*)(std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&)>; bool __same_return_types =
true; _Result_type = std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&; long unsigned int ...__dimensions = {2}; _Variants = {const
std::variant<me_data, me_data>&}; long unsigned int ...__indices = {}]’
/usr/include/c++/9/variant:896:47:   required from ‘constexpr const _Array_type
std::__detail::__variant::__gen_vtable<true,
std::__detail::__variant::__variant_idx_cookie,
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&,
auto:4)>&&, const std::variant<me_data, me_data>&>::_S_vtable’
/usr/include/c++/9/variant:1638:23:   required from ‘constexpr decltype(auto)
std::__do_visit(_Visitor&&, _Variants&& ...) [with bool __use_index = true;
bool __same_return_types = true; _Visitor =
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]::<lambda(auto:3&&, auto:4)>;
_Variants = {const std::variant<me_data, me_data>&}]’
/usr/include/c++/9/variant:586:32:   required from
‘std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&
std::__detail::__variant::_Copy_assign_base<<anonymous>,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<<anonymous>, _Types>&) [with bool
<anonymous> = false; _Types = {me_data, me_data}]’
/usr/include/c++/9/variant:636:12:   required from here
/usr/include/c++/9/variant:609:6: error: no matching function for call to
‘std::variant<me_data, me_data>::variant(const me_data&)’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1342:2: note: candidate: ‘template<long unsigned int
_Np, class _Up, class ... _Args, class _Tp, class> constexpr
std::variant<_Types>::variant(std::in_place_index_t<_Np>,
std::initializer_list<_Up>, _Args&& ...)’
 1342 |  variant(in_place_index_t<_Np>, initializer_list<_Up> __il,
      |  ^~~~~~~
/usr/include/c++/9/variant:1342:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_index_t<_Idx>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1331:2: note: candidate: ‘template<long unsigned int
_Np, class ... _Args, class _Tp, class> constexpr
std::variant<_Types>::variant(std::in_place_index_t<_Np>, _Args&& ...)’
 1331 |  variant(in_place_index_t<_Np>, _Args&&... __args)
      |  ^~~~~~~
/usr/include/c++/9/variant:1331:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_index_t<_Idx>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1321:2: note: candidate: ‘template<class _Tp, class
_Up, class ... _Args, class> constexpr
std::variant<_Types>::variant(std::in_place_type_t<_Tp>,
std::initializer_list<_Up>, _Args&& ...)’
 1321 |  variant(in_place_type_t<_Tp>, initializer_list<_Up> __il,
      |  ^~~~~~~
/usr/include/c++/9/variant:1321:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_type_t<_Tp>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1311:2: note: candidate: ‘template<class _Tp, class
... _Args, class> constexpr
std::variant<_Types>::variant(std::in_place_type_t<_Tp>, _Args&& ...)’
 1311 |  variant(in_place_type_t<_Tp>, _Args&&... __args)
      |  ^~~~~~~
/usr/include/c++/9/variant:1311:2: note:   template argument
deduction/substitution failed:
In file included from main.cpp:1:
/usr/include/c++/9/variant:609:6: note:   ‘me_data’ is not derived from
‘std::in_place_type_t<_Tp>’
  609 |    = variant<_Types...>(__rhs_mem);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/usr/include/c++/9/variant:1301:2: note: candidate: ‘template<class _Tp, class,
class, class _Tj, class> constexpr std::variant<_Types>::variant(_Tp&&)’
 1301 |  variant(_Tp&& __t)
      |  ^~~~~~~
/usr/include/c++/9/variant:1301:2: note:   template argument
deduction/substitution failed:
/usr/include/c++/9/variant:1289:7: note: candidate:
‘std::variant<_Types>::variant(std::variant<_Types>&&) [with _Types = {me_data,
me_data}]’
 1289 |       variant(variant&&) = default;
      |       ^~~~~~~
/usr/include/c++/9/variant:1289:15: note:   no known conversion for argument 1
from ‘const me_data’ to ‘std::variant<me_data, me_data>&&’
 1289 |       variant(variant&&) = default;
      |               ^~~~~~~~~
/usr/include/c++/9/variant:1288:7: note: candidate:
‘std::variant<_Types>::variant(const std::variant<_Types>&) [with _Types =
{me_data, me_data}]’
 1288 |       variant(const variant& __rhs) = default;
      |       ^~~~~~~
/usr/include/c++/9/variant:1288:30: note:   no known conversion for argument 1
from ‘const me_data’ to ‘const std::variant<me_data, me_data>&’
 1288 |       variant(const variant& __rhs) = default;
      |               ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/9/variant:1287:7: note: candidate: ‘constexpr
std::variant<_Types>::variant() [with _Types = {me_data, me_data}]’
 1287 |       variant() = default;
      |       ^~~~~~~
/usr/include/c++/9/variant:1287:7: note:   candidate expects 0 arguments, 1
provided

---
When using variant with the same type two times, it fails to compile if the
type have potentially-throwing copy constructor and noexcept move constructor.
All other combinations of throwing policy work.

Reply via email to