Description
Currently, wrappers are convertible to pointers to the wrapped type. An igRealVec
can be passed directly where an igraph_vector_t *
is expected. This is very convenient, but may have difficult to predict consequences. One particular pitfall that came up was the push_back()
member function of typed lists, which needs to behave differently when passed a wrapper of a raw igraph_vector_t *
.
Lines 86 to 101 in f2e02ba
This is because it must transfer ownership from the igVec
to the list, which is impossible once the igVec
was converted to an igraph_vector_t *
. This was solvable by also providing push_back(igVec &&)
, but it's easy to not notice this situation and make a mistake.
An alternative to implicit conversion is to overload the &
operator, so that instead of
igRealVec v;
igraph_vector_scale(v, 2);
we would need to write
igRealVec v;
igraph_vector_scale(&v, 2);
This is still very concise.