I know that vectors are guaranteed to have the same underlying memory layout as arrays. So for POD (plain-old-data) type like int, vector<int> a can be used as SomeCFun(&a[0], a.size()) when a is non-empty. I’d like to know that when the element type is (complex) Class type, does the trick still work safely?
I know that vectors are guaranteed to have the same underlying memory layout as
Share
Yes, it’ll work. An alternative is
SomeCFun(a.data(), a.size())– but whatever you prefer.