10

If a type has its default member(s)s deleted, does it make a difference what the accessibility of the declaration is?

class FooA {
public:
  FooA() = delete;
  FooA(FooA const&) = delete;
  FooA& operator=(FooA const&) = delete;
}

class FooB {
private:
  FooB() = delete;
  FooB(FooB const&) = delete;
  FooB& operator=(FooB const&) = delete;
}

class FooC {
protected:
  FooC() = delete;
  FooC(FooC const&) = delete;
  FooC& operator=(FooC const&) = delete;
}
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742

2 Answers2

5

Though accessibility and deletedness are orthogonal, it's hard to see how there could be a practical difference in the case you propose.

Community
  • 1
  • 1
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
2

Might be artificial, but it does make a little difference

class FooA {
private:
  FooA& operator=(FooA const&) = delete;
};

class FooB : FooA {
  // ill-formed because FooB has no access
  using FooA::operator=;  
};

Whether it's a practical difference... I don't really know. If FooA is a template parameter and you say using T::BazBang, it might happen in practice.

Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212