Commit f2ede5d6 by Benjamin Kosnik

[multiple changes]


2004-11-24  Benjamin Kosnik  <bkoz@redhat.com>

	* include/Makefile.am (tr1_headers): Add utility, functional.
	* include/Makefile.in: Regenerate.

2004-11-24  Chris Jefferson  <chris@bubblescope.net>

	* include/tr1/tuple(operator!=): Change operator
	definition to match (draft) technical report.
	(operator>): Same.
	(operator<=): Same.
	(operator>=): Same.
	(ref): Move to include/tr1/functional.
	(cref): Same.
	(tuple_size<pair>): Move to include/tr1/utility.
	(tuple_element<,pair>): Same.
	* include/tr1/functional: New.
	* include/tr1/utility: New.
	* testsuite/tr1/6_container/utility/pair.cc: New.

From-SVN: r91171
parent 624b15fa
2004-11-24 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (tr1_headers): Add utility, functional.
* include/Makefile.in: Regenerate.
2004-11-24 Chris Jefferson <chris@bubblescope.net>
* include/tr1/tuple(operator!=): Change operator
definition to match (draft) technical report.
(operator>): Same.
(operator<=): Same.
(operator>=): Same.
(ref): Move to include/tr1/functional.
(cref): Same.
(tuple_size<pair>): Move to include/tr1/utility.
(tuple_element<,pair>): Same.
* include/tr1/functional: New.
* include/tr1/utility: New.
* testsuite/tr1/6_container/utility/pair.cc: New.
2004-11-24 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
* config/locale/ieee_1003.1-2001/codecvt_specializations.h
......
......@@ -229,7 +229,10 @@ tr1_srcdir = ${glibcxx_srcdir}/include/tr1
tr1_builddir = ./tr1
tr1_headers = \
${tr1_srcdir}/array \
${tr1_srcdir}/tuple
${tr1_srcdir}/functional \
${tr1_srcdir}/tuple \
${tr1_srcdir}/utility
# This is the common subset of files that all three "C" header models use.
c_base_srcdir = $(C_INCLUDE_DIR)
......
......@@ -446,7 +446,9 @@ tr1_srcdir = ${glibcxx_srcdir}/include/tr1
tr1_builddir = ./tr1
tr1_headers = \
${tr1_srcdir}/array \
${tr1_srcdir}/tuple
${tr1_srcdir}/functional \
${tr1_srcdir}/tuple \
${tr1_srcdir}/utility
# This is the common subset of files that all three "C" header models use.
......
// TR1 functional header -*- C++ -*-
// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
/** @file
* This is a TR1 C++ Library header.
*/
#ifndef _TR1_FUNCTIONAL
#define _TR1_FUNCTIONAL 1
#include "../functional"
namespace std
{
namespace tr1
{
template<typename _Tp>
class reference_wrapper
{
_Tp* _M_data;
public:
typedef _Tp type;
explicit reference_wrapper(_Tp& __indata): _M_data(&__indata)
{ }
reference_wrapper(const reference_wrapper<_Tp>& __inref):
_M_data(__inref._M_data)
{ }
reference_wrapper&
operator=(const reference_wrapper<_Tp>& __inref)
{
_M_data = __inref._M_data;
return *this;
}
operator _Tp&() const
{ return this->get(); }
_Tp&
get() const
{ return *_M_data; }
};
// Denotes a reference should be taken to a variable.
template<typename _Tp>
reference_wrapper<_Tp>
ref(_Tp& __t)
{ return reference_wrapper<_Tp>(__t); }
// Denotes a const reference should be taken to a variable.
template<typename _Tp>
reference_wrapper<const _Tp>
cref(const _Tp& __t)
{ return reference_wrapper<const _Tp>(__t); }
template<typename _Tp>
reference_wrapper<_Tp> ref(reference_wrapper<_Tp> __t)
{ return ref(__t.get()); }
template<typename _Tp>
reference_wrapper<const _Tp> cref(reference_wrapper<_Tp> __t)
{ return cref(__t.get()); }
}
}
#endif
// TR1 utility -*- C++ -*-
// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
/** @file
* This is a TR1 C++ Library header.
*/
#ifndef _TR1_UTILITY
#define _TR1_UTILITY 1
#include "../utility"
namespace std
{
namespace tr1
{
template<class _Tp> class tuple_size;
template<int _Int, class _Tp> class tuple_element;
// Various functions which give std::pair a tuple-like interface.
template<class _Tp1, class _Tp2>
struct tuple_size<std::pair<_Tp1, _Tp2> >
{ static const int value = 2; };
template<class _Tp1, class _Tp2>
struct tuple_element<0, std::pair<_Tp1, _Tp2> >
{ typedef _Tp1 type; };
template<class _Tp1, class _Tp2>
struct tuple_element<1, std::pair<_Tp1, _Tp2> >
{ typedef _Tp2 type; };
template<int _Int> struct __pair_get;
template<>
struct __pair_get<0>
{
template<typename _Tp1, typename _Tp2>
static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.first; }
template<typename _Tp1, typename _Tp2>
static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.first; }
};
template<>
struct __pair_get<1>
{
template<typename _Tp1, typename _Tp2>
static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.second; }
template<typename _Tp1, typename _Tp2>
static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.second; }
};
template<int _I, class _Tp1, class _Tp2>
typename tuple_element<_I, std::pair<_Tp1, _Tp2> >::type&
get(pair<_Tp1, _Tp2>& __in)
{ return __pair_get<_I>::__get(__in); }
template<int _I, class _Tp1, class _Tp2>
const typename tuple_element<_I, std::pair<_Tp1, _Tp2> >::type&
get(const pair<_Tp1, _Tp2>& __in)
{ return __pair_get<_I>::__const_get(__in); }
}
}
#endif
// 2004-09-23 Chris Jefferson <chris@bubblescope.net>
// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// tr1 additions to pair
#include <tr1/utility>
#include <testsuite_hooks.h>
using namespace std;
using namespace tr1;
struct blank_class
{ };
int
main()
{
bool test __attribute__((unused)) = true;
typedef pair<int,int> test_pair_type;
VERIFY(tuple_size<test_pair_type>::value == 2);
// Test if tuple_element::type returns the correct type
blank_class blank;
tuple_element<0, pair<blank_class, int> >::type blank2 = blank;
tuple_element<1, pair<int ,blank_class> >::type blank3 = blank;
pair<int,int> test_pair(1, 2);
VERIFY(get<0>(test_pair) == 1);
VERIFY(get<1>(test_pair) == 2);
get<0>(test_pair) = 3;
get<1>(test_pair) = 4;
VERIFY(get<0>(test_pair) == 3);
VERIFY(get<1>(test_pair) == 4);
const pair<int,int> test_pair2(1,2);
VERIFY(get<0>(test_pair2) == 1);
VERIFY(get<1>(test_pair2) == 2);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment