[xsd-users] template<typename C> type_(const C*) constructor creates unexpected empty copies of any pointer

Boris Kolpackov boris at codesynthesis.com
Mon Sep 22 01:42:34 EDT 2014


Hi Oliver,

Oliver Schneider <xsd-users at oli-obk.de> writes:

> for (auto id : myref()) {
> 	id->dostuff();
> }
> 
> correct would be
> 
> for (auto& id : myref()) {
> 	id->dostuff();
> }
> 
> as the former copies the object, the object has no reference to the root
> of the structure, and can therefor not find the item it points to.
> I'm actually not sure which constructor is invoked, even if the copy
> constructor is disabled this copying still happens. Maybe the element is
> cast to string and then the string constructor is invoked?

idref has a copy constructor and that's exactly what's called in this
case. I guess the only solution I can think of is it pay attention ;-).

Boris



More information about the xsd-users mailing list