mirror of git://gcc.gnu.org/git/gcc.git
re PR libstdc++/23978 (tr1::tie doesn't work with std::pair)
2005-09-29 Chris Jefferson <chris@bubblescope.net> PR libstdc++/23978 * include/tr1/functional (ref, cref): Make inline. * include/tr1/tuple_iterate.h (tuple): Add operator=(std::pair). (tie): Correct formatting. (make_tuple): Make inline. * testsuite/tr1/6_containers/tuple/creation_functions/23978.cc: New. From-SVN: r104784
This commit is contained in:
parent
2cff1b3e09
commit
2bd8e92c33
|
|
@ -1,3 +1,12 @@
|
||||||
|
2005-09-29 Chris Jefferson <chris@bubblescope.net>
|
||||||
|
|
||||||
|
PR libstdc++/23978
|
||||||
|
* include/tr1/functional (ref, cref): Make inline.
|
||||||
|
* include/tr1/tuple_iterate.h (tuple): Add operator=(std::pair).
|
||||||
|
(tie): Correct formatting.
|
||||||
|
(make_tuple): Make inline.
|
||||||
|
* testsuite/tr1/6_containers/tuple/creation_functions/23978.cc: New.
|
||||||
|
|
||||||
2005-09-25 Benjamin Kosnik <bkoz@redhat.com>
|
2005-09-25 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
Eric Botcazou <ebotcazou@libertysurf.fr>
|
Eric Botcazou <ebotcazou@libertysurf.fr>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -372,22 +372,24 @@ namespace tr1
|
||||||
|
|
||||||
// Denotes a reference should be taken to a variable.
|
// Denotes a reference should be taken to a variable.
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
reference_wrapper<_Tp>
|
inline reference_wrapper<_Tp>
|
||||||
ref(_Tp& __t)
|
ref(_Tp& __t)
|
||||||
{ return reference_wrapper<_Tp>(__t); }
|
{ return reference_wrapper<_Tp>(__t); }
|
||||||
|
|
||||||
// Denotes a const reference should be taken to a variable.
|
// Denotes a const reference should be taken to a variable.
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
reference_wrapper<const _Tp>
|
inline reference_wrapper<const _Tp>
|
||||||
cref(const _Tp& __t)
|
cref(const _Tp& __t)
|
||||||
{ return reference_wrapper<const _Tp>(__t); }
|
{ return reference_wrapper<const _Tp>(__t); }
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
reference_wrapper<_Tp> ref(reference_wrapper<_Tp> __t)
|
inline reference_wrapper<_Tp>
|
||||||
|
ref(reference_wrapper<_Tp> __t)
|
||||||
{ return ref(__t.get()); }
|
{ return ref(__t.get()); }
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
reference_wrapper<const _Tp> cref(reference_wrapper<_Tp> __t)
|
inline reference_wrapper<const _Tp>
|
||||||
|
cref(reference_wrapper<_Tp> __t)
|
||||||
{ return cref(__t.get()); }
|
{ return cref(__t.get()); }
|
||||||
|
|
||||||
template<typename _Tp, bool>
|
template<typename _Tp, bool>
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,18 @@ template<_GLIBCXX_TEMPLATE_PARAMS>
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
#if _GLIBCXX_NUM_ARGS == 2
|
#if _GLIBCXX_NUM_ARGS == 2
|
||||||
template<class _U1, class _U2>
|
template<typename _U1, typename _U2>
|
||||||
tuple(const std::pair<_U1, _U2>& __u):
|
tuple(const std::pair<_U1, _U2>& __u) :
|
||||||
_M_arg1(__u.first), _M_arg2(__u.second)
|
_M_arg1(__u.first), _M_arg2(__u.second)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
template<typename _U1, typename _U2>
|
||||||
|
tuple&
|
||||||
|
operator=(const std::pair<_U1, _U2>& __u)
|
||||||
|
{
|
||||||
|
_M_arg1 = __u.first;
|
||||||
|
_M_arg2 = __u.second;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _GLIBCXX_NUM_ARGS > 0
|
#if _GLIBCXX_NUM_ARGS > 0
|
||||||
|
|
@ -137,14 +144,14 @@ tuple<>
|
||||||
inline make_tuple()
|
inline make_tuple()
|
||||||
{ return tuple<>(); }
|
{ return tuple<>(); }
|
||||||
|
|
||||||
inline tuple<>
|
tuple<>
|
||||||
tie()
|
inline tie()
|
||||||
{ return tuple<>(); }
|
{ return tuple<>(); }
|
||||||
#else
|
#else
|
||||||
|
|
||||||
template<_GLIBCXX_TEMPLATE_PARAMS>
|
template<_GLIBCXX_TEMPLATE_PARAMS>
|
||||||
typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::__type
|
typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::__type
|
||||||
make_tuple(_GLIBCXX_PARAMS)
|
inline make_tuple(_GLIBCXX_PARAMS)
|
||||||
{
|
{
|
||||||
return typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::
|
return typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::
|
||||||
__type(_GLIBCXX_ARGS);
|
__type(_GLIBCXX_ARGS);
|
||||||
|
|
@ -152,7 +159,7 @@ template<_GLIBCXX_TEMPLATE_PARAMS>
|
||||||
|
|
||||||
template<_GLIBCXX_TEMPLATE_PARAMS>
|
template<_GLIBCXX_TEMPLATE_PARAMS>
|
||||||
tuple<_GLIBCXX_REF_TEMPLATE_ARGS>
|
tuple<_GLIBCXX_REF_TEMPLATE_ARGS>
|
||||||
tie(_GLIBCXX_REF_PARAMS)
|
inline tie(_GLIBCXX_REF_PARAMS)
|
||||||
{ return make_tuple(_GLIBCXX_REF_WRAP_PARAMS); }
|
{ return make_tuple(_GLIBCXX_REF_WRAP_PARAMS); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// 2005-09-29 Chris Jefferson <chris@bubblescope.net>
|
||||||
|
//
|
||||||
|
// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// Tuple
|
||||||
|
|
||||||
|
#include <tr1/tuple>
|
||||||
|
#include <tr1/utility>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace tr1;
|
||||||
|
|
||||||
|
// libstdc++/23978
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
|
pair<int, int> p(1, 2);
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
tie(x, y) = p;
|
||||||
|
VERIFY( x == 1 && y == 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue