@@ -169,6 +169,7 @@ class irept
169
169
bool is_nil () const { return id ()==ID_nil; }
170
170
bool is_not_nil () const { return id ()!=ID_nil; }
171
171
172
+ #if !defined(USE_MOVE) || !defined(SHARING)
172
173
explicit irept (const irep_idt &_id)
173
174
#ifdef SHARING
174
175
:data(&empty_d)
@@ -177,7 +178,27 @@ class irept
177
178
id (_id);
178
179
}
179
180
180
- #ifdef SHARING
181
+ irept (const irep_idt &_id, const named_subt &_named_sub, const subt &_sub)
182
+ #ifdef SHARING
183
+ : data(&empty_d)
184
+ #endif
185
+ {
186
+ id (_id);
187
+ get_named_sub () = _named_sub;
188
+ get_sub () = _sub;
189
+ }
190
+ #else
191
+ explicit irept (irep_idt _id) : data(new dt(std::move(_id)))
192
+ {
193
+ }
194
+
195
+ irept (irep_idt _id, named_subt _named_sub, subt _sub)
196
+ : data(new dt(std::move(_id), std::move(_named_sub), std::move(_sub)))
197
+ {
198
+ }
199
+ #endif
200
+
201
+ #ifdef SHARING
181
202
// constructor for blank irep
182
203
irept ():data(&empty_d)
183
204
{
@@ -335,9 +356,9 @@ class irept
335
356
private:
336
357
friend class irept ;
337
358
338
- #ifdef SHARING
339
- unsigned ref_count;
340
- #endif
359
+ #ifdef SHARING
360
+ unsigned ref_count = 1 ;
361
+ #endif
341
362
342
363
// / This irep_idt is the only place to store data in an irep, other than
343
364
// / the mere nesting structure
@@ -346,9 +367,9 @@ class irept
346
367
named_subt named_sub;
347
368
subt sub;
348
369
349
- #ifdef HASH_CODE
350
- mutable std::size_t hash_code;
351
- #endif
370
+ #ifdef HASH_CODE
371
+ mutable std::size_t hash_code = 0 ;
372
+ #endif
352
373
353
374
void clear ()
354
375
{
@@ -370,21 +391,20 @@ class irept
370
391
#endif
371
392
}
372
393
373
- #ifdef SHARING
374
- dt ():ref_count(1 )
375
- #ifdef HASH_CODE
376
- , hash_code(0 )
377
- #endif
394
+ dt () = default ;
395
+
396
+ #ifdef USE_MOVE
397
+ explicit dt (irep_idt _data) : data(std::move(_data))
378
398
{
379
399
}
380
- # else
381
- dt ()
382
- # ifdef HASH_CODE
383
- :hash_code( 0 )
384
- # endif
400
+
401
+ dt (irep_idt _data, named_subt _named_sub, subt _sub )
402
+ : data(std::move(_data)),
403
+ named_sub(std::move(_named_sub)),
404
+ sub(std::move(_sub))
385
405
{
386
406
}
387
- #endif
407
+ #endif
388
408
};
389
409
390
410
protected:
0 commit comments