[constrained_value] serialization

constrained_value does not currently support serialization. 1. Should it be added to the lib? 2. What would be a suggested implementation?

Hi Neal,
From: Neal Becker
Good questions. As to the second, would it be sensible to serialise the value + each of the policies that is non-empty (or stateless)? Detection of class emptiness (statelessness) is not working with all compilers, so this would possibly be a non-portable solution. But otherwise users would need to provide serialization support for each empty policy too. Best regards, Robert

The implementation for general case seems a bit tricky, because some constrained objects (e.g., bounded_int<int, 1, 10>::type) should not be default-constructed by the Serialization library. Therefore, if I understand correctly, load_construct_data() /save_construct_data() should be overloaded rather than serialize() provided (but I'm not sure about this, I haven't used Serialization library).
Possibly by specialising non-member serialize() / load_construct_data() /save_construct_data()?

On Sun, Dec 14, 2008 at 11:58 AM, Robert Kawulak <robert.kawulak@gmail.com> wrote:
What about another optional template parameter for a default-construction value for the object (either an already instanced value, or a function/functor to build one or something)? Less hassle in many cases then, and would allow default construction of any of those that are by default not default constructable.

Right, this would be useful here. Another way to achieve this is to wrap constrained into an initialiser class that would assign some predefined value to its underlying constrained object upon default construction. Unfortunately, none of those methods is perfect and I still have hope to find a better way to do this. ;-) Best regards, Robert
participants (3)
-
Neal Becker
-
OvermindDL1
-
Robert Kawulak