Opened 8 years ago
Last modified 8 years ago
#10277 new Feature Requests
reference_wrapper & implicit conversion to parent types
Reported by: | Owned by: | Peter Dimov | |
---|---|---|---|
Milestone: | To Be Determined | Component: | bind |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I propose a change to reference_wrapper which enables implicit conversion to references and reference_wrappers of base types.
One motivation for this is an unconventional use of reference_wrapper:
Many common library functions in code have a non-trivial set of arguments, some of which being non-const references. When reading code that uses these functions, it is often difficult to tell what side-effects a library function has from call to call. Having a coding policy that mutable references must be reference_wrappers and having calling code use ref() enables readers of the callsites to clearly identify which arguments have the possibility of having side-effects.
However, this is currently not possible without creating a custom implementation of reference_wrapper.
I have attached a proposed modification to the boost 1.55.0 implementation, as well as a simple file testing the extended capability.
Attachments (3)
Change History (4)
by , 8 years ago
by , 8 years ago
by , 8 years ago
comment:1 by , 8 years ago
Component: | None → bind |
---|---|
Owner: | set to |