source: git/ntl/include/NTL/pair.h @ 92c0ac

spielwiese
Last change on this file since 92c0ac was 92c0ac, checked in by Hans Schönemann <hannes@…>, 21 years ago
NTL-5.2 git-svn-id: file:///usr/local/Singular/svn/trunk@6320 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.1 KB
Line 
1
2#ifndef NTL_pair__H
3#define NTL_pair__H
4
5#include <NTL/tools.h>
6
7#define NTL_pair_decl(S,T,pair_S_T)  \
8class pair_S_T {  \
9public:  \
10   S a;  \
11   T b;  \
12  \
13   pair_S_T() { }  \
14   pair_S_T(const pair_S_T& l__x) : a(l__x.a), b(l__x.b) { } \
15   pair_S_T& operator=(const pair_S_T& l__x) { a = l__x.a; b = l__x.b; return *this; } \
16   pair_S_T(const S& l__x, const T& l__y) : a(l__x), b(l__y) { }  \
17   ~pair_S_T() { }  \
18};  \
19  \
20inline pair_S_T cons(const S& l__x, const T& l__y) { return pair_S_T(l__x, l__y); } \
21
22
23
24
25#define NTL_pair_io_decl(S,T,pair_S_T) \
26NTL_SNS istream& operator>>(NTL_SNS istream&, pair_S_T&);  \
27  \
28NTL_SNS ostream& operator<<(NTL_SNS ostream&, const pair_S_T&);  \
29
30
31
32#define NTL_pair_eq_decl(S,T,pair_S_T)  \
33inline long operator==(const pair_S_T& l__x, const pair_S_T& l__y)  \
34   { return l__x.a == l__y.a && l__x.b == l__y.b; }  \
35inline long operator!=(const pair_S_T& l__x, const pair_S_T& l__y) \
36   { return !(l__x == l__y); }  \
37
38
39
40// For compatability...
41#define NTL_pair_impl(S,T,pair_S_T)
42
43
44#define NTL_pair_io_impl(S,T,pair_S_T)  \
45NTL_SNS istream& operator>>(NTL_SNS istream& l__s, pair_S_T& l__x)  \
46{  \
47   long l__c;  \
48  \
49   if (!l__s) NTL_NNS Error("bad pair input");  \
50  \
51   l__c = l__s.peek();  \
52   while (l__c == ' ' || l__c == '\n' || l__c == '\t') {  \
53      l__s.get();  \
54      l__c = l__s.peek();  \
55   }  \
56  \
57   if (l__c != '[')  \
58      NTL_NNS Error("bad pair input");  \
59  \
60   l__s.get();  \
61  \
62   if (!(l__s >> l__x.a))   \
63      NTL_NNS Error("bad pair input");  \
64   if (!(l__s >> l__x.b))  \
65      NTL_NNS Error("bad pair input");  \
66  \
67   l__c = l__s.peek();  \
68   while (l__c == ' ' || l__c == '\n' || l__c == '\t') {  \
69      l__s.get();  \
70      l__c = l__s.peek();  \
71   }  \
72  \
73   if (l__c != ']')  \
74      NTL_NNS Error("bad pair input");  \
75  \
76   l__s.get();  \
77  \
78   return l__s;  \
79}  \
80  \
81NTL_SNS ostream& operator<<(NTL_SNS ostream& l__s, const pair_S_T& l__x)  \
82{  \
83   return l__s << "[" << l__x.a << " " << l__x.b << "]";  \
84}  \
85
86
87
88// For compatability...
89#define NTL_pair_eq_impl(S,T,pair_S_T)
90
91
92
93
94#endif
Note: See TracBrowser for help on using the repository browser.