Opened 6 years ago
Last modified 6 years ago
#12292 new Bugs
[TypeErasure] Construction of any from static_binding fails if compiling with rvalue-ref support
| Reported by: | Owned by: | Steven Watanabe | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | type_erasure |
| Version: | Boost Development Trunk | Severity: | Problem |
| Keywords: | Cc: |
Description
Although the documentation of Boost.TypeErasure explicitly shows how to default-construct an any from the binding of another any, this seems not to work when rvalue-references are supported by the compiler.
The reason is, that the wrong constructor overload is chosen.
binding_of returns a static_binding for which no explicit any-constructor is available. If rvalue-references are not supported by the compiler the constructor-overload which takes a binding is chosen (due to implicit conversion from static_binding to binding).
If rvalue-references are supported the constructor which takes a "universal reference" [1] is chosen instead which does not expect and therefore cannot handle the static_binding.
[1] https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers
Change History (3)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
I am sorry, I must correct some of my above mentioned explanations.
binding_of does not return a static_binding, but a binding, for which any-constructors are available.
However, make_binding returns a static_binding and I see no reason why creating an any with the help of make_binding should not succeed. So, the pull-request still keeps its relevance.
comment:3 by , 6 years ago
I intentionally didn't provide this constructor. I don't see any reasonable use case for it. Also, static_binding in general is not interchangeable with binding, so I don't think it's necessary to provide it for completeness.

This pull-request https://github.com/boostorg/type_erasure/pull/10 fixes it.