
Mikhail Glushenkov wrote:
This is an enhanced version of Unai Uribarri's patch (see http://lists.boost.org/MailArchives/boost/msg42284.php ). Adds support for the following syntax:
boost::any a = 7; int& i = any_cast<int&>(a);
Current syntax for reference extraction is
int& i = *any_cast<int>(&a);
Old syntax is preserved. On compilers without support for partial template specialization users are required to provide explicit specializations of boost::remove_reference for their classes (usually via BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION) if they want to use the new syntax. Patch was tested on msvc 6 and 7.1, intel 8.1 and gcc 3.3.1. If this patch will be accepted, I'll write tests/update documentation.
Hello Mikhail, I've updated your patch to properly support T volatile x; any a(x); It has been tested under Gentoo Linux on g++ 3.3.4 (hardened) and Intel 8.0 with and without BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION. -- Alexander Nasonov