We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This code compiles:
cdef extern from "vectors.hpp": cdef cppclass Vector[T]: Vector() Vector[T] operator-(T other) Vector[U] cast[U]() def test(): Vector[float]() - <float>1.0 # always works Vector[int]().cast[float]() - <float>1.0 # works
But if you just swap two lines declaring operator- and cast:
operator-
cast
cdef extern from "vectors.hpp": cdef cppclass Vector[T]: Vector() Vector[U] cast[U]() Vector[T] operator-(T other) def test(): Vector[float]() - <float>1.0 # always works Vector[int]().cast[float]() - <float>1.0 # error
It throws an error: Invalid operand types for '-' (Vector[float]; float)
Invalid operand types for '-' (Vector[float]; float)
In the second expression cython internally uses Vector[float] type which is different from Vector[float] type in the first expression
Vector[float]
No response
Order of declaration should not matter (it does not matter for equivalent C++ code):
template <typename T> class Vector { public: template <typename U> Vector<U> cast() { return Vector<U>(); } Vector operator-(T other) { return Vector(); } }; void test() { Vector<int>().cast<float>() - 1.0f; }
3.10.5
3.0.10
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
This code compiles:
But if you just swap two lines declaring
operator-
andcast
:It throws an error:
Invalid operand types for '-' (Vector[float]; float)
In the second expression cython internally uses
Vector[float]
type which is different fromVector[float]
type in the first expressionCode to reproduce the behaviour:
No response
Expected behaviour
Order of declaration should not matter (it does not matter for equivalent C++ code):
OS
No response
Python version
3.10.5
Cython version
3.0.10
Additional context
No response
The text was updated successfully, but these errors were encountered: