@@ -28,6 +28,13 @@ template <class T>
2828class auto_ptr {
2929};
3030
31+ namespace pmr {
32+ template <typename TYPE = void >
33+ class allocator {};
34+ }
35+
36+ struct allocator_arg_t {} allocator_arg;
37+
3138} // namespace std
3239
3340void assert (int expression){};
@@ -540,6 +547,89 @@ class NotACopyAssignmentOperator {
540547 Uy *getUy () const { return Ptr2; }
541548};
542549
550+ // Support "extended" copy/move constructors
551+ class AllocatorAwareClass {
552+ // pointer member to trigger bugprone-unhandled-self-assignment
553+ void *foo = nullptr ;
554+
555+ public:
556+ using allocator_type = std::pmr::allocator<>;
557+
558+ AllocatorAwareClass (const AllocatorAwareClass& other) {
559+ }
560+
561+ AllocatorAwareClass (const AllocatorAwareClass& other, const allocator_type& alloc) {
562+ }
563+
564+ AllocatorAwareClass& operator =(const AllocatorAwareClass& other) {
565+ AllocatorAwareClass tmp (other, get_allocator ());
566+ swap (tmp);
567+ return *this ;
568+ }
569+
570+ void swap (AllocatorAwareClass& other) noexcept {
571+ }
572+
573+ allocator_type get_allocator () const {
574+ return allocator_type ();
575+ }
576+ };
577+
578+ // Support "extended" copy/move constructors + std::swap
579+ class AllocatorAwareClassStdSwap {
580+ // pointer member to trigger bugprone-unhandled-self-assignment
581+ void *foo = nullptr ;
582+
583+ public:
584+ using allocator_type = std::pmr::allocator<>;
585+
586+ AllocatorAwareClassStdSwap (const AllocatorAwareClassStdSwap& other) {
587+ }
588+
589+ AllocatorAwareClassStdSwap (const AllocatorAwareClassStdSwap& other, const allocator_type& alloc) {
590+ }
591+
592+ AllocatorAwareClassStdSwap& operator =(const AllocatorAwareClassStdSwap& other) {
593+ using std::swap;
594+
595+ AllocatorAwareClassStdSwap tmp (other, get_allocator ());
596+ swap (*this , tmp);
597+ return *this ;
598+ }
599+
600+ allocator_type get_allocator () const {
601+ return allocator_type ();
602+ }
603+ };
604+
605+ // Support "extended" copy/move constructors + ADL swap
606+ class AllocatorAwareClassAdlSwap {
607+ // pointer member to trigger bugprone-unhandled-self-assignment
608+ void *foo = nullptr ;
609+
610+ public:
611+ using allocator_type = std::pmr::allocator<>;
612+
613+ AllocatorAwareClassAdlSwap (const AllocatorAwareClassAdlSwap& other) {
614+ }
615+
616+ AllocatorAwareClassAdlSwap (const AllocatorAwareClassAdlSwap& other, const allocator_type& alloc) {
617+ }
618+
619+ AllocatorAwareClassAdlSwap& operator =(const AllocatorAwareClassAdlSwap& other) {
620+ AllocatorAwareClassAdlSwap tmp (other, get_allocator ());
621+ swap (*this , tmp);
622+ return *this ;
623+ }
624+
625+ allocator_type get_allocator () const {
626+ return allocator_type ();
627+ }
628+
629+ friend void swap (AllocatorAwareClassAdlSwap&, AllocatorAwareClassAdlSwap&) {
630+ }
631+ };
632+
543633// /////////////////////////////////////////////////////////////////
544634// / Test cases which should be caught by the check.
545635
0 commit comments