- Transferring a value - 1 Update
"Öö Tiib" <ootiib@hot.ee>: Oct 30 06:41PM -0700 On Friday, 30 October 2015 22:47:35 UTC+2, Daniel wrote: > > be your strongest side. Build upon it. > If you are interested in the context, you can look at the section "Converting CSV files to json" in > https://github.com/danielaparker/jsoncons Indeed I was interested in context. Context here seems to be that it is a deserializer? I actually still don't know why the object to deserialize is a data member (component) of the deserializer. It seems that it is so for achieving that deserialization and transfer of deserialization results can then happen as separate steps/calls. May be that is useful but it is not immediately apparent why. Parsers typically produce/allocate the objects during parsing and transfer ownership right as result (return value) of parsing. Less popular alternative is to pass the object as IN-OUT parameter to parser. You deserialize into 'basic_json' that looks somewhat like 'boost::variant'. Real 'boost::variant' does some more tricks to reduce levels of indirection; it may perform slightly better (less news/deletes). Also it does some tricks to achieve more compile-time optimizations and type-safety but that all is perhaps beyond the point. > But I don't think that that context matters very much. Yes, some things you can build up with T:T(...), and other things you can't. My question had to do with the latter, and there's not much else to be said about it. Context can always matter since we have no silver bullets that are equally good in every context. If you want to keep your deserialization as two steps and result of it as by-value data member then you may want to consider: T t = builder.give_result(); // returns r-value reference to result instead of: T t = std::move(builder.result); // result is public data member Both technically move from data member but former is simpler to extend or to change. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment