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
  • 481,675
  • 123
  • 870
  • 1,191
Drew Noakes
  • 284,599
  • 158
  • 653
  • 723

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
  • 369,052
  • 73
  • 620
  • 1,021
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
  • 481,675
  • 123
  • 870
  • 1,191