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 |
|
mirek
Messages: 13975 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?
|
|
|
|
Goto Forum:
Current Time: Fri Apr 19 04:56:23 CEST 2024
Total time taken to generate the page: 0.02887 seconds
|