]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/libstdc++/include/tr1/tuple_defs.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / libstdc++ / include / tr1 / tuple_defs.h
1 // class template tuple -*- C++ -*-
2
3 // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING.  If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction.  Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License.  This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 /** @file tr1/tuple_defs.h
31  *  This is an internal header file, included by other library headers.
32  *  You should not attempt to use it directly.
33  */
34
35 #ifndef _GLIBCXX_REPEAT_HEADER
36 #  define _GLIBCXX_REPEAT_HEADER "tuple_defs.h"
37 #  include "repeat.h"
38 #  undef _GLIBCXX_REPEAT_HEADER
39 #endif
40
41 #ifdef _GLIBCXX_LAST_INCLUDE
42 // Chris Jefferson <chris@bubblescope.net>
43    template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS> class tuple;
44
45    // Returns a const reference to the ith element of a tuple.
46    // Any const or non-const ref elements are returned with their original type.
47    template<int __i, _GLIBCXX_TEMPLATE_PARAMS>
48    typename __add_ref<typename tuple_element<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::type>::type
49    get(tuple<_GLIBCXX_TEMPLATE_ARGS>& __t)
50    {
51      return __get_helper<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::get_value(__t);
52    }
53
54    template<int __i, _GLIBCXX_TEMPLATE_PARAMS>
55    typename __add_c_ref<typename tuple_element<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::type>::type
56    get(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t)
57    {
58      return __get_helper<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::get_value(__t);
59    }
60
61  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
62  bool
63  operator==(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
64             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
65  {
66    typedef tuple<_GLIBCXX_TEMPLATE_ARGS> _Tp;
67    typedef tuple<_GLIBCXX_TEMPLATE_ARGS_U> _Up;
68    return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0,
69                           tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u);
70  }
71
72  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
73  bool
74  operator<(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
75            const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
76  {
77    typedef tuple<_GLIBCXX_TEMPLATE_ARGS> _Tp;
78    typedef tuple<_GLIBCXX_TEMPLATE_ARGS_U> _Up;
79    return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0,
80                           tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u);
81  }
82
83  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
84  bool
85  operator!=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
86             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
87  { return !(__t == __u); }
88
89  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
90  bool
91  operator>(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
92            const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
93  { return __u < __t; }
94
95  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
96  bool
97  operator<=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
98             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
99  { return !(__u < __t); }
100
101  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
102  bool
103  operator>=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
104             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
105  { return !(__t < __u); }
106
107  template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS>
108    struct __stripped_tuple_type
109    {
110      typedef tuple<_GLIBCXX_TEMPLATE_ARGS_STRIPPED>      __type;
111    };
112
113 #endif
114