title: '<function-style-cast>': cannot convert from 'initializer list' to 'std::shared_ptr<SDL_Window>' on creating shared_ptr with custom deleter
body: <p>I created the wrapper functors for SDL2 library methods to return smart pointers with custom deleters. It seems to work fine for unqiue_ptr (class Image) but gives following error for classes returning shared_ptr (class Window) during build:</p>
  
  <p><code>'&lt;function-style-cast&gt;': cannot convert from 'initializer list' to 'std::shared_ptr&lt;SDL_Window&gt;'</code></p>
  
  <p>The <code>SDL_CreateWindow</code> here returns raw <code>SDL_Window*</code> and the <code>IMG_Load</code> returns raw <code>SDL_Surface*</code>. </p>
  
  <p>I have tried moving <code>Deleter</code> to public and removing copy restrictions of Window class, but still it fails with same error. Also, if I just return the <code>nullptr</code> from Window's function cast, it builds fine then. So the issue seems to be with the creation of the shared_ptr itself. What boggles me is why it works fine with <code>unique_ptr</code> but not <code>shared_ptr</code>.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#pragma once
  #include &lt;memory&gt;
  #include &lt;SDL.h&gt;
  #include "Uncopyable.h"
  
  // fails during build with error: '&lt;function-style-cast&gt;': 
  // cannot convert from 'initializer list' to 'std::shared_ptr&lt;SDL_Window&gt;'
  class Window:private Uncopyable {
  private:
  
  
  public:
      class Deleter {
          void operator()(SDL_Window *window) {
              SDL_DestroyWindow(window);
          }
      };
  
      static const int SCREEN_WIDTH = 800;
      static const int SCREEN_HEIGHT = 600;
      std::shared_ptr&lt;SDL_Window&gt; operator()() const {
          return std::shared_ptr&lt;SDL_Window&gt;(
              SDL_CreateWindow("SDL Tutorial",
                  SDL_WINDOWPOS_UNDEFINED,
                  SDL_WINDOWPOS_UNDEFINED,
                  SCREEN_WIDTH,
                  SCREEN_HEIGHT,
                  SDL_WINDOW_SHOWN),
              Deleter());
      }
  };
  
  #pragma once
  #include &lt;memory&gt;
  #include &lt;string&gt;
  #include &lt;SDL.h&gt;
  #include &lt;SDL_image.h&gt;
  #include "Uncopyable.h"
  
  // builds fine
  class Image: private Uncopyable {
  public:
      class Deleter{
          void operator()(SDL_Surface *image) {
              SDL_FreeSurface(image);
          }
      };
  
      std::unique_ptr&lt;SDL_Surface, Deleter&gt; operator()(const std::string &amp;path) const {
          return std::unique_ptr&lt;SDL_Surface, Deleter&gt;(
              IMG_Load(path.c_str()),
              Deleter());
      }
  };
  </code></pre>
  
  <p>Expected result: Window class should build without error like Image class</p>
  
  <p>Actual result: Window class fails with error given above whereas Image class builds fine</p>
  
  <p><strong>Update</strong>: Narrowing down further by moving the the shared_ptr creation logic to simple function, I found that removing the custom <code>Deleter()</code> removes build error. So it seems to be the culprit. But I need the Deleter and also, why same contruct works fine with Image using unique_ptr. </p>