I am struggling to understand why make_unique<T>
does not accept a Brace-enclosed initializer list, when the constructor of T
works fine with them.
I am using SFML and creating an instance of RenderWindow
. RenderWindow
takes a VideoMode
instance as its first parameter. The constructor for VideoMode
takes 3 arguments (the last one optional) and I was successfully able to pass a braced-initializer in its place:
sf::RenderWindow window({w_width, w_height}, title);
I later tried to create a unique_ptr
using make_unique
. The standard says that the arguments to make_unique
are forwarded to the constructor of the template parameter so I thought the following should work:
auto window = std::make_unique<RenderWindow>({w_width, w_height}, title);
But unfortunately, I get the following compiler error using GCC 5.1.1.
error: no matching function for call to ‘make_unique(<brace-enclosed initializer list>, const char* const&)’
auto window_ptr = std::make_unique<sf::RenderWindow>({w_width, w_height}, title);
I guess I've miss-understood the subtleties make_unique, but I couldn't find a clear answer as why the make_unique code above doesn't work.
Please can someone shed some light on this for me?
Cheers