Make tuple_element static_assert in pair if the index is out of range. Also, add a message to variant_alternative<> in the similar case (it already asserted). Add tests for this
llvm-svn: 305196
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 0c69d6e9bbb8f833daf75297a8b7fab724b33bc1
diff --git a/include/variant b/include/variant
index 8505f32..8711ef6 100644
--- a/include/variant
+++ b/include/variant
@@ -278,7 +278,7 @@
template <size_t _Ip, class... _Types>
struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
- static_assert(_Ip < sizeof...(_Types));
+ static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>");
using type = __type_pack_element<_Ip, _Types...>;
};