From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2005-02-18 04:06:28
Vladimir Prus wrote:
> Given that overall reaction is positive, I'll make the change,
> the 'cast to reference' logic I wanted in the first place.
> The only difference between my version and the one you mention above
> snippet in 'any_cast':
> #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
> // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION
> // to generate specialization of remove_reference for your
> // See type traits library documentation for details
> It looks to me that this assert will always be triggered when your
> reference type and BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION is
> right? The assert will fire even if used has specialized
> no? If that's true, the comment is not correct and casting to
> just not supported for broken compilers.
On broken compilers the assert for any_cast<int cv&> fires only if this
thing is not in TU before first use of any_cast<int v&>:
IMHO, if it's there, everything should work. BTW, there is a testcase in
earlier post in that thread. You can try to comment one such workaround
the difference on a broken compiler or with
Be careful, don't mix up the correct patch with previous version that
with the test.
> I see that your patch also:
> 1. Strips cv-qualification in constructor (which is reasonable).
const is already stripped because ctor's argument is 'const ValueType &
So, it's only for volatile. remove_cv is used only to avoid inclusion of
> 2. Strips cv-qualification when casting to pointer.
> Why the second aspect is needed?
> I forgot to mention that the original version has small problem with
> to const type. If any stores T and you cast it to T const you're
> this sequence of static_casts:
> holder<T>* -> (in ctor) -> placeholder* -> (in any_cast) -> holder<T>
> Obviously, it's not getting back to original holder<T> type.
-- Alexander Nasonov
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk