In the boos 1.29 implementation, a code like this:
{
any x=5;
++any_cast<int&>(x);
}
doesn't compile because any_cast tries to instantiate a pointer to int &. With the attached patch (which uses ::boost::remove_reference in boost/type_traits.hpp to translate int& to int) this code compile and works as expected (at least as I expect, setting x to 6).
I believe that it doesn't break the interface for any_cast.
Is there any chance to get the patch accepted?
Good bye!
--- any.hpp.orig 2003-01-14 19:54:44.000000000 +0100 +++ any.hpp 2003-01-14 20:06:02.000000000 +0100 @@ -12,6 +12,7 @@ #include <typeinfo> #include "boost/config.hpp" +#include <boost/type_traits.hpp> namespace boost { @@ -167,12 +168,22 @@ template<typename ValueType> ValueType any_cast(const any & operand) { - const ValueType * result = any_cast<ValueType>(&operand); + typedef ::boost::remove_reference<ValueType>::type type; + const type * result = any_cast<type>(&operand); if(!result) throw bad_any_cast(); return *result; } + template<typename ValueType> + ValueType any_cast(any & operand) + { + typedef ::boost::remove_reference<ValueType>::type type; + type * result = any_cast<type>(&operand); + if(!result) + throw bad_any_cast(); + return *result; + } } // Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost