diff options
author | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2004-11-24 16:04:47 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2004-11-24 16:04:47 +0000 |
commit | f2ede5d6213c42e75ce7dfeaa98950adfa6de73b (patch) | |
tree | f7ae421ab2ab034f148557e5a3f3d6204d84cfa8 /libstdc++-v3 | |
parent | 624b15fa3fe15db62c967c61d265ed405dd7a0ef (diff) | |
download | gcc-f2ede5d6213c42e75ce7dfeaa98950adfa6de73b.zip gcc-f2ede5d6213c42e75ce7dfeaa98950adfa6de73b.tar.gz gcc-f2ede5d6213c42e75ce7dfeaa98950adfa6de73b.tar.bz2 |
[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
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 20 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.am | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.in | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/functional | 85 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/tuple | 177 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/utility | 89 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/tr1/6_containers/utility/pair.cc | 54 |
7 files changed, 284 insertions, 150 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0b94b8a..77e328d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,23 @@ +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 diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 68e7641..2bcc65d 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -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) diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 90ddb9b..913529c 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -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. diff --git a/libstdc++-v3/include/tr1/functional b/libstdc++-v3/include/tr1/functional new file mode 100644 index 0000000..1e897e2 --- /dev/null +++ b/libstdc++-v3/include/tr1/functional @@ -0,0 +1,85 @@ +// 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 + diff --git a/libstdc++-v3/include/tr1/tuple b/libstdc++-v3/include/tr1/tuple index 9a6dfa8..928c75f 100644 --- a/libstdc++-v3/include/tr1/tuple +++ b/libstdc++-v3/include/tr1/tuple @@ -18,18 +18,19 @@ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. -// Chris Jefferson <chris@bubblescope.net> - -// This header is automatically generated: see maketuple.c for details. - /** @file * This is a TR1 C++ Library header. */ +// Chris Jefferson <chris@bubblescope.net> + +// This header is automatically generated: see maketuple.c for details. + #ifndef _TUPLE #define _TUPLE 1 -#include<utility> +#include <tr1/utility> +#include <tr1/functional> namespace std { @@ -1046,9 +1047,8 @@ namespace tr1 { return __in._M_t9; } }; - /* Returns a reference to the ith element of a tuple. - * Any const or non-const ref elements are returned with their original type - */ + // Returns a reference to the ith element of a tuple. + // Any const or non-const ref elements are returned with their original type. template<int __i, typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp8, typename _Tp9> @@ -1063,9 +1063,8 @@ namespace tr1 _Tp7, _Tp8, _Tp9> >::get_value(__t); } - /* Returns a const reference to the ith element of a tuple. - * Any const or non-const ref elements are returned with their original type - */ + // Returns a const reference to the ith element of a tuple. + // Any const or non-const ref elements are returned with their original type. template<int __i, typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp8, typename _Tp9> @@ -1092,31 +1091,11 @@ namespace tr1 return get<__i>(__t) == get<__i>(__u) && __tuple_compare<0, __i+1, __j, _Tp, _Up>::__eq(__t, __u); } - static bool __neq(const _Tp& __t, const _Up& __u) - { - return get<__i>(__t) != get<__i>(__u) || - __tuple_compare<0, __i+1, __j, _Tp, _Up>::__neq(__t, __u); - } static bool __less(const _Tp& __t, const _Up& __u) { return (get<__i>(__t) < get<__i>(__u)) || !(get<__i>(__u) < get<__i>(__t)) && __tuple_compare<0, __i+1, __j, _Tp, _Up>::__less(__t, __u); } - static bool __greater(const _Tp& __t, const _Up& __u) - { - return (get<__i>(__t) > get<__i>(__u)) || !(get<__i>(__u) > get<__i>(__t)) && - __tuple_compare<0, __i+1, __j, _Tp, _Up>::__greater(__t, __u); - } - static bool __leq(const _Tp& __t, const _Up& __u) - { - return (get<__i>(__t) <= get<__i>(__u)) && (!(get<__i>(__u)<=get<__i>(__t)) || - __tuple_compare<0, __i+1, __j, _Tp, _Up>::__leq(__t, __u)); - } - static bool __geq(const _Tp& __t, const _Up& __u) - { - return (get<__i>(__t) >= get<__i>(__u)) && (!(get<__i>(__u)>=get<__i>(__t)) || - __tuple_compare<0, __i+1, __j, _Tp, _Up>::__geq(__t, __u)); - } }; template<int __i, typename _Tp, typename _Up> @@ -1124,16 +1103,8 @@ namespace tr1 { static bool __eq(const _Tp&, const _Up&) { return true; } - static bool __neq(const _Tp&, const _Up&) - { return false; } - static bool __leq(const _Tp&, const _Up&) - { return true; } - static bool __geq(const _Tp&, const _Up&) - { return true; } static bool __less(const _Tp&, const _Up&) { return false; } - static bool __greater(const _Tp&, const _Up&) - { return false; } }; template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, @@ -1146,12 +1117,12 @@ namespace tr1 const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, - _Tp9> __t_tuple; + _Tp9> _Tp; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, - _Up9> __u_tuple; - return __tuple_compare<tuple_size<__t_tuple>::value - - tuple_size<__u_tuple>::value, 0, - tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__eq(__t, __u); + _Up9> _Up; + return __tuple_compare<tuple_size<_Tp>::value - + tuple_size<_Tp>::value, 0, + tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u); } template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, @@ -1160,16 +1131,16 @@ namespace tr1 typename _Up2, typename _Up3, typename _Up4, typename _Up5, typename _Up6, typename _Up7, typename _Up8, typename _Up9> bool - operator!=(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, - const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) + operator<(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, + const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, - _Tp9> __t_tuple; + _Tp9> _Tp; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, - _Up9> __u_tuple; - return __tuple_compare<tuple_size<__t_tuple>::value - - tuple_size<__u_tuple>::value, 0, - tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__neq(__t, __u); + _Up9> _Up; + return __tuple_compare<tuple_size<_Tp>::value - + tuple_size<_Tp>::value, 0, + tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u); } template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, @@ -1178,18 +1149,11 @@ namespace tr1 typename _Up2, typename _Up3, typename _Up4, typename _Up5, typename _Up6, typename _Up7, typename _Up8, typename _Up9> bool - operator<(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, - const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) + operator!=(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, + const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { - typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, - _Tp9> __t_tuple; - typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, - _Up9> __u_tuple; - return __tuple_compare<tuple_size<__t_tuple>::value - - tuple_size<__u_tuple>::value, 0, - tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__less(__t, __u); + return !(__t == __u); } - template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp8, typename _Tp9, typename _Up0, typename _Up1, @@ -1199,15 +1163,8 @@ namespace tr1 operator>(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { - typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, - _Tp9> __t_tuple; - typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, - _Up9> __u_tuple; - return __tuple_compare<tuple_size<__t_tuple>::value - - tuple_size<__u_tuple>::value, 0, - tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__greater(__t, __u); + return __u < __t; } - template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp8, typename _Tp9, typename _Up0, typename _Up1, @@ -1217,15 +1174,8 @@ namespace tr1 operator<=(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { - typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, - _Tp9> __t_tuple; - typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, - _Up9> __u_tuple; - return __tuple_compare<tuple_size<__t_tuple>::value - - tuple_size<__u_tuple>::value, 0, - tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__leq(__t, __u); + return !(__u < __t); } - template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp8, typename _Tp9, typename _Up0, typename _Up1, @@ -1235,54 +1185,9 @@ namespace tr1 operator>=(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { - typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, - _Tp9> __t_tuple; - typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, - _Up9> __u_tuple; - return __tuple_compare<tuple_size<__t_tuple>::value - - tuple_size<__u_tuple>::value, 0, - tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__geq(__t, __u); + return !(__t < __u); } - // Provides a way to annotate that a reference to - // an object should be passed. - template<typename _Tp> - class reference_wrapper - { - _Tp& _M_data; - public: - typedef _Tp type; - explicit reference_wrapper(_Tp& __indata): _M_data(__indata) - { } - - 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<_Tp const> - cref(const _Tp& __t) - { - return reference_wrapper<_Tp const>(__t); - } - // Helper which adds a reference to a type when given a reference_wrapper template<typename _Tp> struct __strip_reference_wrapper @@ -1430,7 +1335,6 @@ namespace tr1 // A class (and instance) which can be used in 'tie' when an element // of a tuple is not required - struct swallow_assign { template<class T> @@ -1439,7 +1343,7 @@ namespace tr1 { return *this; } }; - // TODO: Put this in some kind of shared file + // TODO: Put this in some kind of shared file. namespace { swallow_assign ignore; @@ -1538,29 +1442,6 @@ namespace tr1 ref(__t9)); }; - // 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, class _Tp1, class _Tp2> - typename tuple_element<_Int, tuple<_Tp1, _Tp2> >::type - get(pair<_Tp1, _Tp2>& __in) - { return get<_Int>(tie(__in.first, __in.second)); } - - template<int _Int, class _Tp1, class _Tp2> - typename tuple_element<_Int, tuple<_Tp1, _Tp2> >::type - get(const pair<_Tp1, _Tp2>& __in) - { return get<_Int>(tie(__in.first, __in.second)); } - } } diff --git a/libstdc++-v3/include/tr1/utility b/libstdc++-v3/include/tr1/utility new file mode 100644 index 0000000..92484ea --- /dev/null +++ b/libstdc++-v3/include/tr1/utility @@ -0,0 +1,89 @@ +// 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 diff --git a/libstdc++-v3/testsuite/tr1/6_containers/utility/pair.cc b/libstdc++-v3/testsuite/tr1/6_containers/utility/pair.cc new file mode 100644 index 0000000..e5683b4 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/utility/pair.cc @@ -0,0 +1,54 @@ +// 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); +} + |