PR libstdc++/78939 make tuple_size<cv T> depend on tuple_size<T>
PR libstdc++/78939 * include/std/utility (tuple_size<cv T>) [__cplusplus > 201402L]: Only define partial specializations when tuple_size<T>::value is valid. * testsuite/20_util/tuple/78939.cc: New. From-SVN: r247978
This commit is contained in:
parent
012d90bd74
commit
cf20ff6ff6
|
@ -1,3 +1,11 @@
|
|||
2017-05-12 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/78939
|
||||
* include/std/utility (tuple_size<cv T>) [__cplusplus > 201402L]:
|
||||
Only define partial specializations when tuple_size<T>::value is
|
||||
valid.
|
||||
* testsuite/20_util/tuple/78939.cc: New.
|
||||
|
||||
2017-05-02 Release Manager
|
||||
|
||||
* GCC 7.1.0 released.
|
||||
|
|
|
@ -89,6 +89,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 2770. tuple_size<const T> specialization is not SFINAE compatible
|
||||
|
||||
#if __cplusplus <= 201402L
|
||||
template<typename _Tp, typename = void>
|
||||
struct __tuple_size_cv_impl { };
|
||||
|
||||
|
@ -106,6 +108,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
template<typename _Tp>
|
||||
struct tuple_size<const volatile _Tp> : __tuple_size_cv_impl<_Tp> { };
|
||||
#else
|
||||
template<typename _Tp,
|
||||
typename _Up = typename remove_cv<_Tp>::type,
|
||||
typename = typename enable_if<is_same<_Tp, _Up>::value>::type,
|
||||
size_t = tuple_size<_Tp>::value>
|
||||
using __enable_if_has_tuple_size = _Tp;
|
||||
|
||||
template<typename _Tp>
|
||||
struct tuple_size<const __enable_if_has_tuple_size<_Tp>>
|
||||
: public tuple_size<_Tp> { };
|
||||
|
||||
template<typename _Tp>
|
||||
struct tuple_size<volatile __enable_if_has_tuple_size<_Tp>>
|
||||
: public tuple_size<_Tp> { };
|
||||
|
||||
template<typename _Tp>
|
||||
struct tuple_size<const volatile __enable_if_has_tuple_size<_Tp>>
|
||||
: public tuple_size<_Tp> { };
|
||||
#endif
|
||||
|
||||
/// Gives the type of the ith element of a given tuple type.
|
||||
template<std::size_t __i, typename _Tp>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (C) 2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17" }
|
||||
// { dg-do compile { target c++1z } }
|
||||
|
||||
// PR libstdc++/78939
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A { int i, j; };
|
||||
|
||||
int
|
||||
test01()
|
||||
{
|
||||
A a{};
|
||||
const auto [i, j] = a;
|
||||
return i + j;
|
||||
}
|
||||
|
||||
int
|
||||
test02()
|
||||
{
|
||||
A a{};
|
||||
volatile auto [i, j] = a;
|
||||
return i + j;
|
||||
}
|
||||
|
||||
int
|
||||
test03()
|
||||
{
|
||||
A a{};
|
||||
const volatile auto [i, j] = a;
|
||||
return i + j;
|
||||
}
|
Loading…
Reference in New Issue