在初始化列表中为构造函数指定模板参数的语法是什么?请注意,构造函数是模板化的,而不是整个类。
例如:
class Member {
...
};
class SpecializedMember : public Member {
...
};
class C {
public:
template<class U> C() {
m_member = std::make_unique<U>();
}
Member& getMember() { return *m_member; }
private:
std::unique_ptr<Member> m_member;
};
class User {
public:
User() : m_c{} // Doesn't compile; How can the template class (e.g. SpecializedMember) be specified here?
{
// ...
}
private:
C m_c;
};