Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » PROPOSAL: SerializeStore helper
Re: PROPOSAL: SerializeStore helper [message #29422 is a reply to message #29413] Tue, 19 October 2010 15:28 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
kohait00 wrote on Tue, 19 October 2010 06:05

just a short add..

XmlizeStore exists, to be able to handle 'const T& x'
I couldnt find anything similar for Serialize..
here is a solution.

template<class T>
void SerializeStore(Stream& s, const T& x)
{
	ASSERT(s.IsStoring());
	s % const_cast<T&>(x);
}


this makes thing possible like
SerializeStore(s, mymap.GetKey(i));

without the hassle of a const_cast each time..and an ASSERT is there..

any better solution or didnt i think of every pitfall..



Well, the equivalent function is there, called "Store", but it now accepts only non-const parameter - so the change would be there...

The problem I possibly see with it (and in fact, maybe the XmlizeStore is wrong) is that you are giving option to client code to change const object... I mean, nothing prevents Serialize to mutate the object.

But perhaps I am wrong... Another opinion?
 
Read Message
Read Message
Read Message
Previous Topic: no String::Replace() ?
Next Topic: PolyDeepCopyNew: MSC / GCC differ in behaviour
Goto Forum:
  


Current Time: Sun Aug 24 14:14:44 CEST 2025

Total time taken to generate the page: 0.03710 seconds