У меня есть структура шаблона с конструктором шаблона:
template
struct Vector2
{
template
Vector2(const Vector2& vector);
};
Реализация:
template
template
Vector2::Vector2(const Vector2& vector)
: Vector2(vector.x, vector.y)
{}
Можно ли создать экземпляр этого конструктора для типов float и double в типах Vector2 и Vector2?
Я пробовал:
template struct Vector2::Vector2(const Vector2& vector);
// Errors: "Expected unqualified-id" and "Expected ')'"
template struct Vector2::Vector2(const Vector2& vector);
// Errors: same as in the previous one
template struct Vector2::Vector2(const Vector2& vector);
// Error: "Use of class template 'Vector2' requires template arguments"
template Vector2::Vector2(const Vector2& vector);
// Error: "Explicit instantiation refers to member function 'Vector2::Vector2' that is not an instantiation"
Подробнее здесь: https://stackoverflow.com/questions/781 ... truct-in-c