title: Why unique-ptr doesn't check base class to virtual destructible?
body: <p>Consider this example :</p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;memory&gt;
  
  struct base
  {
      base( int i ): i(i)    {    printf("base ctor\n"); }
      ~base() {     printf("base non-virtual dtor\n"); } // non-virtual
      int i;
  };
  
  struct derived : public base
  {
      char* s;
      derived(int i): base(i), s(new char[i] )
      {
          printf("derived ctor\n");
      }
      ~derived()
      {
          printf("derived dtor\n");
          delete [] s;
      }
  };
  
  int main()
  {
      printf("Success\n");
  
      //raw pointer
      printf("RAW-POINTER\n");
      {
          base* b = new derived(2);
           // ......
          delete b; //here memory leak, but it's old- and error-prone code.
      }
      printf("---END-RAW-POINTER--\n");
  
      //unique-ptr
      printf("UNIQUE_PTR\n");
      {
         // I would that, this doesn't compile, because base- has not virtual destructor.
          std::unique_ptr&lt;base&gt; bu( new derived(3) ); // here still memory leak !!!!
      }
      printf("--END-UNIQUE_PTR--\n");
  
  
      return 0;
  }
  </code></pre>
  
  <p>The code <code>std::unique_ptr&lt;base&gt; bu( new derived(3) );</code> easy prohibit with <a href="http://en.cppreference.com/w/cpp/types/has_virtual_destructor">std::has_virtual_destructor</a> type-traits.
  <a href="http://ideone.com/dnIcjo">Live code</a></p>
  
  <p><strong>So why does above code compiled? Is this allowed by standard ?</strong></p>
  
  <p>EDIT:  interesting, but with std::shared_ptr worked, i.e. both base and derived dtor will call:</p>
  
  <pre><code>    printf("SHARED_PTR\n");
      {
          std::shared_ptr&lt;base&gt; b(new derived(3));
      }
      printf("--END-SHARED_PTR--\n");
  
  Output:
  SHARED_PTR
  base ctor
  derived ctor
  derived dtor
  base non-virtual dtor
  --END-SHARED_PTR--
  </code></pre>
  
  <p><strong>Why std::shared_ptr can call dervied class dtor, but std::unique_ptr can't ???</strong></p>
  
  <p>EDIT2:  simple I need something like:</p>
  
  <pre><code>template&lt; typename T, typename D = default_deleter&lt;T&gt; &gt;
  class unique_ptr{
    .............
  
    template&lt; typename U &gt;
    unique_ptr( U* u ) if ( U != T &amp;&amp; T - is class &amp;&amp; T is base of U, and D - is default_deleter, and T - has not virtual destructor ) then = delete this ctor.
  
  };
  </code></pre>