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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305196 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -653,6 +653,12 @@ template <class _T1, class _T2>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
|
||||
: public integral_constant<size_t, 2> {};
|
||||
|
||||
template <size_t _Ip, class _T1, class _T2>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> >
|
||||
{
|
||||
static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> >
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user