Tony Camuso wrote
On 03/06/2015 07:42 PM, Robert Ramey wrote:
Tony Camuso wrote
Why is the compiler okay with ... std::vector
<int>
intvec; ... but throws an error for ... std::vector
pintvec;
The answer can be found here:
http://stackoverflow.com/questions/19076299/how-do-i-serialize-a-class-conta...
I concede that this should be added to the documentation. Feel free to open a trac item to remind me of this.
actually, I think I can do better than that. I got in the habit of adding a layer of static asserts to trap cases where the user breaks some rule or another. At the site of the trap, a comment in the code explains what on has to do to fix it. Of course this is self defense so I don't have continually answer the same questions over and over. Over the years as I get a new question, I added traps like this. For some reason this question hasn't been asked often enough to trigger my normal behavior. But I think I can more or less easily implement this.
So the solution is to wrap your int inside a class. This will give it a unique type and distinguish from all the other int instances you don't really want to track. Also you can use BOOST_SERIALIZATION to create a wrapper.
Note: it's BOOST_SERIALIZATION_STRONG_TYPEDEF. It's got it's own special section in the manual. But it only works for numeric types. If you want to serialize a string pointer you'll have to snooker your system like this:
Thanks, Robert.
Wasn't aware of the BOOST_SERIALIZATION macro. I'll look it up.
Another question. It seems that attempts to serialize containers of pointers
of any kind throw compiler errors. For example,
std::vector<string> str; // compiler is ok with serializing this
std::vector
Is my reading comprehension off? :)
No, but you might want to do more of it. -- View this message in context: http://boost.2283326.n4.nabble.com/Flood-of-messages-when-building-with-boos... Sent from the Boost - Users mailing list archive at Nabble.com.