When doing mapRequired or mapOptional it is useful to be able to pass context to the operation. This has been partially addressed by having a void *context in the IO instance, but this is inflexible when you context is constructed on the fly, for example, and needs to be passed to only one specific mapping.
The solution implemented here adds an additional overload of mapRequired and mapOptional, taking a parameterized type. If you invoke this overload, you are expected to specialize a MappingTraits with not only the default implementation which takes a n IO& and a T &, but an additional overload that takes an IO&, T &, and Context &. This object is then passed into the map operation. The original no context overload is still required
Is this in some 'internal' or 'detail' namespace that I don't see? If not, I think it probably should be. Seems like too generic of a name.
Also, probably should be doMapping to be consistent with naming conventions (not that this file is terribly consistent with the rest of LLVM's conventions).