summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/tr1/utility
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-24 16:04:47 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-24 16:04:47 +0000
commit5df7dd2dd2a3972977ea5eef8269250dd26e456b (patch)
treef7ae421ab2ab034f148557e5a3f3d6204d84cfa8 /libstdc++-v3/include/tr1/utility
parentfa31fec1d4b49eccbab9cdda0e69b2d45358e013 (diff)
downloadppe42-gcc-5df7dd2dd2a3972977ea5eef8269250dd26e456b.tar.gz
ppe42-gcc-5df7dd2dd2a3972977ea5eef8269250dd26e456b.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91171 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/tr1/utility')
-rw-r--r--libstdc++-v3/include/tr1/utility89
1 files changed, 89 insertions, 0 deletions
diff --git a/libstdc++-v3/include/tr1/utility b/libstdc++-v3/include/tr1/utility
new file mode 100644
index 00000000000..92484ea8cc5
--- /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
OpenPOWER on IntegriCloud