Hi List,
I have been using boost::type_erasure a bit. I found that in the case of
implementing equality_comparable, when it passes into operator== a
placeholder argument corresponding to some any, it always wraps it in
a param, which internally instantiates an any. While this
instantiation does not cause the actual content to be copied, it always
clone the share_ptr pointing to the dispatch table, causing an extra
shared_ptr construct/destruct invocation whenever I do an equality
comparison.
This source of inefficiency seems unnecessary to me. Is it possible to
modify param such that it only stores non-ref counted raw reference
to the original argument? Of course the functions in
type_erasure::detail::access need to be updated accordingly.
Will this modification break some grander scheme underlying type_erasure
that I am unaware of, being new to the code base?
It seems to me that when param wraps a temporary, the temporary is
guaranteed to live past the lifetime of the invocation.
Can people vet this idea before I take a stab at changing the code?
Thanks,
Yuanchen