chaincodelabs / libmultiprocess

C++ library and code generator making it easy to call functions and reference objects in different processes
MIT License
29 stars 20 forks source link

Avoid using boost::optional in PassField() #17

Closed vasild closed 4 years ago

vasild commented 4 years ago

Refactor PassField() to an equivalent one that does not use boost::optional.

vasild commented 4 years ago

@ryanofsky as a followup to https://github.com/chaincodelabs/libmultiprocess/pull/16 I crudely stripped down absl::optional to about 4k lines of code (:-O). With finer stripping maybe it could go down to below 1000 lines, but it does not look good - what if a bug is introduced due to the stripping? Also, changes from upstream would be very tedious to merge and it would be one black box inside the source code. Its better to require the user to install absl externally.

While playing with it the patch in this PR materialized - we could remove some more boost without adding a boost::optional replacement.

ryanofsky commented 4 years ago

This seems like a good approach, and I can merge this PR after a little testing. I agree that replacing optional isn't good if it's going to add a lot of new code. I was thinking a small optional class with basic emplace/get functionality could be implemented in something like ~100 lines, but if this isn't the case it's probably better to avoid adding a new optional class. And maybe it's better to avoid using optional altogether, since most of the changes you've made so far do seem like simplifications.