With C++11, you can restrict the assignment operator to lvalue references like this:
struct Vector {
Vector(float a, float b, float c): x(a), y(b), z(c) {}
float x, y, z;
Vector& operator=(const Vector&) & = default;
};
Now you can drop the const from the return type:
template <>
Vector Field<Vector>::doSomething() const {
return Vector(1,2,3);
}
and your statement is still an error:
error: no match for ‘operator=’ (operand types are ‘Vector’ and ‘Vector’) h.doSomething() = Vector(3,4,5);