reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
// RUN: %clang_cc1 -std=c++11 %s -verify
// expected-no-diagnostics

// C++98 [class.copy]p10 / C++11 [class.copy]p18.

// The implicitly-declared copy assignment operator for a class X will have the form
//   X& X::operator=(const X&)
// if [every direct subobject] has a copy assignment operator whose first parameter is
// of type 'const volatile[opt] T &' or 'T'. Otherwise, it will have the form
//   X &X::operator=(X&)

struct ConstCopy {
  ConstCopy &operator=(const ConstCopy &);
};

struct NonConstCopy {
  NonConstCopy &operator=(NonConstCopy &);
};

struct DeletedConstCopy {
  DeletedConstCopy &operator=(const DeletedConstCopy &) = delete;
};

struct DeletedNonConstCopy {
  DeletedNonConstCopy &operator=(DeletedNonConstCopy &) = delete;
};

struct ImplicitlyDeletedConstCopy {
  ImplicitlyDeletedConstCopy &operator=(ImplicitlyDeletedConstCopy &&);
};

struct ByValueCopy {
  ByValueCopy &operator=(ByValueCopy);
};

struct AmbiguousConstCopy {
  AmbiguousConstCopy &operator=(const AmbiguousConstCopy&);
  AmbiguousConstCopy &operator=(AmbiguousConstCopy);
};


struct A : ConstCopy {};
struct B : NonConstCopy { ConstCopy a; };
struct C : ConstCopy { NonConstCopy a; };
struct D : DeletedConstCopy {};
struct E : DeletedNonConstCopy {};
struct F { ImplicitlyDeletedConstCopy a; };
struct G : virtual B {};
struct H : ByValueCopy {};
struct I : AmbiguousConstCopy {};

struct Test {
  friend A &A::operator=(const A &);
  friend B &B::operator=(B &);
  friend C &C::operator=(C &);
  friend D &D::operator=(const D &);
  friend E &E::operator=(E &);
  friend F &F::operator=(const F &);
  friend G &G::operator=(G &);
  friend H &H::operator=(const H &);
  friend I &I::operator=(const I &);
};