|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2006-04-14 06:13:03
JOAQUIN LOPEZ MU?Z wrote:
> Hello,
>
> In a post from yesterday (see http://tinyurl.com/hzk5w),
> Alexei Alexandrov found a rather serious problem with
> is_convertible in at least MSVC 7.1 and Intel 9.0, namely
> that is_convertible<From,To> fails to compile when
>> From is non-copyable, emitting an error message like this:
>
> boost/boost/type_traits/is_convertible.hpp(254): error:
> class "XXX" has no suitable copy constructor
> BOOST_STATIC_CONSTANT(bool, value =
> ...
>
> where XXX is the From argument. Needless to say, some
> fix for this issue would be most welcome. I'm sorry
> I cannot provide any more help than a mere report
> of the problem.
>
> Thank you,
Using the trivial code below I'm *unable* to reproduce this: it's compiles
cleanly with all the compilers I've tried (including Intel 9 and VC7.1).
However.... there is a long history of is_convertible doing strange things
under very specific circumstances with VC7.1 (and of course Intel emulate
VC's bugs).
Indeed the VC-specific implementation relies on undefined behaviour: passing
UDT's through a function with elipsis, and it's this that appears to be
causing the problem in this case. There are alternative implementations of
is_convertible - almost one per compiler in fact, which shows how much
trouble it's caused in the past - that do not rely on this undefined
behaviour, and do not pass UDT's through elipsis, and so should not have
this problem. Unfortunately these implementations could not be used with
VC++ because even though they pass all our type-traits regression tests,
they cause strange and unexplained failures deep within certain
instantiation contexts. Sound familiar?
Anyway, trivial test case follows,
John.
#include <boost/type_traits.hpp>
#include <boost/noncopyable.hpp>
class bar : private boost::noncopyable
{
};
template <bool b>
class foo
{
public:
static const bool value = b;
};
typedef foo< ::boost::is_convertible<bar, int>::value> foo_t;
const bool b = foo_t::value;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk