Comments (7)
The XMLDocument uses a significant amount of memory, and if it is copied, that means a deep copy of all that memory. In the likely case the compiler needs a temporary, then that memory gets copied twice. The copy and assignment operators are private for the reason that you almost certainly don't intend to move that much memory around.
If the cases you do, there is an open issue for "deep copy", but that's not in the code yet.
For now you need allocate the XMLDocument on the heap and return a pointer.
from tinyxml2.
from XMLDocument class definition, u can see that its copy constructor is private, but it needs copy constructor when returning XMLDocument, this is why u get an error.
from tinyxml2.
so the only way to pass the document around is via pointer/reference? is there any reason for it to not have a copy/move constructor? I'm just not sure I understand the logic here. Thanks so much for the info!
from tinyxml2.
"
XMLDocument( const XMLDocument& ); // not supported
void operator=( const XMLDocument& ); // not supported
"
above is from XMLDocument class definition, i do not know why. but it is intentionally not supported.
besides, consider not pass the document around if possible
from tinyxml2.
Thanks for closing this. What about having a move constructor compiled in if the compiler supports it? I can work on this, but I would rather not work on it and then it to be for nothing. I could just redesign my code. I see what you mean now though. I didn't think about the fact that it was all getting loaded into memory and then copying all of that memory. I probably need to redesign that code anyways, it's about 4 years old now and haven't we all learned a lot since then lol. Thanks for the response and explanation! Let me know if you want me make the move constructor^^
from tinyxml2.
The move constructor is an interesting suggestion. "if the compiler supports" is a frustrating issue, as well. Not yet. But I'll think about it. Thanks for the offer!
"haven't we all learned a lot since then" I hear you. Pretty much sums up why I wrote v2 of the library.
from tinyxml2.
I think move construct / assign would be appropriate at this point for a majority of projects out there.
from tinyxml2.
Related Issues (20)
- Converting CString to UTF-8 for saving to TinyXML2 HOT 1
- Problems occur when building a project
- XMLPrinter printer( fp ) not recognised on arduino ide compiler HOT 2
- Why return XML_ ERROR_ PARSING? HOT 2
- Documentation error? HOT 2
- Turkish Characters Support HOT 1
- When will tinyxml release a new version? HOT 1
- Assessment of the difficulty in porting CPU architecture for tinyXML2 HOT 1
- Support for char8_t and std::u8string HOT 2
- Using IntText(); HOT 1
- FirstChildElement and namespace prefixes.
- Bug with XMLElement::Attribute - it returns 0 instead of "value" if it can't find the attribute -
- Is the Doxygen tagfile published anywhere?
- v10: MinGW DLL build behavior change
- porty guide from tinyxml1
- Tags for versions below 2.0.1
- `Error()` returns false for corrupted XML (when there is no starting tag) HOT 1
- Add xmake build system HOT 1
- xmltest.exe fail Error opening test file 'dream.xml'
- Compilation warnings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinyxml2.