title: Should we declare the desctructor of a Singleton class as private?
body: <p>Providing the simple implementation of a Singleton class below. It is possible for anybody to call the destructor as long as s/he has the reference to the <code>singleInstance</code>.</p>
  <pre><code>class SomeClass {
  public: /** Singleton **/
      static SomeClass &amp;instance() {
          static SomeClass singleInstance;
  
          return singleInstance;
      };
  
  private: 
      SomeClass() = default;
      SomeClass(const SomeClass&amp;) = delete;
      SomeClass &amp;operator=(const SomeClass&amp;) = delete;
  };
  </code></pre>
  <p>To prevent such a nonsense operation, should we declare the destructor of Singleton classes in a private context?</p>
  <pre><code>class SomeClass {
      // ... same above
  private: 
      ~SomeClass() {}
  };
  </code></pre>
  <p>The problem exists also for the heap-allocated Singleton instances. Consider the implementation below.</p>
  <pre><code>class SomeClass {
  public: /** Singleton **/
      static SomeClass &amp;instance() {
          static SomeClass *singleInstance = nullptr;
  
          if(!singleInstance) {
              singleInstance = new SomeClass;
          }
  
          return *singleInstance;
      };
  
  private: 
      SomeClass() = default;
      SomeClass(const SomeClass&amp;) = delete;
      SomeClass &amp;operator=(const SomeClass&amp;) = delete;
  
      // ~SomeClass() {}
  };
  
  int main() 
  {
      SomeClass *const ptr = &amp;SomeClass::instance();
  
      delete ptr; // Compiles if destructor isn't private and vice versa
  
      return 0;
  }
  </code></pre>