Closed thomthom closed 6 years ago
I'm changing the Visual Studio project to treat warnings as errors.
A const pointer would be ideal. This method is useful for passing the wrapper object directly to the C API functions. Mostly for [in] parameters.
Ref objects are so light-weight that I don't see any problem passing by value.
OK, lose the method altogether. Am happy to fix where it breaks.
C doesn't have const refs, so I don't think you could use it directly anyway. The copy by value would be used instead.
So here is a place where it brakes: Edge.cpp line 284.
Do you need to create a new vector<SUEdgeRef>
to pass to the API function, or what is the syntax to go from vector<Edge>
to SUEdgeRef *
?
std::vector<Edge> Entities::add_edges(std::vector<Edge>& edges) {
if (!SUIsValid(m_entities)) {
throw std::logic_error("CW::Entities::add_edges(): Entities is null");
}
SUResult res = SUEntitiesAddEdges(m_entities, edges.size(), edges[0]);
assert(res == SU_ERROR_NONE);
// Transfer ownership of each edge
for (auto& edge : edges)
edge.attached(true);
return edges;
}
Yea, looks like it needs a temporary vector with the SUEdgeRef
.
Even though Edge
have implicit operator to SUEdgeRef
, edges[0]
gives the address of the first Edge
in the vector. Do sure you can iterate that asSUEdgeRef
s. I'm assuming you are seeing some access violations?
(Side note, prefer vector.data()
over vector[0]
)
This is producing errors - and will not work. Either it should return a const ref of the internal member, or a Ref copy.