C++: Add sanity checks in StructureWrapper.