1

Topic: Limits for serialization

Again greetings! I want to add in YAS limits. Obvious application - restrictions on the sizes  containers/lines. An example: struct type {std:: string str; template <typename Ar> void serialize (Ar &ar) {ar and yas:: limit (str, 32);//at deserialising the length of a line is restricted 32 to characters}};//... type t; yas:: binary_oarchive oa; oa and t; at deserialising if  sees that the line  32 came - throws an exception. A question at me two: 1. Whether it is necessary to use limits and for serialization? (For record in archive) like as it is care of the user. 2. Whether it is necessary to use limits and for fundamental types? Thanks.

2

Re: Limits for serialization

Hello, niXman, you wrote: X> 1. Whether it is necessary to use limits and for serialization? (For record in archive) like as it is care of the user. Yes. X> 2. Whether it is necessary to use limits and for fundamental types? Yes. Made two types of limits: yas:: limit (v, 32);//max limit and yas:: limit (v, 32, 64);//min-max limit

3

Re: Limits for serialization

Hello, niXman, you wrote: Still limits can be set for data types at a compilation stage. Something of type constrained_type from https://github.com/foonathan/type_safe I.e. type such struct X {constrained <std:: string, non_empty> name; constrained <int, in_range <0, 150>> age; template <typename Ar> void serialize (Ar& ar) {ar and name and age;}};

4

Re: Limits for serialization

Hello, PM, you wrote: PM> Still limits can be set for data types at a compilation stage. Two minuses: 1. In a kompajl-time  will work only for constexpr expressions. 2. It only for fundamental types.