summaryrefslogtreecommitdiff
path: root/misc/uClibc++/include/uClibc++/utility
blob: 30c6525ae80297fb8348c58674228cfe686db9a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Copyright (C) 2004 Garrett A. Kajmowicz
 * This file is part of the uClibc++ Library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <basic_definitions>

#ifndef __STD_HEADER_UTILITY
#define __STD_HEADER_UTILITY 1

#pragma GCC visibility push(default)

extern "C++"
{

namespace std
{
  namespace rel_ops
  {
    template<class T> inline bool operator!=(const T& x, const T& y)
    {
      return !(x == y);
    }

    template<class T> inline bool operator> (const T& x, const T& y)
    {
      return ( y < x);
    }

    template<class T> inline bool operator<=(const T& x, const T& y)
    {
      return !( y < x );
    }

    template<class T> inline bool operator>=(const T& x, const T& y)
    {
      return !(x < y);
    }
  } // namespace

  template <class T1, class T2> struct _UCXXEXPORT pair
  {
    typedef T1 first_type;
    typedef T2 second_type;

    T1 first;
    T2 second;
    pair() : first(), second() {  }
    pair(const T1& x, const T2& y) : first(x), second(y) {  }
    template<class U, class V> pair(const pair<U, V> &p) : first(p.first), second(p.second) { }
  };

  template <class T1, class T2> bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y)
  {
    using namespace rel_ops;
    return (x.first == y.first && x.second==y.second);
  }

  template <class T1, class T2> bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y)
  {
    return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
  }

  template <class T1, class T2> bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  {
    return !(x == y);
  }

  template <class T1, class T2> bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y)
  {
    return y < x;
  }

  template <class T1, class T2> bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  {
    return !(x < y);
  }

  template <class T1, class T2> bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  {
    return !(y < x);
  }

  template <class T1, class T2> pair<T1,T2> make_pair(const T1& x, const T2& y)
  {
    return pair<T1,T2>(x, y);
  }

} // namespace
} // extern "C++"

#pragma GCC visibility pop

#endif  //__STD_HEADER_UTILITY