I do not understand why this works fine:
std::array<double, 2> someArray = {0,1};
std::shared_ptr<MyClass> myobj = std::make_shared<MyClass>(someArray);
But this does not work:
std::shared_ptr<MyClass> myobj = std::make_shared<MyClass>({0,1});
Compiler says:
too many arguments to function ‘std::shared_ptr< _Tp> std::make_shared(_Args&& ...)
...
candidate expects 1 argument, 0 provided
Question: Can someone clarify why this happens and if there is any way I can fix the second approach without defining an extra variable?
Edit:
Example of MyClass:
#include <memory> //For std::shared_ptr
#include <array>
#include <iostream>
class MyClass{
public:
MyClass(std::array<double, 2> ){
std::cout << "hi" << std::endl;
};
};