Skip to content

Commit 5396a8f

Browse files
committed
work on c++ -std=c++98 compat WIP
1 parent cfed9b0 commit 5396a8f

File tree

3 files changed

+128
-45
lines changed

3 files changed

+128
-45
lines changed

tests/func/digi.hh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,40 @@ digi_hash(digi* a)
7474
return (size_t)int_hash_func(*a->value);
7575
}
7676

77+
#if __cplusplus <= 199711
78+
# define nullptr NULL
79+
#endif
80+
7781
struct DIGI
7882
{
7983
int* value;
84+
#if __cplusplus > 199711
8085
DIGI(int _value): value { new int {_value} }
8186
{
8287
}
8388
DIGI(): DIGI(0)
8489
{
8590
}
86-
~DIGI()
91+
DIGI(const DIGI& a): DIGI()
8792
{
88-
delete value;
93+
*value = a.value ? *a.value : 0;
8994
}
90-
DIGI(const DIGI& a): DIGI()
95+
#else
96+
DIGI(int _value)
9197
{
98+
value = new int;
99+
*value = _value;
100+
}
101+
DIGI(const DIGI& a)
102+
{
103+
value = new int;
92104
*value = a.value ? *a.value : 0;
93105
}
106+
#endif
107+
~DIGI()
108+
{
109+
delete value;
110+
}
94111
DIGI& operator=(const DIGI& a)
95112
{
96113
delete value;
@@ -111,6 +128,11 @@ struct DIGI
111128
value = a.value;
112129
a.value = nullptr;
113130
}
131+
#else
132+
DIGI(DIGI& a)
133+
{
134+
*value = a.value ? *a.value : 0;
135+
}
114136
#endif
115137
bool operator<(const DIGI& a) const
116138
{
@@ -216,4 +238,10 @@ DIGI_bintrans (const DIGI& d1, const DIGI& d2)
216238
return DIGI{*d1.value ^ *d2.value};
217239
}
218240

241+
#if __cplusplus <= 199711
242+
# define DIGI(n) DIGI(n)
243+
#else
244+
# define DIGI(n) DIGI{n}
245+
#endif
246+
219247
#endif

0 commit comments

Comments
 (0)