File: surfacefilter.h

package info (click to toggle)
regina-normal 7.4.1-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 154,244 kB
  • sloc: cpp: 295,026; xml: 9,992; sh: 1,344; python: 1,225; perl: 616; ansic: 138; makefile: 26
file content (667 lines) | stat: -rw-r--r-- 25,279 bytes parent folder | download
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667

/**************************************************************************
 *                                                                        *
 *  Regina - A Normal Surface Theory Calculator                           *
 *  Computational Engine                                                  *
 *                                                                        *
 *  Copyright (c) 1999-2025, Ben Burton                                   *
 *  For further details contact Ben Burton (bab@debian.org).              *
 *                                                                        *
 *  This program is free software; you can redistribute it and/or         *
 *  modify it under the terms of the GNU General Public License as        *
 *  published by the Free Software Foundation; either version 2 of the    *
 *  License, or (at your option) any later version.                       *
 *                                                                        *
 *  As an exception, when this program is distributed through (i) the     *
 *  App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or     *
 *  (iii) Google Play by Google Inc., then that store may impose any      *
 *  digital rights management, device limits and/or redistribution        *
 *  restrictions that are required by its terms of service.               *
 *                                                                        *
 *  This program 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     *
 *  General Public License for more details.                              *
 *                                                                        *
 *  You should have received a copy of the GNU General Public License     *
 *  along with this program. If not, see <https://www.gnu.org/licenses/>. *
 *                                                                        *
 **************************************************************************/

/*! \file surface/surfacefilter.h
 *  \brief Contains a packet that filters through normal surfaces.
 */

#ifndef __REGINA_SURFACEFILTER_H
#ifndef __DOXYGEN
#define __REGINA_SURFACEFILTER_H
#endif

#include <set>
#include "regina-core.h"
#include "maths/integer.h"
#include "packet/packet.h"
#include "surface/surfacefiltertype.h"
#include "utilities/boolset.h"

namespace regina {

class NormalSurface;
class SurfaceFilter;
class SurfaceFilterCombination;
class SurfaceFilterProperties;

/**
 * Defines various constants, types and virtual functions for a
 * descendant class of SurfaceFilter.
 *
 * Every descendant class of SurfaceFilter \a must include
 * REGINA_SURFACE_FILTER at the beginning of the class definition.
 *
 * This macro provides the class with:
 *
 * - a compile-time constant \a filterTypeID, which is equal to the
 *   corresponding SurfaceFilterType constant;
 * - declarations and implementations of the virtual functions
 *   SurfaceFilter::filterType() and SurfaceFilter::filterTypeName();
 *
 * \param id the corresponding SurfaceFilterType constant.
 * \param name a human-readable name for this filter type.
 *
 * \ingroup surface
 */
#define REGINA_SURFACE_FILTER(id, name) \
    public: \
        static constexpr const SurfaceFilterType filterTypeID = id; \
        inline SurfaceFilterType filterType() const override { \
            return id; \
        } \
        inline std::string filterTypeName() const override { \
            return name; \
        }

/**
 * A packet that accepts or rejects normal surfaces.
 * Different subclasses of SurfaceFilter represent different filtering
 * methods.
 *
 * When deriving classes from SurfaceFilter:
 *
 * - Add a new filter constant to the SurfaceFilterType enum;
 *
 * - Create a new subclass \a C of SurfaceFilter, which begins with the
 *   REGINA_SURFACE_FILTER macro;
 *
 * - Perform all tasks required for this new innate packet type \a C, as
 *   outlined in the Packet class documentation;
 *
 * - Override the virtual function writeTextShort(), as well as all pure virtual
 *   functions from both the Packet and SurfaceFilter base classes (except
 *   for those already provided by REGINA_PACKET and REGINA_SURFACE_FILTER).
 *
 * Like all packet types, Regina's filter types do not support C++ move
 * semantics, since this would interfere with the structure of the packet tree.
 * They do support copy construction, copy assignment and swaps, but only in
 * the derived filter classes (e.g., you cannot assign from the polymorphic
 * base class SurfaceFilter).  Moreover, these operations only copy/swap the
 * filter content, not the packet infrastructure (e.g., they do not touch
 * packet labels, or the packet tree, or event listeners).
 *
 * \ingroup surface
 */
class SurfaceFilter : public Packet {
    REGINA_PACKET(PacketType::SurfaceFilter, "Surface filter")

    public:
        /**
         * Decides whether or not the given normal surface is accepted by this
         * filter.
         *
         * The default implementation simply returns \c true.
         *
         * \param surface the normal surface under investigation.
         * \return \c true if and only if the given surface is accepted
         * by this filter.
         */
        virtual bool accept(const NormalSurface& surface) const = 0;

        /**
         * Returns the unique integer ID corresponding to the filtering
         * method that is this particular subclass of SurfaceFilter.
         *
         * \return the unique integer filtering method ID.
         */
        virtual SurfaceFilterType filterType() const = 0;
        /**
         * Returns a string description of the filtering method that is
         * this particular subclass of SurfaceFilter.
         *
         * \return a string description of this filtering method.
         */
        virtual std::string filterTypeName() const = 0;

    protected:
        /**
         * Default constructor.
         */
        SurfaceFilter() = default;
        /**
         * Copy constructor that does not actually copy anything.
         *
         * This is provided so that derived classes can use it implicitly
         * in their own copy constructors.
         */
        SurfaceFilter(const SurfaceFilter&) = default;
};

/**
 * A normal surface filter that simply combines other filters.
 * This filter will combine, using boolean \a and or \a or, all of the
 * filters that are immediate children of this packet.  This packet may
 * have children that are not normal surface filters; such children will
 * simply be ignored.
 *
 * If there are no immediate child filters, a normal surface will be
 * accepted if this is an \a and filter and rejected if this is an \a or
 * filter.
 *
 * Like all packet types, this class does not support C++ move semantics
 * since this would interfere with the structure of the packet tree.
 * It does support copy construction, copy assignment and swaps; however,
 * these operations only copy/swap the mathematical content, not the packet
 * infrastructure (e.g., they do not touch packet labels, or the packet
 * tree, or event listeners).
 *
 * \ingroup surface
 */
class SurfaceFilterCombination : public SurfaceFilter {
    REGINA_SURFACE_FILTER(SurfaceFilterType::Combination, "Combination filter")

    private:
        bool usesAnd_;
            /**< \c true if children are combined using boolean \a and, or
                 \c false if children are combined using boolean \a or. */

    public:
        /**
         * Creates a new surface filter that accepts all normal surfaces.
         * This will be an \a and filter.
         */
        SurfaceFilterCombination();

        /**
         * Creates a new copy of the given filter.
         *
         * Like all packet types, this only copies the filter content, not
         * the packet infrastructure (e.g., it will not copy the packet label,
         * it will not clone the given packet's children, and it will not
         * insert the new packet into any packet tree).
         */
        SurfaceFilterCombination(const SurfaceFilterCombination&) = default;

        /**
         * Sets this to be a copy of the given filter.
         *
         * Like all packet types, this only copies the filter content, not
         * the packet infrastructure (e.g., it will not copy the packet label,
         * or change this packet's location in any packet tree).
         *
         * \param src the filter whose contents should be copied.
         * \return a reference to this filter.
         */
        SurfaceFilterCombination& operator = (
            const SurfaceFilterCombination& src);

        /**
         * Swaps the contents of this and the given filter.
         *
         * Like all packet types, this only swaps the filter content, not
         * the packet infrastructure (e.g., it will not swap packet labels,
         * or change either packet's location in any packet tree).
         *
         * \param other the filter whose contents should be swapped with this.
         */
        void swap(SurfaceFilterCombination& other);

        /**
         * Determines whether this is an \a and or an \a or combination.
         *
         * \return \c true if this is an \a and combination, or \c false
         * if this is an \a or combination.
         */
        bool usesAnd() const;
        /**
         * Sets whether this is an \a and or an \a or combination.
         *
         * \param value \c true if this is to be an \a and combination,
         * or \c false if this is to be an \a or combination.
         */
        void setUsesAnd(bool value);

        /**
         * Determines if this and the given filter use the same boolean
         * operation.
         *
         * \param other the filter to compare with this.
         * \return \c true if and only if this and the given filter
         * use the same boolean operation.
         */
        bool operator == (const SurfaceFilterCombination& other) const;

        bool accept(const NormalSurface& surface) const override;
        void writeTextShort(std::ostream& o) const override;

    protected:
        std::shared_ptr<Packet> internalClonePacket() const override;
        void writeXMLPacketData(std::ostream& out, FileFormat format,
            bool anon, PacketRefs& refs) const override;
};

/**
 * Swaps the contents of the given combination filters.
 *
 * This global routine simply calls SurfaceFilterCombination::swap(); it is
 * provided so that SurfaceFilterCombination meets the C++ Swappable
 * requirements.
 *
 * \param a the first filter whose contents should be swapped.
 * \param b the second filter whose contents should be swapped.
 *
 * \ingroup surface
 */
void swap(SurfaceFilterCombination& a, SurfaceFilterCombination& b);

/**
 * A normal surface filter that filters by basic properties of the normal
 * surface.
 *
 * If a property of the surface (such as Euler characteristic or
 * orientability) cannot be determined, the surface will pass any test
 * based on that particular property.  For instance, say a surface is
 * required to be both orientable and compact, and say that orientability
 * cannot be determined.  Then the surface will be accepted solely on the
 * basis of whether or not it is compact.
 *
 * Like all packet types, this class does not support C++ move semantics
 * since this would interfere with the structure of the packet tree.
 * It does support copy construction, copy assignment and swaps; however,
 * these operations only copy/swap the mathematical content, not the packet
 * infrastructure (e.g., they do not touch packet labels, or the packet
 * tree, or event listeners).
 *
 * \ingroup surface
 */
class SurfaceFilterProperties : public SurfaceFilter {
    REGINA_SURFACE_FILTER(SurfaceFilterType::Properties, "Filter by basic properties")

    private:
        std::set<LargeInteger> eulerChar_;
            /**< The set of allowable Euler characteristics.  An empty
                 set signifies that any Euler characteristic is allowed. */
        BoolSet orientability_;
            /**< The set of allowable orientability properties. */
        BoolSet compactness_;
            /**< The set of allowable compactness properties. */
        BoolSet realBoundary_;
            /**< The set of allowable has-real-boundary properties. */

    public:
        /**
         * Creates a new surface filter that accepts all normal surfaces.
         */
        SurfaceFilterProperties();

        /**
         * Creates a new copy of the given filter.
         *
         * Like all packet types, this only copies the filter content, not
         * the packet infrastructure (e.g., it will not copy the packet label,
         * it will not clone the given packet's children, and it will not
         * insert the new packet into any packet tree).
         */
        SurfaceFilterProperties(const SurfaceFilterProperties&) = default;

        /**
         * Sets this to be a copy of the given filter.
         *
         * Like all packet types, this only copies the filter content, not
         * the packet infrastructure (e.g., it will not copy the packet label,
         * or change this packet's location in any packet tree).
         *
         * \param src the filter whose contents should be copied.
         * \return a reference to this filter.
         */
        SurfaceFilterProperties& operator = (
            const SurfaceFilterProperties& src);

        /**
         * Swaps the contents of this and the given filter.
         *
         * Like all packet types, this only swaps the filter content, not
         * the packet infrastructure (e.g., it will not swap packet labels,
         * or change either packet's location in any packet tree).
         *
         * \param other the filter whose contents should be swapped with this.
         */
        void swap(SurfaceFilterProperties& other);

        /**
         * Returns the set of allowable Euler characteristics.  Any
         * surface whose Euler characteristic is not in this set will not
         * be accepted by this filter.  The set will be given in
         * ascending order with no element repeated.
         *
         * If this set is empty, all Euler characteristics will be
         * accepted.
         *
         * \return the set of allowable Euler characteristics.
         */
        const std::set<LargeInteger>& eulerChars() const;
        /**
         * Returns the number of allowable Euler characteristics.
         * See eulerChars() for further details.
         *
         * \return the number of allowable Euler characteristics.
         */
        size_t countEulerChars() const;
        /**
         * Returns the allowable Euler characteristic at the given index
         * in the set.  See eulerChars() for further details.
         *
         * \param index the index in the set of allowable Euler
         * characteristics; this must be between 0 and countEulerChars()-1
         * inclusive.
         * \return the requested allowable Euler characteristic.
         */
        LargeInteger eulerChar(size_t index) const;
        /**
         * Returns the set of allowable orientabilities.  Note that this
         * is a subset of `{ true, false }`.
         * Any surface whose orientability is not in this set will not be
         * accepted by this filter.
         *
         * \return the set of allowable orientabilities.
         */
        BoolSet orientability() const;
        /**
         * Returns the set of allowable compactness properties.
         * Note that this is a subset of `{ true, false }`.
         * Any surface whose compactness property is not in this set will
         * not be accepted by this filter.
         *
         * \return the set of allowable compactness properties.
         */
        BoolSet compactness() const;
        /**
         * Returns the set of allowable has-real-boundary properties.
         * Note that this is a subset of `{ true, false }`.
         * Any surface whose has-real-boundary property is not in this set
         * will not be accepted by this filter.
         *
         * \return the set of allowable has-real-boundary properties.
         */
        BoolSet realBoundary() const;

        /**
         * Sets the allowable Euler characteristics to be all integers
         * in the given iterator range.  See eulerChars() for further details.
         *
         * \python Instead of a pair of iterators, the set of
         * allowable Euler characteristic should be passed as a Python list.
         *
         * \tparam Iterator an iterator type that, when dereferenced,
         * can be assigned to a LargeInteger.
         *
         * \param beginEuler the beginning of an iterator range that
         * gives the new set of allowable Euler characteristics.
         * \param endEuler the end of an iterator range (i.e., an iterator
         * past the end of the list) that gives the new set of allowable
         * Euler characteristics.
         */
        template <typename Iterator>
        void setEulerChars(Iterator beginEuler, Iterator endEuler);

        /**
         * Adds the given Euler characteristic to the set of allowable
         * Euler characteristics.  See eulerChars() for further details.
         *
         * \param ec the new allowable Euler characteristic.
         */
        void addEulerChar(const LargeInteger& ec);
        /**
         * Removes the given Euler characteristic from the set of allowable
         * Euler characteristics.  See eulerChars() for further details.
         *
         * Note that if the allowable set is completely emptied, this
         * filter will allow <i>any</i> Euler characteristic to pass.
         *
         * \pre The given Euler characteristic is currently in the
         * allowable set.
         *
         * \param ec the allowable Euler characteristic to remove.
         */
        void removeEulerChar(const LargeInteger& ec);
        /**
         * Empties the set of allowable Euler characteristics.  See
         * eulerChars() for further details.
         *
         * Note that this will mean that this filter will allow
         * <i>any</i> Euler characteristic to pass.
         */
        void removeAllEulerChars();
        /**
         * Sets the set of allowable orientabilities.
         * See orientability() for further details.
         *
         * \param value the new set of allowable orientabilities.
         */
        void setOrientability(BoolSet value);
        /**
         * Sets the set of allowable compactness properties.
         * See compactness() for further details.
         *
         * \param value the new set of allowable compactness properties.
         */
        void setCompactness(BoolSet value);
        /**
         * Sets the set of allowable has-real-boundary properties.
         * See realBoundary() for further details.
         *
         * \param value the new set of allowable has-real-boundary
         * properties.
         */
        void setRealBoundary(BoolSet value);

        /**
         * Determines if this and the given filter are configured to
         * filter on the same set of constraints.
         *
         * Even if both filters are designed to reject _every_ surface
         * by having an empty BoolSet for one of the boolean conditions,
         * they will still not compare as equal unless they use an empty
         * BoolSet for the _same_ boolean condition(s).  In other words,
         * this test compares the precise configurations of the filters,
         * not their deduced behaviour.
         *
         * \param other the filter to compare with this.
         * \return \c true if and only if this and the given filters are
         * identical.
         */
        bool operator == (const SurfaceFilterProperties& other) const;

        bool accept(const NormalSurface& surface) const override;
        void writeTextShort(std::ostream& o) const override;

    protected:
        std::shared_ptr<Packet> internalClonePacket() const override;
        void writeXMLPacketData(std::ostream& out, FileFormat format,
            bool anon, PacketRefs& refs) const override;
};

/**
 * Swaps the contents of the given property-based filters.
 *
 * This global routine simply calls SurfaceFilterProperties::swap(); it is
 * provided so that SurfaceFilterProperties meets the C++ Swappable
 * requirements.
 *
 * \param a the first filter whose contents should be swapped.
 * \param b the second filter whose contents should be swapped.
 *
 * \ingroup surface
 */
void swap(SurfaceFilterProperties& a, SurfaceFilterProperties& b);

// Inline functions for SurfaceFilterCombination

inline SurfaceFilterCombination::SurfaceFilterCombination() : usesAnd_(true) {
}

inline SurfaceFilterCombination& SurfaceFilterCombination::operator = (
        const SurfaceFilterCombination& src) {
    PacketChangeSpan span(*this);
    usesAnd_ = src.usesAnd_;
    return *this;
}

inline void SurfaceFilterCombination::swap(SurfaceFilterCombination& other) {
    PacketChangeSpan span1(*this);
    PacketChangeSpan span2(other);
    std::swap(usesAnd_, other.usesAnd_);
}

inline bool SurfaceFilterCombination::usesAnd() const {
    return usesAnd_;
}
inline void SurfaceFilterCombination::setUsesAnd(bool value) {
    if (usesAnd_ != value) {
        PacketChangeSpan span(*this);
        usesAnd_ = value;
    }
}

inline bool SurfaceFilterCombination::operator == (
        const SurfaceFilterCombination& other) const {
    return usesAnd_ == other.usesAnd_;
}

inline void SurfaceFilterCombination::writeTextShort(std::ostream& o) const {
    o << (usesAnd_ ? "AND" : "OR") << " filter";
}

inline std::shared_ptr<Packet> SurfaceFilterCombination::internalClonePacket()
        const {
    return std::make_shared<SurfaceFilterCombination>(*this);
}

inline void swap(SurfaceFilterCombination& a, SurfaceFilterCombination& b) {
    a.swap(b);
}

// Inline functions for SurfaceFilterProperties

inline SurfaceFilterProperties::SurfaceFilterProperties() :
        orientability_(true, true),
        compactness_(true, true),
        realBoundary_(true, true) {
}

inline SurfaceFilterProperties& SurfaceFilterProperties::operator = (
        const SurfaceFilterProperties& src) {
    PacketChangeSpan span(*this);

    eulerChar_ = src.eulerChar_;
    orientability_ = src.orientability_;
    compactness_ = src.compactness_;
    realBoundary_ = src.realBoundary_;

    return *this;
}

inline void SurfaceFilterProperties::swap(SurfaceFilterProperties& other) {
    PacketChangeSpan span1(*this);
    PacketChangeSpan span2(other);

    eulerChar_.swap(other.eulerChar_);
    std::swap(orientability_, other.orientability_);
    std::swap(compactness_, other.compactness_);
    std::swap(realBoundary_, other.realBoundary_);
}

inline const std::set<LargeInteger>& SurfaceFilterProperties::eulerChars()
        const {
    return eulerChar_;
}
inline size_t SurfaceFilterProperties::countEulerChars() const {
    return eulerChar_.size();
}
inline BoolSet SurfaceFilterProperties::orientability() const {
    return orientability_;
}
inline BoolSet SurfaceFilterProperties::compactness() const {
    return compactness_;
}
inline BoolSet SurfaceFilterProperties::realBoundary() const {
    return realBoundary_;
}

template <typename Iterator>
inline void SurfaceFilterProperties::setEulerChars(
        Iterator beginEuler, Iterator endEuler) {
    PacketChangeSpan span(*this);
    eulerChar_.clear();
    eulerChar_.insert(beginEuler, endEuler);
}

inline void SurfaceFilterProperties::addEulerChar(const LargeInteger& ec) {
    PacketChangeSpan span(*this);
    eulerChar_.insert(ec);
}
inline void SurfaceFilterProperties::removeEulerChar(const LargeInteger& ec) {
    PacketChangeSpan span(*this);
    eulerChar_.erase(ec);
}
inline void SurfaceFilterProperties::removeAllEulerChars() {
    PacketChangeSpan span(*this);
    eulerChar_.clear();
}
inline void SurfaceFilterProperties::setOrientability(BoolSet value) {
    if (orientability_ != value) {
        PacketChangeSpan span(*this);
        orientability_ = value;
    }
}
inline void SurfaceFilterProperties::setCompactness(BoolSet value) {
    if (compactness_ != value) {
        PacketChangeSpan span(*this);
        compactness_ = value;
    }
}
inline void SurfaceFilterProperties::setRealBoundary(BoolSet value) {
    if (realBoundary_ != value) {
        PacketChangeSpan span(*this);
        realBoundary_ = value;
    }
}

inline bool SurfaceFilterProperties::operator == (
        const SurfaceFilterProperties& other) const {
    return orientability_ == other.orientability_ &&
        compactness_ == other.compactness_ &&
        realBoundary_ == other.realBoundary_ &&
        eulerChar_ == other.eulerChar_;
}

inline std::shared_ptr<Packet> SurfaceFilterProperties::internalClonePacket()
        const {
    return std::make_shared<SurfaceFilterProperties>(*this);
}

inline void swap(SurfaceFilterProperties& a, SurfaceFilterProperties& b) {
    a.swap(b);
}

} // namespace regina

#endif