Skip to content

Instantly share code, notes, and snippets.

@EricWF
Created December 2, 2016 21:56
Show Gist options
  • Select an option

  • Save EricWF/75468beb4aec22cb8de4519234dd9030 to your computer and use it in GitHub Desktop.

Select an option

Save EricWF/75468beb4aec22cb8de4519234dd9030 to your computer and use it in GitHub Desktop.
diff --git a/include/variant b/include/variant
index 6ecc193..8969790 100644
--- a/include/variant
+++ b/include/variant
@@ -1071,7 +1071,16 @@ using __best_match_t = typename result_of_t<__overload<_Types...>(_Tp&&)>::type;
} // __variant_detail
template <class... _Types>
-class _LIBCPP_TYPE_VIS_ONLY variant {
+class _LIBCPP_TYPE_VIS_ONLY variant :
+ private __sfinae_ctor_base<
+ __all<is_copy_constructible_v<_Types>...>::value,
+ __all<is_move_constructible_v<_Types>...>::value
+ >,
+ private __sfinae_assign_base<
+ __all<(is_copy_constructible_v<_Types> && is_move_constructible_v<_Types>
+ && is_copy_assignable_v<_Types>)...>::value,
+ __all<(is_move_constructible_v<_Types> && is_move_assignable_v<_Types>)...>::value
+ > {
static_assert(0 < sizeof...(_Types),
"variant must consist of at least one alternative.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment