You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 *.
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.
The text was updated successfully, but these errors were encountered:
Currently, wrappers are convertible to pointers to the wrapped type. An
igRealVec
can be passed directly where anigraph_vector_t *
is expected. This is very convenient, but may have difficult to predict consequences. One particular pitfall that came up was thepush_back()
member function of typed lists, which needs to behave differently when passed a wrapper of a rawigraph_vector_t *
.igraph-cpp/typed_list_pmt.hpp
Lines 86 to 101 in f2e02ba
This is because it must transfer ownership from the
igVec
to the list, which is impossible once theigVec
was converted to anigraph_vector_t *
. This was solvable by also providingpush_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 ofwe would need to write
This is still very concise.
The text was updated successfully, but these errors were encountered: