/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/utility/utility.h

  • Committer: edam
  • Date: 2012-02-25 01:31:43 UTC
  • Revision ID: tim@ed.am-20120225013143-9fet2y2d3fjlrwez
added ulibc

Show diffs side-by-side

added added

removed removed

 
1
/*      Copyright (C) 2004 Garrett A. Kajmowicz
 
2
        This file is part of the uClibc++ Library.
 
3
 
 
4
        This library is free software; you can redistribute it and/or
 
5
        modify it under the terms of the GNU Lesser General Public
 
6
        License as published by the Free Software Foundation; either
 
7
        version 2.1 of the License, or (at your option) any later version.
 
8
 
 
9
        This library is distributed in the hope that it will be useful,
 
10
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
        Lesser General Public License for more details.
 
13
 
 
14
        You should have received a copy of the GNU Lesser General Public
 
15
        License along with this library; if not, write to the Free Software
 
16
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
*/
 
19
 
 
20
 
 
21
#include <basic_definitions>
 
22
 
 
23
 
 
24
#ifndef __STD_HEADER_UTILITY
 
25
#define __STD_HEADER_UTILITY 1
 
26
 
 
27
#pragma GCC visibility push(default)
 
28
 
 
29
extern "C" void atexit();
 
30
 
 
31
namespace std{
 
32
 
 
33
        namespace rel_ops {
 
34
                template<class T> inline bool operator!=(const T& x, const T& y){
 
35
                        return !(x == y);
 
36
                }
 
37
 
 
38
                template<class T> inline bool operator> (const T& x, const T& y){
 
39
                        return ( y < x);
 
40
                }
 
41
 
 
42
                template<class T> inline bool operator<=(const T& x, const T& y){
 
43
                        return !( y < x );
 
44
                }
 
45
 
 
46
                template<class T> inline bool operator>=(const T& x, const T& y){
 
47
                        return !(x < y);
 
48
                }
 
49
        }
 
50
 
 
51
        template <class T1, class T2> struct _UCXXEXPORT pair {
 
52
                typedef T1 first_type;
 
53
                typedef T2 second_type;
 
54
 
 
55
                T1 first;
 
56
                T2 second;
 
57
                pair() : first(), second() {  }
 
58
                pair(const T1& x, const T2& y) : first(x), second(y) {  }
 
59
                template<class U, class V> pair(const pair<U, V> &p) : first(p.first), second(p.second) { }
 
60
        };
 
61
        
 
62
        template <class T1, class T2> bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y){
 
63
                using namespace rel_ops;
 
64
                return (x.first == y.first && x.second==y.second);
 
65
        }
 
66
        template <class T1, class T2> bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y){
 
67
                return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
 
68
        }
 
69
        template <class T1, class T2> bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y){
 
70
                return !(x == y);
 
71
        }
 
72
        template <class T1, class T2> bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y){
 
73
                return y < x;
 
74
        }
 
75
        template <class T1, class T2> bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y){
 
76
                return !(x < y);
 
77
        }
 
78
        template <class T1, class T2> bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y){
 
79
                return !(y < x);
 
80
        }
 
81
        template <class T1, class T2> pair<T1,T2> make_pair(const T1& x, const T2& y){
 
82
                return pair<T1,T2>(x, y);
 
83
        }
 
84
 
 
85
 
 
86
}
 
87
 
 
88
#pragma GCC visibility pop
 
89
 
 
90
#endif  //__STD_HEADER_UTILITY