re PR libstdc++/51365 (cannot use final empty class in std::tuple)
PR libstdc++/51365 * include/std/tuple (_Tuple_impl): Check __is_final as well as is_empty. * testsuite/20_util/tuple/51365.cc: New. From-SVN: r182523
This commit is contained in:
parent
1bb4b6a35a
commit
d8ab827382
|
@ -1,3 +1,10 @@
|
||||||
|
2011-12-20 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
|
PR libstdc++/51365
|
||||||
|
* include/std/tuple (_Tuple_impl): Check __is_final as well as
|
||||||
|
is_empty.
|
||||||
|
* testsuite/20_util/tuple/51365.cc: New.
|
||||||
|
|
||||||
2011-12-19 Benjamin Kosnik <bkoz@redhat.com>
|
2011-12-19 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
* libsupc++/eh_tm.cc (free_any_cxa_exception): Use
|
* libsupc++/eh_tm.cc (free_any_cxa_exception): Use
|
||||||
|
|
|
@ -69,7 +69,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
struct __add_r_ref<_Tp&>
|
struct __add_r_ref<_Tp&>
|
||||||
{ typedef _Tp& type; };
|
{ typedef _Tp& type; };
|
||||||
|
|
||||||
template<std::size_t _Idx, typename _Head, bool _IsEmpty>
|
template<std::size_t _Idx, typename _Head, bool _IsEmptyNotFinal>
|
||||||
struct _Head_base;
|
struct _Head_base;
|
||||||
|
|
||||||
template<std::size_t _Idx, typename _Head>
|
template<std::size_t _Idx, typename _Head>
|
||||||
|
@ -201,6 +201,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
void _M_swap(_Tuple_impl&) noexcept { /* no-op */ }
|
void _M_swap(_Tuple_impl&) noexcept { /* no-op */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Use the Empty Base-class Optimization for empty, non-final types.
|
||||||
|
template<typename _Tp>
|
||||||
|
using __empty_not_final
|
||||||
|
= typename conditional<__is_final(_Tp), false_type, is_empty<_Tp>>::type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursive tuple implementation. Here we store the @c Head element
|
* Recursive tuple implementation. Here we store the @c Head element
|
||||||
* and derive from a @c Tuple_impl containing the remaining elements
|
* and derive from a @c Tuple_impl containing the remaining elements
|
||||||
|
@ -209,12 +214,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
template<std::size_t _Idx, typename _Head, typename... _Tail>
|
template<std::size_t _Idx, typename _Head, typename... _Tail>
|
||||||
struct _Tuple_impl<_Idx, _Head, _Tail...>
|
struct _Tuple_impl<_Idx, _Head, _Tail...>
|
||||||
: public _Tuple_impl<_Idx + 1, _Tail...>,
|
: public _Tuple_impl<_Idx + 1, _Tail...>,
|
||||||
private _Head_base<_Idx, _Head, std::is_empty<_Head>::value>
|
private _Head_base<_Idx, _Head, __empty_not_final<_Head>::value>
|
||||||
{
|
{
|
||||||
template<std::size_t, typename...> friend class _Tuple_impl;
|
template<std::size_t, typename...> friend class _Tuple_impl;
|
||||||
|
|
||||||
typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
|
typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
|
||||||
typedef _Head_base<_Idx, _Head, std::is_empty<_Head>::value> _Base;
|
typedef _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> _Base;
|
||||||
|
|
||||||
static constexpr _Head&
|
static constexpr _Head&
|
||||||
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
|
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
// { dg-do compile }
|
||||||
|
|
||||||
|
// Copyright (C) 2011 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/>.
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
// libstdc++/51365
|
||||||
|
|
||||||
|
struct F final { };
|
||||||
|
std::tuple<F> t;
|
||||||
|
|
Loading…
Reference in New Issue