Constexpr alias of overloaded template function

Viewed 442

Trying to alias make_shared on a specific class type for a specific constructor of that class. My best attempt:

class foo { public: foo(int x) : y(x) {} int y; };
constexpr auto newfoo = static_cast<std::shared_ptr<foo>(*)(int)>(std::make_shared<foo>);

Yields:

error: invalid static_cast from type ‘<unresolved overloaded function type>’ to type ‘std::shared_ptr<foo> (*)(int)’
constexpr auto newfoo = static_cast<std::shared_ptr<foo>(*)(int)>(std::make_shared<foo>);

What am I doing wrong?

1 Answers
Related