falcong / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

xml_document copyable? #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Is it possible to get xml_document copyable by declaring 
the copy constructors public? 

Obviously, I'd require the xml_document object to be copied. 
I can't see any reason for prohibiting it, except that copying 
the datastructures hits performance badly. However, I'm aware of that, 
but still, I'd require this feature. 

Sorry, if I'm missing something ..

Thanks for your hard work, 

cheers, Josef

Original issue reported on code.google.com by wein...@gmail.com on 26 Aug 2010 at 9:53

GoogleCodeExporter commented 9 years ago
There are two possible problems:
- performance, as you mentioned
- accidental copies can make the code behave incorrectly - xml_document is 
different in semantics from xml_node, so making a function that accepts 
xml_document by value is probably incorrect.

Still, I do not see any problems with explicit copy constructor; I'll add this 
to my task list.

Original comment by arseny.k...@gmail.com on 30 Aug 2010 at 3:44

GoogleCodeExporter commented 9 years ago
excellent! Thank you again ;-)

Original comment by wein...@gmail.com on 30 Aug 2010 at 3:50

GoogleCodeExporter commented 9 years ago
There were some problems with explicit copy-constructors - the difference 
between explicit and implicit is hidden in a lot of generic code, so the intent 
to make the dangerous and slow operation explicit can not be fulfilled.

For that reason, there is a special function, xml_document::reset(), that can 
be used with one argument; the equivalent for

xml_document doc(otherdoc);

would be

xml_document doc;
doc.reset(otherdoc);

This is implemented in pugixml-1.0.

Original comment by arseny.k...@gmail.com on 31 Oct 2010 at 6:26