-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Many (implicit) operators are not aware of different contexts.
In the following code, both additions fail with an assertion, as in both cases an implicit constructor of Polynomial with the default context is used.
Context ctx;
Polynomial p(ctx);
p = p + 1;
p = p + Integer(1);In both cases, it should rather call a constructor that uses the context of p.
The same is true for many other operators like - and * as well.
Furthermore, the constructor Integer(int i) is marked explicit, while there is a constructor Polynomial(int i) that is called implicitly instead using (again, using the default context).
A possible fix adds explicit operators for Polynomial with Integer such that the Integer object is correctly converted to a Polynomial (using the other polynomial's context).
Furthermore, removing Polynomial(long i) and Polynomial(int i) constructors and allow implicit generation of Integer instead of Polynomial in this cases fixes cases when a C++ integer is used.